/// <summary> /// 流程活动处理 /// </summary> /// <param name="request"></param> /// <returns></returns> public ResultMessage SubmitWorkitemInstance(RequestBySubmitWorkitem request) { ResultMessage rm = new ResultMessage() { State = true, Message = "" }; WorkitemInstance wii = this.GetWorkitemInstance(request.WorkitemInstanceGuid); ///不在许可范围之内的,直接返回失败 if (!this.IsEffective(wii)) { return new ResultMessage() { State = false, Message = "不在许可操作范围内!" } } ; wii.AduitContent = request.AduitContent; wii.AduitSign = request.AduitSign; wii.SelectVoteItem = request.SelectVoteItem; wii.OtherVoteItemContent = request.OtherVoteItemContent; wii.IsProxy = request.IsProxyUser; if (wii.IsProxy) { wii.ProxyUser = this.Context.CurUser; } else { wii.User = this.Context.CurUser; } //wii.SetDataEntity(request.DataEntity); switch (request.State) { #region Running 挂起流程操作 case eWorkitemState.Running: { wii.Hung(); wii.Save(); } break; #endregion #region Abort 退出流程处理,中止流程 case eWorkitemState.Abort: { #region 条件判断 bool b = false; ///是否大管理员 if (this.Context.CurUser.IsAdministrator()) { b = true; } ///是否流程模型管理员 if (wii.GetWorkflowInstance().GetWorkflow().Administrators.Contains(this.Context.CurUser, _uc)) { b = true; } ///是否是流程发起人 if (_uc.Equals(this.Context.CurUser, wii.GetWorkflowInstance().Author)) { b = true; } if (!b) { rm.State = false; rm.Message = "你不具体中止流程的权限。只有管理员和发起人才可以中止流程!"; break; } #endregion wii.Abort(); wii.Save(); wii.GetWorkflowInstance().Save(); break; } #endregion #region Completed 正常完成流程处理 case eWorkitemState.Completed: { wii.GetWorkflowInstance().SetDataEntity(request.DataEntity); #region 创建后继流程活动工作项 IList <NextActivity> tmp = new List <NextActivity>(); foreach (var na in request.NextActivities) { foreach (var o in na.Operaters) { var x = new NextActivity() { WorkitemInstanceGuid = System.Guid.NewGuid().ToString(), ActivityGuid = na.Activity, ActivityByname = na.ActivityName, User = this.GetUser(o), }; #region 创建后继流程活动工作项 WorkitemInstance xwii = new WorkitemInstance(wii.GetWorkflowInstance().Guid, wii.GetWorkflow().GetActivity(na.Activity, eDaoItem.Guid)) { ActivityGuid = x.ActivityGuid, AduitContent = "", ReadTime = null, NextActivities = null, EndTime = null, User = x.User, ProxyUser = null, //WorkitemInstanceState = eWorkitemState.Ready, IsProxy = false, FromWorkitemInstanceGuid = wii.Guid, AttachmentTrainsitions = null, }; xwii.SetContext(this.Context); ///取流程实例数据到流程实例活动 xwii.Start(); //xwii.BeforeTrigger(); xwii.Save(); #endregion tmp.Add(x); } } wii.NextActivities = tmp; #endregion ///完成流程实例活动 wii.AfterTrigger(); wii.Save(); wii.GetWorkflowInstance().Save(); break; } #endregion #region Other case eWorkitemState.Ready: case eWorkitemState.ExclusionCompleted: default: { break; } #endregion } ///解锁 this.DecodeLock(wii); if (!rm.State) { return(rm); } return(rm); } }