/// <summary> /// 获取当前用户待办任务列表 /// </summary> private void GetReadyTasks() { var wfService = new WorkflowService(); var en = new TaskQuery { UserID = LoginUserID.ToString() }; IList <TaskViewEntity> taskViewList = wfService.GetReadyTasks(en); if (taskViewList != null) { Repeater2.DataSource = taskViewList; Repeater2.DataBind(); } }
//提交请假信息 protected void btnSave_Click(object sender, EventArgs e) { try { string processGUID = this.txtProcessGUID.Value.ToString(); decimal days = Helper.ConverToDecimal(this.txtDays.Value); int leaveType = Helper.ConverToInt32(selectLeaveType.Value); string strNextActivityPerformers = hiddenNextActivityPerformers.Value.ToString().Trim(); IDictionary <string, PerformerList> nextActivityPerformers = NextActivityPerformers(strNextActivityPerformers); if (nextActivityPerformers == null) { base.RegisterStartupScript("", "<script>alert('请选择办理步骤或办理人员--Please select next step and user');</script>"); return; } 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 = "请假流程(AskforLeaveProcess)"; 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); */ initiator.NextActivityPerformers = nextActivityPerformers; 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.ToString(); //AppFlowEntity.ChangedUserName = LoginUserName; //WorkFlows.AddBizAppFlow(AppFlowEntity); HrsLeaveOpinionEntity hrsleaveOpinionEntity = new HrsLeaveOpinionEntity(); hrsleaveOpinionEntity.AppInstanceID = instanceId.ToString(); hrsleaveOpinionEntity.ActivityID = System.Guid.Empty.ToString(); hrsleaveOpinionEntity.ActivityName = "流程发起(Apply)"; hrsleaveOpinionEntity.Remark = string.Format("申请人(Applicant):{0}-{1}", LoginUserID, LoginUserName); hrsleaveOpinionEntity.ChangedTime = now; hrsleaveOpinionEntity.ChangedUserID = LoginUserID.ToString(); hrsleaveOpinionEntity.ChangedUserName = LoginUserName; WorkFlows.AddHrsLeaveOpinion(hrsleaveOpinionEntity); base.RegisterStartupScript("", "<script>alert('流程发起成功--Successed');window.location.href='FlowList.aspx';</script>"); } } catch (Exception ex) { base.RegisterStartupScript("", "<script>alert('流程发起出现异常--EXCEPTION:" + ex.ToString() + "');</script>"); } }
//提交请假信息 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 { DateTime now = DateTime.Now; string CurrentActivityText = string.Empty; string currentOpinionRemark = string.Empty; string processGUID = this.txtProcessGUID.Value.ToString(); 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 strNextActivityPerformers = hiddenNextActivityPerformers.Value.ToString().Trim(); IDictionary <string, PerformerList> nextActivityPerformers = NextActivityPerformers(strNextActivityPerformers); if (nextActivityPerformers == null) { base.RegisterStartupScript("", "<script>alert('请选择办理步骤或办理人员--Please select next step and user');</script>"); return; } switch (hiddenPerformField.Value.ToString()) { case "DepManager": //部门经理 currentOpinionRemark = this.txtDepmanagerRemark.Value; break; case "Director": //主管总监 currentOpinionRemark = this.txtDirectorRemark.Value; break; case "Deputy": //副总经理 currentOpinionRemark = this.txtDeputyGeneralRemark.Value; break; case "General": //总经理 currentOpinionRemark = this.txtGeneralManagerRemark.Value; break; } if (!string.IsNullOrEmpty(instanceId)) { //调用流程 IWorkflowService service = new WorkflowService(); WfAppRunner initiator = new WfAppRunner(); initiator.AppName = "请假流程--AskforLeaveProcess"; initiator.AppInstanceID = instanceId; initiator.ProcessGUID = processGUID; initiator.UserID = LoginUserID.ToString(); initiator.UserName = LoginUserName; initiator.Conditions = GetCondition(string.Format("days-{0}", days)); initiator.NextActivityPerformers = nextActivityPerformers; WfExecutedResult runAppResult = service.RunProcessApp(initiator); if (runAppResult.Status != WfExecutedStatus.Success) { base.RegisterStartupScript("", "<script>alert('" + runAppResult.Message + "');</script>"); return; } 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}(ID:{1}) {2}", LoginUserName, LoginUserID, currentOpinionRemark); //AppFlowEntity.ChangedTime = now; //AppFlowEntity.ChangedUserID = LoginUserID.ToString(); //AppFlowEntity.ChangedUserName = LoginUserName; HrsLeaveOpinionEntity hrsleaveOpinionEntity = new HrsLeaveOpinionEntity(); hrsleaveOpinionEntity.AppInstanceID = instanceId.ToString(); hrsleaveOpinionEntity.ActivityID = activityInstanceEntity.ActivityGUID.ToString(); hrsleaveOpinionEntity.ActivityName = CurrentActivityText; hrsleaveOpinionEntity.Remark = string.Format("{0}(ID:{1}) {2}", LoginUserName, LoginUserID, currentOpinionRemark); hrsleaveOpinionEntity.ChangedTime = now; hrsleaveOpinionEntity.ChangedUserID = LoginUserID.ToString(); hrsleaveOpinionEntity.ChangedUserName = LoginUserName; WorkFlows.AddHrsLeaveOpinion(hrsleaveOpinionEntity); } 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('办理成功--Successed');window.location.href='FlowList.aspx';</script>"); } } catch (Exception ex) { base.ClientScript.RegisterStartupScript(this.GetType(), "", "<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>"); } }