public Task <FindResults <Stack> > GetByFilterAsync(ExceptionlessSystemFilter systemFilter, string userFilter, string sort, string field, DateTime utcStart, DateTime utcEnd, CommandOptionsDescriptor <Stack> options = null)
        {
            IRepositoryQuery <Stack> query = new RepositoryQuery <Stack>()
                                             .DateRange(utcStart, utcEnd, field ?? ElasticType.GetFieldName(s => s.LastOccurrence))
                                             .SystemFilter(systemFilter)
                                             .FilterExpression(userFilter);

            query = !String.IsNullOrEmpty(sort) ? query.SortExpression(sort) : query.SortDescending(s => s.LastOccurrence);
            return(FindAsync(q => query, options));
        }
示例#2
0
        public Task <FindResults <PersistentEvent> > GetByFilterAsync(AppFilter systemFilter, string userFilter, string sort, string field, DateTime utcStart, DateTime utcEnd, CommandOptionsDescriptor <PersistentEvent> options = null)
        {
            IRepositoryQuery <PersistentEvent> query = new RepositoryQuery <PersistentEvent>()
                                                       .DateRange(utcStart, utcEnd, field ?? InferField(e => e.Date))
                                                       .Index(utcStart, utcEnd)
                                                       .AppFilter(systemFilter)
                                                       .FilterExpression(userFilter);

            query = !String.IsNullOrEmpty(sort) ? query.SortExpression(sort) : query.SortDescending(e => e.Date);
            return(FindAsync(q => query, options));
        }
示例#3
0
        public Task <FindResults <Organization> > GetByCriteriaAsync(string criteria, CommandOptionsDescriptor <Organization> options, OrganizationSortBy sortBy, bool?paid = null, bool?suspended = null)
        {
            var filter = Query <Organization> .MatchAll();

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

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

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

            var query = new RepositoryQuery <Organization>().ElasticFilter(filter);

            switch (sortBy)
            {
            case OrganizationSortBy.Newest:
                query.SortDescending((Organization o) => o.Id);
                break;

            case OrganizationSortBy.Subscribed:
                query.SortDescending((Organization o) => o.SubscribeDate);
                break;

            // case OrganizationSortBy.MostActive:
            //    query.WithSortDescending((Organization o) => o.TotalEventCount);
            //    break;
            default:
                query.SortAscending(o => o.Name.Suffix("keyword"));
                break;
            }

            return(FindAsync(q => query, options));
        }