RunProcessApp() 공개 메소드

运行流程
public RunProcessApp ( IDbConnection conn, Slickflow.Engine.Common.WfAppRunner runner, IDbTransaction trans ) : WfExecutedResult
conn IDbConnection 连接
runner Slickflow.Engine.Common.WfAppRunner 运行人
trans IDbTransaction 事务
리턴 Slickflow.Engine.Core.Result.WfExecutedResult
예제 #1
0
        /// <summary>
        /// 生产节点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMade_Click(object sender, EventArgs e)
        {
            WfAppRunner appRunner = new WfAppRunner();
            appRunner.ProcessGUID = process_guid;
            appRunner.AppInstanceID = application_instance_id;
            appRunner.AppName = application_name;
            appRunner.UserID = per_dict["limu"];
            appRunner.UserName = "******";

            var wfService = new WorkflowService();
            var nextSteps = wfService.GetNextActivityTree(appRunner);

            if (nextSteps != null)
            {
                //构造下一步办理人的信息
                appRunner.NextActivityPerformers = CreateNextActivityPerformers(nextSteps);

                var r2 = wfService.RunProcessApp(appRunner);
                var msg2 = string.Format("执行【生产】:{0}, {1}\r\n", r2.Status, r2.Message);

                WriteText(msg2);

                if (r2.Status == WfExecutedStatus.Success)
                {
                    WriteText(string.Format("任务已经发送到下一节点:{0}\r\n\r\n", nextSteps[0].ActivityName));
                }
            }
            else
            {
                WriteText("您当前没有办理任务!\r\n");
            }
        }
예제 #2
0
        private void btn仓库签字_Click(object sender, EventArgs e)
        {
            WfAppRunner appRunner = new WfAppRunner();
            appRunner.ProcessGUID = process_guid;
            appRunner.AppInstanceID = application_instance_id;
            //第一步任务承担者,登录后要找到自己的任务
            appRunner.AppName = "officeIn";
            appRunner.UserID = "1";
            appRunner.UserName = "******";
            IWorkflowService wfService = new WorkflowService();

            //外部变量条件
            Dictionary<string, string> dictCondition = new Dictionary<string, string>();
            dictCondition.Add("surplus", cBoxSurplus.Text);
            appRunner.Conditions = dictCondition;

            //动态获取下一跳转后的节点
            NodeView nv = wfService.GetNextActivity(appRunner, dictCondition);
            //指定对象执行者
            PerformerList list = new PerformerList();
            list.Add(new Performer("3", "user3"));
            Dictionary<String, PerformerList> dictPerformer = new Dictionary<String, PerformerList>();
            dictPerformer.Add(nv.ActivityGUID, list);
            appRunner.NextActivityPerformers = dictPerformer;

            var result = wfService.RunProcessApp(appRunner);
            var msg = string.Format("流程运行结果:{0}\r\n{1}\r\n", result.Status, result.Message);
            tBoxResult.Text += msg;
        }
예제 #3
0
        /// <summary>
        /// 打单节点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPrintOrder_Click(object sender, EventArgs e)
        {
            WfAppRunner appRunner = new WfAppRunner();
            appRunner.ProcessGUID = process_guid;
            appRunner.AppInstanceID = application_instance_id;
            appRunner.AppName = application_name;
            appRunner.UserID = per_dict["yiran"];
            appRunner.UserName = "******";

            //先启动流程
            var wfService = new WorkflowService();
            var r1 = wfService.StartProcess(appRunner);

            var msg = string.Format("生产订单流程开始:{0}, {1}\r\n", r1.Status, r1.Message);
            WriteText(msg);

            if (r1.Status == WfExecutedStatus.Success)
            {
                //打单环节加入条件,运行流程
                var cond = new Dictionary<string, string>();

                cond["CanUseStock"] = chkStock.Checked.ToString().ToLower();
                cond["IsHavingWeight"] = chkWeight.Checked.ToString().ToLower();

                appRunner.Conditions = cond;

                string message = string.Empty;
                var nextSteps = wfService.GetNextActivityTree(appRunner, cond);
                if (nextSteps != null)
                {
                    appRunner.NextActivityPerformers = CreateNextActivityPerformers(nextSteps);

                    var r2 = wfService.RunProcessApp(appRunner);
                    message = r2.Message;
                    WriteText(string.Format("执行【打单】: {0}, {1}\r\n", r2.Status, r2.Message));

                    if (r2.Status == WfExecutedStatus.Success)
                    {
                        WriteText(string.Format("任务已经发送到下一节点:{0}\r\n\r\n", nextSteps[0].ActivityName));
                    }
                }
                else
                {
                    message = "下一步节点不匹配!";
                    WriteText(string.Format("{0}\r\n", message));
                }
            }
        }
예제 #4
0
        /// <summary>
        /// 工作流运行
        /// </summary>
        /// <param name="session"></param>
        /// <param name="runner"></param>
        /// <returns></returns>
        public WfExecutedResult RunProcess(IDbSession session, WfAppRunner runner, IDictionary<string, string> conditions = null)
        {
            var result = new WfExecutedResult();
            var wfService = new WorkflowService();
            var nodeViewList = wfService.GetNextActivityTree(runner, conditions).ToList<NodeView>();

            foreach (var node in nodeViewList)
            {
                var performerList = wfService.GetPerformerList(node);       //根据节点角色定义,读取执行者列表
                Dictionary<string, PerformerList> dict = new Dictionary<string, PerformerList>();
                dict.Add(node.ActivityGUID, performerList);
                runner.NextActivityPerformers = dict;

                if (node.IsSkipTo == true)
                {
                    result = wfService.JumpProcess(session.Connection, runner, session.Transaction);
                }
                else
                {
                    result = wfService.RunProcessApp(session.Connection, runner, session.Transaction);
                }
            }
            return result;
        }
예제 #5
0
 private void btn总经理签字_Click(object sender, EventArgs e)
 {
     WfAppRunner appRunner = new WfAppRunner();
     appRunner.ProcessGUID = process_guid;
     appRunner.AppInstanceID = application_instance_id;
     //第一步任务承担者,登录后要找到自己的任务
     appRunner.AppName = "officeIn";
     appRunner.UserID = "4";
     appRunner.UserName = "******";
     IWorkflowService wfService = new WorkflowService();
     PerformerList list = new PerformerList();
     list.Add(new Performer("4", "user4"));
     NodeView nv = wfService.GetNextActivity(appRunner);
     Dictionary<String, PerformerList> dictPerformer = new Dictionary<String, PerformerList>();
     dictPerformer.Add(nv.ActivityGUID, list);
     appRunner.NextActivityPerformers = dictPerformer;
     var result = wfService.RunProcessApp(appRunner);
     var msg = string.Format("流程运行结果:{0}\r\n{1}\r\n", result.Status, result.Message);
     tBoxResult.Text += msg;
 }
        public ResponseResult RunProcessApp(WfAppRunner runner)
        {
            IWorkflowService wfService = new WorkflowService();
            IDbConnection conn = SessionFactory.CreateConnection();

            IDbTransaction trans = null;
            try
            {
                trans = conn.BeginTransaction();
                var result = wfService.RunProcessApp(conn, runner, trans);

                if (result.Status == WfExecutedStatus.Success)
                {
                    trans.Commit();
                    return ResponseResult.Success();
                }
                else
                {
                    trans.Rollback();
                    return ResponseResult.Error(result.Message);
                }
            }
            catch (WorkflowException w)
            {
                trans.Rollback();
                return ResponseResult.Error(w.Message);
            }
            finally
            {
                trans.Dispose();
                if (conn.State == ConnectionState.Open)
                    conn.Close();
            }
        }
예제 #7
0
        public void StartupRunEnd()
        {
            IDbConnection conn = new SqlConnection(DBConfig.ConnectionString);
            conn.Open();

            ////StarterA:
            ////{"UserID":"10","UserName":"******","AppName":"SamplePrice","AppInstanceID":"100","ProcessGUID":"072af8c3-482a-4b1c-890b-685ce2fcc75d"}
            var initiator = new WfAppRunner();
            initiator.AppName = "SamplePrice";
            initiator.AppInstanceID = 100;
            initiator.ProcessGUID = Guid.Parse("072af8c3-482a-4b1c-890b-685ce2fcc75d");
            initiator.UserID = 10;
            initiator.UserName = "******";

            IWorkflowService service = new WorkflowService();

            //流程开始->业务员提交
            IDbTransaction trans = conn.BeginTransaction();
            try
            {
                service.StartProcess(conn, initiator, trans);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }

            //业务员提交->板房签字
            var banFangNodeGuid = "fc8c71c5-8786-450e-af27-9f6a9de8560f";
            PerformerList pList = new PerformerList();
            pList.Add(new Performer(20, "Zhang"));

            initiator.NextActivityPerformers = new Dictionary<Guid, PerformerList>();
            initiator.NextActivityPerformers.Add(Guid.Parse(banFangNodeGuid), pList);

            trans = conn.BeginTransaction();
            try
            {
                service.RunProcessApp(conn, initiator, trans);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }

            //板房签字->业务员签字
            //登录用户身份
            initiator.UserID = 20;
            initiator.UserName = "******";

            var salesGuid = "39c71004-d822-4c15-9ff2-94ca1068d745";
            pList.Clear();
            pList.Add(new Performer(10, "Long"));

            initiator.NextActivityPerformers.Clear();
            initiator.NextActivityPerformers.Add(Guid.Parse(salesGuid), pList);
            trans = conn.BeginTransaction();
            try
            {
                service.RunProcessApp(conn, initiator, trans);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }

            //业务员签字->结束
            //登录用户身份
            initiator.UserID = 10;
            initiator.UserName = "******";

            var endGuid = "b70e717a-08da-419f-b2eb-7a3d71f054de";
            pList.Clear();
            pList.Add(new Performer(10, "Long"));

            initiator.NextActivityPerformers.Clear();
            initiator.NextActivityPerformers.Add(Guid.Parse(endGuid), pList);
            trans = conn.BeginTransaction();
            try
            {
                service.RunProcessApp(conn, initiator, trans);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }

            if (conn.State == ConnectionState.Open)
                conn.Close();
        }
예제 #8
0
        /// <summary>
        /// 运行流程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRun_Click(object sender, EventArgs e)
        {
            WfAppRunner appRunner = new WfAppRunner();
            appRunner.ProcessGUID = process_guid;
            appRunner.AppInstanceID = application_instance_id;
            appRunner.AppName = "WallwaOrder";
            appRunner.UserID = "1";
            appRunner.UserName = "******";

            //下一步执行人
            PerformerList list = new PerformerList();
            Performer p = new Performer("13", "andun");//下一步人ID,Name
            list.Add(p);
            Dictionary<String, PerformerList> dict = new Dictionary<String,PerformerList>();
            dict.Add("fc8c71c5-8786-450e-af27-9f6a9de8560f", list); //print activity:"fc8c71c5-8786-450e-af27-9f6a9de8560f"下一步节点的标识ID
            appRunner.NextActivityPerformers = dict;

            IWorkflowService wfService = new WorkflowService();
            var result = wfService.RunProcessApp(appRunner);

            var msg = string.Format("流程运行结果:{0}\r\n", result.Status);
            textBox1.Text += msg;
        }
예제 #9
0
        //送往下一步
        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>");
            }
        }
예제 #10
0
        public void StartupParalleled()
        {
            IDbConnection conn = new SqlConnection(DBConfig.ConnectionString);
            conn.Open();

            //StarterA:
            //{"UserID":"10","UserName":"******","AppName":"SamplePrice","AppInstanceID":"100","ProcessGUID":"072af8c3-482a-4b1c-890b-685ce2fcc75d"}
            var starterA = new WfAppRunner();
            starterA.ProcessGUID = Guid.Parse("072af8c3-482a-4b1c-890b-685ce2fcc75d");
            starterA.UserID = 10;
            starterA.UserName = "******";

            var runnerA = new WfAppRunner();
            runnerA.ProcessGUID = Guid.Parse("072af8c3-482a-4b1c-890b-685ce2fcc75d");
            runnerA.UserID = 10;
            runnerA.UserName = "******";

            PerformerList pList = new PerformerList();
            pList.Add(new Performer(20, "Xiao"));

            runnerA.NextActivityPerformers = new Dictionary<Guid, PerformerList>();
            runnerA.NextActivityPerformers.Add(Guid.Parse("fc8c71c5-8786-450e-af27-9f6a9de8560f"), pList);

            IWorkflowService serviceA;
            IDbTransaction trans = null;

            //STARTUP 2000 TIMES
            //for (var i = 0; i < 2000; i++)
            //{
            //    serviceA = new WorkflowService();
            //    starterA.AppName = "price";
            //    starterA.AppInstanceID = i;
            //    try
            //    {
            //        trans = conn.BeginTransaction();
            //        serviceA.StartProcess(conn, starterA, trans);
            //        trans.Commit();
            //    }
            //    catch
            //    {
            //        trans.Rollback();
            //        throw;
            //    }
            //    finally
            //    {
            //        trans.Dispose();
            //    }
            //}

            ////RUN process 2000 TIMES
            for (var i = 0; i < 2000; i++)
            {
                serviceA = new WorkflowService();
                runnerA.AppInstanceID = i;
                runnerA.AppName = "price";
                try
                {
                    trans = conn.BeginTransaction();
                    serviceA.RunProcessApp(conn, runnerA, trans);
                    trans.Commit();
                }
                catch
                {
                    trans.Rollback();
                    throw;
                }
                finally
                {
                    trans.Dispose();
                }
            }

            if (conn.State == ConnectionState.Open)
                conn.Close();
        }
예제 #11
0
        //送往下一步
        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('请选择办理步骤或办理人员');</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 = "请假流程";
                    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;
                        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>");
            }
        }
예제 #12
0
        /// <summary>
        /// 运行流程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRun_Click(object sender, EventArgs e)
        {
            WfAppRunner appRunner = new WfAppRunner();
            appRunner.ProcessGUID = process_guid;
            appRunner.AppInstanceID = application_instance_id;
            //第一步任务承担者,登录后要找到自己的任务
            appRunner.AppName = "officeIn";
            appRunner.UserID = "1";
            appRunner.UserName = "******";
            IWorkflowService wfService = new WorkflowService();
            TaskQueryEntity en = new TaskQueryEntity
            {
                UserID = "1"
            };
            IList<TaskViewEntity> taskViewList = wfService.GetReadyTasks(en);
            if (taskViewList != null)
            {
                dataGridView1.DataSource = taskViewList;
            }
            ////下一步执行人
            //PerformerList list = new PerformerList();
            //Performer p = new Performer("3", "user3");
            //下一步人ID,Name 注意有角色区分
            //list.Add(p);
            //Dictionary<string, string> dictCondition = new Dictionary<string, string>();
            //dictCondition.Add("IsHavingWeight", "true");
            //dictCondition.Add("CanUseStock", "false");
            //appRunner.Conditions = dictCondition;
            //NodeView nv = wfService.GetNextActivity(appRunner);//, dictCondition
            //Dictionary<String, PerformerList> dictPerformer = new Dictionary<String, PerformerList>();
            //dictPerformer.Add(nv.ActivityGUID, list);
            //appRunner.NextActivityPerformers = dictPerformer;

            var result = wfService.RunProcessApp(appRunner);
            var msg = string.Format("流程运行结果:{0}\r\n", result.Status);
            textBox1.Text += msg;
        }
예제 #13
0
        //提交请假信息
        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>");
            }
        }
예제 #14
0
         /// <summary>
        /// 输出节点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOutput_Click(object sender, EventArgs e)
        {
            WfAppRunner appRunner = new WfAppRunner();
            appRunner.ProcessGUID = process_guid;
            appRunner.AppInstanceID = application_instance_id;
            appRunner.AppName = application_name;
            appRunner.UserID = per_dict["andun"];
            appRunner.UserName = "******";

            var wfService = new WorkflowService();
            var nextSteps = wfService.GetNextActivityTree(appRunner);

            if (nextSteps != null)
            {
                //构造下一步办理人的信息
                string msg2 = string.Empty;

                foreach (NodeView nodeView in nextSteps)
                {
                    //当前用例只有一个节点能够向下流转
                    appRunner.NextActivityPerformers = CreateNextActivityPerformers(nodeView);

                    if (nodeView.IsSkipTo == true)
                    {
                        var j2 = wfService.JumpProcess(appRunner);
                        msg2 = string.Format("执行【输出】并跳转:{0}, {1}\r\n", j2.Status, j2.Message);

                        WriteText(msg2);

                        if (j2.Status == WfExecutedStatus.Success)
                        {
                            WriteText(string.Format("任务已经发送到下一节点:{0}\r\n\r\n", nodeView.ActivityName));
                        }
                    }
                    else
                    {
                        var r2 = wfService.RunProcessApp(appRunner);
                        msg2 = string.Format("执行【输出】:{0}\r\n", r2.Message);

                        WriteText(msg2);

                        if (r2.Status == WfExecutedStatus.Success)
                        {
                            WriteText(string.Format("任务已经发送到下一节点:{0}\r\n", nodeView.ActivityName));
                        }
                    }
                }

            }
            else
            {
                WriteText("您当前没有办理任务!\r\n");
            }
        }
예제 #15
0
        public async Task<ActionResult> Add(LeaveViewModel leave)
        {
            string processGUID = leave.ProcessGUID;
            //验证不通过,重新填写表单
            if (!ModelState.IsValid)
            {
                return View();
            }
            IWorkflowService service = new WorkflowService();
            //流程开始第一步
            ActivityEntity firstActivity = service.GetFirstActivity(leave.ProcessGUID);

            //该处较上一版本有变化,上一版本为GUID类型
            string firstActivityGUID = firstActivity.ActivityGUID;
            IList<NodeView> nextActivity = service.GetNextActivity(leave.ProcessGUID, firstActivityGUID, GetCondition("days-" + leave.Days));
            //表示有下一位审批者
            if (nextActivity.Count() > 0)
            {
                //下一步角色ID审批者
                string outerId = nextActivity[0].Roles[0].ID.ToString();
                //这里只取第一个审批者,WebDemo 是弹窗形式选择
                //审批用户id
                IEnumerable<int> userId = RoleManager.FindById(Convert.ToInt32(outerId)).Users.Select(t => t.UserId);
                ApplicationUser user = await UserManager.FindByIdAsync(Convert.ToInt32(userId.ToList()[0]));
                //提交请假信息
                LeaveEntity leaveE = new LeaveEntity()
                {
                    FromDate = leave.BeginTime,
                    ToDate = leave.EndTime,
                    Days = leave.Days,
                    LeaveType = leave.LeaveType,
                    CurrentActivityText = "",
                    Status = 0,
                    CreatedUserID = Convert.ToInt32(User.Identity.GetUserId()),
                    CreatedUserName = User.Identity.Name,
                    CreatedDate = DateTime.Now
                };
                HrsLeaveResult result = new WorkFlowManager().Insert(leaveE);
                if (result.Successed)
                {
                    WfAppRunner initiator = new WfAppRunner();
                    initiator.AppName = "请假流程";
                    initiator.AppInstanceID = result.ResultIdentities.ToString();
                    initiator.ProcessGUID = processGUID;
                    initiator.UserID = User.Identity.GetUserId();
                    initiator.UserName = User.Identity.Name;
                    initiator.Conditions = GetCondition(string.Format("days-{0}", leave.Days));
                    WfExecutedResult startedResult = service.StartProcess(initiator);
                    if (startedResult.Status != WfExecutedStatus.Success)
                    {
                        //给出提示
                    }
                    //送往下一步
                    PerformerList pList = new PerformerList();
                    //这里使用真实姓名代替
                    pList.Add(new Performer(user.Id.ToString(), user.RealName));
                    initiator.NextActivityPerformers = new Dictionary<String, PerformerList>();
                    initiator.NextActivityPerformers.Add(nextActivity[0].ActivityGUID, pList);
                    WfExecutedResult runAppResult = service.RunProcessApp(initiator);
                    if (runAppResult.Status != WfExecutedStatus.Success)
                    {
                        this.Content("<script>alert('" + runAppResult.Message + "');</script>");
                    }
                    //保存业务数据
                    BizAppFlowEntity AppFlowEntity = new BizAppFlowEntity();
                    AppFlowEntity.AppName = "流程发起";
                    AppFlowEntity.AppInstanceID = result.ResultIdentities.ToString();
                    AppFlowEntity.ActivityName = "流程发起";
                    AppFlowEntity.Remark = string.Format("申请人:{0}-{1}", User.Identity.GetUserId(), User.Identity.Name);
                    AppFlowEntity.ChangedTime = DateTime.Now;
                    AppFlowEntity.ChangedUserID = User.Identity.GetUserId();
                    AppFlowEntity.ChangedUserName = User.Identity.Name;
                    HrsLeaveResult resultBiz = new WorkFlowManager().Insert(AppFlowEntity);
                    if (resultBiz.Successed)
                    {
                        //给出前台提示
                        this.Content("", "<script>alert('流程发起成功');</script>");
                    }
                }
            }
            else
            {
                //显示前台错误,人事人员审批失败
                ModelState.AddModelError("Human", "该用户暂时不可提交审批,未查询到该用户的下一位审批者");
                return View();
            }
            return RedirectToAction("MySlickflow", "Slickflow");
        }
예제 #16
0
        public async Task<ActionResult> Approval(string type = "agree", string processGUID = "", int instanceId = 0, double days = 0)
        {
            var resolveRequest = HttpContext.Request;
            resolveRequest.InputStream.Seek(0, System.IO.SeekOrigin.Begin);
            string jsonString = new System.IO.StreamReader(resolveRequest.InputStream).ReadToEnd();
            try
            {
                IWorkflowService service = new WorkflowService();
                WfAppRunner runner = new WfAppRunner();
                runner.AppInstanceID = instanceId.ToString();
                runner.ProcessGUID = processGUID;
                runner.UserID = User.Identity.GetUserId();
                IList<NodeView> NodeViewList = service.GetNextActivityTree(runner, GetCondition("days-" + days));
                var leave = JsonConvert.DeserializeObject<LeaveEntity>(jsonString);
                leave.ID = instanceId;
                //调用流程
                WfAppRunner initiator = new WfAppRunner();
                initiator.AppName = "请假流程";
                initiator.AppInstanceID = instanceId.ToString();
                initiator.ProcessGUID = processGUID;
                initiator.UserID = User.Identity.GetUserId();
                initiator.UserName = User.Identity.GetUserName();
                initiator.Conditions = GetCondition(string.Format("days-{0}", days)); //后续节点不用传入条件表达式

                //获取下一步审批人信息
                //下一步角色ID审批者
                PerformerList pList = new PerformerList();
                if (NodeViewList[0].Roles.Count > 0)
                {
                    string outerId = NodeViewList[0].Roles[0].ID.ToString();
                    //这里只取第一个审批者,WebDemo 是弹窗形式选择
                    //审批用户id
                    IEnumerable<int> userId = RoleManager.FindById(Convert.ToInt32(outerId)).Users.Select(t => t.UserId);
                    ApplicationUser user = await UserManager.FindByIdAsync(Convert.ToInt32(userId.ToList()[0]));
                    //送往下一步
                    
                    pList.Add(new Performer(user.Id.ToString(), user.RealName));
                }

                initiator.NextActivityPerformers = new Dictionary<String, PerformerList>();
                initiator.NextActivityPerformers.Add(NodeViewList[0].ActivityGUID, pList);
                WfExecutedResult runAppResult = service.RunProcessApp(initiator);
                if (runAppResult.Status != WfExecutedStatus.Success)
                {
                }
                ProcessEntity processEntity = service.GetProcessById(processGUID);
                if (processEntity != null)
                {
                    ActivityInstanceEntity activityInstanceEntity = service.GetActivityInstance(instanceId);
                    if (activityInstanceEntity != null)
                    {
                        //CurrentActivityText = activityInstanceEntity.ActivityName;
                    }
                }
                new WorkFlowManager().UpdateHrsLeave(leave);
            }
            catch (Exception ex)
            {
                return Json(new
                {
                    success = false,
                    message = ex.Message
                });
            }
            return Json(new
            {
                success = true,
                message = "执行成功"
            });
        }