public Task <SearchResult <ProcessInstanceResult> > Find(FindProcessInstancesParameter parameter, CancellationToken token)
        {
            IQueryable <ProcessInstanceAggregate> result = _instances.AsQueryable();

            if (!string.IsNullOrEmpty(parameter.ProcessFileId))
            {
                result = result.Where(_ => _.ProcessFileId == parameter.ProcessFileId);
            }

            if (parameter.Status != null)
            {
                result = result.Where(_ => _.Status == (ProcessInstanceStatus)parameter.Status.Value);
            }

            if (MAPPING_PROCESSINSTANCE_TO_PROPERTYNAME.ContainsKey(parameter.OrderBy))
            {
                result = result.InvokeOrderBy(MAPPING_PROCESSINSTANCE_TO_PROPERTYNAME[parameter.OrderBy], parameter.Order);
            }

            int totalLength = result.Count();

            result = result.Skip(parameter.StartIndex).Take(parameter.Count);
            return(Task.FromResult(new SearchResult <ProcessInstanceResult>
            {
                StartIndex = parameter.StartIndex,
                Count = parameter.Count,
                TotalLength = totalLength,
                Content = result.Select(_ => ProcessInstanceResult.ToDto(_)).ToList()
            }));
        }
        public Task <ProcessInstanceResult> Get(string id, CancellationToken token)
        {
            var result = _instances.FirstOrDefault(i => i.AggregateId == id);

            if (result == null)
            {
                return(Task.FromResult((ProcessInstanceResult)null));
            }

            return(Task.FromResult(ProcessInstanceResult.ToDto(result)));
        }
コード例 #3
0
        public async Task <ProcessInstanceResult> Get(string id, CancellationToken token)
        {
            var result = await _dbContext.ProcessInstances.FirstOrDefaultAsync(_ => _.AggregateId == id, token);

            if (result == null)
            {
                return(null);
            }

            return(ProcessInstanceResult.ToDto(result));
        }