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.

EmailSendService.cs 4.6 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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.EmailSend
  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 EmailSendService : RepositoryFactory
  16. {
  17. #region 获取数据
  18. /// <summary>
  19. /// 获取发送邮件数据
  20. /// </summary>
  21. /// <param name="pagination">分页参数</param>
  22. /// <param name="queryJson">关键词</param>
  23. /// <returns></returns>
  24. public IEnumerable<EmailSendEntity> GetSendList(Pagination pagination, string queryJson)
  25. {
  26. try
  27. {
  28. var strSql = new StringBuilder();
  29. strSql.Append("SELECT * FROM LR_EmailSend t WHERE t.F_DeleteMark = 0 AND t.F_EnabledMark = 0 ");
  30. var queryParam = queryJson.ToJObject();
  31. DateTime startTime = new DateTime(), endTime = new DateTime();
  32. // 日期
  33. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  34. {
  35. startTime = queryParam["StartTime"].ToDate();
  36. endTime = queryParam["EndTime"].ToDate().AddDays(1);
  37. strSql.Append(" AND ( t.F_CreatorTime >= @startTime AND t.F_CreatorTime <= @endTime ) ");
  38. }
  39. // 关键字
  40. string keyword = "";
  41. if (!queryParam["keyword"].IsEmpty())
  42. {
  43. keyword = queryParam["keyword"].ToString();
  44. strSql.Append(" AND F_Subject like @keyword");
  45. }
  46. return this.BaseRepository().FindList<EmailSendEntity>(strSql.ToString(), new { startTime = startTime, endTime = endTime, keyword = "%" + keyword + "%" }, pagination);
  47. }
  48. catch (Exception ex)
  49. {
  50. if (ex is ExceptionEx)
  51. {
  52. throw;
  53. }
  54. else
  55. {
  56. throw ExceptionEx.ThrowServiceException(ex);
  57. }
  58. }
  59. }
  60. /// <summary>
  61. /// 获取邮件发送实体
  62. /// </summary>
  63. /// <param name="keyValue">主键</param>
  64. /// <returns></returns>
  65. public EmailSendEntity GetSendEntity(string keyValue)
  66. {
  67. try
  68. {
  69. return this.BaseRepository().FindEntity<EmailSendEntity>(keyValue);
  70. }
  71. catch (Exception ex)
  72. {
  73. if (ex is ExceptionEx)
  74. {
  75. throw;
  76. }
  77. else
  78. {
  79. throw ExceptionEx.ThrowServiceException(ex);
  80. }
  81. }
  82. }
  83. #endregion
  84. #region 提交数据
  85. /// <summary>
  86. /// 删除
  87. /// </summary>
  88. /// <param name="keyValue">主键</param>
  89. public void DeleteEntity(string keyValue)
  90. {
  91. try
  92. {
  93. this.BaseRepository().Delete<EmailSendEntity>(t => t.F_Id == keyValue);
  94. }
  95. catch (Exception ex)
  96. {
  97. if (ex is ExceptionEx)
  98. {
  99. throw;
  100. }
  101. else
  102. {
  103. throw ExceptionEx.ThrowServiceException(ex);
  104. }
  105. }
  106. }
  107. /// <summary>
  108. /// 保存(新增、修改)
  109. /// </summary>
  110. /// <param name="keyValue">主键值</param>
  111. /// <param name="sendEntity">邮件发送实体</param>
  112. /// <returns></returns>
  113. public void SaveSendEntity(string keyValue, EmailSendEntity sendEntity)
  114. {
  115. try
  116. {
  117. if (!string.IsNullOrEmpty(keyValue))
  118. {
  119. sendEntity.Modify(keyValue);
  120. this.BaseRepository().Update(sendEntity);
  121. }
  122. else
  123. {
  124. sendEntity.Create();
  125. this.BaseRepository().Insert(sendEntity);
  126. }
  127. }
  128. catch (Exception ex)
  129. {
  130. if (ex is ExceptionEx)
  131. {
  132. throw;
  133. }
  134. else
  135. {
  136. throw ExceptionEx.ThrowServiceException(ex);
  137. }
  138. }
  139. }
  140. #endregion
  141. }
  142. }