WFSchemeInfoService.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. using LeaRun.Application.Code;
  2. using LeaRun.Application.Entity.BaseManage;
  3. using LeaRun.Application.Entity.FlowManage;
  4. using LeaRun.Application.IService.BaseManage;
  5. using LeaRun.Application.IService.FlowManage;
  6. using LeaRun.Application.Service.BaseManage;
  7. using LeaRun.Data;
  8. using LeaRun.Data.Repository;
  9. using LeaRun.Util;
  10. using LeaRun.Util.Extension;
  11. using LeaRun.Util.WebControl;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Data;
  15. using System.Data.Common;
  16. using System.Text;
  17. namespace LeaRun.Application.Service.FlowManage
  18. {
  19. /// <summary>
  20. /// 版 本 6.1
  21. /// Copyright (c) 2013-2016 上海力软信息技术有限公司
  22. /// 创建人:陈彬彬
  23. /// 日 期:2016.02.23 10:02
  24. /// 描 述:工作流模板信息表操作(支持:SqlServer)
  25. /// </summary>
  26. public class WFSchemeInfoService : RepositoryFactory, WFSchemeInfoIService
  27. {
  28. private IUserService userservice = new UserService();
  29. #region 获取数据
  30. /// <summary>
  31. /// 获取流程列表分页数据
  32. /// </summary>
  33. /// <param name="pagination">分页参数</param>
  34. /// <param name="queryJson">查询条件</param>
  35. /// <returns></returns>
  36. public DataTable GetPageList(Pagination pagination, string queryJson)
  37. {
  38. try
  39. {
  40. var strSql = new StringBuilder();
  41. strSql.Append(@"SELECT
  42. w.Id,
  43. w.SchemeCode,
  44. w.SchemeName,
  45. w.SchemeType,
  46. w.SchemeVersion,
  47. w.FrmType,
  48. t2.ItemName AS SchemeTypeName,
  49. w.SortCode,
  50. w.DeleteMark,
  51. w.EnabledMark,
  52. w.Description,
  53. w.CreateDate,
  54. w.CreateUserId,
  55. w.CreateUserName,
  56. w.ModifyDate,
  57. w.ModifyUserId,
  58. w.ModifyUserName,
  59. w.AuthorizeType
  60. FROM
  61. WF_SchemeInfo w
  62. LEFT JOIN
  63. Base_DataItemDetail t2 ON t2.ItemDetailId = w.SchemeType
  64. WHERE w.DeleteMark = 0 ");
  65. var parameter = new List<DbParameter>();
  66. var queryParam = queryJson.ToJObject();
  67. if (!queryParam["SchemeType"].IsEmpty())
  68. {
  69. strSql.Append(" AND w.SchemeType = @SchemeType ");
  70. parameter.Add(DbParameters.CreateDbParameter("@SchemeType", queryParam["SchemeType"].ToString()));
  71. }
  72. else if (!queryParam["Keyword"].IsEmpty())//关键字查询
  73. {
  74. string keyord = queryParam["Keyword"].ToString();
  75. strSql.Append(@" AND ( w.SchemeCode LIKE @keyword
  76. or w.SchemeName LIKE @keyword
  77. or w.Description LIKE @keyword
  78. )");
  79. parameter.Add(DbParameters.CreateDbParameter("@keyword", '%' + keyord + '%'));
  80. }
  81. return this.BaseRepository().FindTable(strSql.ToString(), parameter.ToArray(), pagination);
  82. }
  83. catch (Exception)
  84. {
  85. throw;
  86. }
  87. }
  88. /// <summary>
  89. /// 获取流程列表数据
  90. /// </summary>
  91. /// <param name="queryJson"></param>
  92. /// <returns></returns>
  93. public DataTable GetList(string queryJson)
  94. {
  95. try
  96. {
  97. string dd =OperatorProvider.Provider.Current().ObjectId;
  98. var strSql = new StringBuilder();
  99. strSql.Append(@"SELECT
  100. distinct w.Id,
  101. w.SchemeCode,
  102. w.SchemeName,
  103. w.SchemeType,
  104. w.SchemeVersion,
  105. w.FrmType,
  106. t2.ItemName AS SchemeTypeName,
  107. w.SortCode,
  108. w.DeleteMark,
  109. w.EnabledMark,
  110. w.Description,
  111. w.CreateDate,
  112. w.CreateUserId,
  113. w.CreateUserName,
  114. w.ModifyDate,
  115. w.ModifyUserId,
  116. w.ModifyUserName
  117. FROM
  118. WF_SchemeInfo w
  119. LEFT JOIN
  120. Base_DataItemDetail t2 ON t2.ItemDetailId = w.SchemeType
  121. LEFT JOIN
  122. WF_SchemeInfoAuthorize w2 ON w2.SchemeInfoId = w.Id
  123. WHERE w.DeleteMark = 0 AND w.EnabledMark = 1 AND w.FrmType = 0
  124. AND ( w.AuthorizeType = 0 ");
  125. if (!OperatorProvider.Provider.Current().IsSystem)
  126. {
  127. if (OperatorProvider.Provider.Current().ObjectId != "")
  128. {
  129. strSql.Append(string.Format(" OR w2.ObjectId in ('{0}','{1}') )", OperatorProvider.Provider.Current().ObjectId.Replace(",", "','"), OperatorProvider.Provider.Current().UserId));
  130. }
  131. else
  132. {
  133. strSql.Append(" ) ");
  134. }
  135. }
  136. else
  137. {
  138. strSql.Append(" OR w.AuthorizeType = 1 ) ");
  139. }
  140. var parameter = new List<DbParameter>();
  141. var queryParam = queryJson.ToJObject();
  142. if (!queryParam["SchemeType"].IsEmpty())
  143. {
  144. strSql.Append(" AND w.SchemeType = @SchemeType ");
  145. parameter.Add(DbParameters.CreateDbParameter("@SchemeType", queryParam["SchemeType"].ToString()));
  146. }
  147. else if (!queryParam["Keyword"].IsEmpty())//关键字查询
  148. {
  149. string keyord = queryParam["Keyword"].ToString();
  150. strSql.Append(@" AND ( w.SchemeCode LIKE @keyword
  151. or w.SchemeName LIKE @keyword
  152. or w.Description LIKE @keyword
  153. )");
  154. parameter.Add(DbParameters.CreateDbParameter("@keyword", '%' + keyord + '%'));
  155. }
  156. return this.BaseRepository().FindTable(strSql.ToString(), parameter.ToArray());
  157. }
  158. catch (Exception)
  159. {
  160. throw;
  161. }
  162. }
  163. /// <summary>
  164. /// 获取流程模板列表
  165. /// </summary>
  166. /// <returns></returns>
  167. public DataTable GetList()
  168. {
  169. try
  170. {
  171. var strSql = new StringBuilder();
  172. strSql.Append(@"SELECT
  173. w1.*,
  174. t2.ItemName,
  175. t2.ItemDetailId as ItemId
  176. FROM
  177. WF_SchemeInfo w1
  178. LEFT JOIN Base_DataItemDetail t2 ON t2.ItemDetailId = w1.SchemeType
  179. ORDER BY t2.SortCode");
  180. return this.BaseRepository().FindTable(strSql.ToString());
  181. }
  182. catch
  183. {
  184. throw;
  185. }
  186. }
  187. /// <summary>
  188. /// 设置流程
  189. /// </summary>
  190. /// <param name="keyValue">主键</param>
  191. /// <returns></returns>
  192. public WFSchemeInfoEntity GetEntity(string keyValue)
  193. {
  194. try
  195. {
  196. return this.BaseRepository().FindEntity<WFSchemeInfoEntity>(keyValue);
  197. }
  198. catch (Exception)
  199. {
  200. throw;
  201. }
  202. }
  203. /// <summary>
  204. /// 获取权限列表数据
  205. /// </summary>
  206. /// <param name="schemeInfoId"></param>
  207. /// <returns></returns>
  208. public IEnumerable<WFSchemeInfoAuthorizeEntity> GetAuthorizeEntityList(string schemeInfoId)
  209. {
  210. try
  211. {
  212. var expression = LinqExtensions.True<WFSchemeInfoAuthorizeEntity>();
  213. expression = expression.And(t => t.SchemeInfoId == schemeInfoId);
  214. return this.BaseRepository().FindList<WFSchemeInfoAuthorizeEntity>(expression);
  215. }
  216. catch
  217. {
  218. throw;
  219. }
  220. }
  221. #endregion
  222. #region 提交数据
  223. /// <summary>
  224. /// 更新流程模板状态(启用,停用)
  225. /// </summary>
  226. /// <param name="keyValue">主键</param>
  227. /// <param name="status">状态 1:启用;0.停用</param>
  228. public void UpdateState(string keyValue, int state)
  229. {
  230. try
  231. {
  232. WFSchemeInfoEntity entity = new WFSchemeInfoEntity();
  233. entity.Modify(keyValue);
  234. entity.EnabledMark = state;
  235. this.BaseRepository().Update(entity);
  236. }
  237. catch (Exception)
  238. {
  239. throw;
  240. }
  241. }
  242. #endregion
  243. #region
  244. #endregion
  245. }
  246. }