diff --git a/Infrastructure/Const/FlowInstanceStatus.cs b/Infrastructure/Const/FlowInstanceStatus.cs
new file mode 100644
index 00000000..3e3c86a3
--- /dev/null
+++ b/Infrastructure/Const/FlowInstanceStatus.cs
@@ -0,0 +1,30 @@
+namespace Infrastructure.Const
+{
+ ///
+ /// 流程状态
+ ///
+ public struct FlowInstanceStatus
+ {
+ ///
+ /// 撤销、召回
+ ///
+ public const int Draft = -1;
+ ///
+ /// 正在运行
+ ///
+ public const int Running = 0;
+ ///
+ /// 完成
+ ///
+ public const int Finished = 1;
+ ///
+ /// 不同意
+ ///
+ public const int Disagree = 3;
+ ///
+ /// 驳回
+ ///
+ public const int Rejected = 4;
+
+ }
+}
\ No newline at end of file
diff --git a/Infrastructure/Helpers/FileHelper.cs b/Infrastructure/Helpers/FileHelper.cs
index 02763216..238526e5 100644
--- a/Infrastructure/Helpers/FileHelper.cs
+++ b/Infrastructure/Helpers/FileHelper.cs
@@ -381,6 +381,7 @@ namespace Infrastructure.Helpers
/// 追加内容
public static void RegxAddContentByParenthesis(string path, string addStr)
{
+ path = StringExtension.ReplacePath(path);
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
string originStr = sr.ReadToEnd();
diff --git a/OpenAuth.App/AppManager.cs b/OpenAuth.App/AppManager/AppManager.cs
similarity index 100%
rename from OpenAuth.App/AppManager.cs
rename to OpenAuth.App/AppManager/AppManager.cs
diff --git a/OpenAuth.App/Request/QueryAppListReq.cs b/OpenAuth.App/AppManager/Request/QueryAppListReq.cs
similarity index 100%
rename from OpenAuth.App/Request/QueryAppListReq.cs
rename to OpenAuth.App/AppManager/Request/QueryAppListReq.cs
diff --git a/OpenAuth.App/Request/IdPageReq.cs b/OpenAuth.App/Base/IdPageReq.cs
similarity index 94%
rename from OpenAuth.App/Request/IdPageReq.cs
rename to OpenAuth.App/Base/IdPageReq.cs
index 127250a5..59491cbf 100644
--- a/OpenAuth.App/Request/IdPageReq.cs
+++ b/OpenAuth.App/Base/IdPageReq.cs
@@ -1,7 +1,7 @@
-namespace OpenAuth.App.Request
-{
- public class IdPageReq :PageReq
- {
- public string id { get; set; }
- }
-}
+namespace OpenAuth.App.Request
+{
+ public class IdPageReq :PageReq
+ {
+ public string id { get; set; }
+ }
+}
diff --git a/OpenAuth.App/Request/PageReq.cs b/OpenAuth.App/Base/PageReq.cs
similarity index 94%
rename from OpenAuth.App/Request/PageReq.cs
rename to OpenAuth.App/Base/PageReq.cs
index 8dcf7ff3..73eb9695 100644
--- a/OpenAuth.App/Request/PageReq.cs
+++ b/OpenAuth.App/Base/PageReq.cs
@@ -1,16 +1,16 @@
-namespace OpenAuth.App.Request
-{
- public class PageReq
- {
- public int page { get; set; }
- public int limit { get; set; }
-
- public string key { get; set; }
-
- public PageReq()
- {
- page = 1;
- limit = 10;
- }
- }
-}
+namespace OpenAuth.App.Request
+{
+ public class PageReq
+ {
+ public int page { get; set; }
+ public int limit { get; set; }
+
+ public string key { get; set; }
+
+ public PageReq()
+ {
+ page = 1;
+ limit = 10;
+ }
+ }
+}
diff --git a/OpenAuth.App/Response/TableData.cs b/OpenAuth.App/Base/TableData.cs
similarity index 96%
rename from OpenAuth.App/Response/TableData.cs
rename to OpenAuth.App/Base/TableData.cs
index 2ebd7f4d..63f6e171 100644
--- a/OpenAuth.App/Response/TableData.cs
+++ b/OpenAuth.App/Base/TableData.cs
@@ -1,56 +1,56 @@
-// ***********************************************************************
-// Assembly : FundationAdmin
-// Author : yubaolee
-// Created : 03-09-2016
-//
-// Last Modified By : yubaolee
-// Last Modified On : 03-09-2016
-// ***********************************************************************
-//
-// 版权所有(C) Microsoft 2015
-//
-// layui datatable数据返回
-// ***********************************************************************
-
-using System.Collections.Generic;
-using Infrastructure;
-
-namespace OpenAuth.App.Response
-{
- ///
- /// table的返回数据
- ///
- public class TableData
- {
- ///
- /// 状态码
- ///
- public int code { get; set; }
- ///
- /// 操作消息
- ///
- public string msg { get; set; }
-
- ///
- /// 总记录条数
- ///
- public int count { get; set; }
-
- ///
- /// 返回的列表头信息
- ///
- public List columnHeaders;
-
- ///
- /// 数据内容
- ///
- public dynamic data { get; set; }
-
- public TableData()
- {
- code = 200;
- msg = "加载成功";
- columnHeaders = new List();
- }
- }
+// ***********************************************************************
+// Assembly : FundationAdmin
+// Author : yubaolee
+// Created : 03-09-2016
+//
+// Last Modified By : yubaolee
+// Last Modified On : 03-09-2016
+// ***********************************************************************
+//
+// 版权所有(C) Microsoft 2015
+//
+// layui datatable数据返回
+// ***********************************************************************
+
+using System.Collections.Generic;
+using Infrastructure;
+
+namespace OpenAuth.App.Response
+{
+ ///
+ /// table的返回数据
+ ///
+ public class TableData
+ {
+ ///
+ /// 状态码
+ ///
+ public int code { get; set; }
+ ///
+ /// 操作消息
+ ///
+ public string msg { get; set; }
+
+ ///
+ /// 总记录条数
+ ///
+ public int count { get; set; }
+
+ ///
+ /// 返回的列表头信息
+ ///
+ public List columnHeaders;
+
+ ///
+ /// 数据内容
+ ///
+ public dynamic data { get; set; }
+
+ public TableData()
+ {
+ code = 200;
+ msg = "加载成功";
+ columnHeaders = new List();
+ }
+ }
}
\ No newline at end of file
diff --git a/OpenAuth.App/Response/TableResp.cs b/OpenAuth.App/Base/TableResp.cs
similarity index 100%
rename from OpenAuth.App/Response/TableResp.cs
rename to OpenAuth.App/Base/TableResp.cs
diff --git a/OpenAuth.App/BuilderTableApp.cs b/OpenAuth.App/BuilderTable/BuilderTableApp.cs
similarity index 100%
rename from OpenAuth.App/BuilderTableApp.cs
rename to OpenAuth.App/BuilderTable/BuilderTableApp.cs
diff --git a/OpenAuth.App/BuilderTableColumnApp.cs b/OpenAuth.App/BuilderTable/BuilderTableColumnApp.cs
similarity index 100%
rename from OpenAuth.App/BuilderTableColumnApp.cs
rename to OpenAuth.App/BuilderTable/BuilderTableColumnApp.cs
diff --git a/OpenAuth.App/Request/AddOrUpdateBuilderTableColumnReq.cs b/OpenAuth.App/BuilderTable/Request/AddOrUpdateBuilderTableColumnReq.cs
similarity index 100%
rename from OpenAuth.App/Request/AddOrUpdateBuilderTableColumnReq.cs
rename to OpenAuth.App/BuilderTable/Request/AddOrUpdateBuilderTableColumnReq.cs
diff --git a/OpenAuth.App/Request/AddOrUpdateBuilderTableReq.cs b/OpenAuth.App/BuilderTable/Request/AddOrUpdateBuilderTableReq.cs
similarity index 100%
rename from OpenAuth.App/Request/AddOrUpdateBuilderTableReq.cs
rename to OpenAuth.App/BuilderTable/Request/AddOrUpdateBuilderTableReq.cs
diff --git a/OpenAuth.App/Request/CreateBusiReq.cs b/OpenAuth.App/BuilderTable/Request/CreateBusiReq.cs
similarity index 100%
rename from OpenAuth.App/Request/CreateBusiReq.cs
rename to OpenAuth.App/BuilderTable/Request/CreateBusiReq.cs
diff --git a/OpenAuth.App/Request/CreateEntityReq.cs b/OpenAuth.App/BuilderTable/Request/CreateEntityReq.cs
similarity index 100%
rename from OpenAuth.App/Request/CreateEntityReq.cs
rename to OpenAuth.App/BuilderTable/Request/CreateEntityReq.cs
diff --git a/OpenAuth.App/Request/CreateVueReq.cs b/OpenAuth.App/BuilderTable/Request/CreateVueReq.cs
similarity index 100%
rename from OpenAuth.App/Request/CreateVueReq.cs
rename to OpenAuth.App/BuilderTable/Request/CreateVueReq.cs
diff --git a/OpenAuth.App/Request/QueryBuilderTableColumnListReq.cs b/OpenAuth.App/BuilderTable/Request/QueryBuilderTableColumnListReq.cs
similarity index 100%
rename from OpenAuth.App/Request/QueryBuilderTableColumnListReq.cs
rename to OpenAuth.App/BuilderTable/Request/QueryBuilderTableColumnListReq.cs
diff --git a/OpenAuth.App/Request/QueryBuilderTableListReq.cs b/OpenAuth.App/BuilderTable/Request/QueryBuilderTableListReq.cs
similarity index 100%
rename from OpenAuth.App/Request/QueryBuilderTableListReq.cs
rename to OpenAuth.App/BuilderTable/Request/QueryBuilderTableListReq.cs
diff --git a/OpenAuth.App/CategoryApp.cs b/OpenAuth.App/Category/CategoryApp.cs
similarity index 97%
rename from OpenAuth.App/CategoryApp.cs
rename to OpenAuth.App/Category/CategoryApp.cs
index 382cdbde..0a44d3e9 100644
--- a/OpenAuth.App/CategoryApp.cs
+++ b/OpenAuth.App/Category/CategoryApp.cs
@@ -1,98 +1,98 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Infrastructure;
-using OpenAuth.App.Interface;
-using OpenAuth.App.Request;
-using OpenAuth.App.Response;
-using OpenAuth.Repository;
-using OpenAuth.Repository.Domain;
-using OpenAuth.Repository.Interface;
-
-
-namespace OpenAuth.App
-{
- public class CategoryApp : BaseStringApp
- {
- ///
- /// 加载列表
- ///
- public async Task Load(QueryCategoryListReq request)
- {
- var loginContext = _auth.GetCurrentUser();
- if (loginContext == null)
- {
- throw new CommonException("登录已过期", Define.INVALID_TOKEN);
- }
-
- var properties = loginContext.GetProperties("Category");
-
- if (properties == null || properties.Count == 0)
- {
- throw new Exception("当前登录用户没有访问该模块字段的权限,请联系管理员配置");
- }
-
- var result = new TableData();
- var objs = UnitWork.Find(null);
- if (!string.IsNullOrEmpty(request.TypeId))
- {
- objs = objs.Where(u => u.TypeId == request.TypeId);
- }
-
- if (!string.IsNullOrEmpty(request.key))
- {
- objs = objs.Where(u => u.Id.Contains(request.key) || u.Name.Contains(request.key));
- }
-
- var propertyStr = string.Join(',', properties.Select(u =>u.Key));
- result.columnHeaders = properties;
- result.data = objs.OrderBy(u => u.DtCode)
- .Skip((request.page - 1) * request.limit)
- .Take(request.limit).Select($"new ({propertyStr})");
- result.count = objs.Count();
- return result;
- }
-
- public void Add(AddOrUpdateCategoryReq req)
- {
- var obj = req.MapTo();
- obj.CreateTime = DateTime.Now;
- var user = _auth.GetCurrentUser().User;
- obj.CreateUserId = user.Id;
- obj.CreateUserName = user.Name;
- Repository.Add(obj);
- }
-
- public void Update(AddOrUpdateCategoryReq obj)
- {
- var user = _auth.GetCurrentUser().User;
- UnitWork.Update(u => u.Id == obj.Id, u => new Category
- {
- Enable = obj.Enable,
- DtValue = obj.DtValue,
- DtCode = obj.DtCode,
- TypeId = obj.TypeId,
- UpdateTime = DateTime.Now,
- UpdateUserId = user.Id,
- UpdateUserName = user.Name
- //todo:要修改的字段赋值
- });
-
- }
-
- ///
- /// 加载一个分类类型里面的所有值,即字典的所有值
- ///
- ///
- ///
- public List LoadByTypeId(string typeId)
- {
- return Repository.Find(u => u.TypeId == typeId).ToList();
- }
-
- public CategoryApp(IUnitWork unitWork, IRepository repository,IAuth auth) : base(unitWork, repository, auth)
- {
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Infrastructure;
+using OpenAuth.App.Interface;
+using OpenAuth.App.Request;
+using OpenAuth.App.Response;
+using OpenAuth.Repository;
+using OpenAuth.Repository.Domain;
+using OpenAuth.Repository.Interface;
+
+
+namespace OpenAuth.App
+{
+ public class CategoryApp : BaseStringApp
+ {
+ ///
+ /// 加载列表
+ ///
+ public async Task Load(QueryCategoryListReq request)
+ {
+ var loginContext = _auth.GetCurrentUser();
+ if (loginContext == null)
+ {
+ throw new CommonException("登录已过期", Define.INVALID_TOKEN);
+ }
+
+ var properties = loginContext.GetProperties("Category");
+
+ if (properties == null || properties.Count == 0)
+ {
+ throw new Exception("当前登录用户没有访问该模块字段的权限,请联系管理员配置");
+ }
+
+ var result = new TableData();
+ var objs = UnitWork.Find(null);
+ if (!string.IsNullOrEmpty(request.TypeId))
+ {
+ objs = objs.Where(u => u.TypeId == request.TypeId);
+ }
+
+ if (!string.IsNullOrEmpty(request.key))
+ {
+ objs = objs.Where(u => u.Id.Contains(request.key) || u.Name.Contains(request.key));
+ }
+
+ var propertyStr = string.Join(',', properties.Select(u =>u.Key));
+ result.columnHeaders = properties;
+ result.data = objs.OrderBy(u => u.DtCode)
+ .Skip((request.page - 1) * request.limit)
+ .Take(request.limit).Select($"new ({propertyStr})");
+ result.count = objs.Count();
+ return result;
+ }
+
+ public void Add(AddOrUpdateCategoryReq req)
+ {
+ var obj = req.MapTo();
+ obj.CreateTime = DateTime.Now;
+ var user = _auth.GetCurrentUser().User;
+ obj.CreateUserId = user.Id;
+ obj.CreateUserName = user.Name;
+ Repository.Add(obj);
+ }
+
+ public void Update(AddOrUpdateCategoryReq obj)
+ {
+ var user = _auth.GetCurrentUser().User;
+ UnitWork.Update(u => u.Id == obj.Id, u => new Category
+ {
+ Enable = obj.Enable,
+ DtValue = obj.DtValue,
+ DtCode = obj.DtCode,
+ TypeId = obj.TypeId,
+ UpdateTime = DateTime.Now,
+ UpdateUserId = user.Id,
+ UpdateUserName = user.Name
+ //todo:要修改的字段赋值
+ });
+
+ }
+
+ ///
+ /// 加载一个分类类型里面的所有值,即字典的所有值
+ ///
+ ///
+ ///
+ public List LoadByTypeId(string typeId)
+ {
+ return Repository.Find(u => u.TypeId == typeId).ToList();
+ }
+
+ public CategoryApp(IUnitWork unitWork, IRepository repository,IAuth auth) : base(unitWork, repository, auth)
+ {
+ }
+ }
}
\ No newline at end of file
diff --git a/OpenAuth.App/CategoryTypeApp.cs b/OpenAuth.App/Category/CategoryTypeApp.cs
similarity index 100%
rename from OpenAuth.App/CategoryTypeApp.cs
rename to OpenAuth.App/Category/CategoryTypeApp.cs
diff --git a/OpenAuth.App/Request/AddOrUpdateCategoryReq.cs b/OpenAuth.App/Category/Request/AddOrUpdateCategoryReq.cs
similarity index 100%
rename from OpenAuth.App/Request/AddOrUpdateCategoryReq.cs
rename to OpenAuth.App/Category/Request/AddOrUpdateCategoryReq.cs
diff --git a/OpenAuth.App/Request/AddOrUpdateCategoryTypeReq.cs b/OpenAuth.App/Category/Request/AddOrUpdateCategoryTypeReq.cs
similarity index 100%
rename from OpenAuth.App/Request/AddOrUpdateCategoryTypeReq.cs
rename to OpenAuth.App/Category/Request/AddOrUpdateCategoryTypeReq.cs
diff --git a/OpenAuth.App/Request/QueryCategoryListReq.cs b/OpenAuth.App/Category/Request/QueryCategoryListReq.cs
similarity index 100%
rename from OpenAuth.App/Request/QueryCategoryListReq.cs
rename to OpenAuth.App/Category/Request/QueryCategoryListReq.cs
diff --git a/OpenAuth.App/Request/QueryCategoryTypeListReq.cs b/OpenAuth.App/Category/Request/QueryCategoryTypeListReq.cs
similarity index 100%
rename from OpenAuth.App/Request/QueryCategoryTypeListReq.cs
rename to OpenAuth.App/Category/Request/QueryCategoryTypeListReq.cs
diff --git a/OpenAuth.App/DataPrivilegeRuleApp.cs b/OpenAuth.App/DataPrivilege/DataPrivilegeRuleApp.cs
similarity index 100%
rename from OpenAuth.App/DataPrivilegeRuleApp.cs
rename to OpenAuth.App/DataPrivilege/DataPrivilegeRuleApp.cs
diff --git a/OpenAuth.App/Request/AddOrUpdateDataPriviReq.cs b/OpenAuth.App/DataPrivilege/Request/AddOrUpdateDataPriviReq.cs
similarity index 100%
rename from OpenAuth.App/Request/AddOrUpdateDataPriviReq.cs
rename to OpenAuth.App/DataPrivilege/Request/AddOrUpdateDataPriviReq.cs
diff --git a/OpenAuth.App/Request/QueryDataPrivilegeRuleListReq.cs b/OpenAuth.App/DataPrivilege/Request/QueryDataPrivilegeRuleListReq.cs
similarity index 100%
rename from OpenAuth.App/Request/QueryDataPrivilegeRuleListReq.cs
rename to OpenAuth.App/DataPrivilege/Request/QueryDataPrivilegeRuleListReq.cs
diff --git a/OpenAuth.App/FileApp.cs b/OpenAuth.App/Files/FileApp.cs
similarity index 100%
rename from OpenAuth.App/FileApp.cs
rename to OpenAuth.App/Files/FileApp.cs
diff --git a/OpenAuth.App/Request/QueryFileListReq.cs b/OpenAuth.App/Files/Request/QueryFileListReq.cs
similarity index 100%
rename from OpenAuth.App/Request/QueryFileListReq.cs
rename to OpenAuth.App/Files/Request/QueryFileListReq.cs
diff --git a/OpenAuth.App/Flow/FlowRuntime.cs b/OpenAuth.App/Flow/FlowRuntime.cs
index ce73ad8e..d5b4b06d 100644
--- a/OpenAuth.App/Flow/FlowRuntime.cs
+++ b/OpenAuth.App/Flow/FlowRuntime.cs
@@ -325,6 +325,17 @@ namespace OpenAuth.App.Flow
return previousId;
}
+ ///
+ /// 撤销流程,清空所有节点
+ ///
+ public void ReCall()
+ {
+ foreach (var item in Nodes)
+ {
+ item.Value.setInfo = null;
+ }
+ }
+
///
/// 标记节点1通过,-1不通过,0驳回
///
diff --git a/OpenAuth.App/FlowInstanceApp.cs b/OpenAuth.App/FlowInstance/FlowInstanceApp.cs
similarity index 75%
rename from OpenAuth.App/FlowInstanceApp.cs
rename to OpenAuth.App/FlowInstance/FlowInstanceApp.cs
index 182865b8..4664e90c 100644
--- a/OpenAuth.App/FlowInstanceApp.cs
+++ b/OpenAuth.App/FlowInstance/FlowInstanceApp.cs
@@ -1,575 +1,674 @@
-// ***********************************************************************
-// Assembly : OpenAuth.App
-// Author : 李玉宝
-// Created : 07-19-2018
-//
-// Last Modified By : 李玉宝
-// Last Modified On : 07-19-2018
-// ***********************************************************************
-//
-// Copyright (c) http://www.openauth.me. All rights reserved.
-//
-//
-// ***********************************************************************
-
-using Infrastructure;
-using OpenAuth.App.Flow;
-using OpenAuth.App.Interface;
-using OpenAuth.App.Request;
-using OpenAuth.App.Response;
-using OpenAuth.Repository.Domain;
-using OpenAuth.Repository.Interface;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Infrastructure.Helpers;
-using OpenAuth.Repository;
-
-namespace OpenAuth.App
-{
- ///
- /// 工作流实例表操作
- ///
- public class FlowInstanceApp : BaseStringApp
- {
- private RevelanceManagerApp _revelanceApp;
- private FlowSchemeApp _flowSchemeApp;
- private FormApp _formApp;
- private IHttpClientFactory _httpClientFactory;
- private IServiceProvider _serviceProvider;
-
- #region 流程处理API
-
- ///
- /// 创建一个实例
- ///
- ///
- public bool CreateInstance(AddFlowInstanceReq addFlowInstanceReq)
- {
- FlowScheme scheme = null;
- if (!string.IsNullOrEmpty(addFlowInstanceReq.SchemeId))
- {
- scheme = _flowSchemeApp.Get(addFlowInstanceReq.SchemeId);
- }
-
- if ((scheme == null) && !string.IsNullOrEmpty(addFlowInstanceReq.SchemeCode))
- {
- scheme = _flowSchemeApp.FindByCode(addFlowInstanceReq.SchemeCode);
- }
-
- if (scheme == null)
- {
- throw new Exception("该流程模板已不存在,请重新设计流程");
- }
-
- addFlowInstanceReq.SchemeContent = scheme.SchemeContent;
-
- var form = _formApp.FindSingle(scheme.FrmId);
- if (form == null)
- {
- throw new Exception("该流程模板对应的表单已不存在,请重新设计流程");
- }
-
- addFlowInstanceReq.FrmContentData = form.ContentData;
- addFlowInstanceReq.FrmContentParse = form.ContentParse;
- addFlowInstanceReq.FrmType = form.FrmType;
- addFlowInstanceReq.FrmId = form.Id;
-
- var flowInstance = addFlowInstanceReq.MapTo();
-
- //创建运行实例
- var wfruntime = new FlowRuntime(flowInstance);
- var user = _auth.GetCurrentUser();
-
- #region 根据运行实例改变当前节点状态
-
- flowInstance.ActivityId = wfruntime.nextNodeId;
- flowInstance.ActivityType = wfruntime.GetNextNodeType();
- flowInstance.ActivityName = wfruntime.nextNode.name;
- flowInstance.PreviousId = wfruntime.currentNodeId;
- flowInstance.CreateUserId = user.User.Id;
- flowInstance.CreateUserName = user.User.Account;
- flowInstance.MakerList = (wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : "");
- flowInstance.IsFinish = (wfruntime.GetNextNodeType() == 4 ? 1 : 0);
-
- UnitWork.Add(flowInstance);
- wfruntime.flowInstanceId = flowInstance.Id;
-
- if (flowInstance.FrmType == 1) //如果是开发者自定义的表单
- {
- var t = Type.GetType("OpenAuth.App."+ flowInstance.DbName +"App");
- ICustomerForm icf = (ICustomerForm) _serviceProvider.GetService(t);
- icf.Add(flowInstance.Id, flowInstance.FrmData);
- }
-
- #endregion 根据运行实例改变当前节点状态
-
- #region 流程操作记录
-
- FlowInstanceOperationHistory processOperationHistoryEntity = new FlowInstanceOperationHistory
- {
- InstanceId = flowInstance.Id,
- CreateUserId = user.User.Id,
- CreateUserName = user.User.Name,
- CreateDate = DateTime.Now,
- Content = "【创建】"
- + user.User.Name
- + "创建了一个流程进程【"
- + addFlowInstanceReq.Code + "/"
- + addFlowInstanceReq.CustomName + "】"
- };
- UnitWork.Add(processOperationHistoryEntity);
-
- #endregion 流程操作记录
-
- AddTransHistory(wfruntime);
- UnitWork.Save();
- return true;
- }
-
- ///
- /// 节点审核
- ///
- ///
- ///
- public bool NodeVerification(string instanceId, Tag tag)
- {
- FlowInstance flowInstance = Get(instanceId);
- FlowInstanceOperationHistory flowInstanceOperationHistory = new FlowInstanceOperationHistory
- {
- InstanceId = instanceId,
- CreateUserId = tag.UserId,
- CreateUserName = tag.UserName,
- CreateDate = DateTime.Now
- };//操作记录
- FlowRuntime wfruntime = new FlowRuntime(flowInstance);
-
- #region 会签
-
- if (flowInstance.ActivityType == 0)//当前节点是会签节点
- {
- //会签时的【当前节点】一直是会签开始节点
- //TODO: 标记会签节点的状态,这个地方感觉怪怪的
- wfruntime.MakeTagNode(wfruntime.currentNodeId, tag);
-
- string canCheckId = ""; //寻找当前登录用户可审核的节点Id
- foreach (string fromForkStartNodeId in wfruntime.FromNodeLines[wfruntime.currentNodeId].Select(u => u.to))
- {
- var fromForkStartNode = wfruntime.Nodes[fromForkStartNodeId]; //与会前开始节点直接连接的节点
- canCheckId = GetOneForkLineCanCheckNodeId(fromForkStartNode, wfruntime, tag);
- if(!string.IsNullOrEmpty(canCheckId)) break;
- }
-
- if (canCheckId == "")
- {
- throw (new Exception("审核异常,找不到审核节点"));
- }
-
- flowInstanceOperationHistory.Content = "【" + wfruntime.Nodes[canCheckId].name
- + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm")
- + "】" + (tag.Taged == 1 ? "同意" : "不同意") + ",备注:"
- + tag.Description;
-
- wfruntime.MakeTagNode(canCheckId, tag); //标记审核节点状态
- string res = wfruntime.NodeConfluence(canCheckId, tag);
- if (res == TagState.No.ToString("D"))
- {
- flowInstance.IsFinish = 3;
- }
- else if(!string.IsNullOrEmpty(res))
- {
- flowInstance.PreviousId = flowInstance.ActivityId;
- flowInstance.ActivityId = wfruntime.nextNodeId;
- flowInstance.ActivityType = wfruntime.nextNodeType;
- flowInstance.ActivityName = wfruntime.nextNode.name;
- flowInstance.IsFinish = (wfruntime.nextNodeType == 4 ? 1 : 0);
- flowInstance.MakerList =
- (wfruntime.nextNodeType == 4 ? "" : GetNextMakers(wfruntime));
-
- AddTransHistory(wfruntime);
- }
- else
- {
- //会签过程中,需要更新用户
- flowInstance.MakerList = GetForkNodeMakers(wfruntime, wfruntime.currentNodeId);
- AddTransHistory(wfruntime);
- }
-
- }
- #endregion 会签
-
- #region 一般审核
-
- else
- {
- wfruntime.MakeTagNode(wfruntime.currentNodeId, tag);
- if (tag.Taged == (int) TagState.Ok)
- {
- flowInstance.PreviousId = flowInstance.ActivityId;
- flowInstance.ActivityId = wfruntime.nextNodeId;
- flowInstance.ActivityType = wfruntime.nextNodeType;
- flowInstance.ActivityName = wfruntime.nextNode.name;
- flowInstance.MakerList = wfruntime.nextNodeType == 4 ? "" : GetNextMakers(wfruntime);
- flowInstance.IsFinish = (wfruntime.nextNodeType == 4 ? 1 : 0);
- AddTransHistory(wfruntime);
- }
- else
- {
- flowInstance.IsFinish = 3; //表示该节点不同意
- }
- flowInstanceOperationHistory.Content = "【" + wfruntime.currentNode.name
- + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm")
- + "】" + (tag.Taged == 1 ? "同意" : "不同意") + ",备注:"
- + tag.Description;
- }
-
- #endregion 一般审核
-
- flowInstance.SchemeContent = JsonHelper.Instance.Serialize(wfruntime.ToSchemeObj());
-
- UnitWork.Update(flowInstance);
- UnitWork.Add(flowInstanceOperationHistory);
- UnitWork.Save();
-
- wfruntime.NotifyThirdParty(_httpClientFactory.CreateClient(), tag);
- return true;
- }
-
- //会签时,获取一条会签分支上面是否有用户可审核的节点
- private string GetOneForkLineCanCheckNodeId(FlowNode fromForkStartNode, FlowRuntime wfruntime, Tag tag)
- {
- string canCheckId="";
- var node = fromForkStartNode;
- do //沿一条分支线路执行,直到遇到会签结束节点
- {
- var makerList = GetNodeMarkers(node);
-
- if (node.setInfo.Taged == null && !string.IsNullOrEmpty(makerList) && makerList.Split(',').Any(one => tag.UserId == one))
- {
- canCheckId = node.id;
- break;
- }
-
- node = wfruntime.GetNextNode(node.id);
- } while (node.type != FlowNode.JOIN);
-
- return canCheckId;
- }
-
- ///
- /// 驳回
- /// 如果NodeRejectStep不为空,优先使用;否则按照NodeRejectType驳回
- ///
- ///
- public bool NodeReject(VerificationReq reqest)
- {
- var user = _auth.GetCurrentUser().User;
-
- FlowInstance flowInstance = Get(reqest.FlowInstanceId);
-
- FlowRuntime wfruntime = new FlowRuntime(flowInstance);
-
- string rejectNode = ""; //驳回的节点
- rejectNode = string.IsNullOrEmpty(reqest.NodeRejectStep) ? wfruntime.RejectNode(reqest.NodeRejectType) : reqest.NodeRejectStep;
-
- var tag = new Tag
- {
- Description = reqest.VerificationOpinion,
- Taged = (int) TagState.Reject,
- UserId = user.Id,
- UserName = user.Name
- };
-
- wfruntime.MakeTagNode(wfruntime.currentNodeId, tag);
- flowInstance.IsFinish = 4;//4表示驳回(需要申请者重新提交表单)
- if (rejectNode != "")
- {
- flowInstance.PreviousId = flowInstance.ActivityId;
- flowInstance.ActivityId = rejectNode;
- flowInstance.ActivityType = wfruntime.GetNodeType(rejectNode);
- flowInstance.ActivityName = wfruntime.Nodes[rejectNode].name;
- flowInstance.MakerList = GetNodeMarkers(wfruntime.Nodes[rejectNode], flowInstance.CreateUserId);
-
- AddTransHistory(wfruntime);
- }
-
- UnitWork.Update(flowInstance);
-
- UnitWork.Add(new FlowInstanceOperationHistory
- {
- InstanceId = reqest.FlowInstanceId
- ,
- CreateUserId = user.Id
- ,
- CreateUserName = user.Name
- ,
- CreateDate = DateTime.Now
- ,
- Content = "【"
- + wfruntime.currentNode.name
- + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】驳回,备注:"
- + reqest.VerificationOpinion
- });
-
- UnitWork.Save();
-
- wfruntime.NotifyThirdParty(_httpClientFactory.CreateClient(), tag);
-
- return true;
- }
-
- #endregion 流程处理API
-
- #region 获取各种节点的流程审核者
- ///
- /// 寻找下一步的执行人
- /// 一般用于本节点审核完成后,修改流程实例的当前执行人,可以做到通知等功能
- ///
- ///
- private string GetNextMakers(FlowRuntime wfruntime)
- {
- string makerList = "";
- if (wfruntime.nextNodeId == "-1")
- {
- throw (new Exception("无法寻找到下一个节点"));
- }
- if (wfruntime.nextNodeType == 0)//如果是会签节点
- {
- makerList = GetForkNodeMakers(wfruntime, wfruntime.nextNodeId);
- }
- else
- {
- makerList = GetNodeMarkers(wfruntime.nextNode);
- if (string.IsNullOrEmpty(makerList))
- {
- throw (new Exception("无法寻找到节点的审核者,请查看流程设计是否有问题!"));
- }
- }
-
- return makerList;
- }
-
- ///
- /// 获取会签开始节点的所有可执行者
- ///
- /// 会签开始节点
- ///
- private string GetForkNodeMakers(FlowRuntime wfruntime, string forkNodeId)
- {
- string makerList="";
- foreach (string fromForkStartNodeId in wfruntime.FromNodeLines[forkNodeId].Select(u => u.to))
- {
- var fromForkStartNode = wfruntime.Nodes[fromForkStartNodeId]; //与会前开始节点直接连接的节点
- if (makerList != "")
- {
- makerList += ",";
- }
-
- makerList += GetOneForkLineMakers(fromForkStartNode, wfruntime);
- }
-
- return makerList;
- }
-
- //获取会签一条线上的审核者,该审核者应该是已审核过的节点的下一个人
- private string GetOneForkLineMakers(FlowNode fromForkStartNode, FlowRuntime wfruntime)
- {
- string markers="";
- var node = fromForkStartNode;
- do //沿一条分支线路执行,直到遇到第一个没有审核的节点
- {
- if (node.setInfo != null && node.setInfo.Taged != null)
- {
- if (node.type != FlowNode.FORK && node.setInfo.Taged != (int) TagState.Ok) //如果节点是不同意或驳回,则不用再找了
- {
- break;
- }
- node = wfruntime.GetNextNode(node.id); //下一个节点
- continue;
- }
- var marker = GetNodeMarkers(node);
- if (marker == "")
- {
- throw (new Exception($"节点{node.name}没有审核者,请检查!"));
- }
- if (marker == "1")
- {
- throw (new Exception($"节点{node.name}是会签节点,不能用所有人,请检查!"));
- }
-
- if (markers != "")
- {
- markers += ",";
- }
- markers += marker;
- break;
- } while (node.type != FlowNode.JOIN);
-
- return markers;
- }
-
- ///
- /// 寻找该节点执行人
- ///
- ///
- ///
- private string GetNodeMarkers(FlowNode node,string flowinstanceCreateUserId="")
- {
- string makerList = "";
- if (node.type == FlowNode.START && (!string.IsNullOrEmpty(flowinstanceCreateUserId))) //如果是开始节点,通常情况下是驳回到开始了
- {
- makerList = flowinstanceCreateUserId;
- }
- else if (node.setInfo != null)
- {
- if (node.setInfo.NodeDesignate == Setinfo.ALL_USER)//所有成员
- {
- makerList = "1";
- }
- else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_USER)//指定成员
- {
- makerList = GenericHelpers.ArrayToString(node.setInfo.NodeDesignateData.users, makerList);
- }
- else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_ROLE) //指定角色
- {
- var users = _revelanceApp.Get(Define.USERROLE, false, node.setInfo.NodeDesignateData.roles);
- makerList = GenericHelpers.ArrayToString(users, makerList);
- }
- }
- else //如果没有设置节点信息,默认所有人都可以审核
- {
- makerList = "1";
- }
- return makerList;
- }
- #endregion
-
- ///
- /// 审核流程
- /// 李玉宝于2017-01-20 15:44:45
- ///
- public void Verification(VerificationReq request)
- {
- var user = _auth.GetCurrentUser().User;
- var tag = new Tag
- {
- UserName = user.Name,
- UserId = user.Id,
- Description = request.VerificationOpinion,
- Taged = Int32.Parse(request.VerificationFinally)
- };
- bool isReject = TagState.Reject.Equals((TagState) tag.Taged);
- if (isReject) //驳回
- {
- NodeReject(request);
- }
- else
- {
- NodeVerification(request.FlowInstanceId, tag);
- }
- }
-
- public void Update(FlowInstance flowScheme)
- {
- Repository.Update(flowScheme);
- }
-
- public async Task Load(QueryFlowInstanceListReq request)
- {
- var result = new TableData();
- var user = _auth.GetCurrentUser();
-
- if (request.type == "wait") //待办事项
- {
- Expression> waitExp = u => (u.MakerList == "1" || u.MakerList.Contains(user.User.Id)) && (u.IsFinish == 0|| u.IsFinish==4);
-
- // 加入搜索自定义标题
- if (!string.IsNullOrEmpty(request.key))
- {
- waitExp = waitExp.And(t => t.CustomName.Contains(request.key));
- }
-
- result.count = UnitWork.Find(waitExp).Count();
-
- result.data = UnitWork.Find(request.page, request.limit, "CreateDate descending", waitExp).ToList();
- }
- else if (request.type == "disposed") //已办事项(即我参与过的流程)
- {
- var instances = UnitWork.Find(u => u.CreateUserId == user.User.Id)
- .Select(u => u.InstanceId).Distinct();
- var query = from ti in instances
- join ct in UnitWork.Find(null) on ti equals ct.Id
- select ct;
-
- // 加入搜索自定义标题
- if (!string.IsNullOrEmpty(request.key))
- {
- query = query.Where(t => t.CustomName.Contains(request.key));
- }
-
- result.data = query.OrderByDescending(u => u.CreateDate)
- .Skip((request.page - 1) * request.limit)
- .Take(request.limit).ToList();
- result.count = instances.Count();
- }
- else //我的流程
- {
- Expression> myFlowExp = u => u.CreateUserId == user.User.Id;
-
- // 加入搜索自定义标题
- if (!string.IsNullOrEmpty(request.key))
- {
- myFlowExp = myFlowExp.And(t => t.CustomName.Contains(request.key));
- }
-
- result.count = UnitWork.Find(myFlowExp).Count();
- result.data = UnitWork.Find(request.page, request.limit,
- "CreateDate descending", myFlowExp).ToList();
- }
-
- return result;
- }
-
- ///
- /// 添加扭转记录
- ///
- private void AddTransHistory(FlowRuntime wfruntime)
- {
- var tag = _auth.GetCurrentUser().User;
- UnitWork.Add(new FlowInstanceTransitionHistory
- {
- InstanceId = wfruntime.flowInstanceId,
- CreateUserId = tag.Id,
- CreateUserName = tag.Name,
- FromNodeId = wfruntime.currentNodeId,
- FromNodeName = wfruntime.currentNode.name,
- FromNodeType = wfruntime.currentNodeType,
- ToNodeId = wfruntime.nextNodeId,
- ToNodeName = wfruntime.nextNode.name,
- ToNodeType = wfruntime.nextNodeType,
- IsFinish = wfruntime.nextNodeType == 4 ? 1 : 0,
- TransitionSate = 0
- });
- }
-
- public FlowInstanceApp(IUnitWork unitWork, IRepository repository
- , RevelanceManagerApp app, FlowSchemeApp flowSchemeApp, FormApp formApp, IHttpClientFactory httpClientFactory,IAuth auth, IServiceProvider serviceProvider)
- : base(unitWork, repository, auth)
- {
- _revelanceApp = app;
- _flowSchemeApp = flowSchemeApp;
- _formApp = formApp;
- _httpClientFactory = httpClientFactory;
- _serviceProvider = serviceProvider;
- }
-
- public List QueryHistories(QueryFlowInstanceHistoryReq request)
- {
- return UnitWork.Find(u => u.InstanceId == request.FlowInstanceId)
- .OrderByDescending(u => u.CreateDate).ToList();
- }
- }
+// ***********************************************************************
+// Assembly : OpenAuth.App
+// Author : 李玉宝
+// Created : 07-19-2018
+//
+// Last Modified By : 李玉宝
+// Last Modified On : 07-19-2018
+// ***********************************************************************
+//
+// Copyright (c) http://www.openauth.me. All rights reserved.
+//
+//
+// ***********************************************************************
+
+using Infrastructure;
+using OpenAuth.App.Flow;
+using OpenAuth.App.Interface;
+using OpenAuth.App.Request;
+using OpenAuth.App.Response;
+using OpenAuth.Repository.Domain;
+using OpenAuth.Repository.Interface;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Net.Http;
+using System.Threading.Tasks;
+using Infrastructure.Const;
+using Infrastructure.Helpers;
+using OpenAuth.Repository;
+
+namespace OpenAuth.App
+{
+ ///
+ /// 工作流实例表操作
+ ///
+ public class FlowInstanceApp : BaseStringApp
+ {
+ private RevelanceManagerApp _revelanceApp;
+ private FlowSchemeApp _flowSchemeApp;
+ private FormApp _formApp;
+ private IHttpClientFactory _httpClientFactory;
+ private IServiceProvider _serviceProvider;
+
+ public FlowInstanceApp(IUnitWork unitWork,
+ IRepository repository
+ , RevelanceManagerApp app, FlowSchemeApp flowSchemeApp, FormApp formApp,
+ IHttpClientFactory httpClientFactory, IAuth auth, IServiceProvider serviceProvider)
+ : base(unitWork, repository, auth)
+ {
+ _revelanceApp = app;
+ _flowSchemeApp = flowSchemeApp;
+ _formApp = formApp;
+ _httpClientFactory = httpClientFactory;
+ _serviceProvider = serviceProvider;
+ }
+
+ #region 流程处理API
+
+ ///
+ /// 创建一个实例
+ ///
+ ///
+ public bool CreateInstance(AddFlowInstanceReq addFlowInstanceReq)
+ {
+ FlowScheme scheme = null;
+ if (!string.IsNullOrEmpty(addFlowInstanceReq.SchemeId))
+ {
+ scheme = _flowSchemeApp.Get(addFlowInstanceReq.SchemeId);
+ }
+
+ if ((scheme == null) && !string.IsNullOrEmpty(addFlowInstanceReq.SchemeCode))
+ {
+ scheme = _flowSchemeApp.FindByCode(addFlowInstanceReq.SchemeCode);
+ }
+
+ if (scheme == null)
+ {
+ throw new Exception("该流程模板已不存在,请重新设计流程");
+ }
+
+ addFlowInstanceReq.SchemeContent = scheme.SchemeContent;
+
+ var form = _formApp.FindSingle(scheme.FrmId);
+ if (form == null)
+ {
+ throw new Exception("该流程模板对应的表单已不存在,请重新设计流程");
+ }
+
+ addFlowInstanceReq.FrmContentData = form.ContentData;
+ addFlowInstanceReq.FrmContentParse = form.ContentParse;
+ addFlowInstanceReq.FrmType = form.FrmType;
+ addFlowInstanceReq.FrmId = form.Id;
+
+ var flowInstance = addFlowInstanceReq.MapTo();
+
+ //创建运行实例
+ var wfruntime = new FlowRuntime(flowInstance);
+ var user = _auth.GetCurrentUser();
+
+ #region 根据运行实例改变当前节点状态
+
+ flowInstance.ActivityId = wfruntime.nextNodeId;
+ flowInstance.ActivityType = wfruntime.GetNextNodeType();
+ flowInstance.ActivityName = wfruntime.nextNode.name;
+ flowInstance.PreviousId = wfruntime.currentNodeId;
+ flowInstance.CreateUserId = user.User.Id;
+ flowInstance.CreateUserName = user.User.Account;
+ flowInstance.MakerList = (wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : "");
+ flowInstance.IsFinish = (wfruntime.GetNextNodeType() == 4
+ ? FlowInstanceStatus.Finished
+ : FlowInstanceStatus.Running);
+
+ UnitWork.Add(flowInstance);
+ wfruntime.flowInstanceId = flowInstance.Id;
+
+ if (flowInstance.FrmType == 1) //如果是开发者自定义的表单
+ {
+ var t = Type.GetType("OpenAuth.App." + flowInstance.DbName + "App");
+ ICustomerForm icf = (ICustomerForm) _serviceProvider.GetService(t);
+ icf.Add(flowInstance.Id, flowInstance.FrmData);
+ }
+
+ #endregion 根据运行实例改变当前节点状态
+
+ #region 流程操作记录
+
+ FlowInstanceOperationHistory processOperationHistoryEntity = new FlowInstanceOperationHistory
+ {
+ InstanceId = flowInstance.Id,
+ CreateUserId = user.User.Id,
+ CreateUserName = user.User.Name,
+ CreateDate = DateTime.Now,
+ Content = "【创建】"
+ + user.User.Name
+ + "创建了一个流程进程【"
+ + addFlowInstanceReq.Code + "/"
+ + addFlowInstanceReq.CustomName + "】"
+ };
+ UnitWork.Add(processOperationHistoryEntity);
+
+ #endregion 流程操作记录
+
+ AddTransHistory(wfruntime);
+ UnitWork.Save();
+ return true;
+ }
+
+ ///
+ /// 节点审核
+ ///
+ ///
+ ///
+ public bool NodeVerification(string instanceId, Tag tag)
+ {
+ FlowInstance flowInstance = Get(instanceId);
+ FlowInstanceOperationHistory flowInstanceOperationHistory = new FlowInstanceOperationHistory
+ {
+ InstanceId = instanceId,
+ CreateUserId = tag.UserId,
+ CreateUserName = tag.UserName,
+ CreateDate = DateTime.Now
+ }; //操作记录
+ FlowRuntime wfruntime = new FlowRuntime(flowInstance);
+
+ #region 会签
+
+ if (flowInstance.ActivityType == 0) //当前节点是会签节点
+ {
+ //会签时的【当前节点】一直是会签开始节点
+ //TODO: 标记会签节点的状态,这个地方感觉怪怪的
+ wfruntime.MakeTagNode(wfruntime.currentNodeId, tag);
+
+ string canCheckId = ""; //寻找当前登录用户可审核的节点Id
+ foreach (string fromForkStartNodeId in wfruntime.FromNodeLines[wfruntime.currentNodeId]
+ .Select(u => u.to))
+ {
+ var fromForkStartNode = wfruntime.Nodes[fromForkStartNodeId]; //与会前开始节点直接连接的节点
+ canCheckId = GetOneForkLineCanCheckNodeId(fromForkStartNode, wfruntime, tag);
+ if (!string.IsNullOrEmpty(canCheckId)) break;
+ }
+
+ if (canCheckId == "")
+ {
+ throw (new Exception("审核异常,找不到审核节点"));
+ }
+
+ flowInstanceOperationHistory.Content = "【" + wfruntime.Nodes[canCheckId].name
+ + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm")
+ + "】" + (tag.Taged == 1 ? "同意" : "不同意") + ",备注:"
+ + tag.Description;
+
+ wfruntime.MakeTagNode(canCheckId, tag); //标记审核节点状态
+ string res = wfruntime.NodeConfluence(canCheckId, tag);
+ if (res == TagState.No.ToString("D"))
+ {
+ flowInstance.IsFinish = FlowInstanceStatus.Disagree;
+ }
+ else if (!string.IsNullOrEmpty(res))
+ {
+ flowInstance.PreviousId = flowInstance.ActivityId;
+ flowInstance.ActivityId = wfruntime.nextNodeId;
+ flowInstance.ActivityType = wfruntime.nextNodeType;
+ flowInstance.ActivityName = wfruntime.nextNode.name;
+ flowInstance.IsFinish = (wfruntime.nextNodeType == 4
+ ? FlowInstanceStatus.Finished
+ : FlowInstanceStatus.Running);
+ flowInstance.MakerList =
+ (wfruntime.nextNodeType == 4 ? "" : GetNextMakers(wfruntime));
+
+ AddTransHistory(wfruntime);
+ }
+ else
+ {
+ //会签过程中,需要更新用户
+ flowInstance.MakerList = GetForkNodeMakers(wfruntime, wfruntime.currentNodeId);
+ AddTransHistory(wfruntime);
+ }
+ }
+
+ #endregion 会签
+
+ #region 一般审核
+
+ else
+ {
+ wfruntime.MakeTagNode(wfruntime.currentNodeId, tag);
+ if (tag.Taged == (int) TagState.Ok)
+ {
+ flowInstance.PreviousId = flowInstance.ActivityId;
+ flowInstance.ActivityId = wfruntime.nextNodeId;
+ flowInstance.ActivityType = wfruntime.nextNodeType;
+ flowInstance.ActivityName = wfruntime.nextNode.name;
+ flowInstance.MakerList = wfruntime.nextNodeType == 4 ? "" : GetNextMakers(wfruntime);
+ flowInstance.IsFinish = (wfruntime.nextNodeType == 4
+ ? FlowInstanceStatus.Finished
+ : FlowInstanceStatus.Running);
+ AddTransHistory(wfruntime);
+ }
+ else
+ {
+ flowInstance.IsFinish = FlowInstanceStatus.Disagree; //表示该节点不同意
+ }
+
+ flowInstanceOperationHistory.Content = "【" + wfruntime.currentNode.name
+ + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm")
+ + "】" + (tag.Taged == 1 ? "同意" : "不同意") + ",备注:"
+ + tag.Description;
+ }
+
+ #endregion 一般审核
+
+ flowInstance.SchemeContent = JsonHelper.Instance.Serialize(wfruntime.ToSchemeObj());
+
+ UnitWork.Update(flowInstance);
+ UnitWork.Add(flowInstanceOperationHistory);
+ UnitWork.Save();
+
+ wfruntime.NotifyThirdParty(_httpClientFactory.CreateClient(), tag);
+ return true;
+ }
+
+ //会签时,获取一条会签分支上面是否有用户可审核的节点
+ private string GetOneForkLineCanCheckNodeId(FlowNode fromForkStartNode, FlowRuntime wfruntime, Tag tag)
+ {
+ string canCheckId = "";
+ var node = fromForkStartNode;
+ do //沿一条分支线路执行,直到遇到会签结束节点
+ {
+ var makerList = GetNodeMarkers(node);
+
+ if (node.setInfo.Taged == null && !string.IsNullOrEmpty(makerList) &&
+ makerList.Split(',').Any(one => tag.UserId == one))
+ {
+ canCheckId = node.id;
+ break;
+ }
+
+ node = wfruntime.GetNextNode(node.id);
+ } while (node.type != FlowNode.JOIN);
+
+ return canCheckId;
+ }
+
+ ///
+ /// 驳回
+ /// 如果NodeRejectStep不为空,优先使用;否则按照NodeRejectType驳回
+ ///
+ ///
+ public bool NodeReject(VerificationReq reqest)
+ {
+ var user = _auth.GetCurrentUser().User;
+
+ FlowInstance flowInstance = Get(reqest.FlowInstanceId);
+
+ FlowRuntime wfruntime = new FlowRuntime(flowInstance);
+
+ string rejectNode = ""; //驳回的节点
+ rejectNode = string.IsNullOrEmpty(reqest.NodeRejectStep)
+ ? wfruntime.RejectNode(reqest.NodeRejectType)
+ : reqest.NodeRejectStep;
+
+ var tag = new Tag
+ {
+ Description = reqest.VerificationOpinion,
+ Taged = (int) TagState.Reject,
+ UserId = user.Id,
+ UserName = user.Name
+ };
+
+ wfruntime.MakeTagNode(wfruntime.currentNodeId, tag);
+ flowInstance.IsFinish = FlowInstanceStatus.Rejected; //4表示驳回(需要申请者重新提交表单)
+ if (rejectNode != "")
+ {
+ flowInstance.PreviousId = flowInstance.ActivityId;
+ flowInstance.ActivityId = rejectNode;
+ flowInstance.ActivityType = wfruntime.GetNodeType(rejectNode);
+ flowInstance.ActivityName = wfruntime.Nodes[rejectNode].name;
+ flowInstance.MakerList = GetNodeMarkers(wfruntime.Nodes[rejectNode], flowInstance.CreateUserId);
+
+ AddTransHistory(wfruntime);
+ }
+
+ UnitWork.Update(flowInstance);
+
+ UnitWork.Add(new FlowInstanceOperationHistory
+ {
+ InstanceId = reqest.FlowInstanceId,
+ CreateUserId = user.Id,
+ CreateUserName = user.Name,
+ CreateDate = DateTime.Now,
+ Content = "【"
+ + wfruntime.currentNode.name
+ + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】驳回,备注:"
+ + reqest.VerificationOpinion
+ });
+
+ UnitWork.Save();
+
+ wfruntime.NotifyThirdParty(_httpClientFactory.CreateClient(), tag);
+
+ return true;
+ }
+
+ #endregion 流程处理API
+
+ #region 获取各种节点的流程审核者
+
+ ///
+ /// 寻找下一步的执行人
+ /// 一般用于本节点审核完成后,修改流程实例的当前执行人,可以做到通知等功能
+ ///
+ ///
+ private string GetNextMakers(FlowRuntime wfruntime)
+ {
+ string makerList = "";
+ if (wfruntime.nextNodeId == "-1")
+ {
+ throw (new Exception("无法寻找到下一个节点"));
+ }
+
+ if (wfruntime.nextNodeType == 0) //如果是会签节点
+ {
+ makerList = GetForkNodeMakers(wfruntime, wfruntime.nextNodeId);
+ }
+ else
+ {
+ makerList = GetNodeMarkers(wfruntime.nextNode);
+ if (string.IsNullOrEmpty(makerList))
+ {
+ throw (new Exception("无法寻找到节点的审核者,请查看流程设计是否有问题!"));
+ }
+ }
+
+ return makerList;
+ }
+
+ ///
+ /// 获取会签开始节点的所有可执行者
+ ///
+ /// 会签开始节点
+ ///
+ private string GetForkNodeMakers(FlowRuntime wfruntime, string forkNodeId)
+ {
+ string makerList = "";
+ foreach (string fromForkStartNodeId in wfruntime.FromNodeLines[forkNodeId].Select(u => u.to))
+ {
+ var fromForkStartNode = wfruntime.Nodes[fromForkStartNodeId]; //与会前开始节点直接连接的节点
+ if (makerList != "")
+ {
+ makerList += ",";
+ }
+
+ makerList += GetOneForkLineMakers(fromForkStartNode, wfruntime);
+ }
+
+ return makerList;
+ }
+
+ //获取会签一条线上的审核者,该审核者应该是已审核过的节点的下一个人
+ private string GetOneForkLineMakers(FlowNode fromForkStartNode, FlowRuntime wfruntime)
+ {
+ string markers = "";
+ var node = fromForkStartNode;
+ do //沿一条分支线路执行,直到遇到第一个没有审核的节点
+ {
+ if (node.setInfo != null && node.setInfo.Taged != null)
+ {
+ if (node.type != FlowNode.FORK && node.setInfo.Taged != (int) TagState.Ok) //如果节点是不同意或驳回,则不用再找了
+ {
+ break;
+ }
+
+ node = wfruntime.GetNextNode(node.id); //下一个节点
+ continue;
+ }
+
+ var marker = GetNodeMarkers(node);
+ if (marker == "")
+ {
+ throw (new Exception($"节点{node.name}没有审核者,请检查!"));
+ }
+
+ if (marker == "1")
+ {
+ throw (new Exception($"节点{node.name}是会签节点,不能用所有人,请检查!"));
+ }
+
+ if (markers != "")
+ {
+ markers += ",";
+ }
+
+ markers += marker;
+ break;
+ } while (node.type != FlowNode.JOIN);
+
+ return markers;
+ }
+
+ ///
+ /// 寻找该节点执行人
+ ///
+ ///
+ ///
+ private string GetNodeMarkers(FlowNode node, string flowinstanceCreateUserId = "")
+ {
+ string makerList = "";
+ if (node.type == FlowNode.START && (!string.IsNullOrEmpty(flowinstanceCreateUserId))) //如果是开始节点,通常情况下是驳回到开始了
+ {
+ makerList = flowinstanceCreateUserId;
+ }
+ else if (node.setInfo != null)
+ {
+ if (node.setInfo.NodeDesignate == Setinfo.ALL_USER) //所有成员
+ {
+ makerList = "1";
+ }
+ else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_USER) //指定成员
+ {
+ makerList = GenericHelpers.ArrayToString(node.setInfo.NodeDesignateData.users, makerList);
+ }
+ else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_ROLE) //指定角色
+ {
+ var users = _revelanceApp.Get(Define.USERROLE, false, node.setInfo.NodeDesignateData.roles);
+ makerList = GenericHelpers.ArrayToString(users, makerList);
+ }
+ }
+ else //如果没有设置节点信息,默认所有人都可以审核
+ {
+ makerList = "1";
+ }
+
+ return makerList;
+ }
+
+ #endregion
+
+ ///
+ /// 审核流程
+ /// 李玉宝于2017-01-20 15:44:45
+ ///
+ public void Verification(VerificationReq request)
+ {
+ var user = _auth.GetCurrentUser().User;
+ var tag = new Tag
+ {
+ UserName = user.Name,
+ UserId = user.Id,
+ Description = request.VerificationOpinion,
+ Taged = Int32.Parse(request.VerificationFinally)
+ };
+ bool isReject = TagState.Reject.Equals((TagState) tag.Taged);
+ if (isReject) //驳回
+ {
+ NodeReject(request);
+ }
+ else
+ {
+ NodeVerification(request.FlowInstanceId, tag);
+ }
+ }
+
+ public void Update(FlowInstance flowScheme)
+ {
+ Repository.Update(flowScheme);
+ }
+
+ public async Task Load(QueryFlowInstanceListReq request)
+ {
+ var result = new TableData();
+ var user = _auth.GetCurrentUser();
+
+ if (request.type == "wait") //待办事项
+ {
+ Expression> waitExp = u => (u.MakerList == "1"
+ || u.MakerList.Contains(user.User.Id)) &&
+ (u.IsFinish == FlowInstanceStatus.Running ||
+ u.IsFinish == FlowInstanceStatus.Rejected);
+
+ // 加入搜索自定义标题
+ if (!string.IsNullOrEmpty(request.key))
+ {
+ waitExp = waitExp.And(t => t.CustomName.Contains(request.key));
+ }
+
+ result.count = UnitWork.Find(waitExp).Count();
+
+ result.data = UnitWork.Find(request.page, request.limit, "CreateDate descending", waitExp).ToList();
+ }
+ else if (request.type == "disposed") //已办事项(即我参与过的流程)
+ {
+ var instances = UnitWork.Find(u => u.CreateUserId == user.User.Id)
+ .Select(u => u.InstanceId).Distinct();
+ var query = from ti in instances
+ join ct in UnitWork.Find(null) on ti equals ct.Id
+ select ct;
+
+ // 加入搜索自定义标题
+ if (!string.IsNullOrEmpty(request.key))
+ {
+ query = query.Where(t => t.CustomName.Contains(request.key));
+ }
+
+ result.data = query.OrderByDescending(u => u.CreateDate)
+ .Skip((request.page - 1) * request.limit)
+ .Take(request.limit).ToList();
+ result.count = instances.Count();
+ }
+ else //我的流程
+ {
+ Expression> myFlowExp = u => u.CreateUserId == user.User.Id;
+
+ // 加入搜索自定义标题
+ if (!string.IsNullOrEmpty(request.key))
+ {
+ myFlowExp = myFlowExp.And(t => t.CustomName.Contains(request.key));
+ }
+
+ result.count = UnitWork.Find(myFlowExp).Count();
+ result.data = UnitWork.Find(request.page, request.limit,
+ "CreateDate descending", myFlowExp).ToList();
+ }
+
+ return result;
+ }
+
+ ///
+ /// 添加扭转记录
+ ///
+ private void AddTransHistory(FlowRuntime wfruntime)
+ {
+ var tag = _auth.GetCurrentUser().User;
+ UnitWork.Add(new FlowInstanceTransitionHistory
+ {
+ InstanceId = wfruntime.flowInstanceId,
+ CreateUserId = tag.Id,
+ CreateUserName = tag.Name,
+ FromNodeId = wfruntime.currentNodeId,
+ FromNodeName = wfruntime.currentNode.name,
+ FromNodeType = wfruntime.currentNodeType,
+ ToNodeId = wfruntime.nextNodeId,
+ ToNodeName = wfruntime.nextNode.name,
+ ToNodeType = wfruntime.nextNodeType,
+ IsFinish = wfruntime.nextNodeType == 4 ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running,
+ TransitionSate = 0
+ });
+ }
+
+ public List QueryHistories(QueryFlowInstanceHistoryReq request)
+ {
+ return UnitWork.Find(u => u.InstanceId == request.FlowInstanceId)
+ .OrderByDescending(u => u.CreateDate).ToList();
+ }
+
+ ///
+ /// 召回流程
+ ///
+ public void ReCall(RecallFlowInstanceReq request)
+ {
+ var user = _auth.GetCurrentUser().User;
+ FlowInstance flowInstance = Get(request.FlowInstanceId);
+
+ FlowRuntime wfruntime = new FlowRuntime(flowInstance);
+
+ string startNodeId = wfruntime.startNodeId; //起始节点
+
+ wfruntime.ReCall();
+
+ flowInstance.IsFinish = FlowInstanceStatus.Draft;
+ flowInstance.PreviousId = flowInstance.ActivityId;
+ flowInstance.ActivityId = startNodeId;
+ flowInstance.ActivityType = wfruntime.GetNodeType(startNodeId);
+ flowInstance.ActivityName = wfruntime.Nodes[startNodeId].name;
+ flowInstance.MakerList = GetNodeMarkers(wfruntime.Nodes[startNodeId], flowInstance.CreateUserId);
+
+ AddTransHistory(wfruntime);
+
+ UnitWork.Update(flowInstance);
+
+ UnitWork.Add(new FlowInstanceOperationHistory
+ {
+ InstanceId = request.FlowInstanceId,
+ CreateUserId = user.Id,
+ CreateUserName = user.Name,
+ CreateDate = DateTime.Now,
+ Content = $"【撤销】由{user.Name}撤销,备注:{request.Description}"
+ });
+
+ UnitWork.Save();
+ }
+
+ /// 启动流程
+ /// 通常是对状态为【草稿】的流程进行操作,进入运行状态
+ public void Start(StartFlowInstanceReq request)
+ {
+ FlowInstance flowInstance = Get(request.FlowInstanceId);
+ var wfruntime = new FlowRuntime(flowInstance);
+ var user = _auth.GetCurrentUser();
+
+ #region 根据运行实例改变当前节点状态
+ flowInstance.ActivityId = wfruntime.nextNodeId;
+ flowInstance.ActivityType = wfruntime.GetNextNodeType();
+ flowInstance.ActivityName = wfruntime.nextNode.name;
+ flowInstance.PreviousId = wfruntime.currentNodeId;
+ flowInstance.CreateUserId = user.User.Id;
+ flowInstance.CreateUserName = user.User.Account;
+ flowInstance.MakerList = (wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : "");
+ flowInstance.IsFinish = (wfruntime.GetNextNodeType() == 4
+ ? FlowInstanceStatus.Finished
+ : FlowInstanceStatus.Running);
+
+ UnitWork.Update(flowInstance);
+ #endregion 根据运行实例改变当前节点状态
+
+ #region 流程操作记录
+
+ FlowInstanceOperationHistory processOperationHistoryEntity = new FlowInstanceOperationHistory
+ {
+ InstanceId = flowInstance.Id,
+ CreateUserId = user.User.Id,
+ CreateUserName = user.User.Name,
+ CreateDate = DateTime.Now,
+ Content = $"【启动】由用户{user.User.Name}启动"
+ };
+ UnitWork.Add(processOperationHistoryEntity);
+
+ #endregion 流程操作记录
+
+ AddTransHistory(wfruntime);
+ UnitWork.Save();
+ }
+ }
}
\ No newline at end of file
diff --git a/OpenAuth.App/Request/AddFlowInstanceReq.cs b/OpenAuth.App/FlowInstance/Request/AddFlowInstanceReq.cs
similarity index 100%
rename from OpenAuth.App/Request/AddFlowInstanceReq.cs
rename to OpenAuth.App/FlowInstance/Request/AddFlowInstanceReq.cs
diff --git a/OpenAuth.App/Request/QueryFlowInstanceHistoryReq.cs b/OpenAuth.App/FlowInstance/Request/QueryFlowInstanceHistoryReq.cs
similarity index 100%
rename from OpenAuth.App/Request/QueryFlowInstanceHistoryReq.cs
rename to OpenAuth.App/FlowInstance/Request/QueryFlowInstanceHistoryReq.cs
diff --git a/OpenAuth.App/Request/QueryFlowInstanceListReq.cs b/OpenAuth.App/FlowInstance/Request/QueryFlowInstanceListReq.cs
similarity index 95%
rename from OpenAuth.App/Request/QueryFlowInstanceListReq.cs
rename to OpenAuth.App/FlowInstance/Request/QueryFlowInstanceListReq.cs
index 06a57187..0c8546fd 100644
--- a/OpenAuth.App/Request/QueryFlowInstanceListReq.cs
+++ b/OpenAuth.App/FlowInstance/Request/QueryFlowInstanceListReq.cs
@@ -1,7 +1,7 @@
-namespace OpenAuth.App.Request
-{
- public class QueryFlowInstanceListReq : PageReq
- {
- public string type { get; set; }
- }
-}
+namespace OpenAuth.App.Request
+{
+ public class QueryFlowInstanceListReq : PageReq
+ {
+ public string type { get; set; }
+ }
+}
diff --git a/OpenAuth.App/FlowInstance/Request/RecallFlowInstanceReq.cs b/OpenAuth.App/FlowInstance/Request/RecallFlowInstanceReq.cs
new file mode 100644
index 00000000..68e8d8a0
--- /dev/null
+++ b/OpenAuth.App/FlowInstance/Request/RecallFlowInstanceReq.cs
@@ -0,0 +1,18 @@
+namespace OpenAuth.App.Request
+{
+ ///
+ /// 召回、撤销流程
+ ///
+ public class RecallFlowInstanceReq
+ {
+ ///
+ /// 召回、撤销的流程实例ID
+ ///
+ public string FlowInstanceId { get; set; }
+ ///
+ /// 撤回备注
+ ///
+ public string Description { get; set; }
+
+ }
+}
diff --git a/OpenAuth.App/FlowInstance/Request/StartFlowInstanceReq.cs b/OpenAuth.App/FlowInstance/Request/StartFlowInstanceReq.cs
new file mode 100644
index 00000000..ec6a8743
--- /dev/null
+++ b/OpenAuth.App/FlowInstance/Request/StartFlowInstanceReq.cs
@@ -0,0 +1,14 @@
+namespace OpenAuth.App.Request
+{
+ ///
+ /// 启动流程
+ ///
+ public class StartFlowInstanceReq
+ {
+ ///
+ /// 启动流程的实例Id
+ ///
+ public string FlowInstanceId { get; set; }
+
+ }
+}
diff --git a/OpenAuth.App/Request/VerificationReq.cs b/OpenAuth.App/FlowInstance/Request/VerificationReq.cs
similarity index 96%
rename from OpenAuth.App/Request/VerificationReq.cs
rename to OpenAuth.App/FlowInstance/Request/VerificationReq.cs
index 5ef05f43..ae35949e 100644
--- a/OpenAuth.App/Request/VerificationReq.cs
+++ b/OpenAuth.App/FlowInstance/Request/VerificationReq.cs
@@ -1,26 +1,26 @@
-namespace OpenAuth.App.Request
-{
- public class VerificationReq
- {
- public string FlowInstanceId { get; set; }
- ///
- /// 1:同意;2:不同意;3:驳回
- ///
- public string VerificationFinally { get; set; }
-
- ///
- /// 审核意见
- ///
- public string VerificationOpinion { get; set; }
-
- ///
- /// 驳回的步骤,即驳回到的节点ID
- ///
- public string NodeRejectStep { get; set; }
-
- ///
- /// 驳回类型。null:使用节点配置的驳回类型/0:前一步/1:第一步/2:指定节点,使用NodeRejectStep
- ///
- public string NodeRejectType { get; set; }
- }
-}
+namespace OpenAuth.App.Request
+{
+ public class VerificationReq
+ {
+ public string FlowInstanceId { get; set; }
+ ///
+ /// 1:同意;2:不同意;3:驳回
+ ///
+ public string VerificationFinally { get; set; }
+
+ ///
+ /// 审核意见
+ ///
+ public string VerificationOpinion { get; set; }
+
+ ///
+ /// 驳回的步骤,即驳回到的节点ID
+ ///
+ public string NodeRejectStep { get; set; }
+
+ ///
+ /// 驳回类型。null:使用节点配置的驳回类型/0:前一步/1:第一步/2:指定节点,使用NodeRejectStep
+ ///
+ public string NodeRejectType { get; set; }
+ }
+}
diff --git a/OpenAuth.App/Response/FlowVerificationResp.cs b/OpenAuth.App/FlowInstance/Response/FlowVerificationResp.cs
similarity index 95%
rename from OpenAuth.App/Response/FlowVerificationResp.cs
rename to OpenAuth.App/FlowInstance/Response/FlowVerificationResp.cs
index c543368b..400a13ca 100644
--- a/OpenAuth.App/Response/FlowVerificationResp.cs
+++ b/OpenAuth.App/FlowInstance/Response/FlowVerificationResp.cs
@@ -1,16 +1,16 @@
-using OpenAuth.Repository.Domain;
-
-namespace OpenAuth.App.Response
-{
- public class FlowVerificationResp :FlowInstance
- {
- ///
- /// 预览表单数据
- ///
- /// The FRM data HTML.
- public string FrmPreviewHtml
- {
- get { return FormUtil.Preview(this); }
- }
- }
-}
+using OpenAuth.Repository.Domain;
+
+namespace OpenAuth.App.Response
+{
+ public class FlowVerificationResp :FlowInstance
+ {
+ ///
+ /// 预览表单数据
+ ///
+ /// The FRM data HTML.
+ public string FrmPreviewHtml
+ {
+ get { return FormUtil.Preview(this); }
+ }
+ }
+}
diff --git a/OpenAuth.App/FlowSchemeApp.cs b/OpenAuth.App/FlowScheme/FlowSchemeApp.cs
similarity index 97%
rename from OpenAuth.App/FlowSchemeApp.cs
rename to OpenAuth.App/FlowScheme/FlowSchemeApp.cs
index a320e19f..b2c873d6 100644
--- a/OpenAuth.App/FlowSchemeApp.cs
+++ b/OpenAuth.App/FlowScheme/FlowSchemeApp.cs
@@ -1,73 +1,73 @@
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-using OpenAuth.App.Interface;
-using OpenAuth.App.Request;
-using OpenAuth.App.Response;
-using OpenAuth.Repository;
-using OpenAuth.Repository.Domain;
-using OpenAuth.Repository.Interface;
-
-namespace OpenAuth.App
-{
- public class FlowSchemeApp :BaseStringApp
- {
- public void Add(FlowScheme flowScheme)
- {
- if (Repository.Any(u => u.SchemeName == flowScheme.SchemeName))
- {
- throw new Exception("流程名称已经存在");
- }
-
- var user = _auth.GetCurrentUser().User;
- flowScheme.CreateUserId = user.Id;
- flowScheme.CreateUserName = user.Name;
- Repository.Add(flowScheme);
- }
-
- public FlowScheme FindByCode(string code)
- {
- return Repository.FirstOrDefault(u => u.SchemeCode == code);
- }
-
- public void Update(FlowScheme flowScheme)
- {
- if (Repository.Any(u => u.SchemeName == flowScheme.SchemeName && u.Id != flowScheme.Id))
- {
- throw new Exception("流程名称已经存在");
- }
-
- UnitWork.Update(u => u.Id == flowScheme.Id, u => new FlowScheme
- {
- SchemeContent = flowScheme.SchemeContent,
- SchemeName = flowScheme.SchemeName,
- ModifyDate = DateTime.Now,
- FrmId = flowScheme.FrmId,
- FrmType = flowScheme.FrmType,
- Disabled = flowScheme.Disabled,
- Description = flowScheme.Description,
- OrgId = flowScheme.OrgId
- });
- }
-
- public async Task Load(QueryFlowSchemeListReq request)
- {
- var result = new TableData();
- var objs = GetDataPrivilege("u");
- if (!string.IsNullOrEmpty(request.key))
- {
- objs = objs.Where(u => u.SchemeName.Contains(request.key) || u.Id.Contains(request.key));
- }
-
- result.data = objs.OrderByDescending(u => u.CreateDate)
- .Skip((request.page - 1) * request.limit)
- .Take(request.limit).ToList();
- result.count = objs.Count();
- return result;
- }
-
- public FlowSchemeApp(IUnitWork unitWork, IRepository repository,IAuth auth) : base(unitWork, repository, auth)
- {
- }
- }
-}
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using OpenAuth.App.Interface;
+using OpenAuth.App.Request;
+using OpenAuth.App.Response;
+using OpenAuth.Repository;
+using OpenAuth.Repository.Domain;
+using OpenAuth.Repository.Interface;
+
+namespace OpenAuth.App
+{
+ public class FlowSchemeApp :BaseStringApp
+ {
+ public void Add(FlowScheme flowScheme)
+ {
+ if (Repository.Any(u => u.SchemeName == flowScheme.SchemeName))
+ {
+ throw new Exception("流程名称已经存在");
+ }
+
+ var user = _auth.GetCurrentUser().User;
+ flowScheme.CreateUserId = user.Id;
+ flowScheme.CreateUserName = user.Name;
+ Repository.Add(flowScheme);
+ }
+
+ public FlowScheme FindByCode(string code)
+ {
+ return Repository.FirstOrDefault(u => u.SchemeCode == code);
+ }
+
+ public void Update(FlowScheme flowScheme)
+ {
+ if (Repository.Any(u => u.SchemeName == flowScheme.SchemeName && u.Id != flowScheme.Id))
+ {
+ throw new Exception("流程名称已经存在");
+ }
+
+ UnitWork.Update(u => u.Id == flowScheme.Id, u => new FlowScheme
+ {
+ SchemeContent = flowScheme.SchemeContent,
+ SchemeName = flowScheme.SchemeName,
+ ModifyDate = DateTime.Now,
+ FrmId = flowScheme.FrmId,
+ FrmType = flowScheme.FrmType,
+ Disabled = flowScheme.Disabled,
+ Description = flowScheme.Description,
+ OrgId = flowScheme.OrgId
+ });
+ }
+
+ public async Task Load(QueryFlowSchemeListReq request)
+ {
+ var result = new TableData();
+ var objs = GetDataPrivilege("u");
+ if (!string.IsNullOrEmpty(request.key))
+ {
+ objs = objs.Where(u => u.SchemeName.Contains(request.key) || u.Id.Contains(request.key));
+ }
+
+ result.data = objs.OrderByDescending(u => u.CreateDate)
+ .Skip((request.page - 1) * request.limit)
+ .Take(request.limit).ToList();
+ result.count = objs.Count();
+ return result;
+ }
+
+ public FlowSchemeApp(IUnitWork unitWork, IRepository repository,IAuth auth) : base(unitWork, repository, auth)
+ {
+ }
+ }
+}
diff --git a/OpenAuth.App/Request/QueryFlowSchemeListReq.cs b/OpenAuth.App/FlowScheme/Request/QueryFlowSchemeListReq.cs
similarity index 95%
rename from OpenAuth.App/Request/QueryFlowSchemeListReq.cs
rename to OpenAuth.App/FlowScheme/Request/QueryFlowSchemeListReq.cs
index 6b36d215..16ac8800 100644
--- a/OpenAuth.App/Request/QueryFlowSchemeListReq.cs
+++ b/OpenAuth.App/FlowScheme/Request/QueryFlowSchemeListReq.cs
@@ -1,7 +1,7 @@
-namespace OpenAuth.App.Request
-{
- public class QueryFlowSchemeListReq : PageReq
- {
- public string orgId { get; set; }
- }
-}
+namespace OpenAuth.App.Request
+{
+ public class QueryFlowSchemeListReq : PageReq
+ {
+ public string orgId { get; set; }
+ }
+}
diff --git a/OpenAuth.App/FormApp.cs b/OpenAuth.App/Form/FormApp.cs
similarity index 96%
rename from OpenAuth.App/FormApp.cs
rename to OpenAuth.App/Form/FormApp.cs
index e87ef975..76da85da 100644
--- a/OpenAuth.App/FormApp.cs
+++ b/OpenAuth.App/Form/FormApp.cs
@@ -1,87 +1,87 @@
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-using Infrastructure;
-using Microsoft.Extensions.Options;
-using OpenAuth.App.Interface;
-using OpenAuth.App.Request;
-using OpenAuth.App.Response;
-using OpenAuth.Repository;
-using OpenAuth.Repository.Domain;
-using OpenAuth.Repository.Interface;
-
-
-namespace OpenAuth.App
-{
- public class FormApp : BaseStringApp