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.
 
 
 
 
 
 

171 lines
5.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.Extention.TaskScheduling
  7. {
  8. /// <summary>
  9. /// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架
  10. /// Copyright (c) 2013-2018 上海力软信息技术有限公司
  11. /// 创 建:超级管理员
  12. /// 日 期:2019-01-09 16:07
  13. /// 描 述:任务执行日志
  14. /// </summary>
  15. public class TSLogService : RepositoryFactory
  16. {
  17. #region 获取数据
  18. /// <summary>
  19. /// 获取页面显示列表数据
  20. /// <summary>
  21. /// <param name="queryJson">查询参数</param>
  22. /// <returns></returns>
  23. public IEnumerable<TSLogEntity> GetPageList(Pagination pagination, string queryJson)
  24. {
  25. try
  26. {
  27. var strSql = new StringBuilder();
  28. strSql.Append(@"
  29. SELECT
  30. t.F_Id,
  31. t.F_ProcessId,
  32. t.F_ExecuteResult,
  33. t.F_CreateDate,
  34. t.F_Des,
  35. s.F_Name
  36. FROM
  37. LR_TS_Log t
  38. LEFT JOIN LR_TS_Process p ON p.F_Id = t.F_ProcessId
  39. LEFT JOIN LR_TS_SchemeInfo s ON s.F_Id = p.F_SchemeInfoId
  40. ");
  41. strSql.Append(" WHERE 1=1 ");
  42. var queryParam = queryJson.ToJObject();
  43. DateTime startTime = DateTime.Now, endTime = DateTime.Now;
  44. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  45. {
  46. startTime = queryParam["StartTime"].ToDate();
  47. endTime = queryParam["EndTime"].ToDate();
  48. strSql.Append(" AND ( t.F_CreateDate >= @startTime AND t.F_CreateDate <= @endTime ) ");
  49. }
  50. string keyword = "";
  51. if (!queryParam["keyword"].IsEmpty())
  52. {
  53. keyword = "%" + queryParam["keyword"].ToString() + "%";
  54. strSql.Append(" AND ( s.F_Name like @keyword ) ");
  55. }
  56. int executeResult = 1;
  57. if (!queryParam["executeResult"].IsEmpty())
  58. {
  59. executeResult = Convert.ToInt32(queryParam["executeResult"].ToString());
  60. strSql.Append(" AND t.F_ExecuteResult = @executeResult ");
  61. }
  62. return this.BaseRepository().FindList<TSLogEntity>(strSql.ToString(), new { startTime, endTime, keyword , executeResult }, pagination);
  63. }
  64. catch (Exception ex)
  65. {
  66. if (ex is ExceptionEx)
  67. {
  68. throw;
  69. }
  70. else
  71. {
  72. throw ExceptionEx.ThrowServiceException(ex);
  73. }
  74. }
  75. }
  76. /// <summary>
  77. /// 获取LR_TS_Log表实体数据
  78. /// <param name="keyValue">主键</param>
  79. /// <summary>
  80. /// <returns></returns>
  81. public TSLogEntity GetLogEntity(string keyValue)
  82. {
  83. try
  84. {
  85. return this.BaseRepository().FindEntity<TSLogEntity>(keyValue);
  86. }
  87. catch (Exception ex)
  88. {
  89. if (ex is ExceptionEx)
  90. {
  91. throw;
  92. }
  93. else
  94. {
  95. throw ExceptionEx.ThrowServiceException(ex);
  96. }
  97. }
  98. }
  99. #endregion
  100. #region 提交数据
  101. /// <summary>
  102. /// 删除实体数据
  103. /// <param name="keyValue">主键</param>
  104. /// <summary>
  105. /// <returns></returns>
  106. public void DeleteEntity(string keyValue)
  107. {
  108. try
  109. {
  110. this.BaseRepository().Delete<TSLogEntity>(t => t.F_Id == keyValue);
  111. }
  112. catch (Exception ex)
  113. {
  114. if (ex is ExceptionEx)
  115. {
  116. throw;
  117. }
  118. else
  119. {
  120. throw ExceptionEx.ThrowServiceException(ex);
  121. }
  122. }
  123. }
  124. /// <summary>
  125. /// 保存实体数据(新增、修改)
  126. /// <param name="keyValue">主键</param>
  127. /// <summary>
  128. /// <returns></returns>
  129. public void SaveEntity(string keyValue, TSLogEntity entity)
  130. {
  131. try
  132. {
  133. if (!string.IsNullOrEmpty(keyValue))
  134. {
  135. entity.Modify(keyValue);
  136. this.BaseRepository().Update(entity);
  137. }
  138. else
  139. {
  140. entity.Create();
  141. this.BaseRepository().Insert(entity);
  142. }
  143. }
  144. catch (Exception ex)
  145. {
  146. if (ex is ExceptionEx)
  147. {
  148. throw;
  149. }
  150. else
  151. {
  152. throw ExceptionEx.ThrowServiceException(ex);
  153. }
  154. }
  155. }
  156. #endregion
  157. }
  158. }