25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

202 satır
6.2 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. ";
  57. }
  58. #endregion
  59. #region 获取数据
  60. /// <summary>
  61. /// 获取公司列表信息(全部)
  62. /// </summary>
  63. /// <returns></returns>
  64. public IEnumerable<CompanyEntity> GetList()
  65. {
  66. try
  67. {
  68. var strSql = new StringBuilder();
  69. strSql.Append("SELECT ");
  70. strSql.Append(fieldSql);
  71. 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 ");
  72. return this.BaseRepository().FindList<CompanyEntity>(strSql.ToString());
  73. }
  74. catch (Exception ex)
  75. {
  76. if (ex is ExceptionEx)
  77. {
  78. throw;
  79. }
  80. else
  81. {
  82. throw ExceptionEx.ThrowServiceException(ex);
  83. }
  84. }
  85. }
  86. /// <summary>
  87. /// 获取公司列表信息(微信用)
  88. /// </summary>
  89. /// <param name="keyWord">查询关键字</param>
  90. /// <returns></returns>
  91. public IEnumerable<CompanyEntity> GetWeChatList(string keyword)
  92. {
  93. try
  94. {
  95. 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
  96. UNION ALL
  97. 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
  98. ORDER BY t.F_ParentId,t.F_FullName";
  99. return this.BaseRepository().FindList<CompanyEntity>(sql);
  100. }
  101. catch (Exception ex)
  102. {
  103. if (ex is ExceptionEx)
  104. {
  105. throw;
  106. }
  107. else
  108. {
  109. throw ExceptionEx.ThrowServiceException(ex);
  110. }
  111. }
  112. }
  113. #endregion
  114. #region 提交数据
  115. /// <summary>
  116. /// 虚拟删除公司
  117. /// </summary>
  118. /// <param name="keyValue">主键</param>
  119. public void VirtualDelete(string keyValue)
  120. {
  121. try
  122. {
  123. CompanyEntity entity = new CompanyEntity()
  124. {
  125. F_CompanyId = keyValue,
  126. F_DeleteMark = 1
  127. };
  128. this.BaseRepository().Update(entity);
  129. }
  130. catch (Exception ex)
  131. {
  132. if (ex is ExceptionEx)
  133. {
  134. throw;
  135. }
  136. else
  137. {
  138. throw ExceptionEx.ThrowServiceException(ex);
  139. }
  140. }
  141. }
  142. /// <summary>
  143. /// 保存公司表单(新增、修改)
  144. /// </summary>
  145. /// <param name="keyValue">主键值</param>
  146. /// <param name="companyEntity">公司实体</param>
  147. /// <returns></returns>
  148. public void SaveEntity(string keyValue, CompanyEntity companyEntity)
  149. {
  150. try
  151. {
  152. if (!string.IsNullOrEmpty(keyValue))
  153. {
  154. companyEntity.Modify(keyValue);
  155. this.BaseRepository().Update(companyEntity);
  156. }
  157. else
  158. {
  159. companyEntity.Create();
  160. this.BaseRepository().Insert(companyEntity);
  161. }
  162. }
  163. catch (Exception ex)
  164. {
  165. if (ex is ExceptionEx)
  166. {
  167. throw;
  168. }
  169. else
  170. {
  171. throw ExceptionEx.ThrowServiceException(ex);
  172. }
  173. }
  174. }
  175. internal bool GetAny()
  176. {
  177. try
  178. {
  179. return this.BaseRepository().FindList<CompanyEntity>(a => true).ToList().Count() > 0 ? true : false;
  180. }
  181. catch (Exception ex)
  182. {
  183. if (ex is ExceptionEx)
  184. {
  185. throw;
  186. }
  187. else
  188. {
  189. throw ExceptionEx.ThrowServiceException(ex);
  190. }
  191. }
  192. }
  193. #endregion
  194. }
  195. }