Exemplo n.º 1
0
        public Task <FindResults <PersistentEvent> > GetByFilterAsync(IExceptionlessSystemFilterQuery systemFilter, string userFilter, string sort, string field, DateTime utcStart, DateTime utcEnd, PagingOptions paging)
        {
            var search = new ExceptionlessQuery()
                         .WithDateRange(utcStart, utcEnd, field ?? ElasticType.GetFieldName(e => e.Date))
                         .WithIndexes(utcStart, utcEnd)
                         .WithSystemFilter(systemFilter)
                         .WithFilter(userFilter)
                         .WithPaging(paging);

            search = !String.IsNullOrEmpty(sort) ? search.WithSort(sort) : search.WithSortDescending((PersistentEvent e) => e.Date);
            return(FindAsync(search));
        }
Exemplo n.º 2
0
        public Task <FindResults <Stack> > GetByFilterAsync(IExceptionlessSystemFilterQuery systemFilter, string userFilter, string sort, string field, DateTime utcStart, DateTime utcEnd, PagingOptions paging)
        {
            var search = new ExceptionlessQuery()
                         .WithDateRange(utcStart, utcEnd, field ?? ElasticType.GetFieldName(s => s.LastOccurrence))
                         .WithSystemFilter(systemFilter)
                         .WithFilter(userFilter)
                         .WithPaging(paging)
                         .WithSort(sort);

            search = !String.IsNullOrEmpty(sort) ? search.WithSort(sort) : search.WithSortDescending((Stack s) => s.LastOccurrence);
            return(FindAsync(search));
        }
Exemplo n.º 3
0
        public Task <FindResults <Organization> > GetByCriteriaAsync(string criteria, PagingOptions paging, OrganizationSortBy sortBy, bool?paid = null, bool?suspended = null)
        {
            var filter = Filter <Organization> .MatchAll();

            if (!String.IsNullOrWhiteSpace(criteria))
            {
                filter &= Filter <Organization> .Term(o => o.Name, criteria);
            }

            if (paid.HasValue)
            {
                if (paid.Value)
                {
                    filter &= !Filter <Organization> .Term(o => o.PlanId, BillingManager.FreePlan.Id);
                }
                else
                {
                    filter &= Filter <Organization> .Term(o => o.PlanId, BillingManager.FreePlan.Id);
                }
            }

            if (suspended.HasValue)
            {
                if (suspended.Value)
                {
                    filter &= Filter <Organization> .And(and => ((
                                                                     !Filter <Organization> .Term(o => o.BillingStatus, BillingStatus.Active) &&
                                                                     !Filter <Organization> .Term(o => o.BillingStatus, BillingStatus.Trialing) &&
                                                                     !Filter <Organization> .Term(o => o.BillingStatus, BillingStatus.Canceled)
                                                                     ) || Filter <Organization> .Term(o => o.IsSuspended, true)));
                }
                else
                {
                    filter &= Filter <Organization> .And(and => ((
                                                                     Filter <Organization> .Term(o => o.BillingStatus, BillingStatus.Active) &&
                                                                     Filter <Organization> .Term(o => o.BillingStatus, BillingStatus.Trialing) &&
                                                                     Filter <Organization> .Term(o => o.BillingStatus, BillingStatus.Canceled)
                                                                     ) || Filter <Organization> .Term(o => o.IsSuspended, false)));
                }
            }

            var query = new ExceptionlessQuery().WithPaging(paging).WithElasticFilter(filter);

            switch (sortBy)
            {
            case OrganizationSortBy.Newest:
                query.WithSort(OrganizationIndex.Fields.Organization.Id, SortOrder.Descending);
                break;

            case OrganizationSortBy.Subscribed:
                query.WithSort(OrganizationIndex.Fields.Organization.SubscribeDate, SortOrder.Descending);
                break;

            // case OrganizationSortBy.MostActive:
            //    query.WithSort(OrganizationIndex.Fields.Organization.TotalEventCount, SortOrder.Descending);
            //    break;
            default:
                query.WithSort(OrganizationIndex.Fields.Organization.Name, SortOrder.Ascending);
                break;
            }

            return(FindAsync(query));
        }