public IDictionary <string, PerformerList> NextActivityPerformers(string nextActivityPerformers) { IDictionary <string, PerformerList> nextActivityPerformersDictionary = new Dictionary <string, PerformerList>(); string[] array = nextActivityPerformers.Split(','); foreach (string items in array) { string stepId = GetValueOfNodeIdList(items, "step"); if (!string.IsNullOrWhiteSpace(stepId) && stepId != "0") { string userId = GetValueOfNodeIdList(items, "member"); Performer performer = null; if (!string.IsNullOrWhiteSpace(userId) && userId != "0" && userId.Length > 0) { SysUserEntity userEntity = WorkFlows.GetSysUserModel(Convert.ToInt32(userId)); if (userEntity != null && userEntity.ID > 0) { performer = new Performer(userId, userEntity.UserName); } } if (performer == null) { performer = new Performer("0", string.Empty); } if (nextActivityPerformersDictionary.ContainsKey(stepId)) { (nextActivityPerformersDictionary[stepId]).Add(performer); } else { PerformerList pList = new PerformerList(); pList.Add(performer); nextActivityPerformersDictionary.Add(stepId, pList); } } } return(nextActivityPerformersDictionary); }
//提交请假信息 protected void btnSave_Click(object sender, EventArgs e) { try { string processGUID = this.txtProcessGUID.Value.ToString(); string stepGuid = this.hiddenStepGuid.Value.ToString(); int stepUserID = Helper.ConverToInt32(this.hiddenStepUser.Value.ToString().Trim()); decimal days = Helper.ConverToDecimal(this.txtDays.Value); int leaveType = Helper.ConverToInt32(selectLeaveType.Value); int nextUserID = 0; string nextUserName = string.Empty; SysUserEntity userEntity = WorkFlows.GetSysUserModel(stepUserID); if (userEntity != null && userEntity.ID > 0) { nextUserID = userEntity.ID; nextUserName = userEntity.UserName; } DateTime now = DateTime.Now; //请假业务数据 HrsLeaveEntity hrsLeaveEntity = new HrsLeaveEntity(); hrsLeaveEntity.LeaveType = leaveType; hrsLeaveEntity.Days = days; try { hrsLeaveEntity.FromDate = Helper.ConvertToDateTime(this.txtFromDate.Value, now); } catch (Exception ex) { hrsLeaveEntity.FromDate = now; } try { hrsLeaveEntity.ToDate = Helper.ConvertToDateTime(this.txtToDate.Value, now); } catch (Exception ex) { hrsLeaveEntity.ToDate = now; } hrsLeaveEntity.CurrentActivityText = string.Empty; hrsLeaveEntity.Status = 0; hrsLeaveEntity.CreatedUserID = LoginUserID; hrsLeaveEntity.CreatedUserName = this.LoginUserName; hrsLeaveEntity.CreatedDate = now; int instanceId = WorkFlows.AddHrsLeave(hrsLeaveEntity); if (instanceId > 0) { //调用流程 IWorkflowService service = new WorkflowService(); WfAppRunner initiator = new WfAppRunner(); initiator.AppName = "请假流程"; initiator.AppInstanceID = instanceId.ToString(); initiator.ProcessGUID = processGUID; initiator.UserID = LoginUserID.ToString(); initiator.UserName = LoginUserName; initiator.Conditions = GetCondition(string.Format("days-{0}", days)); WfExecutedResult startedResult = service.StartProcess(initiator); if (startedResult.Status != WfExecutedStatus.Success) { base.RegisterStartupScript("", "<script>alert('" + startedResult.Message + "');</script>"); return; } //送往下一步 PerformerList pList = new PerformerList(); pList.Add(new Performer(nextUserID.ToString(), nextUserName)); initiator.NextActivityPerformers = new Dictionary <String, PerformerList>(); initiator.NextActivityPerformers.Add(stepGuid, pList); WfExecutedResult runAppResult = service.RunProcessApp(initiator); if (runAppResult.Status != WfExecutedStatus.Success) { base.RegisterStartupScript("", "<script>alert('" + runAppResult.Message + "');</script>"); return; } //保存业务数据 BizAppFlowEntity AppFlowEntity = new Entity.BizAppFlowEntity(); AppFlowEntity.AppName = "流程发起"; AppFlowEntity.AppInstanceID = instanceId.ToString(); AppFlowEntity.ActivityName = "流程发起"; AppFlowEntity.Remark = string.Format("申请人:{0}-{1}", LoginUserID, LoginUserName); AppFlowEntity.ChangedTime = now; AppFlowEntity.ChangedUserID = LoginUserID; AppFlowEntity.ChangedUserName = LoginUserName; WorkFlows.AddBizAppFlow(AppFlowEntity); base.RegisterStartupScript("", "<script>alert('流程发起成功');window.location.href='FlowList.aspx';</script>"); } } catch (Exception ex) { base.RegisterStartupScript("", "<script>alert('流程发起出现异常 EXCEPTION:" + ex.ToString() + "');</script>"); } }
//送往下一步 protected void btnSendNext_Click(object sender, EventArgs e) { try { string processGUID = this.txtProcessGUID.Value.ToString(); string stepGuid = this.hiddenStepGuid.Value.ToString(); int stepUserID = Helper.ConverToInt32(this.hiddenStepUser.Value.ToString().Trim()); decimal days = Helper.ConverToDecimal(this.txtDays.Value); string instanceId = this.hiddenInstanceId.Value; string DepManagerRemark = this.txtDepmanagerRemark.Value; string DirectorRemark = this.txtDirectorRemark.Value; string DeputyGeneralRemark = this.txtDeputyGeneralRemark.Value; string GeneralManagerRemark = this.txtGeneralManagerRemark.Value; int activityInstanceID = Helper.ConverToInt32(hiddenActivityInstanceID.Value); string CurrentActivityText = string.Empty;; int nextUserID = 0; string nextUserName = string.Empty; SysUserEntity userEntity = WorkFlows.GetSysUserModel(stepUserID); if (userEntity != null && userEntity.ID > 0) { nextUserID = userEntity.ID; nextUserName = userEntity.UserName; } DateTime now = DateTime.Now; if (!string.IsNullOrEmpty(instanceId)) { //调用流程 IWorkflowService service = new WorkflowService(); WfAppRunner initiator = new WfAppRunner(); initiator.AppName = "请假流程"; initiator.AppInstanceID = instanceId; initiator.ProcessGUID = processGUID; initiator.UserID = LoginUserID.ToString(); initiator.UserName = LoginUserName; initiator.Conditions = GetCondition(string.Format("days-{0}", days)); //送往下一步 PerformerList pList = new PerformerList(); pList.Add(new Performer(nextUserID.ToString(), nextUserName)); initiator.NextActivityPerformers = new Dictionary <String, PerformerList>(); initiator.NextActivityPerformers.Add(stepGuid, pList); WfExecutedResult runAppResult = service.RunProcessApp(initiator); if (runAppResult.Status != WfExecutedStatus.Success) { base.RegisterStartupScript("", "<script>alert('" + runAppResult.Message + "');</script>"); return; } ProcessEntity processEntity = service.GetProcessById(processGUID); if (processEntity != null) { ActivityInstanceEntity activityInstanceEntity = service.GetActivityInstance(activityInstanceID); if (activityInstanceEntity != null) { CurrentActivityText = activityInstanceEntity.ActivityName; } } try { //保存业务数据 BizAppFlowEntity AppFlowEntity = new Entity.BizAppFlowEntity(); AppFlowEntity.AppName = "请假流程"; AppFlowEntity.AppInstanceID = instanceId.ToString(); AppFlowEntity.ActivityName = CurrentActivityText; AppFlowEntity.Remark = string.Format("申请人:{0}-{1}", LoginUserID, LoginUserName) + CurrentActivityText; AppFlowEntity.ChangedTime = now; AppFlowEntity.ChangedUserID = LoginUserID; AppFlowEntity.ChangedUserName = LoginUserName; WorkFlows.AddBizAppFlow(AppFlowEntity); } catch (Exception ex) { } try { HrsLeaveEntity hrsLeaveEntity = new Entity.HrsLeaveEntity(); hrsLeaveEntity.ID = Helper.ConverToInt32(instanceId); hrsLeaveEntity.DepManagerRemark = DepManagerRemark; hrsLeaveEntity.DirectorRemark = DirectorRemark; hrsLeaveEntity.DeputyGeneralRemark = DeputyGeneralRemark; hrsLeaveEntity.GeneralManagerRemark = GeneralManagerRemark; hrsLeaveEntity.CurrentActivityText = CurrentActivityText; WorkFlows.UpdateHrsLeave(hrsLeaveEntity); } catch (Exception ex) { } base.RegisterStartupScript("", "<script>alert('办理成功');window.location.href='FlowList.aspx';</script>"); } } catch (Exception ex) { base.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('流程发起出现异常 EXCEPTION:" + ex.ToString() + "');</script>"); } }