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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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 Task <HistoricInstance> GetProcessInstanceById(string processInstanceId)
        {
            HistoricInstance processInstance = processEngine.GetHistoryProcessInstanceById(processInstanceId);

            if (processInstance == null)
            {
                throw new ActivitiObjectNotFoundException("Unable to find process definition for the given id:'" + processInstanceId + "'");
            }
            return(Task.FromResult <HistoricInstance>(processInstance));
        }