GetNextActivityTree() public method

根据应用获取流程下一步节点列表
public GetNextActivityTree ( Slickflow.Engine.Common.WfAppRunner runner, string>.IDictionary condition = null, IUserRoleService roleService = null ) : IList
runner Slickflow.Engine.Common.WfAppRunner 应用执行人
condition string>.IDictionary 条件
roleService IUserRoleService
return IList
コード例 #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
        /// <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));
                }
            }
        }
コード例 #3
0
 public ResponseResult<List<NodeView>> QueryNextStep(WfAppRunner runner)
 {
     var result = ResponseResult<List<NodeView>>.Default();
     try
     {
         var wfservice = new WorkflowService();
         var nodeViewList = wfservice.GetNextActivityTree(runner).ToList<NodeView>();
         result = ResponseResult<List<NodeView>>.Success(nodeViewList, "获取流程下一步信息成功!");
     }
     catch(System.Exception ex)
     {
         result = ResponseResult<List<NodeView>>.Error(string.Format(
             " 请确认角色身份是否切换?! {0}", 
             ex.Message));
     }
     return result;
 }
コード例 #4
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;
            //动态获取下一跳转后的节点
            var nodeViewList = wfService.GetNextActivityTree(appRunner,dictCondition);
            //指定对象执行者
            PerformerList list3 = new PerformerList();
            list3.Add(new Performer("3", "user3"));

            PerformerList list4 = new PerformerList();
            list4.Add(new Performer("4", "user4"));

            Dictionary<String, PerformerList> dictPerformer = new Dictionary<String, PerformerList>();
            int i = 3;
            foreach (NodeView nv in nodeViewList)
            {   
                if (i==3)
                    dictPerformer.Add(nv.ActivityGUID, list3);
                else
                    dictPerformer.Add(nv.ActivityGUID, list4);

                i ++;
            }
            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;
        }
コード例 #5
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;
        }
コード例 #6
0
        public ResponseResult StartProcess(WfAppRunner starter)
        {
            IWorkflowService wfService = new WorkflowService();
            IDbConnection conn = SessionFactory.CreateConnection();

            IDbTransaction trans = null;
            try
            {
                trans = conn.BeginTransaction();
                WfExecutedResult result = wfService.StartProcess(conn, starter, trans);
                trans.Commit();

                int newProcessInstanceID = result.ProcessInstanceIDStarted;
                IList<NodeView> nextSteps = wfService.GetNextActivityTree(starter);

                if (result.Status == WfExecutedStatus.Success)
                {
                    return ResponseResult.Success();
                }
                else
                {
                    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 ResponseResult<IList<NodeView>> GetNextStepsContainer(WfAppRunner runner)
        {
            IWorkflowService wfService = new WorkflowService();
            var nodeList = wfService.GetNextActivityTree(runner, null);

            return ResponseResult<IList<NodeView>>.Success(nodeList);
        }
コード例 #8
0
        public ResponseResult<IList<NodeView>> GetTaskNextSteps(int id)
        {
            IWorkflowService wfService = new WorkflowService();
            var nodeList = wfService.GetNextActivityTree(id);

            return ResponseResult<IList<NodeView>>.Success(nodeList);
        }
コード例 #9
0
ファイル: FlowForm.cs プロジェクト: zengfanlin/Slickflow
        /// <summary>
        /// XML节点预定义跳转
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSkip_Click(object sender, EventArgs e)
        {
            WfAppRunner appRunner = new WfAppRunner();
            appRunner.ProcessGUID = process_guid;
            appRunner.AppInstanceID = application_instance_id;
            appRunner.AppName = "WallwaOrder";
            appRunner.UserID = "13";
            appRunner.UserName = "******";

            IWorkflowService wfService = new WorkflowService();
            var nodeViewList = wfService.GetNextActivityTree(appRunner);
            if (nodeViewList != null && nodeViewList.Count() == 1)
            {
                var nodeView = nodeViewList[0];
                if (nodeView.IsSkipTo == true)
                {
                    //下一步执行人
                    PerformerList list = new PerformerList();
                    Performer p = new Performer("1", "admin");//下一步人ID,Name
                    list.Add(p);
                    Dictionary<String, PerformerList> dict = new Dictionary<String, PerformerList>();
                    dict.Add(nodeView.ActivityGUID, list); //nodeView.ID  下一步节点的标识ID
                    appRunner.NextActivityPerformers = dict;

                    var result = wfService.JumpProcess(appRunner);
                    var msg = string.Format("流程跳转结果:{0}\r\n", result.Status);
                    textBox1.Text += msg;
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// 
        /// </summary>
        protected void InitStepMember()
        {
            string strNodes = string.Empty;

            //流程定义的GUID
            string flowGuid = Request.QueryString["ProcessGUID"] == null ? "" : Request.QueryString["ProcessGUID"].ToString();
            string Step = Request.QueryString["Step"] == null ? "" : Request.QueryString["Step"].ToString();
            if (string.IsNullOrEmpty(flowGuid) || string.IsNullOrEmpty(Step))
            {
                base.RegisterStartupScript("", "<script>alert('流程GUID为空');</script>");
            }
            else
            {
                List<ZTreeEntity> zTreeEntityList = new List<ZTreeEntity>();

                String processGUID = flowGuid;
                IWorkflowService service = new WorkflowService();
                switch (Step)
                {
                    case "start"://流程第一步选择
                        ActivityEntity firstActivity = service.GetFirstActivity(processGUID, string.Empty);
                        String firstActivityGUID = firstActivity.ActivityGUID;
                        string conditions = Request.QueryString["condition"] == null ? "" : Request.QueryString["condition"].ToString();
                        IList<NodeView> nextNodes = service.GetNextActivity(processGUID, string.Empty, firstActivityGUID, GetCondition(conditions));
                        if (nextNodes != null)
                        {
                            if (nextNodes != null)
                            {
                                ZTreeEntity zTreeEntity = null;
                                foreach (NodeView item in nextNodes)
                                {
                                    zTreeEntity = new ZTreeEntity();
                                    zTreeEntity.id = string.Format("step[{0}]", item.ActivityGUID);
                                    zTreeEntity.pId = "0";
                                    zTreeEntity.name = item.ActivityName;
                                    zTreeEntity.nocheck = false;
                                    zTreeEntityList.Add(zTreeEntity);


                                    DataTable dt = GetUsers(item.Roles);
                                    foreach (DataRow dr in dt.Rows)
                                    {
                                        zTreeEntity = new ZTreeEntity();
                                        zTreeEntity.id = string.Format("step[{0}]member[{1}]", item.ActivityGUID, dr["ID"].ToString());
                                        zTreeEntity.pId = string.Format("step[{0}]", item.ActivityGUID);
                                        zTreeEntity.name = dr["UserName"].ToString();
                                        zTreeEntity.nocheck = false;
                                        zTreeEntityList.Add(zTreeEntity);
                                    }

                                }
                            }
                        }
                        else
                        {
                            LiteralMSG.Text = "当前没有需要您办理的步骤";
                        }
                        break;
                    case "task":
                        try
                        {
                            if (LoginUserID > 0)
                            {
                                string condition = Request.QueryString["condition"] == null ? "" : Request.QueryString["condition"].ToString();
                                string instanceId = Request.QueryString["instanceId"] == null ? string.Empty : Request.QueryString["instanceId"].ToString();
                                WfAppRunner runner = new WfAppRunner();
                                runner.AppInstanceID = instanceId;
                                runner.ProcessGUID = processGUID;
                                runner.UserID = this.LoginUserID.ToString();
                                hiddenIsSelectMember.Value = "true";
                                IList<NodeView> NodeViewList = service.GetNextActivityTree(runner, GetCondition(condition));


                                if (NodeViewList != null)
                                {
                                    ZTreeEntity zTreeEntity = null;
                                    foreach (NodeView item in NodeViewList)
                                    {
                                        zTreeEntity = new ZTreeEntity();
                                        zTreeEntity.id = string.Format("step[{0}]", item.ActivityGUID);
                                        zTreeEntity.pId = "0";
                                        zTreeEntity.name = item.ActivityName;
                                        zTreeEntityList.Add(zTreeEntity);

                                        DataTable dt = GetUsers(item.Roles);
                                        foreach (DataRow dr in dt.Rows)
                                        {
                                            zTreeEntity = new ZTreeEntity();
                                            zTreeEntity.id = string.Format("step[{0}]member[{1}]", item.ActivityGUID, dr["ID"].ToString());
                                            zTreeEntity.pId = string.Format("step[{0}]", item.ActivityGUID);
                                            zTreeEntity.name = dr["UserName"].ToString();
                                            zTreeEntity.nocheck = false;
                                            zTreeEntityList.Add(zTreeEntity);
                                        }
                                    }
                                }
                                else
                                {
                                    LiteralMSG.Text = "当前没有需要您办理的步骤";
                                }
                            }
                        }
                        catch (Exception ex)
                        { }
                        break;
                }
                strNodes = JsonHelper.ObjectToJson(zTreeEntityList);
            }

            Response.Write(strNodes);
            Response.End();
        }
コード例 #11
0
        /// <summary>
        /// 
        /// </summary>
        protected void InitStepMember()
        {
            //流程定义的GUID
            string flowGuid = Request.QueryString["ProcessGUID"] == null ? "" : Request.QueryString["ProcessGUID"].ToString();
            string Step = Request.QueryString["Step"] == null ? "" : Request.QueryString["Step"].ToString();
            if (string.IsNullOrEmpty(flowGuid) || string.IsNullOrEmpty(Step))
            {
                base.RegisterStartupScript("", "<script>alert('流程GUID为空');</script>");
            }
            else
            {
                String processGUID = flowGuid;
                IWorkflowService service = new WorkflowService();
                switch (Step)
                {
                    case "start"://流程第一步选择
                        ActivityEntity firstActivity = service.GetFirstActivity(processGUID);
                        String firstActivityGUID = firstActivity.ActivityGUID;

                        string conditions = Request.QueryString["condition"] == null ? "" : Request.QueryString["condition"].ToString();

                        IList<NodeView> nextNodes = service.GetNextActivity(processGUID, firstActivityGUID, GetCondition(conditions));
                        if (nextNodes != null)
                        {
                            Repeater1.DataSource = nextNodes;
                            Repeater1.DataBind();
                        }
                        else
                        {
                            LiteralMSG.Text = "当前没有需要您办理的步骤";
                        }
                        break;
                    case "task":
                        try
                        {
                            if (LoginUserID > 0)
                            {
                                string condition = Request.QueryString["condition"] == null ? "" : Request.QueryString["condition"].ToString();
                                string instanceId = Request.QueryString["instanceId"] == null ? string.Empty : Request.QueryString["instanceId"].ToString();
                                WfAppRunner runner = new WfAppRunner();
                                runner.AppInstanceID = instanceId;
                                runner.ProcessGUID = processGUID;
                                runner.UserID = this.LoginUserID.ToString();
                                hiddenIsSelectMember.Value = "true";
                                IList<NodeView> NodeViewList = service.GetNextActivityTree(runner, GetCondition(condition));
                                if (NodeViewList != null)
                                {
                                    Repeater1.DataSource = NodeViewList;
                                    Repeater1.DataBind();
                                    if (NodeViewList.Count == 1)
                                    {
                                        string nextActivityGuid = NodeViewList[0].ActivityGUID;
                                        /*
                                        ActivityEntity activityEntity = service.GetActivityInstance(processGUID, nextActivityGuid);
                                        if (activityEntity.ActivityType == ActivityTypeEnum.EndNode)
                                        {
                                            hiddenIsSelectMember.Value = "false";
                                        }*/
                                    }
                                }
                                else
                                {
                                    LiteralMSG.Text = "当前没有需要您办理的步骤";
                                }
                            }
                        }
                        catch (Exception ex)
                        { }
                        break;
                }
            }
        }
コード例 #12
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");
            }
        }
コード例 #13
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 = "执行成功"
            });
        }