private static FlowActionRequest saveToDB(FlowAction incomingReq) { using (var db = new EnouFlowInstanceContext()) { var dbReq = db.flowActionRequests.Create(); dbReq.requestType = incomingReq.requestType; dbReq.clientRequestGuid = incomingReq.clientRequestGuid; dbReq.bizDocumentGuid = incomingReq.bizDocumentGuid; dbReq.bizDocumentTypeCode = incomingReq.bizDocumentTypeCode; if (incomingReq.flowInstanceId > 0) // 穿入了有效的flowInstanceId { dbReq.flowInstance = FlowInstanceHelper.GetFlowInstance(incomingReq.flowInstanceId, db); dbReq.flowInstanceGuid = incomingReq.flowInstanceGuid; } dbReq.userMemo = incomingReq.userMemo; dbReq.bizDataPayloadJson = incomingReq.bizDataPayloadJson; dbReq.concreteFlowActionMetaJson = incomingReq.concreteFlowActionMetaJson; dbReq.optionalFlowActionDataJson = incomingReq.optionalFlowActionDataJson; dbReq.userId = incomingReq.userId; dbReq.userGuid = incomingReq.userGuid; dbReq.delegateeUserId = incomingReq.delegateeUserId; dbReq.delegateeUserGuid = incomingReq.delegateeUserGuid; db.flowActionRequests.Add(dbReq); db.SaveChanges(); return(dbReq); } }
// MoveToAutoGenerated public static FlowActionRequest PostFlowActionMoveToAutoGenerated( string clientRequestGuid, string bizDocumentGuid, string bizDocumentTypeCode, DateTime bizTimeStamp, string userMemo, string bizDataPayloadJson, string optionalFlowActionDataJson, int flowInstanceId, string flowInstanceGuid, string code, string currentActivityGuid, // 当前所处的活动状态(也许流程有多个入口) string connectionGuid, // 接办人选择的Connection string nextActivityGuid, // 接办人选择的Connection指向的活动(理论上应该由FlowTemplate算出) List <Paticipant> roles, // 接办人选择的下一个活动状态待办角色/人员列表 EnouFlowInstanceContext db // 自动规则生成的活动需要等待前Request成功过完成处理才能一并保存,只在同一个Context上创建对象 ) { // 未通过合法性检查直接返回 if (!preValidate(clientRequestGuid)) { return(null); } var incomingReq = new FlowActionMoveToAutoGenerated( clientRequestGuid, bizDocumentGuid, bizDocumentTypeCode, bizTimeStamp, userMemo, bizDataPayloadJson, optionalFlowActionDataJson, flowInstanceId, flowInstanceGuid, code, currentActivityGuid, connectionGuid, nextActivityGuid, roles); return(createWoSave(incomingReq, db)); }
public static List <FlowTaskForUser> GetWaitingFlowTaskForUserListOfFlowInstance( int flowInstanceId, EnouFlowInstanceContext db) { List <FlowTaskForUser> flowTaskForUsers = db.flowTaskForUsers.Where( task => task.flowInstanceId == flowInstanceId && task.taskState == EnumFlowTaskState.initial && (task.taskType == EnumFlowTaskType.normal || task.taskType == EnumFlowTaskType.redraft)).ToList(); return(flowTaskForUsers); }
public static FlowAction GetFirstUnprocessedRequest() { using (var db = new EnouFlowInstanceContext()) { db.Configuration.LazyLoadingEnabled = true; var dbObj = db.flowActionRequests .Where(rq => !rq.isProcessed) .OrderBy(rq => rq.createTime) .FirstOrDefault(); return(generateFlowAction(dbObj)); } }
public static FlowAction GetFirstUnprocessedRequest( int flowInstanceId, EnumFlowActionRequestType[] flowActionRequestTypes) { using (var db = new EnouFlowInstanceContext()) { db.Configuration.LazyLoadingEnabled = true; var dbObjs = db.flowActionRequests .Where(rq => !rq.isProcessed && rq.flowInstance.flowInstanceId == flowInstanceId) .OrderBy(rq => rq.createTime).ToList(); var dbObj = dbObjs.Where(rq => flowActionRequestTypes.Contains(rq.requestType)).ToList().FirstOrDefault(); return(generateFlowAction(dbObj)); } }
public static FlowAction GetFlowAction(int flowActionRequestId, bool onlyNotProcessed = true) { using (var db = new EnouFlowInstanceContext()) { db.Configuration.LazyLoadingEnabled = true; var dbObj = db.flowActionRequests.Find(flowActionRequestId); if (dbObj == null || (dbObj.isProcessed && onlyNotProcessed)) { return(null); } return(generateFlowAction(dbObj)); } }
private static bool preValidate(string clientRequestGuid) { #region 验证是否为同一个处理请求 using (var db = new EnouFlowInstanceContext()) { if (db.flowActionRequests.Where( r => r.clientRequestGuid == clientRequestGuid).Count() > 0) { throw new FlowActionRequestException( string.Format("请不要重复提交同一个处理请求'{0}'!", clientRequestGuid)); } } #endregion return(true); }
public static List <FlowTaskForUser> GetFlowTaskForUserListOfUser( string userGuid, EnouFlowInstanceContext db) { List <FlowTaskForUser> flowTaskForUsers = db.flowTaskForUsers.Where( task => task.userGuid == userGuid).ToList(); if (flowTaskForUsers.Count() > 0) { flowTaskForUsers = flowTaskForUsers.Where( task => task.isValidToProcess()).ToList(); } else { flowTaskForUsers = new List <FlowTaskForUser>(); } return(flowTaskForUsers); }
public static List <FlowTaskForUser> GetDelegatableFlowTaskForUserListOfUser( string userGuid, EnouFlowInstanceContext db) { List <FlowTaskForUser> flowTaskForUsers = db.flowTaskForUsers.Where( task => task.userGuid == userGuid && (task.taskType == EnumFlowTaskType.normal || task.taskType == EnumFlowTaskType.invitationFeedback) ).ToList(); if (flowTaskForUsers.Count() > 0) { flowTaskForUsers = flowTaskForUsers.Where( task => task.isValidToProcess()).ToList(); } else { flowTaskForUsers = new List <FlowTaskForUser>(); } return(flowTaskForUsers); }
public static IEnumerable <FlowInstanceFriendlyLog> GetFlowInstanceFriendlyLogs( int flowInstanceId, EnouFlowInstanceContext db) { return(db.flowFriendlyLogs.Where(obj => obj.flowInstanceId == flowInstanceId).ToList()); }
public static FlowTaskForUser GetFlowTaskForUser(string guid, EnouFlowInstanceContext db) { return(db.flowTaskForUsers.Where(task => task.guid == guid).FirstOrDefault()); }
public static FlowTaskForUser GetFlowTaskForUser(int id, EnouFlowInstanceContext db) { return(db.flowTaskForUsers.Find(id)); }
public static FlowInstance GetFlowInstance(string guid, EnouFlowInstanceContext db) { return(db.flowInstances.Where( obj => obj.guid == guid).FirstOrDefault()); }
public static FlowInstance GetFlowInstance(int id, EnouFlowInstanceContext db) { return(db.flowInstances.Find(id)); }