//InviteOtherFeedback public static FlowActionRequest PostFlowActionInviteOtherFeedback( string clientRequestGuid, string bizDocumentGuid, string bizDocumentTypeCode, DateTime bizTimeStamp, string userMemo, string bizDataPayloadJson, string optionalFlowActionDataJson, int userId, // 执行人员 string userGuid, int flowInstanceId, string flowInstanceGuid, string code, string currentActivityGuid, // 当前所处的活动状态 string connectionGuid, // 被征求意见人建议的connection List <Paticipant> roles, // 被征求意见人选择的角色/人员列表 int relativeFlowTaskForUserId, // 被邀请者的taskid int?delegateeUserId, string delegateeUserGuid ) { // 未通过合法性检查直接返回 if (!preValidate(clientRequestGuid)) { return(null); } var incomingReq = new FlowActionInviteOtherFeedback( clientRequestGuid, bizDocumentGuid, bizDocumentTypeCode, bizTimeStamp, userMemo, bizDataPayloadJson, optionalFlowActionDataJson, userId, userGuid, flowInstanceId, flowInstanceGuid, code, currentActivityGuid, connectionGuid, roles, relativeFlowTaskForUserId, delegateeUserId, delegateeUserGuid); return(saveToDB(incomingReq)); }
processActionRequest(FlowActionInviteOtherFeedback req) { var concreteMetaObj = req.concreteMetaObj; using (var db = new EnouFlowInstanceContext()) { var flowInst = getFlowInstance(db, req.flowInstanceId, req.bizDocumentGuid); var reqInDb = getReqInDB(req.flowActionRequestId, db); string failReason; // 此类型ActionRequest不改TimeStamp DateTime bizTimeStampToUse = flowInst.bizTimeStamp; #region Check BizTimeStamp Valid if (!isBizTimeStampValid((DateTime)concreteMetaObj.bizTimeStamp, req, flowInst, out failReason)) { updateReqProcessingResultInDB(reqInDb, EnumFlowActionRequestResultType.fail, failReason); db.SaveChanges(); return(new FlowActionInviteOtherFeedbackResult(req.flowActionRequestId, req.clientRequestGuid, flowInst, false, failReason)); } #endregion #region Decide List<UserDTO> // 需要追溯到最初发出征询意见的用户作为任务目标用户 List <UserDTO> taskUsers = new List <UserDTO>(); var taskInviteOther = db.flowTaskForUsers.Find( req.relativeFlowTaskForUserId); var flowTaskForUserOrigin = db.flowTaskForUsers.Find( taskInviteOther.relativeFlowTaskForUserId); using (var orgDb = new EnouFlowOrgMgmtContext()) { taskUsers.Add( new UserHelper(orgDb).getUserDTO( flowTaskForUserOrigin.userId)); } #endregion #region add the invitation-feedback "task" for users FlowTemplateDefHelper flowTemplateDefHelper = new FlowTemplateDefHelper(flowInst.flowTemplateJson); string suggestedConnectionName = ""; if (!string.IsNullOrWhiteSpace(req.connectionGuid)) { suggestedConnectionName = flowTemplateDefHelper.getNodesOfConnection( req.connectionGuid).Item3.name; } string suggestedPaticipants = ""; if (req.roles.Count() > 0) { suggestedPaticipants = req.roles.Aggregate( "", (names, role) => { if (role != null) { return(names + role.PaticipantObj.name + ";"); } else { return(names); } }); } taskUsers.ForEach(user => { var task = addFlowTaskForUser( db, user, flowInst, EnumFlowTaskType.invitationFeedback); // 设置任务之间的跟踪关系 task.relativeFlowTaskForUserId = req.relativeFlowTaskForUserId; // 设置征询意见反馈型任务的自定义字段 task.stringField_1 = req.userMemo; task.stringField_2 = suggestedConnectionName; task.stringField_3 = suggestedPaticipants; }); // 顺便把原征询意见的任务也一并更新 taskInviteOther.stringField_1 = req.userMemo; taskInviteOther.stringField_2 = suggestedConnectionName; taskInviteOther.stringField_3 = suggestedPaticipants; taskInviteOther.finishTime = DateTime.Now; taskInviteOther.taskState = EnumFlowTaskState.done; #endregion #region write 3 type logs addFlowInstanceFriendlyLog( flowInst, reqInDb.flowActionRequestId, flowInst.currentActivityName, reqInDb.userId.Value, reqInDb.delegateeUserId, "意见征询答复/Opinions invited", req.userMemo, db); #warning TODO: another 2 type logs #endregion #region update request updateRequestToSuccess(reqInDb, flowInst); #endregion #region save all to db db.SaveChanges(); #endregion return(new FlowActionInviteOtherFeedbackResult(req.flowActionRequestId, req.clientRequestGuid, flowInst)); } }