WFSchemeContentService.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using LeaRun.Application.IService.FlowManage;
  2. using LeaRun.Data.Repository;
  3. using LeaRun.Application.Entity.FlowManage;
  4. using LeaRun.Util.Extension;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Text;
  8. using System.Data.Common;
  9. using LeaRun.Data;
  10. namespace LeaRun.Application.Service.FlowManage
  11. {
  12. /// <summary>
  13. /// 版 本 6.1
  14. /// Copyright (c) 2013-2016 上海力软信息技术有限公司
  15. /// 创建人:陈彬彬
  16. /// 日 期:2016.03.04 16:58
  17. /// 描 述:工作流模板内容表操作(支持:SqlServer)
  18. /// </summary>
  19. public class WFSchemeContentService : RepositoryFactory, WFSchemeContentIService
  20. {
  21. #region 获取数据
  22. /// <summary>
  23. /// 获取对象
  24. /// </summary>
  25. /// <param name="wfSchemeInfoId">工作流模板信息表主键</param>
  26. /// <param name="schemeVersion">模板版本号</param>
  27. /// <returns></returns>
  28. public WFSchemeContentEntity GetEntity(string wfSchemeInfoId, string schemeVersion)
  29. {
  30. try
  31. {
  32. var expression = LinqExtensions.True<WFSchemeContentEntity>();
  33. expression = expression.And(t => t.WFSchemeInfoId == wfSchemeInfoId).And(t => t.SchemeVersion == schemeVersion);
  34. return this.BaseRepository().FindEntity<WFSchemeContentEntity>(expression);
  35. }
  36. catch {
  37. throw;
  38. }
  39. }
  40. /// <summary>
  41. /// 获取对象列表
  42. /// </summary>
  43. /// <param name="wfSchemeInfoId">工作流模板信息表Id</param>
  44. /// <returns></returns>
  45. public IEnumerable<WFSchemeContentEntity> GetEntityList(string wfSchemeInfoId)
  46. {
  47. var expression = LinqExtensions.True<WFSchemeContentEntity>();
  48. expression = expression.And(t => t.WFSchemeInfoId == wfSchemeInfoId);
  49. return this.BaseRepository().FindList<WFSchemeContentEntity>(expression);
  50. }
  51. /// <summary>
  52. /// 获取对象列表(不包括模板内容)
  53. /// </summary>
  54. /// <param name="wfSchemeInfoId">工作流模板信息表Id</param>
  55. /// <returns></returns>
  56. public DataTable GetTableList(string wfSchemeInfoId)
  57. {
  58. try
  59. {
  60. var strSql = new StringBuilder();
  61. strSql.Append(@"SELECT
  62. w.Id,
  63. w.WFSchemeInfoId,
  64. w.SchemeVersion,
  65. w.CreateDate,
  66. w.CreateUserId,
  67. w.CreateUserName
  68. FROM
  69. WF_SchemeContent w
  70. where w.WFSchemeInfoId = @wfSchemeInfoId
  71. Order by w.SchemeVersion DESC ");
  72. var parameter = new List<DbParameter>();
  73. parameter.Add(DbParameters.CreateDbParameter("@wfSchemeInfoId", wfSchemeInfoId));
  74. return this.BaseRepository().FindTable(strSql.ToString(), parameter.ToArray());
  75. }
  76. catch
  77. {
  78. throw;
  79. }
  80. }
  81. #endregion
  82. #region 提交数据
  83. /// <summary>
  84. /// 保存对象
  85. /// </summary>
  86. /// <param name="entity">类</param>
  87. /// <param name="keyValue">主键</param>
  88. /// <returns></returns>
  89. public int SaveEntity(WFSchemeContentEntity entity, string keyValue)
  90. {
  91. try
  92. {
  93. if (string.IsNullOrEmpty(keyValue))
  94. {
  95. entity.Create();
  96. return this.BaseRepository().Insert<WFSchemeContentEntity>(entity);
  97. }
  98. else
  99. {
  100. entity.Modify(keyValue);
  101. return this.BaseRepository().Update<WFSchemeContentEntity>(entity);
  102. }
  103. }
  104. catch {
  105. throw;
  106. }
  107. }
  108. #endregion
  109. }
  110. }