Esempio n. 1
0
 public new static DocEntityUnits Get(int?primaryKey, bool noCache, DocQuery query)
 {
     if (!(primaryKey > 0))
     {
         return(null);
     }
     return(query.SelectAll <DocEntityUnits>().FirstOrDefault(e => e.Id == primaryKey.Value));
 }
Esempio n. 2
0
        private IQueryable <DocEntityHistory> _ExecSearch(HistorySearch request, DocQuery query)
        {
            request = InitSearch <History, HistorySearch>(request);
            IQueryable <DocEntityHistory> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityHistory>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new HistoryFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityHistory, HistoryFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.HISTORY, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.App) && !DocTools.IsNullOrEmpty(request.App.Id))
                {
                    entities = entities.Where(en => en.App.Id == request.App.Id);
                }
                if (true == request.AppIds?.Any())
                {
                    entities = entities.Where(en => en.App.Id.In(request.AppIds));
                }
                if (!DocTools.IsNullOrEmpty(request.DocumentSet) && !DocTools.IsNullOrEmpty(request.DocumentSet.Id))
                {
                    entities = entities.Where(en => en.DocumentSet.Id == request.DocumentSet.Id);
                }
                if (true == request.DocumentSetIds?.Any())
                {
                    entities = entities.Where(en => en.DocumentSet.Id.In(request.DocumentSetIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Impersonation) && !DocTools.IsNullOrEmpty(request.Impersonation.Id))
                {
                    entities = entities.Where(en => en.Impersonation.Id == request.Impersonation.Id);
                }
                if (true == request.ImpersonationIds?.Any())
                {
                    entities = entities.Where(en => en.Impersonation.Id.In(request.ImpersonationIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Page) && !DocTools.IsNullOrEmpty(request.Page.Id))
                {
                    entities = entities.Where(en => en.Page.Id == request.Page.Id);
                }
                if (true == request.PageIds?.Any())
                {
                    entities = entities.Where(en => en.Page.Id.In(request.PageIds));
                }
                if (!DocTools.IsNullOrEmpty(request.URL))
                {
                    entities = entities.Where(en => en.URL.Contains(request.URL));
                }
                if (!DocTools.IsNullOrEmpty(request.URLs))
                {
                    entities = entities.Where(en => en.URL.In(request.URLs));
                }
                if (!DocTools.IsNullOrEmpty(request.User) && !DocTools.IsNullOrEmpty(request.User.Id))
                {
                    entities = entities.Where(en => en.User.Id == request.User.Id);
                }
                if (true == request.UserIds?.Any())
                {
                    entities = entities.Where(en => en.User.Id.In(request.UserIds));
                }
                if (!DocTools.IsNullOrEmpty(request.UserSession) && !DocTools.IsNullOrEmpty(request.UserSession.Id))
                {
                    entities = entities.Where(en => en.UserSession.Id == request.UserSession.Id);
                }
                if (true == request.UserSessionIds?.Any())
                {
                    entities = entities.Where(en => en.UserSession.Id.In(request.UserSessionIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Workflow) && !DocTools.IsNullOrEmpty(request.Workflow.Id))
                {
                    entities = entities.Where(en => en.Workflow.Id == request.Workflow.Id);
                }
                if (true == request.WorkflowIds?.Any())
                {
                    entities = entities.Where(en => en.Workflow.Id.In(request.WorkflowIds));
                }

                entities = ApplyFilters <DocEntityHistory, HistorySearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 3
0
        private IQueryable <DocEntityTimeCard> _ExecSearch(TimeCardSearch request, DocQuery query)
        {
            request = InitSearch <TimeCard, TimeCardSearch>(request);
            IQueryable <DocEntityTimeCard> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityTimeCard>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new TimeCardFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityTimeCard, TimeCardFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.TIMECARD, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.Description))
                {
                    entities = entities.Where(en => en.Description.Contains(request.Description));
                }
                if (!DocTools.IsNullOrEmpty(request.Descriptions))
                {
                    entities = entities.Where(en => en.Description.In(request.Descriptions));
                }
                if (!DocTools.IsNullOrEmpty(request.Document) && !DocTools.IsNullOrEmpty(request.Document.Id))
                {
                    entities = entities.Where(en => en.Document.Id == request.Document.Id);
                }
                if (true == request.DocumentIds?.Any())
                {
                    entities = entities.Where(en => en.Document.Id.In(request.DocumentIds));
                }
                if (!DocTools.IsNullOrEmpty(request.End))
                {
                    entities = entities.Where(en => request.End.Value.Date == en.End.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.EndBefore))
                {
                    entities = entities.Where(en => en.End <= request.EndBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.EndAfter))
                {
                    entities = entities.Where(en => en.End >= request.EndAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Project) && !DocTools.IsNullOrEmpty(request.Project.Id))
                {
                    entities = entities.Where(en => en.Project.Id == request.Project.Id);
                }
                if (true == request.ProjectIds?.Any())
                {
                    entities = entities.Where(en => en.Project.Id.In(request.ProjectIds));
                }
                if (request.ReferenceId.HasValue)
                {
                    entities = entities.Where(en => request.ReferenceId.Value == en.ReferenceId);
                }
                if (!DocTools.IsNullOrEmpty(request.Start))
                {
                    entities = entities.Where(en => request.Start.Value.Date == en.Start.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.StartBefore))
                {
                    entities = entities.Where(en => en.Start <= request.StartBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.StartAfter))
                {
                    entities = entities.Where(en => en.Start >= request.StartAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Status) && !DocTools.IsNullOrEmpty(request.Status.Id))
                {
                    entities = entities.Where(en => en.Status.Id == request.Status.Id);
                }
                if (true == request.StatusIds?.Any())
                {
                    entities = entities.Where(en => en.Status.Id.In(request.StatusIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.Status) && !DocTools.IsNullOrEmpty(request.Status.Name))
                {
                    entities = entities.Where(en => en.Status.Name == request.Status.Name);
                }
                if (true == request.StatusNames?.Any())
                {
                    entities = entities.Where(en => en.Status.Name.In(request.StatusNames));
                }
                if (!DocTools.IsNullOrEmpty(request.User) && !DocTools.IsNullOrEmpty(request.User.Id))
                {
                    entities = entities.Where(en => en.User.Id == request.User.Id);
                }
                if (true == request.UserIds?.Any())
                {
                    entities = entities.Where(en => en.User.Id.In(request.UserIds));
                }
                if (!DocTools.IsNullOrEmpty(request.WorkType) && !DocTools.IsNullOrEmpty(request.WorkType.Id))
                {
                    entities = entities.Where(en => en.WorkType.Id == request.WorkType.Id);
                }
                if (true == request.WorkTypeIds?.Any())
                {
                    entities = entities.Where(en => en.WorkType.Id.In(request.WorkTypeIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.WorkType) && !DocTools.IsNullOrEmpty(request.WorkType.Name))
                {
                    entities = entities.Where(en => en.WorkType.Name == request.WorkType.Name);
                }
                if (true == request.WorkTypeNames?.Any())
                {
                    entities = entities.Where(en => en.WorkType.Name.In(request.WorkTypeNames));
                }

                entities = ApplyFilters <DocEntityTimeCard, TimeCardSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 4
0
        private IQueryable <DocEntityTeam> _ExecSearch(TeamSearch request, DocQuery query)
        {
            request = InitSearch <Team, TeamSearch>(request);
            IQueryable <DocEntityTeam> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityTeam>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new TeamFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityTeam, TeamFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.TEAM, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (true == request.AdminRolesIds?.Any())
                {
                    entities = entities.Where(en => en.AdminRoles.Any(r => r.Id.In(request.AdminRolesIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Description))
                {
                    entities = entities.Where(en => en.Description.Contains(request.Description));
                }
                if (!DocTools.IsNullOrEmpty(request.Descriptions))
                {
                    entities = entities.Where(en => en.Description.In(request.Descriptions));
                }
                if (!DocTools.IsNullOrEmpty(request.Email))
                {
                    entities = entities.Where(en => en.Email.Contains(request.Email));
                }
                if (!DocTools.IsNullOrEmpty(request.Emails))
                {
                    entities = entities.Where(en => en.Email.In(request.Emails));
                }
                if (true == request.IsInternal?.Any())
                {
                    entities = entities.Where(en => en.IsInternal.In(request.IsInternal));
                }
                if (!DocTools.IsNullOrEmpty(request.Name))
                {
                    entities = entities.Where(en => en.Name.Contains(request.Name));
                }
                if (!DocTools.IsNullOrEmpty(request.Names))
                {
                    entities = entities.Where(en => en.Name.In(request.Names));
                }
                if (!DocTools.IsNullOrEmpty(request.Owner) && !DocTools.IsNullOrEmpty(request.Owner.Id))
                {
                    entities = entities.Where(en => en.Owner.Id == request.Owner.Id);
                }
                if (true == request.OwnerIds?.Any())
                {
                    entities = entities.Where(en => en.Owner.Id.In(request.OwnerIds));
                }
                if (true == request.ScopesIds?.Any())
                {
                    entities = entities.Where(en => en.Scopes.Any(r => r.Id.In(request.ScopesIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Slack))
                {
                    entities = entities.Where(en => en.Slack.Contains(request.Slack));
                }
                if (!DocTools.IsNullOrEmpty(request.Slacks))
                {
                    entities = entities.Where(en => en.Slack.In(request.Slacks));
                }
                if (true == request.UpdatesIds?.Any())
                {
                    entities = entities.Where(en => en.Updates.Any(r => r.Id.In(request.UpdatesIds)));
                }
                if (true == request.UsersIds?.Any())
                {
                    entities = entities.Where(en => en.Users.Any(r => r.Id.In(request.UsersIds)));
                }

                entities = ApplyFilters <DocEntityTeam, TeamSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 5
0
        private IQueryable <DocEntityDateTime> _ExecSearch(DateTimeSearch request, DocQuery query)
        {
            request = InitSearch <DateTimeDto, DateTimeSearch>(request);
            IQueryable <DocEntityDateTime> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityDateTime>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new DateTimeFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityDateTime, DateTimeFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.DATETIME, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (request.DateDay.HasValue)
                {
                    entities = entities.Where(en => request.DateDay.Value == en.DateDay);
                }
                if (request.DateMonth.HasValue)
                {
                    entities = entities.Where(en => request.DateMonth.Value == en.DateMonth);
                }
                if (!DocTools.IsNullOrEmpty(request.DateTime))
                {
                    entities = entities.Where(en => null != en.DateTime && request.DateTime.Value.Date == en.DateTime.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.DateTimeBefore))
                {
                    entities = entities.Where(en => en.DateTime <= request.DateTimeBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.DateTimeAfter))
                {
                    entities = entities.Where(en => en.DateTime >= request.DateTimeAfter);
                }
                if (request.DateYear.HasValue)
                {
                    entities = entities.Where(en => request.DateYear.Value == en.DateYear);
                }

                entities = ApplyFilters <DocEntityDateTime, DateTimeSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 6
0
        private IQueryable <DocEntityAttribute> _ExecSearch(AttributeSearch request, DocQuery query)
        {
            request = InitSearch <Attribute, AttributeSearch>(request);
            IQueryable <DocEntityAttribute> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityAttribute>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new AttributeFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityAttribute, AttributeFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.ATTRIBUTE, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.AttributeName) && !DocTools.IsNullOrEmpty(request.AttributeName.Id))
                {
                    entities = entities.Where(en => en.AttributeName.Id == request.AttributeName.Id);
                }
                if (true == request.AttributeNameIds?.Any())
                {
                    entities = entities.Where(en => en.AttributeName.Id.In(request.AttributeNameIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.AttributeName) && !DocTools.IsNullOrEmpty(request.AttributeName.Name))
                {
                    entities = entities.Where(en => en.AttributeName.Name == request.AttributeName.Name);
                }
                if (true == request.AttributeNameNames?.Any())
                {
                    entities = entities.Where(en => en.AttributeName.Name.In(request.AttributeNameNames));
                }
                if (!DocTools.IsNullOrEmpty(request.AttributeType) && !DocTools.IsNullOrEmpty(request.AttributeType.Id))
                {
                    entities = entities.Where(en => en.AttributeType.Id == request.AttributeType.Id);
                }
                if (true == request.AttributeTypeIds?.Any())
                {
                    entities = entities.Where(en => en.AttributeType.Id.In(request.AttributeTypeIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.AttributeType) && !DocTools.IsNullOrEmpty(request.AttributeType.Name))
                {
                    entities = entities.Where(en => en.AttributeType.Name == request.AttributeType.Name);
                }
                if (true == request.AttributeTypeNames?.Any())
                {
                    entities = entities.Where(en => en.AttributeType.Name.In(request.AttributeTypeNames));
                }
                if (!DocTools.IsNullOrEmpty(request.Interval) && !DocTools.IsNullOrEmpty(request.Interval.Id))
                {
                    entities = entities.Where(en => en.Interval.Id == request.Interval.Id);
                }
                if (true == request.IntervalIds?.Any())
                {
                    entities = entities.Where(en => en.Interval.Id.In(request.IntervalIds));
                }
                if (true == request.IsCharacteristic?.Any())
                {
                    entities = entities.Where(en => en.IsCharacteristic.In(request.IsCharacteristic));
                }
                if (true == request.IsOutcome?.Any())
                {
                    entities = entities.Where(en => en.IsOutcome.In(request.IsOutcome));
                }
                if (true == request.IsPositive?.Any())
                {
                    if (request.IsPositive.Any(v => v == null))
                    {
                        entities = entities.Where(en => en.IsPositive.In(request.IsPositive) || en.IsPositive == null);
                    }
                    else
                    {
                        entities = entities.Where(en => en.IsPositive.In(request.IsPositive));
                    }
                }
                if (!DocTools.IsNullOrEmpty(request.UniqueKey))
                {
                    entities = entities.Where(en => en.UniqueKey.Contains(request.UniqueKey));
                }
                if (!DocTools.IsNullOrEmpty(request.UniqueKeys))
                {
                    entities = entities.Where(en => en.UniqueKey.In(request.UniqueKeys));
                }
                if (!DocTools.IsNullOrEmpty(request.ValueType) && !DocTools.IsNullOrEmpty(request.ValueType.Id))
                {
                    entities = entities.Where(en => en.ValueType.Id == request.ValueType.Id);
                }
                if (true == request.ValueTypeIds?.Any())
                {
                    entities = entities.Where(en => en.ValueType.Id.In(request.ValueTypeIds));
                }

                entities = ApplyFilters <DocEntityAttribute, AttributeSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
        private IQueryable <DocEntityLookupTableBinding> _ExecSearch(LookupTableBindingSearch request, DocQuery query)
        {
            request = InitSearch <LookupTableBinding, LookupTableBindingSearch>(request);
            IQueryable <DocEntityLookupTableBinding> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityLookupTableBinding>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new LookupTableBindingFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityLookupTableBinding, LookupTableBindingFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.LOOKUPTABLEBINDING, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.BoundName))
                {
                    entities = entities.Where(en => en.BoundName.Contains(request.BoundName));
                }
                if (!DocTools.IsNullOrEmpty(request.BoundNames))
                {
                    entities = entities.Where(en => en.BoundName.In(request.BoundNames));
                }
                if (!DocTools.IsNullOrEmpty(request.LookupTable) && !DocTools.IsNullOrEmpty(request.LookupTable.Id))
                {
                    entities = entities.Where(en => en.LookupTable.Id == request.LookupTable.Id);
                }
                if (true == request.LookupTableIds?.Any())
                {
                    entities = entities.Where(en => en.LookupTable.Id.In(request.LookupTableIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.LookupTable) && !DocTools.IsNullOrEmpty(request.LookupTable.Name))
                {
                    entities = entities.Where(en => en.LookupTable.Name == request.LookupTable.Name);
                }
                if (true == request.LookupTableNames?.Any())
                {
                    entities = entities.Where(en => en.LookupTable.Name.In(request.LookupTableNames));
                }
                if (!DocTools.IsNullOrEmpty(request.Scope) && !DocTools.IsNullOrEmpty(request.Scope.Id))
                {
                    entities = entities.Where(en => en.Scope.Id == request.Scope.Id);
                }
                if (true == request.ScopeIds?.Any())
                {
                    entities = entities.Where(en => en.Scope.Id.In(request.ScopeIds));
                }
                if (true == request.SynonymsIds?.Any())
                {
                    entities = entities.Where(en => en.Synonyms.Any(r => r.Id.In(request.SynonymsIds)));
                }
                if (true == request.WorkflowsIds?.Any())
                {
                    entities = entities.Where(en => en.Workflows.Any(r => r.Id.In(request.WorkflowsIds)));
                }

                entities = ApplyFilters <DocEntityLookupTableBinding, LookupTableBindingSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
        private IQueryable <DocEntityDiseaseStateSet> _ExecSearch(DiseaseStateSetSearch request, DocQuery query)
        {
            request = InitSearch <DiseaseStateSet, DiseaseStateSetSearch>(request);
            IQueryable <DocEntityDiseaseStateSet> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityDiseaseStateSet>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new DiseaseStateSetFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityDiseaseStateSet, DiseaseStateSetFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.DISEASESTATESET, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (true == request.ClientsIds?.Any())
                {
                    entities = entities.Where(en => en.Clients.Any(r => r.Id.In(request.ClientsIds)));
                }
                if (true == request.Confidential?.Any())
                {
                    entities = entities.Where(en => en.Confidential.In(request.Confidential));
                }
                if (true == request.DivisionsIds?.Any())
                {
                    entities = entities.Where(en => en.Divisions.Any(r => r.Id.In(request.DivisionsIds)));
                }
                if (true == request.DocumentsIds?.Any())
                {
                    entities = entities.Where(en => en.Documents.Any(r => r.Id.In(request.DocumentsIds)));
                }
                if (true == request.DocumentSetsIds?.Any())
                {
                    entities = entities.Where(en => en.DocumentSets.Any(r => r.Id.In(request.DocumentSetsIds)));
                }
                if (true == request.HistoriesIds?.Any())
                {
                    entities = entities.Where(en => en.Histories.Any(r => r.Id.In(request.HistoriesIds)));
                }
                if (request.LegacyDocumentSetId.HasValue)
                {
                    entities = entities.Where(en => request.LegacyDocumentSetId.Value == en.LegacyDocumentSetId);
                }
                if (!DocTools.IsNullOrEmpty(request.Name))
                {
                    entities = entities.Where(en => en.Name.Contains(request.Name));
                }
                if (!DocTools.IsNullOrEmpty(request.Names))
                {
                    entities = entities.Where(en => en.Name.In(request.Names));
                }
                if (!DocTools.IsNullOrEmpty(request.Owner) && !DocTools.IsNullOrEmpty(request.Owner.Id))
                {
                    entities = entities.Where(en => en.Owner.Id == request.Owner.Id);
                }
                if (true == request.OwnerIds?.Any())
                {
                    entities = entities.Where(en => en.Owner.Id.In(request.OwnerIds));
                }
                if (!DocTools.IsNullOrEmpty(request.ProjectTeam) && !DocTools.IsNullOrEmpty(request.ProjectTeam.Id))
                {
                    entities = entities.Where(en => en.ProjectTeam.Id == request.ProjectTeam.Id);
                }
                if (true == request.ProjectTeamIds?.Any())
                {
                    entities = entities.Where(en => en.ProjectTeam.Id.In(request.ProjectTeamIds));
                }
                if (true == request.ScopesIds?.Any())
                {
                    entities = entities.Where(en => en.Scopes.Any(r => r.Id.In(request.ScopesIds)));
                }
                if (true == request.StatsIds?.Any())
                {
                    entities = entities.Where(en => en.Stats.Any(r => r.Id.In(request.StatsIds)));
                }
                if (request.Type.HasValue)
                {
                    entities = entities.Where(en => request.Type.Value == en.Type);
                }
                if (!DocTools.IsNullOrEmpty(request.Types))
                {
                    entities = entities.Where(en => en.Type.In(request.Types));
                }
                if (true == request.UsersIds?.Any())
                {
                    entities = entities.Where(en => en.Users.Any(r => r.Id.In(request.UsersIds)));
                }
                if (true == request.ClientsIds?.Any())
                {
                    entities = entities.Where(en => en.Clients.Any(r => r.Id.In(request.ClientsIds)));
                }
                if (true == request.Confidential?.Any())
                {
                    entities = entities.Where(en => en.Confidential.In(request.Confidential));
                }
                if (true == request.DivisionsIds?.Any())
                {
                    entities = entities.Where(en => en.Divisions.Any(r => r.Id.In(request.DivisionsIds)));
                }
                if (true == request.DocumentsIds?.Any())
                {
                    entities = entities.Where(en => en.Documents.Any(r => r.Id.In(request.DocumentsIds)));
                }
                if (true == request.DocumentSetsIds?.Any())
                {
                    entities = entities.Where(en => en.DocumentSets.Any(r => r.Id.In(request.DocumentSetsIds)));
                }
                if (true == request.HistoriesIds?.Any())
                {
                    entities = entities.Where(en => en.Histories.Any(r => r.Id.In(request.HistoriesIds)));
                }
                if (request.LegacyDocumentSetId.HasValue)
                {
                    entities = entities.Where(en => request.LegacyDocumentSetId.Value == en.LegacyDocumentSetId);
                }
                if (!DocTools.IsNullOrEmpty(request.Name))
                {
                    entities = entities.Where(en => en.Name.Contains(request.Name));
                }
                if (!DocTools.IsNullOrEmpty(request.Names))
                {
                    entities = entities.Where(en => en.Name.In(request.Names));
                }
                if (!DocTools.IsNullOrEmpty(request.Owner) && !DocTools.IsNullOrEmpty(request.Owner.Id))
                {
                    entities = entities.Where(en => en.Owner.Id == request.Owner.Id);
                }
                if (true == request.OwnerIds?.Any())
                {
                    entities = entities.Where(en => en.Owner.Id.In(request.OwnerIds));
                }
                if (!DocTools.IsNullOrEmpty(request.ProjectTeam) && !DocTools.IsNullOrEmpty(request.ProjectTeam.Id))
                {
                    entities = entities.Where(en => en.ProjectTeam.Id == request.ProjectTeam.Id);
                }
                if (true == request.ProjectTeamIds?.Any())
                {
                    entities = entities.Where(en => en.ProjectTeam.Id.In(request.ProjectTeamIds));
                }
                if (true == request.ScopesIds?.Any())
                {
                    entities = entities.Where(en => en.Scopes.Any(r => r.Id.In(request.ScopesIds)));
                }
                if (true == request.StatsIds?.Any())
                {
                    entities = entities.Where(en => en.Stats.Any(r => r.Id.In(request.StatsIds)));
                }
                if (request.Type.HasValue)
                {
                    entities = entities.Where(en => request.Type.Value == en.Type);
                }
                if (!DocTools.IsNullOrEmpty(request.Types))
                {
                    entities = entities.Where(en => en.Type.In(request.Types));
                }
                if (true == request.UsersIds?.Any())
                {
                    entities = entities.Where(en => en.Users.Any(r => r.Id.In(request.UsersIds)));
                }

                entities = ApplyFilters <DocEntityDiseaseStateSet, DiseaseStateSetSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 9
0
        private IQueryable <DocEntityScope> _ExecSearch(ScopeSearch request, DocQuery query)
        {
            request = InitSearch <Scope, ScopeSearch>(request);
            IQueryable <DocEntityScope> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityScope>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new ScopeFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityScope, ScopeFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.SCOPE, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.App) && !DocTools.IsNullOrEmpty(request.App.Id))
                {
                    entities = entities.Where(en => en.App.Id == request.App.Id);
                }
                if (true == request.AppIds?.Any())
                {
                    entities = entities.Where(en => en.App.Id.In(request.AppIds));
                }
                if (true == request.BindingsIds?.Any())
                {
                    entities = entities.Where(en => en.Bindings.Any(r => r.Id.In(request.BindingsIds)));
                }
                if (true == request.BroadcastsIds?.Any())
                {
                    entities = entities.Where(en => en.Broadcasts.Any(r => r.Id.In(request.BroadcastsIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Client) && !DocTools.IsNullOrEmpty(request.Client.Id))
                {
                    entities = entities.Where(en => en.Client.Id == request.Client.Id);
                }
                if (true == request.ClientIds?.Any())
                {
                    entities = entities.Where(en => en.Client.Id.In(request.ClientIds));
                }
                if (true == request.Delete?.Any())
                {
                    entities = entities.Where(en => en.Delete.In(request.Delete));
                }
                if (!DocTools.IsNullOrEmpty(request.DocumentSet) && !DocTools.IsNullOrEmpty(request.DocumentSet.Id))
                {
                    entities = entities.Where(en => en.DocumentSet.Id == request.DocumentSet.Id);
                }
                if (true == request.DocumentSetIds?.Any())
                {
                    entities = entities.Where(en => en.DocumentSet.Id.In(request.DocumentSetIds));
                }
                if (true == request.Edit?.Any())
                {
                    entities = entities.Where(en => en.Edit.In(request.Edit));
                }
                if (true == request.HelpIds?.Any())
                {
                    entities = entities.Where(en => en.Help.Any(r => r.Id.In(request.HelpIds)));
                }
                if (true == request.IsGlobal?.Any())
                {
                    entities = entities.Where(en => en.IsGlobal.In(request.IsGlobal));
                }
                if (true == request.ScopedCommentsIds?.Any())
                {
                    entities = entities.Where(en => en.ScopedComments.Any(r => r.Id.In(request.ScopedCommentsIds)));
                }
                if (true == request.ScopedFilesIds?.Any())
                {
                    entities = entities.Where(en => en.ScopedFiles.Any(r => r.Id.In(request.ScopedFilesIds)));
                }
                if (true == request.ScopedTagsIds?.Any())
                {
                    entities = entities.Where(en => en.ScopedTags.Any(r => r.Id.In(request.ScopedTagsIds)));
                }
                if (true == request.SynonymsIds?.Any())
                {
                    entities = entities.Where(en => en.Synonyms.Any(r => r.Id.In(request.SynonymsIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Team) && !DocTools.IsNullOrEmpty(request.Team.Id))
                {
                    entities = entities.Where(en => en.Team.Id == request.Team.Id);
                }
                if (true == request.TeamIds?.Any())
                {
                    entities = entities.Where(en => en.Team.Id.In(request.TeamIds));
                }
                if (request.Type.HasValue)
                {
                    entities = entities.Where(en => request.Type.Value == en.Type);
                }
                if (!DocTools.IsNullOrEmpty(request.Types))
                {
                    entities = entities.Where(en => en.Type.In(request.Types));
                }
                if (!DocTools.IsNullOrEmpty(request.User) && !DocTools.IsNullOrEmpty(request.User.Id))
                {
                    entities = entities.Where(en => en.User.Id == request.User.Id);
                }
                if (true == request.UserIds?.Any())
                {
                    entities = entities.Where(en => en.User.Id.In(request.UserIds));
                }
                if (true == request.VariableRulesIds?.Any())
                {
                    entities = entities.Where(en => en.VariableRules.Any(r => r.Id.In(request.VariableRulesIds)));
                }
                if (true == request.View?.Any())
                {
                    entities = entities.Where(en => en.View.In(request.View));
                }
                if (true == request.WorkflowsIds?.Any())
                {
                    entities = entities.Where(en => en.Workflows.Any(r => r.Id.In(request.WorkflowsIds)));
                }

                entities = ApplyFilters <DocEntityScope, ScopeSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 10
0
        private IQueryable <DocEntityQueueChannel> _ExecSearch(QueueChannelSearch request, DocQuery query)
        {
            request = InitSearch <QueueChannel, QueueChannelSearch>(request);
            IQueryable <DocEntityQueueChannel> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityQueueChannel>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new QueueChannelFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityQueueChannel, QueueChannelFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.QUEUECHANNEL, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (true == request.AutoDelete?.Any())
                {
                    entities = entities.Where(en => en.AutoDelete.In(request.AutoDelete));
                }
                if (!DocTools.IsNullOrEmpty(request.BackgroundTask) && !DocTools.IsNullOrEmpty(request.BackgroundTask.Id))
                {
                    entities = entities.Where(en => en.BackgroundTask.Id == request.BackgroundTask.Id);
                }
                if (true == request.BackgroundTaskIds?.Any())
                {
                    entities = entities.Where(en => en.BackgroundTask.Id.In(request.BackgroundTaskIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Description))
                {
                    entities = entities.Where(en => en.Description.Contains(request.Description));
                }
                if (!DocTools.IsNullOrEmpty(request.Descriptions))
                {
                    entities = entities.Where(en => en.Description.In(request.Descriptions));
                }
                if (true == request.Durable?.Any())
                {
                    entities = entities.Where(en => en.Durable.In(request.Durable));
                }
                if (true == request.Enabled?.Any())
                {
                    entities = entities.Where(en => en.Enabled.In(request.Enabled));
                }
                if (true == request.Exclusive?.Any())
                {
                    entities = entities.Where(en => en.Exclusive.In(request.Exclusive));
                }
                if (!DocTools.IsNullOrEmpty(request.Name))
                {
                    entities = entities.Where(en => en.Name.Contains(request.Name));
                }
                if (!DocTools.IsNullOrEmpty(request.Names))
                {
                    entities = entities.Where(en => en.Name.In(request.Names));
                }

                entities = ApplyFilters <DocEntityQueueChannel, QueueChannelSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 11
0
        private IQueryable <DocEntityStatsStudySet> _ExecSearch(StatsStudySetSearch request, DocQuery query)
        {
            request = InitSearch <StatsStudySet, StatsStudySetSearch>(request);
            IQueryable <DocEntityStatsStudySet> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityStatsStudySet>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new StatsStudySetFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityStatsStudySet, StatsStudySetFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.STATSSTUDYSET, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (request.BoundTerms.HasValue)
                {
                    entities = entities.Where(en => request.BoundTerms.Value == en.BoundTerms);
                }
                if (request.Characteristics.HasValue)
                {
                    entities = entities.Where(en => request.Characteristics.Value == en.Characteristics);
                }
                if (request.DataPoints.HasValue)
                {
                    entities = entities.Where(en => request.DataPoints.Value == en.DataPoints);
                }
                if (request.DesignCount.HasValue)
                {
                    entities = entities.Where(en => request.DesignCount.Value == en.DesignCount);
                }
                if (!DocTools.IsNullOrEmpty(request.DesignList))
                {
                    entities = entities.Where(en => en.DesignList.Contains(request.DesignList));
                }
                if (!DocTools.IsNullOrEmpty(request.DesignLists))
                {
                    entities = entities.Where(en => en.DesignList.In(request.DesignLists));
                }
                if (!DocTools.IsNullOrEmpty(request.DocumentSet) && !DocTools.IsNullOrEmpty(request.DocumentSet.Id))
                {
                    entities = entities.Where(en => en.DocumentSet.Id == request.DocumentSet.Id);
                }
                if (true == request.DocumentSetIds?.Any())
                {
                    entities = entities.Where(en => en.DocumentSet.Id.In(request.DocumentSetIds));
                }
                if (request.Interventions.HasValue)
                {
                    entities = entities.Where(en => request.Interventions.Value == en.Interventions);
                }
                if (request.Outcomes.HasValue)
                {
                    entities = entities.Where(en => request.Outcomes.Value == en.Outcomes);
                }
                if (request.OutcomesReported.HasValue)
                {
                    entities = entities.Where(en => request.OutcomesReported.Value == en.OutcomesReported);
                }
                if (true == request.RecordsIds?.Any())
                {
                    entities = entities.Where(en => en.Records.Any(r => r.Id.In(request.RecordsIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Stat) && !DocTools.IsNullOrEmpty(request.Stat.Id))
                {
                    entities = entities.Where(en => en.Stat.Id == request.Stat.Id);
                }
                if (true == request.StatIds?.Any())
                {
                    entities = entities.Where(en => en.Stat.Id.In(request.StatIds));
                }
                if (request.Studies.HasValue)
                {
                    entities = entities.Where(en => request.Studies.Value == en.Studies);
                }
                if (request.TypeCount.HasValue)
                {
                    entities = entities.Where(en => request.TypeCount.Value == en.TypeCount);
                }
                if (!DocTools.IsNullOrEmpty(request.TypeList))
                {
                    entities = entities.Where(en => en.TypeList.Contains(request.TypeList));
                }
                if (!DocTools.IsNullOrEmpty(request.TypeLists))
                {
                    entities = entities.Where(en => en.TypeList.In(request.TypeLists));
                }
                if (request.UnboundTerms.HasValue)
                {
                    entities = entities.Where(en => request.UnboundTerms.Value == en.UnboundTerms);
                }

                entities = ApplyFilters <DocEntityStatsStudySet, StatsStudySetSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 12
0
        private IQueryable <DocEntityWorkflowComment> _ExecSearch(WorkflowCommentSearch request, DocQuery query)
        {
            request = InitSearch <WorkflowComment, WorkflowCommentSearch>(request);
            IQueryable <DocEntityWorkflowComment> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityWorkflowComment>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new WorkflowCommentFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityWorkflowComment, WorkflowCommentFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.WORKFLOWCOMMENT, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }

                if (true == request.ChildrenIds?.Any())
                {
                    entities = entities.Where(en => en.Children.Any(r => r.Id.In(request.ChildrenIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Parent) && !DocTools.IsNullOrEmpty(request.Parent.Id))
                {
                    entities = entities.Where(en => en.Parent.Id == request.Parent.Id);
                }
                if (true == request.ParentIds?.Any())
                {
                    entities = entities.Where(en => en.Parent.Id.In(request.ParentIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Text))
                {
                    entities = entities.Where(en => en.Text.Contains(request.Text));
                }
                if (!DocTools.IsNullOrEmpty(request.User) && !DocTools.IsNullOrEmpty(request.User.Id))
                {
                    entities = entities.Where(en => en.User.Id == request.User.Id);
                }
                if (true == request.UserIds?.Any())
                {
                    entities = entities.Where(en => en.User.Id.In(request.UserIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Workflow) && !DocTools.IsNullOrEmpty(request.Workflow.Id))
                {
                    entities = entities.Where(en => en.Workflow.Id == request.Workflow.Id);
                }
                if (true == request.WorkflowIds?.Any())
                {
                    entities = entities.Where(en => en.Workflow.Id.In(request.WorkflowIds));
                }

                entities = ApplyFilters <DocEntityWorkflowComment, WorkflowCommentSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
        private IQueryable <DocEntityDocumentSetHistory> _ExecSearch(DocumentSetHistorySearch request, DocQuery query)
        {
            request = InitSearch <DocumentSetHistory, DocumentSetHistorySearch>(request);
            IQueryable <DocEntityDocumentSetHistory> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityDocumentSetHistory>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new DocumentSetHistoryFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityDocumentSetHistory, DocumentSetHistoryFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.DOCUMENTSETHISTORY, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.DocumentSet) && !DocTools.IsNullOrEmpty(request.DocumentSet.Id))
                {
                    entities = entities.Where(en => en.DocumentSet.Id == request.DocumentSet.Id);
                }
                if (true == request.DocumentSetIds?.Any())
                {
                    entities = entities.Where(en => en.DocumentSet.Id.In(request.DocumentSetIds));
                }
                if (request.EvidencePortalID.HasValue)
                {
                    entities = entities.Where(en => request.EvidencePortalID.Value == en.EvidencePortalID);
                }
                if (request.FqId.HasValue)
                {
                    entities = entities.Where(en => request.FqId.Value == en.FqId);
                }
                if (request.StudyCount.HasValue)
                {
                    entities = entities.Where(en => request.StudyCount.Value == en.StudyCount);
                }
                if (request.StudyCountFQ.HasValue)
                {
                    entities = entities.Where(en => request.StudyCountFQ.Value == en.StudyCountFQ);
                }

                entities = ApplyFilters <DocEntityDocumentSetHistory, DocumentSetHistorySearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 14
0
        private IQueryable <DocEntityUnitConversionRules> _ExecSearch(UnitConversionRulesSearch request, DocQuery query)
        {
            request = InitSearch <UnitConversionRules, UnitConversionRulesSearch>(request);
            IQueryable <DocEntityUnitConversionRules> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityUnitConversionRules>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new UnitConversionRulesFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityUnitConversionRules, UnitConversionRulesFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.UNITCONVERSIONRULES, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.DestinationUnit) && !DocTools.IsNullOrEmpty(request.DestinationUnit.Id))
                {
                    entities = entities.Where(en => en.DestinationUnit.Id == request.DestinationUnit.Id);
                }
                if (true == request.DestinationUnitIds?.Any())
                {
                    entities = entities.Where(en => en.DestinationUnit.Id.In(request.DestinationUnitIds));
                }
                if (true == request.IsDefault?.Any())
                {
                    entities = entities.Where(en => en.IsDefault.In(request.IsDefault));
                }
                if (true == request.IsDestinationSi?.Any())
                {
                    entities = entities.Where(en => en.IsDestinationSi.In(request.IsDestinationSi));
                }
                if (!DocTools.IsNullOrEmpty(request.ModifierTerm) && !DocTools.IsNullOrEmpty(request.ModifierTerm.Id))
                {
                    entities = entities.Where(en => en.ModifierTerm.Id == request.ModifierTerm.Id);
                }
                if (true == request.ModifierTermIds?.Any())
                {
                    entities = entities.Where(en => en.ModifierTerm.Id.In(request.ModifierTermIds));
                }
                if (request.Multiplier.HasValue)
                {
                    entities = entities.Where(en => request.Multiplier.Value == en.Multiplier);
                }
                if (!DocTools.IsNullOrEmpty(request.Parent) && !DocTools.IsNullOrEmpty(request.Parent.Id))
                {
                    entities = entities.Where(en => en.Parent.Id == request.Parent.Id);
                }
                if (true == request.ParentIds?.Any())
                {
                    entities = entities.Where(en => en.Parent.Id.In(request.ParentIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.Parent) && !DocTools.IsNullOrEmpty(request.Parent.Name))
                {
                    entities = entities.Where(en => en.Parent.Name == request.Parent.Name);
                }
                if (true == request.ParentNames?.Any())
                {
                    entities = entities.Where(en => en.Parent.Name.In(request.ParentNames));
                }
                if (!DocTools.IsNullOrEmpty(request.RootTerm) && !DocTools.IsNullOrEmpty(request.RootTerm.Id))
                {
                    entities = entities.Where(en => en.RootTerm.Id == request.RootTerm.Id);
                }
                if (true == request.RootTermIds?.Any())
                {
                    entities = entities.Where(en => en.RootTerm.Id.In(request.RootTermIds));
                }
                if (!DocTools.IsNullOrEmpty(request.SourceUnit) && !DocTools.IsNullOrEmpty(request.SourceUnit.Id))
                {
                    entities = entities.Where(en => en.SourceUnit.Id == request.SourceUnit.Id);
                }
                if (true == request.SourceUnitIds?.Any())
                {
                    entities = entities.Where(en => en.SourceUnit.Id.In(request.SourceUnitIds));
                }

                entities = ApplyFilters <DocEntityUnitConversionRules, UnitConversionRulesSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 15
0
        private IQueryable <DocEntityStats> _ExecSearch(StatsSearch request, DocQuery query)
        {
            request = InitSearch <Stats, StatsSearch>(request);
            IQueryable <DocEntityStats> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityStats>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new StatsFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityStats, StatsFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.STATS, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.App) && !DocTools.IsNullOrEmpty(request.App.Id))
                {
                    entities = entities.Where(en => en.App.Id == request.App.Id);
                }
                if (true == request.AppIds?.Any())
                {
                    entities = entities.Where(en => en.App.Id.In(request.AppIds));
                }
                if (request.ExternalId.HasValue)
                {
                    entities = entities.Where(en => request.ExternalId.Value == en.ExternalId);
                }
                if (!DocTools.IsNullOrEmpty(request.ExternalType))
                {
                    entities = entities.Where(en => en.ExternalType.Contains(request.ExternalType));
                }
                if (!DocTools.IsNullOrEmpty(request.ExternalTypes))
                {
                    entities = entities.Where(en => en.ExternalType.In(request.ExternalTypes));
                }
                if (request.ObjectId.HasValue)
                {
                    entities = entities.Where(en => request.ObjectId.Value == en.ObjectId);
                }
                if (!DocTools.IsNullOrEmpty(request.ObjectType))
                {
                    entities = entities.Where(en => en.ObjectType.Contains(request.ObjectType));
                }
                if (!DocTools.IsNullOrEmpty(request.ObjectTypes))
                {
                    entities = entities.Where(en => en.ObjectType.In(request.ObjectTypes));
                }
                if (!DocTools.IsNullOrEmpty(request.StudySetStats) && !DocTools.IsNullOrEmpty(request.StudySetStats.Id))
                {
                    entities = entities.Where(en => en.StudySetStats.Id == request.StudySetStats.Id);
                }
                if (true == request.StudySetStatsIds?.Any())
                {
                    entities = entities.Where(en => en.StudySetStats.Id.In(request.StudySetStatsIds));
                }

                entities = ApplyFilters <DocEntityStats, StatsSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 16
0
        private IQueryable <DocEntityWorkflow> _ExecSearch(WorkflowSearch request, DocQuery query)
        {
            request = InitSearch <Workflow, WorkflowSearch>(request);
            IQueryable <DocEntityWorkflow> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityWorkflow>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new WorkflowFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityWorkflow, WorkflowFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.WORKFLOW, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (true == request.BindingsIds?.Any())
                {
                    entities = entities.Where(en => en.Bindings.Any(r => r.Id.In(request.BindingsIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Description))
                {
                    entities = entities.Where(en => en.Description.Contains(request.Description));
                }
                if (!DocTools.IsNullOrEmpty(request.Descriptions))
                {
                    entities = entities.Where(en => en.Description.In(request.Descriptions));
                }
                if (true == request.DocumentsIds?.Any())
                {
                    entities = entities.Where(en => en.Documents.Any(r => r.Id.In(request.DocumentsIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.DocumentSet) && !DocTools.IsNullOrEmpty(request.DocumentSet.Id))
                {
                    entities = entities.Where(en => en.DocumentSet.Id == request.DocumentSet.Id);
                }
                if (true == request.DocumentSetIds?.Any())
                {
                    entities = entities.Where(en => en.DocumentSet.Id.In(request.DocumentSetIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Name))
                {
                    entities = entities.Where(en => en.Name.Contains(request.Name));
                }
                if (!DocTools.IsNullOrEmpty(request.Names))
                {
                    entities = entities.Where(en => en.Name.In(request.Names));
                }
                if (!DocTools.IsNullOrEmpty(request.Owner) && !DocTools.IsNullOrEmpty(request.Owner.Id))
                {
                    entities = entities.Where(en => en.Owner.Id == request.Owner.Id);
                }
                if (true == request.OwnerIds?.Any())
                {
                    entities = entities.Where(en => en.Owner.Id.In(request.OwnerIds));
                }
                if (true == request.ScopesIds?.Any())
                {
                    entities = entities.Where(en => en.Scopes.Any(r => r.Id.In(request.ScopesIds)));
                }
                if (request.Status.HasValue)
                {
                    entities = entities.Where(en => request.Status.Value == en.Status);
                }
                if (!DocTools.IsNullOrEmpty(request.Statuss))
                {
                    entities = entities.Where(en => en.Status.In(request.Statuss));
                }
                if (true == request.TasksIds?.Any())
                {
                    entities = entities.Where(en => en.Tasks.Any(r => r.Id.In(request.TasksIds)));
                }
                if (request.Type.HasValue)
                {
                    entities = entities.Where(en => request.Type.Value == en.Type);
                }
                if (!DocTools.IsNullOrEmpty(request.Types))
                {
                    entities = entities.Where(en => en.Type.In(request.Types));
                }
                if (!DocTools.IsNullOrEmpty(request.User) && !DocTools.IsNullOrEmpty(request.User.Id))
                {
                    entities = entities.Where(en => en.User.Id == request.User.Id);
                }
                if (true == request.UserIds?.Any())
                {
                    entities = entities.Where(en => en.User.Id.In(request.UserIds));
                }
                if (true == request.VariablesIds?.Any())
                {
                    entities = entities.Where(en => en.Variables.Any(r => r.Id.In(request.VariablesIds)));
                }
                if (true == request.WorkflowsIds?.Any())
                {
                    entities = entities.Where(en => en.Workflows.Any(r => r.Id.In(request.WorkflowsIds)));
                }

                entities = ApplyFilters <DocEntityWorkflow, WorkflowSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 17
0
        private IQueryable <DocEntityAuditRecord> _ExecSearch(AuditRecordSearch request, DocQuery query)
        {
            request = InitSearch <AuditRecord, AuditRecordSearch>(request);
            IQueryable <DocEntityAuditRecord> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityAuditRecord>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new AuditRecordFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityAuditRecord, AuditRecordFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.AUDITRECORD, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.Action))
                {
                    entities = entities.Where(en => en.Action.Contains(request.Action));
                }
                if (!DocTools.IsNullOrEmpty(request.Actions))
                {
                    entities = entities.Where(en => en.Action.In(request.Actions));
                }
                if (!DocTools.IsNullOrEmpty(request.BackgroundTask) && !DocTools.IsNullOrEmpty(request.BackgroundTask.Id))
                {
                    entities = entities.Where(en => en.BackgroundTask.Id == request.BackgroundTask.Id);
                }
                if (true == request.BackgroundTaskIds?.Any())
                {
                    entities = entities.Where(en => en.BackgroundTask.Id.In(request.BackgroundTaskIds));
                }
                if (!DocTools.IsNullOrEmpty(request.ChangedOnDate))
                {
                    entities = entities.Where(en => request.ChangedOnDate.Value.Date == en.ChangedOnDate.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.ChangedOnDateBefore))
                {
                    entities = entities.Where(en => en.ChangedOnDate <= request.ChangedOnDateBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.ChangedOnDateAfter))
                {
                    entities = entities.Where(en => en.ChangedOnDate >= request.ChangedOnDateAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.DatabaseSessionId))
                {
                    entities = entities.Where(en => en.DatabaseSessionId.Contains(request.DatabaseSessionId));
                }
                if (!DocTools.IsNullOrEmpty(request.DatabaseSessionIds))
                {
                    entities = entities.Where(en => en.DatabaseSessionId.In(request.DatabaseSessionIds));
                }
                if (true == request.DeltasIds?.Any())
                {
                    entities = entities.Where(en => en.Deltas.Any(r => r.Id.In(request.DeltasIds)));
                }
                if (request.EntityId.HasValue)
                {
                    entities = entities.Where(en => request.EntityId.Value == en.EntityId);
                }
                if (!DocTools.IsNullOrEmpty(request.EntityType))
                {
                    entities = entities.Where(en => en.EntityType.Contains(request.EntityType));
                }
                if (!DocTools.IsNullOrEmpty(request.EntityTypes))
                {
                    entities = entities.Where(en => en.EntityType.In(request.EntityTypes));
                }
                if (request.EntityVersion.HasValue)
                {
                    entities = entities.Where(en => request.EntityVersion.Value == en.EntityVersion);
                }
                if (true == request.EventsIds?.Any())
                {
                    entities = entities.Where(en => en.Events.Any(r => r.Id.In(request.EventsIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Impersonation) && !DocTools.IsNullOrEmpty(request.Impersonation.Id))
                {
                    entities = entities.Where(en => en.Impersonation.Id == request.Impersonation.Id);
                }
                if (true == request.ImpersonationIds?.Any())
                {
                    entities = entities.Where(en => en.Impersonation.Id.In(request.ImpersonationIds));
                }
                if (request.TargetId.HasValue)
                {
                    entities = entities.Where(en => request.TargetId.Value == en.TargetId);
                }
                if (!DocTools.IsNullOrEmpty(request.TargetType))
                {
                    entities = entities.Where(en => en.TargetType.Contains(request.TargetType));
                }
                if (!DocTools.IsNullOrEmpty(request.TargetTypes))
                {
                    entities = entities.Where(en => en.TargetType.In(request.TargetTypes));
                }
                if (request.TargetVersion.HasValue)
                {
                    entities = entities.Where(en => request.TargetVersion.Value == en.TargetVersion);
                }
                if (!DocTools.IsNullOrEmpty(request.User) && !DocTools.IsNullOrEmpty(request.User.Id))
                {
                    entities = entities.Where(en => en.User.Id == request.User.Id);
                }
                if (true == request.UserIds?.Any())
                {
                    entities = entities.Where(en => en.User.Id.In(request.UserIds));
                }
                if (!DocTools.IsNullOrEmpty(request.UserSession) && !DocTools.IsNullOrEmpty(request.UserSession.Id))
                {
                    entities = entities.Where(en => en.UserSession.Id == request.UserSession.Id);
                }
                if (true == request.UserSessionIds?.Any())
                {
                    entities = entities.Where(en => en.UserSession.Id.In(request.UserSessionIds));
                }

                entities = ApplyFilters <DocEntityAuditRecord, AuditRecordSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 18
0
        private IQueryable <DocEntityJunction> _ExecSearch(JunctionSearch request, DocQuery query)
        {
            request = InitSearch <Junction, JunctionSearch>(request);
            IQueryable <DocEntityJunction> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityJunction>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new JunctionFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityJunction, JunctionFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.JUNCTION, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (true == request.ChildrenIds?.Any())
                {
                    entities = entities.Where(en => en.Children.Any(r => r.Id.In(request.ChildrenIds)));
                }
                if (request.OwnerId.HasValue)
                {
                    entities = entities.Where(en => request.OwnerId.Value == en.OwnerId);
                }
                if (!DocTools.IsNullOrEmpty(request.OwnerType))
                {
                    entities = entities.Where(en => en.OwnerType.Contains(request.OwnerType));
                }
                if (!DocTools.IsNullOrEmpty(request.OwnerTypes))
                {
                    entities = entities.Where(en => en.OwnerType.In(request.OwnerTypes));
                }
                if (!DocTools.IsNullOrEmpty(request.Parent) && !DocTools.IsNullOrEmpty(request.Parent.Id))
                {
                    entities = entities.Where(en => en.Parent.Id == request.Parent.Id);
                }
                if (true == request.ParentIds?.Any())
                {
                    entities = entities.Where(en => en.Parent.Id.In(request.ParentIds));
                }
                if (request.TargetId.HasValue)
                {
                    entities = entities.Where(en => request.TargetId.Value == en.TargetId);
                }
                if (!DocTools.IsNullOrEmpty(request.TargetType))
                {
                    entities = entities.Where(en => en.TargetType.Contains(request.TargetType));
                }
                if (!DocTools.IsNullOrEmpty(request.TargetTypes))
                {
                    entities = entities.Where(en => en.TargetType.In(request.TargetTypes));
                }
                if (!DocTools.IsNullOrEmpty(request.Type) && !DocTools.IsNullOrEmpty(request.Type.Id))
                {
                    entities = entities.Where(en => en.Type.Id == request.Type.Id);
                }
                if (true == request.TypeIds?.Any())
                {
                    entities = entities.Where(en => en.Type.Id.In(request.TypeIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.Type) && !DocTools.IsNullOrEmpty(request.Type.Name))
                {
                    entities = entities.Where(en => en.Type.Name == request.Type.Name);
                }
                if (true == request.TypeNames?.Any())
                {
                    entities = entities.Where(en => en.Type.Name.In(request.TypeNames));
                }
                if (!DocTools.IsNullOrEmpty(request.User) && !DocTools.IsNullOrEmpty(request.User.Id))
                {
                    entities = entities.Where(en => en.User.Id == request.User.Id);
                }
                if (true == request.UserIds?.Any())
                {
                    entities = entities.Where(en => en.User.Id.In(request.UserIds));
                }

                entities = ApplyFilters <DocEntityJunction, JunctionSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 19
0
        private IQueryable <DocEntityEvent> _ExecSearch(EventSearch request, DocQuery query)
        {
            request = InitSearch <Event, EventSearch>(request);
            IQueryable <DocEntityEvent> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityEvent>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new EventFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityEvent, EventFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.EVENT, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.AuditRecord) && !DocTools.IsNullOrEmpty(request.AuditRecord.Id))
                {
                    entities = entities.Where(en => en.AuditRecord.Id == request.AuditRecord.Id);
                }
                if (true == request.AuditRecordIds?.Any())
                {
                    entities = entities.Where(en => en.AuditRecord.Id.In(request.AuditRecordIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Description))
                {
                    entities = entities.Where(en => en.Description.Contains(request.Description));
                }
                if (!DocTools.IsNullOrEmpty(request.Descriptions))
                {
                    entities = entities.Where(en => en.Description.In(request.Descriptions));
                }
                if (!DocTools.IsNullOrEmpty(request.Processed))
                {
                    entities = entities.Where(en => null != en.Processed && request.Processed.Value.Date == en.Processed.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.ProcessedBefore))
                {
                    entities = entities.Where(en => en.Processed <= request.ProcessedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.ProcessedAfter))
                {
                    entities = entities.Where(en => en.Processed >= request.ProcessedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Status))
                {
                    entities = entities.Where(en => en.Status.Contains(request.Status));
                }
                if (!DocTools.IsNullOrEmpty(request.Statuss))
                {
                    entities = entities.Where(en => en.Status.In(request.Statuss));
                }
                if (true == request.TeamsIds?.Any())
                {
                    entities = entities.Where(en => en.Teams.Any(r => r.Id.In(request.TeamsIds)));
                }
                if (true == request.UpdatesIds?.Any())
                {
                    entities = entities.Where(en => en.Updates.Any(r => r.Id.In(request.UpdatesIds)));
                }
                if (true == request.UsersIds?.Any())
                {
                    entities = entities.Where(en => en.Users.Any(r => r.Id.In(request.UsersIds)));
                }

                entities = ApplyFilters <DocEntityEvent, EventSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 20
0
        private IQueryable <DocEntityInterval> _ExecSearch(IntervalSearch request, DocQuery query)
        {
            request = InitSearch <Interval, IntervalSearch>(request);
            IQueryable <DocEntityInterval> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityInterval>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new IntervalFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityInterval, IntervalFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.INTERVAL, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.CalendarDateEnd) && !DocTools.IsNullOrEmpty(request.CalendarDateEnd.Id))
                {
                    entities = entities.Where(en => en.CalendarDateEnd.Id == request.CalendarDateEnd.Id);
                }
                if (true == request.CalendarDateEndIds?.Any())
                {
                    entities = entities.Where(en => en.CalendarDateEnd.Id.In(request.CalendarDateEndIds));
                }
                if (!DocTools.IsNullOrEmpty(request.CalendarDateStart) && !DocTools.IsNullOrEmpty(request.CalendarDateStart.Id))
                {
                    entities = entities.Where(en => en.CalendarDateStart.Id == request.CalendarDateStart.Id);
                }
                if (true == request.CalendarDateStartIds?.Any())
                {
                    entities = entities.Where(en => en.CalendarDateStart.Id.In(request.CalendarDateStartIds));
                }
                if (!DocTools.IsNullOrEmpty(request.CalendarType))
                {
                    entities = entities.Where(en => en.CalendarType.Contains(request.CalendarType));
                }
                if (!DocTools.IsNullOrEmpty(request.CalendarTypes))
                {
                    entities = entities.Where(en => en.CalendarType.In(request.CalendarTypes));
                }
                if (!DocTools.IsNullOrEmpty(request.FollowUp) && !DocTools.IsNullOrEmpty(request.FollowUp.Id))
                {
                    entities = entities.Where(en => en.FollowUp.Id == request.FollowUp.Id);
                }
                if (true == request.FollowUpIds?.Any())
                {
                    entities = entities.Where(en => en.FollowUp.Id.In(request.FollowUpIds));
                }
                if (!DocTools.IsNullOrEmpty(request.TimeOfDay) && !DocTools.IsNullOrEmpty(request.TimeOfDay.Id))
                {
                    entities = entities.Where(en => en.TimeOfDay.Id == request.TimeOfDay.Id);
                }
                if (true == request.TimeOfDayIds?.Any())
                {
                    entities = entities.Where(en => en.TimeOfDay.Id.In(request.TimeOfDayIds));
                }

                entities = ApplyFilters <DocEntityInterval, IntervalSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 21
0
        private IQueryable <DocEntityGlossary> _ExecSearch(GlossarySearch request, DocQuery query)
        {
            request = InitSearch <Glossary, GlossarySearch>(request);
            IQueryable <DocEntityGlossary> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityGlossary>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new GlossaryFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityGlossary, GlossaryFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.GLOSSARY, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.Definition))
                {
                    entities = entities.Where(en => en.Definition.Contains(request.Definition));
                }
                if (!DocTools.IsNullOrEmpty(request.Definitions))
                {
                    entities = entities.Where(en => en.Definition.In(request.Definitions));
                }
                if (!DocTools.IsNullOrEmpty(request.Enum) && !DocTools.IsNullOrEmpty(request.Enum.Id))
                {
                    entities = entities.Where(en => en.Enum.Id == request.Enum.Id);
                }
                if (true == request.EnumIds?.Any())
                {
                    entities = entities.Where(en => en.Enum.Id.In(request.EnumIds));
                }
                if (true == request.EnumNames?.Any())
                {
                    entities = entities.Where(en => en.Enum.Name.In(request.EnumNames));
                }
                if (!DocTools.IsNullOrEmpty(request.Icon))
                {
                    entities = entities.Where(en => en.Icon.Contains(request.Icon));
                }
                if (!DocTools.IsNullOrEmpty(request.Icons))
                {
                    entities = entities.Where(en => en.Icon.In(request.Icons));
                }
                if (!DocTools.IsNullOrEmpty(request.Page) && !DocTools.IsNullOrEmpty(request.Page.Id))
                {
                    entities = entities.Where(en => en.Page.Id == request.Page.Id);
                }
                if (true == request.PageIds?.Any())
                {
                    entities = entities.Where(en => en.Page.Id.In(request.PageIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Term) && !DocTools.IsNullOrEmpty(request.Term.Id))
                {
                    entities = entities.Where(en => en.Term.Id == request.Term.Id);
                }
                if (true == request.TermIds?.Any())
                {
                    entities = entities.Where(en => en.Term.Id.In(request.TermIds));
                }

                entities = ApplyFilters <DocEntityGlossary, GlossarySearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 22
0
        private IQueryable <DocEntityProject> _ExecSearch(ProjectSearch request, DocQuery query)
        {
            request = InitSearch <Project, ProjectSearch>(request);
            IQueryable <DocEntityProject> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityProject>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new ProjectFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityProject, ProjectFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.PROJECT, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (true == request.ChildrenIds?.Any())
                {
                    entities = entities.Where(en => en.Children.Any(r => r.Id.In(request.ChildrenIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Client) && !DocTools.IsNullOrEmpty(request.Client.Id))
                {
                    entities = entities.Where(en => en.Client.Id == request.Client.Id);
                }
                if (true == request.ClientIds?.Any())
                {
                    entities = entities.Where(en => en.Client.Id.In(request.ClientIds));
                }
                if (!DocTools.IsNullOrEmpty(request.DatabaseDeadline))
                {
                    entities = entities.Where(en => null != en.DatabaseDeadline && request.DatabaseDeadline.Value.Date == en.DatabaseDeadline.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.DatabaseDeadlineBefore))
                {
                    entities = entities.Where(en => en.DatabaseDeadline <= request.DatabaseDeadlineBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.DatabaseDeadlineAfter))
                {
                    entities = entities.Where(en => en.DatabaseDeadline >= request.DatabaseDeadlineAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.DatabaseName))
                {
                    entities = entities.Where(en => en.DatabaseName.Contains(request.DatabaseName));
                }
                if (!DocTools.IsNullOrEmpty(request.DatabaseNames))
                {
                    entities = entities.Where(en => en.DatabaseName.In(request.DatabaseNames));
                }
                if (!DocTools.IsNullOrEmpty(request.Dataset) && !DocTools.IsNullOrEmpty(request.Dataset.Id))
                {
                    entities = entities.Where(en => en.Dataset.Id == request.Dataset.Id);
                }
                if (true == request.DatasetIds?.Any())
                {
                    entities = entities.Where(en => en.Dataset.Id.In(request.DatasetIds));
                }
                if (!DocTools.IsNullOrEmpty(request.DeliverableDeadline))
                {
                    entities = entities.Where(en => null != en.DeliverableDeadline && request.DeliverableDeadline.Value.Date == en.DeliverableDeadline.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.DeliverableDeadlineBefore))
                {
                    entities = entities.Where(en => en.DeliverableDeadline <= request.DeliverableDeadlineBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.DeliverableDeadlineAfter))
                {
                    entities = entities.Where(en => en.DeliverableDeadline >= request.DeliverableDeadlineAfter);
                }
                if (request.FqId.HasValue)
                {
                    entities = entities.Where(en => request.FqId.Value == en.FqId);
                }
                if (!DocTools.IsNullOrEmpty(request.FqWorkflow) && !DocTools.IsNullOrEmpty(request.FqWorkflow.Id))
                {
                    entities = entities.Where(en => en.FqWorkflow.Id == request.FqWorkflow.Id);
                }
                if (true == request.FqWorkflowIds?.Any())
                {
                    entities = entities.Where(en => en.FqWorkflow.Id.In(request.FqWorkflowIds));
                }
                if (request.LegacyPackageId.HasValue)
                {
                    entities = entities.Where(en => request.LegacyPackageId.Value == en.LegacyPackageId);
                }
                if (!DocTools.IsNullOrEmpty(request.Library) && !DocTools.IsNullOrEmpty(request.Library.Id))
                {
                    entities = entities.Where(en => en.Library.Id == request.Library.Id);
                }
                if (true == request.LibraryIds?.Any())
                {
                    entities = entities.Where(en => en.Library.Id.In(request.LibraryIds));
                }
                if (request.LibraryPackageId.HasValue)
                {
                    entities = entities.Where(en => request.LibraryPackageId.Value == en.LibraryPackageId);
                }
                if (!DocTools.IsNullOrEmpty(request.LibraryPackageName))
                {
                    entities = entities.Where(en => en.LibraryPackageName.Contains(request.LibraryPackageName));
                }
                if (!DocTools.IsNullOrEmpty(request.LibraryPackageNames))
                {
                    entities = entities.Where(en => en.LibraryPackageName.In(request.LibraryPackageNames));
                }
                if (!DocTools.IsNullOrEmpty(request.Number))
                {
                    entities = entities.Where(en => en.Number.Contains(request.Number));
                }
                if (!DocTools.IsNullOrEmpty(request.Numbers))
                {
                    entities = entities.Where(en => en.Number.In(request.Numbers));
                }
                if (!DocTools.IsNullOrEmpty(request.OperationsDeliverable))
                {
                    entities = entities.Where(en => en.OperationsDeliverable.Contains(request.OperationsDeliverable));
                }
                if (!DocTools.IsNullOrEmpty(request.OperationsDeliverables))
                {
                    entities = entities.Where(en => en.OperationsDeliverable.In(request.OperationsDeliverables));
                }
                if (!DocTools.IsNullOrEmpty(request.OpportunityId))
                {
                    entities = entities.Where(en => en.OpportunityId.Contains(request.OpportunityId));
                }
                if (!DocTools.IsNullOrEmpty(request.OpportunityIds))
                {
                    entities = entities.Where(en => en.OpportunityId.In(request.OpportunityIds));
                }
                if (!DocTools.IsNullOrEmpty(request.OpportunityName))
                {
                    entities = entities.Where(en => en.OpportunityName.Contains(request.OpportunityName));
                }
                if (!DocTools.IsNullOrEmpty(request.OpportunityNames))
                {
                    entities = entities.Where(en => en.OpportunityName.In(request.OpportunityNames));
                }
                if (!DocTools.IsNullOrEmpty(request.Parent) && !DocTools.IsNullOrEmpty(request.Parent.Id))
                {
                    entities = entities.Where(en => en.Parent.Id == request.Parent.Id);
                }
                if (true == request.ParentIds?.Any())
                {
                    entities = entities.Where(en => en.Parent.Id.In(request.ParentIds));
                }
                if (!DocTools.IsNullOrEmpty(request.PICO))
                {
                    entities = entities.Where(en => en.PICO.Contains(request.PICO));
                }
                if (!DocTools.IsNullOrEmpty(request.PICOs))
                {
                    entities = entities.Where(en => en.PICO.In(request.PICOs));
                }
                if (!DocTools.IsNullOrEmpty(request.ProjectId))
                {
                    entities = entities.Where(en => en.ProjectId.Contains(request.ProjectId));
                }
                if (!DocTools.IsNullOrEmpty(request.ProjectIds))
                {
                    entities = entities.Where(en => en.ProjectId.In(request.ProjectIds));
                }
                if (!DocTools.IsNullOrEmpty(request.ProjectName))
                {
                    entities = entities.Where(en => en.ProjectName.Contains(request.ProjectName));
                }
                if (!DocTools.IsNullOrEmpty(request.ProjectNames))
                {
                    entities = entities.Where(en => en.ProjectName.In(request.ProjectNames));
                }
                if (request.Status.HasValue)
                {
                    entities = entities.Where(en => request.Status.Value == en.Status);
                }
                if (!DocTools.IsNullOrEmpty(request.Statuss))
                {
                    entities = entities.Where(en => en.Status.In(request.Statuss));
                }
                if (true == request.TimeCardsIds?.Any())
                {
                    entities = entities.Where(en => en.TimeCards.Any(r => r.Id.In(request.TimeCardsIds)));
                }

                entities = ApplyFilters <DocEntityProject, ProjectSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 23
0
        private IQueryable <DocEntityImportData> _ExecSearch(ImportDataSearch request, DocQuery query)
        {
            request = InitSearch <ImportData, ImportDataSearch>(request);
            IQueryable <DocEntityImportData> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityImportData>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new ImportDataFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityImportData, ImportDataFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.IMPORTDATA, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.CompletedOn))
                {
                    entities = entities.Where(en => null != en.CompletedOn && request.CompletedOn.Value.Date == en.CompletedOn.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CompletedOnBefore))
                {
                    entities = entities.Where(en => en.CompletedOn <= request.CompletedOnBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CompletedOnAfter))
                {
                    entities = entities.Where(en => en.CompletedOn >= request.CompletedOnAfter);
                }
                if (true == request.DataSetsIds?.Any())
                {
                    entities = entities.Where(en => en.DataSets.Any(r => r.Id.In(request.DataSetsIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Document) && !DocTools.IsNullOrEmpty(request.Document.Id))
                {
                    entities = entities.Where(en => en.Document.Id == request.Document.Id);
                }
                if (true == request.DocumentIds?.Any())
                {
                    entities = entities.Where(en => en.Document.Id.In(request.DocumentIds));
                }
                if (!DocTools.IsNullOrEmpty(request.ErrorData))
                {
                    entities = entities.Where(en => en.ErrorData.Contains(request.ErrorData));
                }
                if (!DocTools.IsNullOrEmpty(request.ErrorDatas))
                {
                    entities = entities.Where(en => en.ErrorData.In(request.ErrorDatas));
                }
                if (!DocTools.IsNullOrEmpty(request.ExtractUrl))
                {
                    entities = entities.Where(en => en.ExtractUrl.Contains(request.ExtractUrl));
                }
                if (!DocTools.IsNullOrEmpty(request.ExtractUrls))
                {
                    entities = entities.Where(en => en.ExtractUrl.In(request.ExtractUrls));
                }
                if (true == request.HighPriority?.Any())
                {
                    entities = entities.Where(en => en.HighPriority.In(request.HighPriority));
                }
                if (true == request.ImportFr?.Any())
                {
                    entities = entities.Where(en => en.ImportFr.In(request.ImportFr));
                }
                if (!DocTools.IsNullOrEmpty(request.ImportLocation) && !DocTools.IsNullOrEmpty(request.ImportLocation.Id))
                {
                    entities = entities.Where(en => en.ImportLocation.Id == request.ImportLocation.Id);
                }
                if (true == request.ImportLocationIds?.Any())
                {
                    entities = entities.Where(en => en.ImportLocation.Id.In(request.ImportLocationIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.ImportLocation) && !DocTools.IsNullOrEmpty(request.ImportLocation.Name))
                {
                    entities = entities.Where(en => en.ImportLocation.Name == request.ImportLocation.Name);
                }
                if (true == request.ImportLocationNames?.Any())
                {
                    entities = entities.Where(en => en.ImportLocation.Name.In(request.ImportLocationNames));
                }
                if (true == request.ImportNewName?.Any())
                {
                    entities = entities.Where(en => en.ImportNewName.In(request.ImportNewName));
                }
                if (true == request.ImportTable?.Any())
                {
                    entities = entities.Where(en => en.ImportTable.In(request.ImportTable));
                }
                if (true == request.ImportText?.Any())
                {
                    entities = entities.Where(en => en.ImportText.In(request.ImportText));
                }
                if (!DocTools.IsNullOrEmpty(request.ImportType) && !DocTools.IsNullOrEmpty(request.ImportType.Id))
                {
                    entities = entities.Where(en => en.ImportType.Id == request.ImportType.Id);
                }
                if (true == request.ImportTypeIds?.Any())
                {
                    entities = entities.Where(en => en.ImportType.Id.In(request.ImportTypeIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.ImportType) && !DocTools.IsNullOrEmpty(request.ImportType.Name))
                {
                    entities = entities.Where(en => en.ImportType.Name == request.ImportType.Name);
                }
                if (true == request.ImportTypeNames?.Any())
                {
                    entities = entities.Where(en => en.ImportType.Name.In(request.ImportTypeNames));
                }
                if (true == request.IsLegacy?.Any())
                {
                    entities = entities.Where(en => en.IsLegacy.In(request.IsLegacy));
                }
                if (request.Order.HasValue)
                {
                    entities = entities.Where(en => request.Order.Value == en.Order);
                }
                if (request.ReferenceId.HasValue)
                {
                    entities = entities.Where(en => request.ReferenceId.Value == en.ReferenceId);
                }
                if (!DocTools.IsNullOrEmpty(request.RequestedBy) && !DocTools.IsNullOrEmpty(request.RequestedBy.Id))
                {
                    entities = entities.Where(en => en.RequestedBy.Id == request.RequestedBy.Id);
                }
                if (true == request.RequestedByIds?.Any())
                {
                    entities = entities.Where(en => en.RequestedBy.Id.In(request.RequestedByIds));
                }
                if (!DocTools.IsNullOrEmpty(request.RequestedOn))
                {
                    entities = entities.Where(en => null != en.RequestedOn && request.RequestedOn.Value.Date == en.RequestedOn.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.RequestedOnBefore))
                {
                    entities = entities.Where(en => en.RequestedOn <= request.RequestedOnBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.RequestedOnAfter))
                {
                    entities = entities.Where(en => en.RequestedOn >= request.RequestedOnAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.StartedOn))
                {
                    entities = entities.Where(en => null != en.StartedOn && request.StartedOn.Value.Date == en.StartedOn.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.StartedOnBefore))
                {
                    entities = entities.Where(en => en.StartedOn <= request.StartedOnBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.StartedOnAfter))
                {
                    entities = entities.Where(en => en.StartedOn >= request.StartedOnAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Status) && !DocTools.IsNullOrEmpty(request.Status.Id))
                {
                    entities = entities.Where(en => en.Status.Id == request.Status.Id);
                }
                if (true == request.StatusIds?.Any())
                {
                    entities = entities.Where(en => en.Status.Id.In(request.StatusIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.Status) && !DocTools.IsNullOrEmpty(request.Status.Name))
                {
                    entities = entities.Where(en => en.Status.Name == request.Status.Name);
                }
                if (true == request.StatusNames?.Any())
                {
                    entities = entities.Where(en => en.Status.Name.In(request.StatusNames));
                }

                entities = ApplyFilters <DocEntityImportData, ImportDataSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 24
0
        private IQueryable <DocEntityReleaseStatus> _ExecSearch(ReleaseStatusSearch request, DocQuery query)
        {
            request = InitSearch <ReleaseStatus, ReleaseStatusSearch>(request);
            IQueryable <DocEntityReleaseStatus> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityReleaseStatus>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new ReleaseStatusFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityReleaseStatus, ReleaseStatusFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.RELEASESTATUS, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }

                if (!DocTools.IsNullOrEmpty(request.Branch))
                {
                    entities = entities.Where(en => en.Branch.Contains(request.Branch));
                }
                if (!DocTools.IsNullOrEmpty(request.Release))
                {
                    entities = entities.Where(en => en.Release.Contains(request.Release));
                }
                if (!DocTools.IsNullOrEmpty(request.Server))
                {
                    entities = entities.Where(en => en.Server.Contains(request.Server));
                }
                if (!DocTools.IsNullOrEmpty(request.URL))
                {
                    entities = entities.Where(en => en.URL.Contains(request.URL));
                }
                if (!DocTools.IsNullOrEmpty(request.Version))
                {
                    entities = entities.Where(en => en.Version.Contains(request.Version));
                }

                entities = ApplyFilters <DocEntityReleaseStatus, ReleaseStatusSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 25
0
        private IQueryable <DocEntityValueType> _ExecSearch(ValueTypeSearch request, DocQuery query)
        {
            request = InitSearch <ValueType, ValueTypeSearch>(request);
            IQueryable <DocEntityValueType> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityValueType>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new ValueTypeFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityValueType, ValueTypeFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.VALUETYPE, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.FieldType) && !DocTools.IsNullOrEmpty(request.FieldType.Id))
                {
                    entities = entities.Where(en => en.FieldType.Id == request.FieldType.Id);
                }
                if (true == request.FieldTypeIds?.Any())
                {
                    entities = entities.Where(en => en.FieldType.Id.In(request.FieldTypeIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.FieldType) && !DocTools.IsNullOrEmpty(request.FieldType.Name))
                {
                    entities = entities.Where(en => en.FieldType.Name == request.FieldType.Name);
                }
                if (true == request.FieldTypeNames?.Any())
                {
                    entities = entities.Where(en => en.FieldType.Name.In(request.FieldTypeNames));
                }
                if (!DocTools.IsNullOrEmpty(request.Name) && !DocTools.IsNullOrEmpty(request.Name.Id))
                {
                    entities = entities.Where(en => en.Name.Id == request.Name.Id);
                }
                if (true == request.NameIds?.Any())
                {
                    entities = entities.Where(en => en.Name.Id.In(request.NameIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.Name) && !DocTools.IsNullOrEmpty(request.Name.Name))
                {
                    entities = entities.Where(en => en.Name.Name == request.Name.Name);
                }
                if (true == request.NameNames?.Any())
                {
                    entities = entities.Where(en => en.Name.Name.In(request.NameNames));
                }

                entities = ApplyFilters <DocEntityValueType, ValueTypeSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 26
0
        private IQueryable <DocEntityBackgroundTask> _ExecSearch(BackgroundTaskSearch request, DocQuery query)
        {
            request = InitSearch <BackgroundTask, BackgroundTaskSearch>(request);
            IQueryable <DocEntityBackgroundTask> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityBackgroundTask>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new BackgroundTaskFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityBackgroundTask, BackgroundTaskFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.BACKGROUNDTASK, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.App) && !DocTools.IsNullOrEmpty(request.App.Id))
                {
                    entities = entities.Where(en => en.App.Id == request.App.Id);
                }
                if (true == request.AppIds?.Any())
                {
                    entities = entities.Where(en => en.App.Id.In(request.AppIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Channel) && !DocTools.IsNullOrEmpty(request.Channel.Id))
                {
                    entities = entities.Where(en => en.Channel.Id == request.Channel.Id);
                }
                if (true == request.ChannelIds?.Any())
                {
                    entities = entities.Where(en => en.Channel.Id.In(request.ChannelIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Description))
                {
                    entities = entities.Where(en => en.Description.Contains(request.Description));
                }
                if (!DocTools.IsNullOrEmpty(request.Descriptions))
                {
                    entities = entities.Where(en => en.Description.In(request.Descriptions));
                }
                if (true == request.Enabled?.Any())
                {
                    entities = entities.Where(en => en.Enabled.In(request.Enabled));
                }
                if (request.Frequency.HasValue)
                {
                    entities = entities.Where(en => request.Frequency.Value == en.Frequency);
                }
                if (request.HistoryRetention.HasValue)
                {
                    entities = entities.Where(en => request.HistoryRetention.Value == en.HistoryRetention);
                }
                if (true == request.ItemsIds?.Any())
                {
                    entities = entities.Where(en => en.Items.Any(r => r.Id.In(request.ItemsIds)));
                }
                if (true == request.KeepHistory?.Any())
                {
                    entities = entities.Where(en => en.KeepHistory.In(request.KeepHistory));
                }
                if (!DocTools.IsNullOrEmpty(request.LastRunVersion))
                {
                    entities = entities.Where(en => en.LastRunVersion.Contains(request.LastRunVersion));
                }
                if (!DocTools.IsNullOrEmpty(request.LastRunVersions))
                {
                    entities = entities.Where(en => en.LastRunVersion.In(request.LastRunVersions));
                }
                if (true == request.LogError?.Any())
                {
                    entities = entities.Where(en => en.LogError.In(request.LogError));
                }
                if (true == request.LogInfo?.Any())
                {
                    entities = entities.Where(en => en.LogInfo.In(request.LogInfo));
                }
                if (!DocTools.IsNullOrEmpty(request.Name))
                {
                    entities = entities.Where(en => en.Name.Contains(request.Name));
                }
                if (!DocTools.IsNullOrEmpty(request.Names))
                {
                    entities = entities.Where(en => en.Name.In(request.Names));
                }
                if (request.RowsToProcessPerIteration.HasValue)
                {
                    entities = entities.Where(en => request.RowsToProcessPerIteration.Value == en.RowsToProcessPerIteration);
                }
                if (true == request.RunNow?.Any())
                {
                    entities = entities.Where(en => en.RunNow.In(request.RunNow));
                }
                if (!DocTools.IsNullOrEmpty(request.StartAt))
                {
                    entities = entities.Where(en => en.StartAt.Contains(request.StartAt));
                }
                if (!DocTools.IsNullOrEmpty(request.StartAts))
                {
                    entities = entities.Where(en => en.StartAt.In(request.StartAts));
                }
                if (true == request.TaskHistoryIds?.Any())
                {
                    entities = entities.Where(en => en.TaskHistory.Any(r => r.Id.In(request.TaskHistoryIds)));
                }

                entities = ApplyFilters <DocEntityBackgroundTask, BackgroundTaskSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 27
0
        private IQueryable <DocEntityDataProperty> _ExecSearch(DataPropertySearch request, DocQuery query)
        {
            request = InitSearch <DataProperty, DataPropertySearch>(request);
            IQueryable <DocEntityDataProperty> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityDataProperty>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new DataPropertyFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityDataProperty, DataPropertyFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.DATAPROPERTY, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (true == request.AutoCreateMissing?.Any())
                {
                    entities = entities.Where(en => en.AutoCreateMissing.In(request.AutoCreateMissing));
                }
                if (true == request.ChildrenIds?.Any())
                {
                    entities = entities.Where(en => en.Children.Any(r => r.Id.In(request.ChildrenIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Class) && !DocTools.IsNullOrEmpty(request.Class.Id))
                {
                    entities = entities.Where(en => en.Class.Id == request.Class.Id);
                }
                if (true == request.ClassIds?.Any())
                {
                    entities = entities.Where(en => en.Class.Id.In(request.ClassIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Description))
                {
                    entities = entities.Where(en => en.Description.Contains(request.Description));
                }
                if (!DocTools.IsNullOrEmpty(request.Descriptions))
                {
                    entities = entities.Where(en => en.Description.In(request.Descriptions));
                }
                if (!DocTools.IsNullOrEmpty(request.DisplayName))
                {
                    entities = entities.Where(en => en.DisplayName.Contains(request.DisplayName));
                }
                if (!DocTools.IsNullOrEmpty(request.DisplayNames))
                {
                    entities = entities.Where(en => en.DisplayName.In(request.DisplayNames));
                }
                if (true == request.IsAllowAddInForm?.Any())
                {
                    entities = entities.Where(en => en.IsAllowAddInForm.In(request.IsAllowAddInForm));
                }
                if (true == request.IsAllowCreateInForm?.Any())
                {
                    entities = entities.Where(en => en.IsAllowCreateInForm.In(request.IsAllowCreateInForm));
                }
                if (true == request.IsAllowEditInForm?.Any())
                {
                    entities = entities.Where(en => en.IsAllowEditInForm.In(request.IsAllowEditInForm));
                }
                if (true == request.IsAllowFreeText?.Any())
                {
                    entities = entities.Where(en => en.IsAllowFreeText.In(request.IsAllowFreeText));
                }
                if (true == request.IsAllowRemoveInForm?.Any())
                {
                    entities = entities.Where(en => en.IsAllowRemoveInForm.In(request.IsAllowRemoveInForm));
                }
                if (true == request.IsAudited?.Any())
                {
                    entities = entities.Where(en => en.IsAudited.In(request.IsAudited));
                }
                if (true == request.IsCompressed?.Any())
                {
                    entities = entities.Where(en => en.IsCompressed.In(request.IsCompressed));
                }
                if (true == request.IsDisplayInForm?.Any())
                {
                    entities = entities.Where(en => en.IsDisplayInForm.In(request.IsDisplayInForm));
                }
                if (true == request.IsDisplayInGrid?.Any())
                {
                    entities = entities.Where(en => en.IsDisplayInGrid.In(request.IsDisplayInGrid));
                }
                if (true == request.IsEditColumn?.Any())
                {
                    entities = entities.Where(en => en.IsEditColumn.In(request.IsEditColumn));
                }
                if (true == request.IsInsertOnly?.Any())
                {
                    entities = entities.Where(en => en.IsInsertOnly.In(request.IsInsertOnly));
                }
                if (true == request.IsJSON?.Any())
                {
                    entities = entities.Where(en => en.IsJSON.In(request.IsJSON));
                }
                if (true == request.IsLazy?.Any())
                {
                    entities = entities.Where(en => en.IsLazy.In(request.IsLazy));
                }
                if (true == request.IsNullOnUpgrade?.Any())
                {
                    entities = entities.Where(en => en.IsNullOnUpgrade.In(request.IsNullOnUpgrade));
                }
                if (true == request.IsReadOnly?.Any())
                {
                    entities = entities.Where(en => en.IsReadOnly.In(request.IsReadOnly));
                }
                if (true == request.IsRelationship?.Any())
                {
                    entities = entities.Where(en => en.IsRelationship.In(request.IsRelationship));
                }
                if (true == request.IsRequired?.Any())
                {
                    entities = entities.Where(en => en.IsRequired.In(request.IsRequired));
                }
                if (true == request.IsRequiredInForm?.Any())
                {
                    entities = entities.Where(en => en.IsRequiredInForm.In(request.IsRequiredInForm));
                }
                if (true == request.IsVirtual?.Any())
                {
                    entities = entities.Where(en => en.IsVirtual.In(request.IsVirtual));
                }
                if (!DocTools.IsNullOrEmpty(request.JsonType))
                {
                    entities = entities.Where(en => en.JsonType.Contains(request.JsonType));
                }
                if (!DocTools.IsNullOrEmpty(request.JsonTypes))
                {
                    entities = entities.Where(en => en.JsonType.In(request.JsonTypes));
                }
                if (!DocTools.IsNullOrEmpty(request.LookupTableEnum) && !DocTools.IsNullOrEmpty(request.LookupTableEnum.Id))
                {
                    entities = entities.Where(en => en.LookupTableEnum.Id == request.LookupTableEnum.Id);
                }
                if (true == request.LookupTableEnumIds?.Any())
                {
                    entities = entities.Where(en => en.LookupTableEnum.Id.In(request.LookupTableEnumIds));
                }
                if (true == request.LookupTableEnumNames?.Any())
                {
                    entities = entities.Where(en => en.LookupTableEnum.Name.In(request.LookupTableEnumNames));
                }
                if (!DocTools.IsNullOrEmpty(request.Name))
                {
                    entities = entities.Where(en => en.Name.Contains(request.Name));
                }
                if (!DocTools.IsNullOrEmpty(request.Names))
                {
                    entities = entities.Where(en => en.Name.In(request.Names));
                }
                if (request.Order.HasValue)
                {
                    entities = entities.Where(en => request.Order.Value == en.Order);
                }
                if (!DocTools.IsNullOrEmpty(request.Owner) && !DocTools.IsNullOrEmpty(request.Owner.Id))
                {
                    entities = entities.Where(en => en.Owner.Id == request.Owner.Id);
                }
                if (true == request.OwnerIds?.Any())
                {
                    entities = entities.Where(en => en.Owner.Id.In(request.OwnerIds));
                }
                if (request.Precision.HasValue)
                {
                    entities = entities.Where(en => request.Precision.Value == en.Precision);
                }
                if (request.RelationshipOnOwnerRemove.HasValue)
                {
                    entities = entities.Where(en => request.RelationshipOnOwnerRemove.Value == en.RelationshipOnOwnerRemove);
                }
                if (!DocTools.IsNullOrEmpty(request.RelationshipOnOwnerRemoves))
                {
                    entities = entities.Where(en => en.RelationshipOnOwnerRemove.In(request.RelationshipOnOwnerRemoves));
                }
                if (request.RelationshipOnTargetRemove.HasValue)
                {
                    entities = entities.Where(en => request.RelationshipOnTargetRemove.Value == en.RelationshipOnTargetRemove);
                }
                if (!DocTools.IsNullOrEmpty(request.RelationshipOnTargetRemoves))
                {
                    entities = entities.Where(en => en.RelationshipOnTargetRemove.In(request.RelationshipOnTargetRemoves));
                }
                if (!DocTools.IsNullOrEmpty(request.RelationshipPairTo) && !DocTools.IsNullOrEmpty(request.RelationshipPairTo.Id))
                {
                    entities = entities.Where(en => en.RelationshipPairTo.Id == request.RelationshipPairTo.Id);
                }
                if (true == request.RelationshipPairToIds?.Any())
                {
                    entities = entities.Where(en => en.RelationshipPairTo.Id.In(request.RelationshipPairToIds));
                }
                if (request.Scale.HasValue)
                {
                    entities = entities.Where(en => request.Scale.Value == en.Scale);
                }
                if (!DocTools.IsNullOrEmpty(request.SetDefaultValue))
                {
                    entities = entities.Where(en => en.SetDefaultValue.Contains(request.SetDefaultValue));
                }
                if (!DocTools.IsNullOrEmpty(request.SetDefaultValues))
                {
                    entities = entities.Where(en => en.SetDefaultValue.In(request.SetDefaultValues));
                }
                if (!DocTools.IsNullOrEmpty(request.Tab) && !DocTools.IsNullOrEmpty(request.Tab.Id))
                {
                    entities = entities.Where(en => en.Tab.Id == request.Tab.Id);
                }
                if (true == request.TabIds?.Any())
                {
                    entities = entities.Where(en => en.Tab.Id.In(request.TabIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Target) && !DocTools.IsNullOrEmpty(request.Target.Id))
                {
                    entities = entities.Where(en => en.Target.Id == request.Target.Id);
                }
                if (true == request.TargetIds?.Any())
                {
                    entities = entities.Where(en => en.Target.Id.In(request.TargetIds));
                }
                if (!DocTools.IsNullOrEmpty(request.TargetAlias))
                {
                    entities = entities.Where(en => en.TargetAlias.Contains(request.TargetAlias));
                }
                if (!DocTools.IsNullOrEmpty(request.TargetAliass))
                {
                    entities = entities.Where(en => en.TargetAlias.In(request.TargetAliass));
                }
                if (request.Type.HasValue)
                {
                    entities = entities.Where(en => request.Type.Value == en.Type);
                }
                if (!DocTools.IsNullOrEmpty(request.Types))
                {
                    entities = entities.Where(en => en.Type.In(request.Types));
                }
                if (request.UIType.HasValue)
                {
                    entities = entities.Where(en => request.UIType.Value == en.UIType);
                }
                if (!DocTools.IsNullOrEmpty(request.UITypes))
                {
                    entities = entities.Where(en => en.UIType.In(request.UITypes));
                }

                entities = ApplyFilters <DocEntityDataProperty, DataPropertySearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 28
0
        private IQueryable <DocEntityRating> _ExecSearch(RatingSearch request, DocQuery query)
        {
            request = InitSearch <Rating, RatingSearch>(request);
            IQueryable <DocEntityRating> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityRating>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new RatingFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityRating, RatingFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.RATING, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.Assignee) && !DocTools.IsNullOrEmpty(request.Assignee.Id))
                {
                    entities = entities.Where(en => en.Assignee.Id == request.Assignee.Id);
                }
                if (true == request.AssigneeIds?.Any())
                {
                    entities = entities.Where(en => en.Assignee.Id.In(request.AssigneeIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Description))
                {
                    entities = entities.Where(en => en.Description.Contains(request.Description));
                }
                if (!DocTools.IsNullOrEmpty(request.Descriptions))
                {
                    entities = entities.Where(en => en.Description.In(request.Descriptions));
                }
                if (!DocTools.IsNullOrEmpty(request.DueDate))
                {
                    entities = entities.Where(en => null != en.DueDate && request.DueDate.Value.Date == en.DueDate.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.DueDateBefore))
                {
                    entities = entities.Where(en => en.DueDate <= request.DueDateBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.DueDateAfter))
                {
                    entities = entities.Where(en => en.DueDate >= request.DueDateAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Reporter) && !DocTools.IsNullOrEmpty(request.Reporter.Id))
                {
                    entities = entities.Where(en => en.Reporter.Id == request.Reporter.Id);
                }
                if (true == request.ReporterIds?.Any())
                {
                    entities = entities.Where(en => en.Reporter.Id.In(request.ReporterIds));
                }
                if (request.Type.HasValue)
                {
                    entities = entities.Where(en => request.Type.Value == en.Type);
                }
                if (!DocTools.IsNullOrEmpty(request.Types))
                {
                    entities = entities.Where(en => en.Type.In(request.Types));
                }
                if (!DocTools.IsNullOrEmpty(request.Workflow) && !DocTools.IsNullOrEmpty(request.Workflow.Id))
                {
                    entities = entities.Where(en => en.Workflow.Id == request.Workflow.Id);
                }
                if (true == request.WorkflowIds?.Any())
                {
                    entities = entities.Where(en => en.Workflow.Id.In(request.WorkflowIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Assignee) && !DocTools.IsNullOrEmpty(request.Assignee.Id))
                {
                    entities = entities.Where(en => en.Assignee.Id == request.Assignee.Id);
                }
                if (true == request.AssigneeIds?.Any())
                {
                    entities = entities.Where(en => en.Assignee.Id.In(request.AssigneeIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Description))
                {
                    entities = entities.Where(en => en.Description.Contains(request.Description));
                }
                if (!DocTools.IsNullOrEmpty(request.Descriptions))
                {
                    entities = entities.Where(en => en.Description.In(request.Descriptions));
                }
                if (!DocTools.IsNullOrEmpty(request.Document) && !DocTools.IsNullOrEmpty(request.Document.Id))
                {
                    entities = entities.Where(en => en.Document.Id == request.Document.Id);
                }
                if (true == request.DocumentIds?.Any())
                {
                    entities = entities.Where(en => en.Document.Id.In(request.DocumentIds));
                }
                if (!DocTools.IsNullOrEmpty(request.DueDate))
                {
                    entities = entities.Where(en => null != en.DueDate && request.DueDate.Value.Date == en.DueDate.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.DueDateBefore))
                {
                    entities = entities.Where(en => en.DueDate <= request.DueDateBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.DueDateAfter))
                {
                    entities = entities.Where(en => en.DueDate >= request.DueDateAfter);
                }
                if (request.Rating.HasValue)
                {
                    entities = entities.Where(en => request.Rating.Value == en.Rating);
                }
                if (!DocTools.IsNullOrEmpty(request.Ratings))
                {
                    entities = entities.Where(en => en.Rating.In(request.Ratings));
                }
                if (request.ReasonRejected.HasValue)
                {
                    entities = entities.Where(en => request.ReasonRejected.Value == en.ReasonRejected);
                }
                if (!DocTools.IsNullOrEmpty(request.ReasonRejecteds))
                {
                    entities = entities.Where(en => en.ReasonRejected.In(request.ReasonRejecteds));
                }
                if (!DocTools.IsNullOrEmpty(request.Reporter) && !DocTools.IsNullOrEmpty(request.Reporter.Id))
                {
                    entities = entities.Where(en => en.Reporter.Id == request.Reporter.Id);
                }
                if (true == request.ReporterIds?.Any())
                {
                    entities = entities.Where(en => en.Reporter.Id.In(request.ReporterIds));
                }
                if (request.Type.HasValue)
                {
                    entities = entities.Where(en => request.Type.Value == en.Type);
                }
                if (!DocTools.IsNullOrEmpty(request.Types))
                {
                    entities = entities.Where(en => en.Type.In(request.Types));
                }
                if (!DocTools.IsNullOrEmpty(request.Workflow) && !DocTools.IsNullOrEmpty(request.Workflow.Id))
                {
                    entities = entities.Where(en => en.Workflow.Id == request.Workflow.Id);
                }
                if (true == request.WorkflowIds?.Any())
                {
                    entities = entities.Where(en => en.Workflow.Id.In(request.WorkflowIds));
                }

                entities = ApplyFilters <DocEntityRating, RatingSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 29
0
        private IQueryable <DocEntityIntervention> _ExecSearch(InterventionSearch request, DocQuery query)
        {
            request = InitSearch <Intervention, InterventionSearch>(request);
            IQueryable <DocEntityIntervention> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityIntervention>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new InterventionFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityIntervention, InterventionFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.INTERVENTION, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }

                if (true == request.DocumentSetsIds?.Any())
                {
                    entities = entities.Where(en => en.DocumentSets.Any(r => r.Id.In(request.DocumentSetsIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Name))
                {
                    entities = entities.Where(en => en.Name.Contains(request.Name));
                }
                if (!DocTools.IsNullOrEmpty(request.URI))
                {
                    entities = entities.Where(en => en.URI.Contains(request.URI));
                }

                entities = ApplyFilters <DocEntityIntervention, InterventionSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Esempio n. 30
0
        private IQueryable <DocEntityTermSynonym> _ExecSearch(TermSynonymSearch request, DocQuery query)
        {
            request = InitSearch <TermSynonym, TermSynonymSearch>(request);
            IQueryable <DocEntityTermSynonym> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityTermSynonym>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new TermSynonymFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityTermSynonym, TermSynonymFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.TERMSYNONYM, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (true == request.Approved?.Any())
                {
                    entities = entities.Where(en => en.Approved.In(request.Approved));
                }
                if (true == request.BindingsIds?.Any())
                {
                    entities = entities.Where(en => en.Bindings.Any(r => r.Id.In(request.BindingsIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Master) && !DocTools.IsNullOrEmpty(request.Master.Id))
                {
                    entities = entities.Where(en => en.Master.Id == request.Master.Id);
                }
                if (true == request.MasterIds?.Any())
                {
                    entities = entities.Where(en => en.Master.Id.In(request.MasterIds));
                }
                if (true == request.Preferred?.Any())
                {
                    entities = entities.Where(en => en.Preferred.In(request.Preferred));
                }
                if (!DocTools.IsNullOrEmpty(request.Scope) && !DocTools.IsNullOrEmpty(request.Scope.Id))
                {
                    entities = entities.Where(en => en.Scope.Id == request.Scope.Id);
                }
                if (true == request.ScopeIds?.Any())
                {
                    entities = entities.Where(en => en.Scope.Id.In(request.ScopeIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Synonym))
                {
                    entities = entities.Where(en => en.Synonym.Contains(request.Synonym));
                }
                if (!DocTools.IsNullOrEmpty(request.Synonyms))
                {
                    entities = entities.Where(en => en.Synonym.In(request.Synonyms));
                }

                entities = ApplyFilters <DocEntityTermSynonym, TermSynonymSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }