public void GetProcessInstanceById_主键查找历史实例()
        {
            var ex = Record.Exception(() =>
            {
                IProcessInstanceHistoriceController client = ctx.CreateWorkflowHttpProxy().GetProcessInstanceHistoriceClient();

                HistoricInstanceQuery query = new HistoricInstanceQuery();
                query.TenantId = ctx.TenantId;
                query.Pageable = new Pageable
                {
                    PageNo   = 1,
                    PageSize = 1
                };

                Resources <HistoricInstance> list = client.ProcessInstances(query).GetAwaiter().GetResult();
                if (list.TotalCount == 0)
                {
                    return;
                }

                HistoricInstance inst = client.GetProcessInstanceById(list.List.First().Id).GetAwaiter().GetResult();

                Assert.NotNull(inst);
            });

            Assert.Null(ex);
        }
Пример #2
0
        public async Task 延时10秒后执行用户任务(string bpmnFile)
        {
            ProcessInstance[] insts         = null;
            DateTime          timerDateTime = DateTime.Now.AddSeconds(10);

            TimeSpan timespan = TimeSpan.FromTicks(timerDateTime.Ticks);

            //转换为ISO8601 duration格式字符串
            string duration = XmlConvert.ToString(timespan);

            var ex = Record.Exception(() =>
            {
                string uid = Guid.NewGuid().ToString();
                insts      = AsyncHelper.RunSync(() => ctx.StartUseFile(bpmnFile, new string[] { uid }, new Dictionary <string, object>
                {
                    { "timerDateTime", timerDateTime }
                }));
            });

            Thread.Sleep(15000);

            Assert.Null(ex);

            ex = await Record.ExceptionAsync(async() =>
            {
                IProcessInstanceHistoriceController hisClient = ctx.CreateWorkflowHttpProxy().GetProcessInstanceHistoriceClient();

                HistoricInstance hi = await hisClient.GetProcessInstanceById(insts[0].Id).ConfigureAwait(false);
            }).ConfigureAwait(false);

            Assert.Null(ex);
        }
Пример #3
0
        public void 定时10秒后取消用户任务(string bpmnFile)
        {
            ProcessInstance[] insts         = null;
            DateTime          timerDateTime = DateTime.Now.AddSeconds(10);

            var ex = Record.Exception(() =>
            {
                string uid = Guid.NewGuid().ToString();
                insts      = AsyncHelper.RunSync(() => ctx.StartUseFile(bpmnFile, new string[] { uid }, new Dictionary <string, object>
                {
                    { "timerDateTime", timerDateTime }
                }));
            });

            Thread.Sleep(15000);

            Assert.Null(ex);

            ex = Record.Exception(() =>
            {
                IProcessInstanceHistoriceController hisClient = ctx.CreateWorkflowHttpProxy().GetProcessInstanceHistoriceClient();

                HistoricInstance hi = AsyncHelper.RunSync(() => hisClient.GetProcessInstanceById(insts[0].Id));
            });

            Assert.Null(ex);
        }
        public void ProcessInstances_分页获取流程历史实例列表()
        {
            var ex = Record.Exception(() =>
            {
                IProcessInstanceHistoriceController client = ctx.CreateWorkflowHttpProxy().GetProcessInstanceHistoriceClient();

                int offset = 1;
                Resources <HistoricInstance> list = null;
                while (true)
                {
                    HistoricInstanceQuery query = new HistoricInstanceQuery();
                    query.TenantId     = ctx.TenantId;
                    query.IsTerminated = true;
                    query.Pageable     = new Pageable
                    {
                        PageNo   = offset,
                        PageSize = 10,
                        Sort     = new Sort(new Sort.Order[]
                        {
                            new Sort.Order
                            {
                                Property  = "name",
                                Direction = Sort.Direction.ASC
                            }
                        })
                    };

                    list = client.ProcessInstances(query).GetAwaiter().GetResult();
                    if (list.List.Count() < 10)
                    {
                        break;
                    }

                    offset = offset + 1;
                }

                Assert.True(offset == 1 && list.TotalCount <= 0 ? true : list.TotalCount / 10 + 1 == offset);
            });

            Assert.Null(ex);
        }
Пример #5
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);
        }