public void GetTasks_先启动一个流程_再查询流程任务记录数(string bpmnFile) { var ex = Record.Exception(() => { string uid = Guid.NewGuid().ToString(); ProcessInstance[] inst = AsyncHelper.RunSync(() => ctx.StartUseFile(bpmnFile, new string[] { uid })); ProcessInstanceTaskQuery query = new ProcessInstanceTaskQuery { ProcessInstanceId = inst[0].Id, IncludeCompleted = true }; IProcessInstanceTasksController taskClient = ctx.CreateWorkflowHttpProxy().GetProcessInstanceTasksClient(); Resources <TaskModel> list = AsyncHelper.RunSync <Resources <TaskModel> >(() => taskClient.GetTasks(query)); Assert.NotNull(list); Assert.True(list.TotalCount == list.List.Count()); }); Assert.Null(ex); }
public virtual Task <Resources <TaskModel> > GetTasks([FromBody] ProcessInstanceTaskQuery query) { if (query == null) { throw new ArgumentNullException("query"); } IPage <TaskModel> page = pageableTaskService.GetTasks(query.ProcessInstanceId, query.BusinessKey, query.TenantId, query.Pageable); List <TaskResource> res = taskResourceAssembler.ToResources(page.GetContent()).ToList(); IPage <TaskModel> historics = null; if (query.IncludeCompleted) { historics = pageableTaskService.GetHistoryTasks(query.ProcessInstanceId, query.BusinessKey, query.TenantId, query.Pageable); res.AddRange(taskResourceAssembler.ToResources(historics.GetContent())); } Resources <TaskModel> tasks = new Resources <TaskModel>(res.Select(x => x.Content), page.GetTotalItems() + (query.IncludeCompleted ? historics.GetTotalItems() : 0), query.Pageable.PageNo, query.Pageable.PageSize); return(Task.FromResult <Resources <TaskModel> >(tasks)); }
/// <inheritdoc /> public async Task <Resources <TaskModel> > GetTasks(ProcessInstanceTaskQuery query) { return(await httpProxy.PostAsync <Resources <TaskModel> >($"{serviceUrl}/tasks", query).ConfigureAwait(false)); }