コード例 #1
0
        public async Task <IActionResult> GetHistory(string id, [FromBody] GetHumanTaskInstanceHistoryQuery parameter, CancellationToken token)
        {
            try
            {
                parameter.HumanTaskInstanceId = id;
                var result = await _mediator.Send(parameter, token);

                return(new OkObjectResult(result));
            }
            catch (UnknownHumanTaskInstanceException ex)
            {
                return(this.ToError(new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("bad_request", ex.Message)
                }, HttpStatusCode.NotFound, Request));
            }
        }
        public async Task <SearchResult <TaskInstanceHistoryResult> > Handle(GetHumanTaskInstanceHistoryQuery request, CancellationToken cancellationToken)
        {
            var result = await _humanTaskInstanceQueryRepository.FindHumanTaskInstanceHistory(new FindHumanTaskInstanceHistoryParameter
            {
                HumanTaskInstanceId = request.HumanTaskInstanceId
            }, cancellationToken);

            if (result == null)
            {
                _logger.LogError($"HumanTask '{request.HumanTaskInstanceId}' doesn't exist");
                throw new UnknownHumanTaskInstanceException(string.Format(Global.UnknownHumanTaskInstance, request.HumanTaskInstanceId));
            }

            return(new SearchResult <TaskInstanceHistoryResult>
            {
                Count = result.Count,
                StartIndex = result.StartIndex,
                TotalLength = result.TotalLength,
                Content = result.Content.Select(_ => TaskInstanceHistoryResult.ToDto(_, request.IncludeData))
            });
        }