示例#1
0
        public void 协同审批分支流程(string bpmnFile)
        {
            var ex = Record.Exception(() =>
            {
                ProcessInstance[] instances = AsyncHelper.RunSync(() => ctx.StartUseFile(bpmnFile, null, new Dictionary <string, object>
                {
                    ["同意"] = false
                }));

                ITaskController tc = ctx.CreateWorkflowHttpProxy().GetTaskClient();

                Thread.Sleep(1000);

                var tasks = AsyncHelper.RunSync(() => tc.MyTasks("8e45aba4-c648-4d71-a1c3-3d15b5518b84"));

                var task = tasks.List.ElementAt(0);

                tc.Approvaled(new ApprovaleTaskCmd {
                    TaskId = task.Id
                });

                Assert.NotNull(instances);
                Assert.True(instances.Count() > 0);
            });

            Assert.Null(ex);
        }
示例#2
0
        public void 协同审批一票否决(string bpmnFile)
        {
            var ex = Record.Exception(() =>
            {
                string[] users = new string[]
                {
                    "8e45aba4-c648-4d71-a1c3-3d15b5518b84",
                    "1f387de4-0e26-47dd-b2f1-57771a268bc5",
                    //"e561d025-76c7-4674-b799-5eae802a4980"
                };

                ProcessInstance[] instances = AsyncHelper.RunSync(() => ctx.StartUseFile(bpmnFile, null, new Dictionary <string, object>
                {
                    ["UserTask_11w47k9s"] = users
                }));

                ITaskController tc = ctx.CreateWorkflowHttpProxy().GetTaskClient();

                var tasks = AsyncHelper.RunSync(() => tc.MyTasks(users[0]));

                var task = tasks.List.ElementAt(0);

                tc.Approvaled(new ApprovaleTaskCmd {
                    TaskId = task.Id
                });

                Thread.Sleep(1000);

                tasks = AsyncHelper.RunSync(() => tc.MyTasks(users[1]));

                if (tasks.List.Count() > 0)
                {
                    task = tasks.List.ElementAt(0);

                    tc.Reject(new RejectTaskCmd {
                        TaskId = task.Id, RejectReason = "不同意"
                    });
                }

                Assert.NotNull(instances);
                Assert.True(instances.Count() > 0);
            });

            Assert.Null(ex);
        }
示例#3
0
        public void 协同审批半数拒绝(string bpmnFile)
        {
            var ex = Record.Exception(() =>
            {
                string[] users = new string[]
                {
                    "8e45aba4-c648-4d71-a1c3-3d15b5518b84",
                    "1f387de4-0e26-47dd-b2f1-57771a268bc5",
                    "e561d025-76c7-4674-b799-5eae802a4980"
                };

                ProcessInstance[] instances = AsyncHelper.RunSync(() => ctx.StartUseFile(bpmnFile, null, new Dictionary <string, object>
                {
                    ["UserTask_11w47k9s"] = users
                }));

                var action = new Action <string, bool>((uid, app) =>
                {
                    ITaskController tc = ctx.CreateWorkflowHttpProxy().GetTaskClient();

                    var tasks = AsyncHelper.RunSync(() => tc.MyTasks(uid));

                    if (tasks.RecordCount > 0)
                    {
                        var task = tasks.List.ElementAt(0);

                        if (app)
                        {
                            tc.Approvaled(new ApprovaleTaskCmd {
                                TaskId = task.Id
                            });
                        }
                        else
                        {
                            tc.Reject(new RejectTaskCmd
                            {
                                TaskId       = task.Id,
                                RejectReason = "半数拒绝"
                            });
                        }
                    }
                });

                action(users[0], false);

                action(users[1], true);

                action(users[2], false);

                IProcessInstanceHistoriceController pvc = ctx.CreateWorkflowHttpProxy().GetProcessInstanceHistoriceClient();

                var variables = AsyncHelper.RunSync(() => pvc.GetVariables(new ProcessVariablesQuery
                {
                    ProcessInstanceId    = instances[0].Id,
                    ExcludeTaskVariables = true,
                    VariableName         = WorkflowVariable.GLOBAL_APPROVALED_VARIABLE
                }));
            });

            Assert.Null(ex);
        }