public Task <FindResponse <ProcessInstanceAggregate> > 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 FindResponse <ProcessInstanceAggregate>
            {
                StartIndex = parameter.StartIndex,
                Count = parameter.Count,
                TotalLength = totalLength,
                Content = result.ToList()
            }));
        }
Exemplo n.º 2
0
        public async Task <SearchResult <ProcessInstanceResult> > Find(FindProcessInstancesParameter parameter, CancellationToken token)
        {
            IQueryable <ProcessInstanceAggregate> result = _dbContext.ProcessInstances;

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

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

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

            int totalLength = await result.CountAsync(token);

            result = result.Skip(parameter.StartIndex).Take(parameter.Count);
            var content = await result.ToListAsync(token);

            return(new SearchResult <ProcessInstanceResult>
            {
                StartIndex = parameter.StartIndex,
                Count = parameter.Count,
                TotalLength = totalLength,
                Content = content.Select(_ => ProcessInstanceResult.ToDto(_)).ToList()
            });
        }
Exemplo n.º 3
0
        public async Task <FindResponse <ProcessInstanceAggregate> > Find(FindProcessInstancesParameter parameter, CancellationToken token)
        {
            IQueryable <ProcessInstanceModel> result = _dbContext.ProcessInstances
                                                       .AsNoTracking()
                                                       .Include(_ => _.ItemDefs)
                                                       .Include(_ => _.Interfaces).ThenInclude(_ => _.Operations)
                                                       .Include(_ => _.Messages)
                                                       .Include(_ => _.ElementDefs)
                                                       .Include(_ => _.SequenceFlows)
                                                       .Include(_ => _.ExecutionPathLst).ThenInclude(_ => _.Pointers).ThenInclude(_ => _.Tokens)
                                                       .Include(_ => _.StateTransitions)
                                                       .Include(_ => _.ElementInstances).ThenInclude(_ => _.ActivityStates);

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

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

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

            int totalLength = await result.CountAsync(token);

            result = result.Skip(parameter.StartIndex).Take(parameter.Count);
            var content = await result.ToListAsync(token);

            return(new FindResponse <ProcessInstanceAggregate>
            {
                StartIndex = parameter.StartIndex,
                Count = parameter.Count,
                TotalLength = totalLength,
                Content = content.Select(_ => _.ToDomain()).ToList()
            });
        }