You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

203 lines
6.3 KiB

  1. using Learun.DataBase.Repository;
  2. using Learun.Util;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. using System.Linq;
  7. namespace Learun.Application.Organization
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  11. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  12. /// 创建人:陈彬彬
  13. /// 日 期:2017.04.17
  14. /// 描 述:公司管理
  15. /// </summary>
  16. public class CompanyService : RepositoryFactory
  17. {
  18. #region 构造函数和属性
  19. private string fieldSql;
  20. public CompanyService()
  21. {
  22. fieldSql = @"
  23. t.F_CompanyId,
  24. t.F_Category,
  25. t.F_ParentId,
  26. t.F_EnCode,
  27. t.F_ShortName,
  28. t.F_FullName,
  29. t.F_Nature,
  30. t.F_OuterPhone,
  31. t.F_InnerPhone,
  32. t.F_Fax,
  33. t.F_Postalcode,
  34. t.F_Email,
  35. t.F_Manager,
  36. t.F_ProvinceId,
  37. t.F_CityId,
  38. t.F_CountyId,
  39. t.F_Address,
  40. t.F_WebAddress,
  41. t.F_FoundedTime,
  42. t.F_BusinessScope,
  43. t.F_SortCode,
  44. t.F_DeleteMark,
  45. t.F_EnabledMark,
  46. t.F_Description,
  47. t.F_CreateDate,
  48. t.F_CreateUserId,
  49. t.F_CreateUserName,
  50. t.F_ModifyDate,
  51. t.F_ModifyUserId,
  52. t.F_Photo,
  53. t.F_BriefIntroduction,
  54. t.F_EnrollmentInformation,
  55. t.F_ModifyUserName,
  56. T.F_USCreditCode
  57. ";
  58. }
  59. #endregion
  60. #region 获取数据
  61. /// <summary>
  62. /// 获取公司列表信息(全部)
  63. /// </summary>
  64. /// <returns></returns>
  65. public IEnumerable<CompanyEntity> GetList()
  66. {
  67. try
  68. {
  69. var strSql = new StringBuilder();
  70. strSql.Append("SELECT ");
  71. strSql.Append(fieldSql);
  72. strSql.Append(" FROM LR_Base_Company t WHERE t.F_EnabledMark = 1 AND t.F_DeleteMark = 0 ORDER BY t.F_ParentId,t.F_FullName ");
  73. return this.BaseRepository().FindList<CompanyEntity>(strSql.ToString());
  74. }
  75. catch (Exception ex)
  76. {
  77. if (ex is ExceptionEx)
  78. {
  79. throw;
  80. }
  81. else
  82. {
  83. throw ExceptionEx.ThrowServiceException(ex);
  84. }
  85. }
  86. }
  87. /// <summary>
  88. /// 获取公司列表信息(微信用)
  89. /// </summary>
  90. /// <param name="keyWord">查询关键字</param>
  91. /// <returns></returns>
  92. public IEnumerable<CompanyEntity> GetWeChatList(string keyword)
  93. {
  94. try
  95. {
  96. var sql = @"SELECT t.F_CompanyId,t.F_ParentId,t.F_EnCode,t.F_FullName,t.F_Fax FROM LR_Base_Company t WHERE t.F_EnabledMark = 1 AND t.F_DeleteMark = 0 AND t.F_EnCode IS NOT NULL
  97. UNION ALL
  98. SELECT m.F_DepartmentId as F_CompanyId,m.F_CompanyId as F_ParentId,m.F_EnCode,m.F_FullName,m.F_Fax FROM LR_Base_Department m WHERE m.F_EnabledMark = 1 AND m.F_DeleteMark = 0 AND m.F_EnCode IS NOT NULL
  99. ORDER BY t.F_ParentId,t.F_FullName";
  100. return this.BaseRepository().FindList<CompanyEntity>(sql);
  101. }
  102. catch (Exception ex)
  103. {
  104. if (ex is ExceptionEx)
  105. {
  106. throw;
  107. }
  108. else
  109. {
  110. throw ExceptionEx.ThrowServiceException(ex);
  111. }
  112. }
  113. }
  114. #endregion
  115. #region 提交数据
  116. /// <summary>
  117. /// 虚拟删除公司
  118. /// </summary>
  119. /// <param name="keyValue">主键</param>
  120. public void VirtualDelete(string keyValue)
  121. {
  122. try
  123. {
  124. CompanyEntity entity = new CompanyEntity()
  125. {
  126. F_CompanyId = keyValue,
  127. F_DeleteMark = 1
  128. };
  129. this.BaseRepository().Update(entity);
  130. }
  131. catch (Exception ex)
  132. {
  133. if (ex is ExceptionEx)
  134. {
  135. throw;
  136. }
  137. else
  138. {
  139. throw ExceptionEx.ThrowServiceException(ex);
  140. }
  141. }
  142. }
  143. /// <summary>
  144. /// 保存公司表单(新增、修改)
  145. /// </summary>
  146. /// <param name="keyValue">主键值</param>
  147. /// <param name="companyEntity">公司实体</param>
  148. /// <returns></returns>
  149. public void SaveEntity(string keyValue, CompanyEntity companyEntity)
  150. {
  151. try
  152. {
  153. if (!string.IsNullOrEmpty(keyValue))
  154. {
  155. companyEntity.Modify(keyValue);
  156. this.BaseRepository().Update(companyEntity);
  157. }
  158. else
  159. {
  160. companyEntity.Create();
  161. this.BaseRepository().Insert(companyEntity);
  162. }
  163. }
  164. catch (Exception ex)
  165. {
  166. if (ex is ExceptionEx)
  167. {
  168. throw;
  169. }
  170. else
  171. {
  172. throw ExceptionEx.ThrowServiceException(ex);
  173. }
  174. }
  175. }
  176. internal bool GetAny()
  177. {
  178. try
  179. {
  180. return this.BaseRepository().FindList<CompanyEntity>(a => true).ToList().Count() > 0 ? true : false;
  181. }
  182. catch (Exception ex)
  183. {
  184. if (ex is ExceptionEx)
  185. {
  186. throw;
  187. }
  188. else
  189. {
  190. throw ExceptionEx.ThrowServiceException(ex);
  191. }
  192. }
  193. }
  194. #endregion
  195. }
  196. }