WFDelegateRecordService.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using LeaRun.Application.Entity.FlowManage;
  2. using LeaRun.Application.IService.FlowManage;
  3. using LeaRun.Data;
  4. using LeaRun.Data.Repository;
  5. using LeaRun.Util;
  6. using LeaRun.Util.Extension;
  7. using LeaRun.Util.WebControl;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Data.Common;
  11. using System.Text;
  12. namespace LeaRun.Application.Service.FlowManage
  13. {
  14. /// <summary>
  15. /// 版 本 6.1
  16. /// Copyright (c) 2013-2016 上海力软信息技术有限公司
  17. /// 创建人:陈彬彬
  18. /// 日 期:2016.01.14 11:02
  19. /// 描 述:工作流委托记录操作类(支持:SqlServer)
  20. /// </summary>
  21. public class WFDelegateRecordService : RepositoryFactory, WFDelegateRecordIService
  22. {
  23. #region 获取数据
  24. /// <summary>
  25. /// 获取分页数据(type 1:委托记录,其他:被委托记录)
  26. /// </summary>
  27. /// <param name="pagination"></param>
  28. /// <param name="queryJson"></param>
  29. /// <param name="type"></param>
  30. /// <param name="userId"></param>
  31. /// <returns></returns>
  32. public DataTable GetPageList(Pagination pagination, string queryJson,int type, string userId = null)
  33. {
  34. try
  35. {
  36. var strSql = new StringBuilder();
  37. strSql.Append(@"SELECT
  38. w.Id,
  39. w.WFDelegateRuleId,
  40. w.FromUserId,
  41. w.FromUserName,
  42. w.ToUserId,
  43. w.ToUserName,
  44. w.CreateDate,
  45. w.ProcessId,
  46. w.ProcessCode,
  47. w.ProcessName
  48. FROM
  49. WF_DelegateRecord w
  50. Where 1=1
  51. ");
  52. var parameter = new List<DbParameter>();
  53. var queryParam = queryJson.ToJObject();
  54. if (!string.IsNullOrEmpty(userId))
  55. {
  56. if (type == 1)
  57. {
  58. strSql.Append(@" AND ( w.FromUserId = @UserId )");
  59. }
  60. else
  61. {
  62. strSql.Append(@" AND ( w.ToUserId = @UserId )");
  63. }
  64. parameter.Add(DbParameters.CreateDbParameter("@UserId", userId));
  65. }
  66. if (!queryParam["Keyword"].IsEmpty())//关键字查询
  67. {
  68. string keyord = queryParam["Keyword"].ToString();
  69. strSql.Append(@" AND ( w.ToUserName LIKE @keyword or w.ProcessName LIKE @keyword or w.ProcessCode LIKE @keyword )");
  70. parameter.Add(DbParameters.CreateDbParameter("@keyword", '%' + keyord + '%'));
  71. }
  72. return this.BaseRepository().FindTable(strSql.ToString(), parameter.ToArray(), pagination);
  73. }
  74. catch
  75. {
  76. throw;
  77. }
  78. }
  79. #endregion
  80. #region 提交数据
  81. /// <summary>
  82. /// 保存实体数据
  83. /// </summary>
  84. /// <param name="keyValue"></param>
  85. /// <param name="entity"></param>
  86. /// <returns></returns>
  87. public int SaveEntity(string keyValue, WFDelegateRecordEntity entity)
  88. {
  89. try
  90. {
  91. int num;
  92. if (string.IsNullOrEmpty(keyValue))
  93. {
  94. entity.Create();
  95. num = this.BaseRepository().Insert(entity);
  96. }
  97. else
  98. {
  99. entity.Modify(keyValue);
  100. num = this.BaseRepository().Update(entity);
  101. }
  102. return num;
  103. }
  104. catch
  105. {
  106. throw;
  107. }
  108. }
  109. #endregion
  110. }
  111. }