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.
 
 
 
 
 
 

155 lines
4.3 KiB

  1. using Learun.DataBase.Repository;
  2. using Learun.Util;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. namespace Learun.Application.OA.Email.EmailConfig
  7. {
  8. /// <summary>
  9. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  10. /// Copyright (c) 2013-2017
  11. /// 创建人:陈彬彬
  12. /// 日 期:2018.06.04
  13. /// 描 述:邮件配置管理
  14. /// </summary>
  15. public class EmailConfigService : RepositoryFactory
  16. {
  17. #region 获取数据
  18. /// <summary>
  19. /// 获取配置信息
  20. /// </summary>
  21. /// <param name="queryJson">关键词</param>
  22. /// <returns></returns>
  23. public IEnumerable<EmailConfigEntity> GetConfigList(string queryJson)
  24. {
  25. try
  26. {
  27. var strSql = new StringBuilder();
  28. strSql.Append("SELECT * FROM LR_EmailConfig");
  29. return this.BaseRepository().FindList<EmailConfigEntity>(strSql.ToString());
  30. }
  31. catch (Exception ex)
  32. {
  33. if (ex is ExceptionEx)
  34. {
  35. throw;
  36. }
  37. else
  38. {
  39. throw ExceptionEx.ThrowServiceException(ex);
  40. }
  41. }
  42. }
  43. /// <summary>
  44. /// 获取邮件配置实体
  45. /// </summary>
  46. /// <param name="keyValue">主键</param>
  47. /// <returns></returns>
  48. public EmailConfigEntity GetConfigEntity(string keyValue)
  49. {
  50. try
  51. {
  52. return this.BaseRepository().FindEntity<EmailConfigEntity>(t => t.F_CreatorUserId == keyValue);
  53. }
  54. catch (Exception ex)
  55. {
  56. if (ex is ExceptionEx)
  57. {
  58. throw;
  59. }
  60. else
  61. {
  62. throw ExceptionEx.ThrowServiceException(ex);
  63. }
  64. }
  65. }
  66. /// <summary>
  67. /// 获取当前有效邮件配置实体
  68. /// </summary>
  69. /// <param name="keyValue">主键</param>
  70. /// <returns></returns>
  71. public EmailConfigEntity GetCurrentConfig()
  72. {
  73. try
  74. {
  75. return this.BaseRepository().FindEntity<EmailConfigEntity>(t => t.F_EnabledMark == 1);
  76. }
  77. catch (Exception ex)
  78. {
  79. if (ex is ExceptionEx)
  80. {
  81. throw;
  82. }
  83. else
  84. {
  85. throw ExceptionEx.ThrowServiceException(ex);
  86. }
  87. }
  88. }
  89. #endregion
  90. #region 提交数据
  91. /// <summary>
  92. /// 删除
  93. /// </summary>
  94. /// <param name="keyValue">主键</param>
  95. public void DeleteEntity(string keyValue)
  96. {
  97. try
  98. {
  99. this.BaseRepository().Delete<EmailConfigEntity>(t => t.F_Id == keyValue);
  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. /// <summary>
  114. /// 保存(新增、修改)
  115. /// </summary>
  116. /// <param name="keyValue">主键值</param>
  117. /// <param name="configEntity">邮件配置实体</param>
  118. /// <returns></returns>
  119. public void SaveConfigEntity(string keyValue, EmailConfigEntity configEntity)
  120. {
  121. try
  122. {
  123. if (!string.IsNullOrEmpty(keyValue))
  124. {
  125. configEntity.Modify(keyValue);
  126. this.BaseRepository().Update(configEntity);
  127. }
  128. else
  129. {
  130. configEntity.Create();
  131. this.BaseRepository().Insert(configEntity);
  132. }
  133. }
  134. catch (Exception ex)
  135. {
  136. if (ex is ExceptionEx)
  137. {
  138. throw;
  139. }
  140. else
  141. {
  142. throw ExceptionEx.ThrowServiceException(ex);
  143. }
  144. }
  145. }
  146. #endregion
  147. }
  148. }