public async Task <int> Count(WorkflowParameterFilter filter)
        {
            IQueryable <WorkflowParameterDAO> WorkflowParameters = DataContext.WorkflowParameter.AsNoTracking();

            WorkflowParameters = DynamicFilter(WorkflowParameters, filter);
            return(await WorkflowParameters.CountAsync());
        }
        public async Task <List <WorkflowParameter> > List(WorkflowParameterFilter filter)
        {
            if (filter == null)
            {
                return(new List <WorkflowParameter>());
            }
            IQueryable <WorkflowParameterDAO> WorkflowParameterDAOs = DataContext.WorkflowParameter.AsNoTracking();

            WorkflowParameterDAOs = DynamicFilter(WorkflowParameterDAOs, filter);
            WorkflowParameterDAOs = DynamicOrder(WorkflowParameterDAOs, filter);
            List <WorkflowParameter> WorkflowParameters = await DynamicSelect(WorkflowParameterDAOs, filter);

            return(WorkflowParameters);
        }
Exemple #3
0
        public async Task <bool> ValidateId(WorkflowParameter WorkflowParameter)
        {
            WorkflowParameterFilter WorkflowParameterFilter = new WorkflowParameterFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = WorkflowParameter.Id
                },
                Selects = WorkflowParameterSelect.Id
            };

            int count = await UOW.WorkflowParameterRepository.Count(WorkflowParameterFilter);

            if (count == 0)
            {
                WorkflowParameter.AddError(nameof(WorkflowParameterValidator), nameof(WorkflowParameter.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
Exemple #4
0
 public WorkflowParameterFilter ToFilter(WorkflowParameterFilter filter)
 {
     if (filter.OrFilter == null)
     {
         filter.OrFilter = new List <WorkflowParameterFilter>();
     }
     if (CurrentContext.Filters == null || CurrentContext.Filters.Count == 0)
     {
         return(filter);
     }
     foreach (var currentFilter in CurrentContext.Filters)
     {
         WorkflowParameterFilter subFilter = new WorkflowParameterFilter();
         filter.OrFilter.Add(subFilter);
         List <FilterPermissionDefinition> FilterPermissionDefinitions = currentFilter.Value;
         foreach (FilterPermissionDefinition FilterPermissionDefinition in FilterPermissionDefinitions)
         {
         }
     }
     return(filter);
 }
Exemple #5
0
        public async Task <List <WorkflowParameter> > List(WorkflowParameterFilter WorkflowParameterFilter)
        {
            try
            {
                List <WorkflowParameter> WorkflowParameters = await UOW.WorkflowParameterRepository.List(WorkflowParameterFilter);

                return(WorkflowParameters);
            }
            catch (Exception ex)
            {
                await Logging.CreateSystemLog(ex.InnerException, nameof(WorkflowParameterService));

                if (ex.InnerException == null)
                {
                    throw new MessageException(ex);
                }
                else
                {
                    throw new MessageException(ex.InnerException);
                }
            }
        }
Exemple #6
0
        public async Task <int> Count(WorkflowParameterFilter WorkflowParameterFilter)
        {
            try
            {
                int result = await UOW.WorkflowParameterRepository.Count(WorkflowParameterFilter);

                return(result);
            }
            catch (Exception ex)
            {
                await Logging.CreateSystemLog(ex.InnerException, nameof(WorkflowParameterService));

                if (ex.InnerException == null)
                {
                    throw new MessageException(ex);
                }
                else
                {
                    throw new MessageException(ex.InnerException);
                }
            }
        }
        private IQueryable <WorkflowParameterDAO> DynamicOrder(IQueryable <WorkflowParameterDAO> query, WorkflowParameterFilter filter)
        {
            switch (filter.OrderType)
            {
            case OrderType.ASC:
                switch (filter.OrderBy)
                {
                case WorkflowParameterOrder.Id:
                    query = query.OrderBy(q => q.Id);
                    break;

                case WorkflowParameterOrder.WorkflowDefinition:
                    query = query.OrderBy(q => q.WorkflowDefinitionId);
                    break;

                case WorkflowParameterOrder.Name:
                    query = query.OrderBy(q => q.Name);
                    break;

                case WorkflowParameterOrder.Code:
                    query = query.OrderBy(q => q.Code);
                    break;
                }
                break;

            case OrderType.DESC:
                switch (filter.OrderBy)
                {
                case WorkflowParameterOrder.Id:
                    query = query.OrderByDescending(q => q.Id);
                    break;

                case WorkflowParameterOrder.WorkflowDefinition:
                    query = query.OrderByDescending(q => q.WorkflowDefinitionId);
                    break;

                case WorkflowParameterOrder.Name:
                    query = query.OrderByDescending(q => q.Name);
                    break;

                case WorkflowParameterOrder.Code:
                    query = query.OrderByDescending(q => q.Code);
                    break;
                }
                break;
            }
            query = query.Skip(filter.Skip).Take(filter.Take);
            return(query);
        }
        private IQueryable <WorkflowParameterDAO> OrFilter(IQueryable <WorkflowParameterDAO> query, WorkflowParameterFilter filter)
        {
            if (filter.OrFilter == null || filter.OrFilter.Count == 0)
            {
                return(query);
            }
            IQueryable <WorkflowParameterDAO> initQuery = query.Where(q => false);

            foreach (WorkflowParameterFilter WorkflowParameterFilter in filter.OrFilter)
            {
                IQueryable <WorkflowParameterDAO> queryable = query;
                if (WorkflowParameterFilter.Id != null)
                {
                    queryable = queryable.Where(q => q.Id, WorkflowParameterFilter.Id);
                }
                if (WorkflowParameterFilter.WorkflowDefinitionId != null)
                {
                    queryable = queryable.Where(q => q.WorkflowDefinitionId, WorkflowParameterFilter.WorkflowDefinitionId);
                }
                if (WorkflowParameterFilter.Code != null)
                {
                    queryable = queryable.Where(q => q.Code, WorkflowParameterFilter.Code);
                }
                if (WorkflowParameterFilter.Name != null)
                {
                    queryable = queryable.Where(q => q.Name, WorkflowParameterFilter.Name);
                }
                initQuery = initQuery.Union(queryable);
            }
            return(initQuery);
        }
 private IQueryable <WorkflowParameterDAO> DynamicFilter(IQueryable <WorkflowParameterDAO> query, WorkflowParameterFilter filter)
 {
     if (filter == null)
     {
         return(query.Where(q => false));
     }
     if (filter.Id != null)
     {
         query = query.Where(q => q.Id, filter.Id);
     }
     if (filter.WorkflowDefinitionId != null)
     {
         query = query.Where(q => q.WorkflowDefinitionId, filter.WorkflowDefinitionId);
     }
     if (filter.Code != null)
     {
         query = query.Where(q => q.Code, filter.Code);
     }
     if (filter.Name != null)
     {
         query = query.Where(q => q.Name, filter.Name);
     }
     query = OrFilter(query, filter);
     return(query);
 }
        private async Task <List <WorkflowParameter> > DynamicSelect(IQueryable <WorkflowParameterDAO> query, WorkflowParameterFilter filter)
        {
            List <WorkflowParameter> WorkflowParameters = await query.Select(q => new WorkflowParameter()
            {
                Id = filter.Selects.Contains(WorkflowParameterSelect.Id) ? q.Id : default(long),
                WorkflowDefinitionId = filter.Selects.Contains(WorkflowParameterSelect.WorkflowDefinition) ? q.WorkflowDefinitionId : default(long),
                Code = filter.Selects.Contains(WorkflowParameterSelect.Code) ? q.Code : default(string),
                Name = filter.Selects.Contains(WorkflowParameterSelect.Name) ? q.Name : default(string),
                WorkflowDefinition = filter.Selects.Contains(WorkflowParameterSelect.WorkflowDefinition) && q.WorkflowDefinition != null ? new WorkflowDefinition
                {
                    Id             = q.WorkflowDefinition.Id,
                    Code           = q.WorkflowDefinition.Code,
                    Name           = q.WorkflowDefinition.Name,
                    WorkflowTypeId = q.WorkflowDefinition.WorkflowTypeId,
                    StartDate      = q.WorkflowDefinition.StartDate,
                    EndDate        = q.WorkflowDefinition.EndDate,
                    StatusId       = q.WorkflowDefinition.StatusId,
                    UpdatedAt      = q.WorkflowDefinition.UpdatedAt,
                } : null,
            }).ToListAsync();

            return(WorkflowParameters);
        }