Beispiel #1
0
        public TrialsListModel()
        {
            Trials = new BindableCollection<Trial>(new PrimaryKeyComparer<Trial>(x => x.Id));

            Search = GetQueryParam("search");

            RavenQueryStatistics stats;
            var query = Session.Query<Trials_Search.ReduceResult>("Trials/Search")
                .Statistics(out stats)
                .Skip(Paging.PageNumber * ItemsPerPage)
                .Take(ItemsPerPage);

            if (string.IsNullOrEmpty(Search) == false)
            {
                query = query

                    .Where(x => x.Query == Search);
            }

            query
                .OrderByDescending(x => x.StartedAt)
                .As<Trial>()
                .ToListAsync()
                .ContinueOnSuccess(trials =>
                {
                    Trials.Match(trials);
                    Paging.NumberOfItems.Value = stats.TotalResults;
                    Paging.NumberOfPages.Value = Paging.NumberOfItems.Value / ItemsPerPage;
                });
        }
Beispiel #2
0
        private void UpdateAvailableIndexes()
        {
            if (Database.Value == null || Database.Value.Statistics.Value == null)
            {
                return;
            }

            AvailableIndexes.Match(Database.Value.Statistics.Value.Indexes.Select(i => i.Id.ToString()).ToArray());
        }
Beispiel #3
0
        protected override Task LoadedTimerTickedAsync()
        {
            if (IsLogsEnabled == false)
            {
                return(null);
            }

            return(DatabaseCommands.GetLogsAsync(showErrorsOnly)
                   .ContinueOnSuccess(logs =>
            {
                Logs.Match(logs);
                IsLogsEnabled = true;
            })
                   .CatchIgnore <WebException>(LogsIsNotEnabled));
        }
Beispiel #4
0
        protected override Task LoadedTimerTickedAsync()
        {
            if (Database.Value == null)
            {
                return(null);
            }

            return(DatabaseCommands.GetLogsAsync(showErrorsOnly)
                   .ContinueOnSuccess(logs => Logs.Match(logs.OrderByDescending(x => x.TimeStamp).ToList(), () =>
            {
                if (DisplayedLogs.Count == 0)
                {
                    DisplayedLogs.Match(Logs);
                }
            })));
        }
Beispiel #5
0
        public HomeListModel()
        {
            string date = GetQueryParam("date");

            if (date == null)
                LookAtDate = DateTime.Today;
            else
            {
                int year, month;
                int.TryParse(date.Substring(6, 4), out year);
                int.TryParse(date.Substring(3, 2), out month);
                LookAtDate = new DateTime(year, month, 1);
            }

            ProductStats =
                new BindableCollection<Products_Stats.ReduceResult>(
                    new PrimaryKeyComparer<Products_Stats.ReduceResult>(
                        x => Tuple.Create(x.Year, x.Month, x.Total.Currency, x.ProductId)));

            Session.Query<Products_Stats.ReduceResult>("Products/Stats")
                .Where(x => x.Year == LookAtDate.Year && x.Month == LookAtDate.Month)
                .ToListAsync()
                .ContinueOnSuccess(items => ProductStats.Match(items));

            OrderStatsUsd = new BindableCollection<Orders_Stats.ReduceResult>(
                    new PrimaryKeyComparer<Orders_Stats.ReduceResult>(
                        x => Tuple.Create(x.Date, x.Currency)));

            OrderStatsEuro =
                new BindableCollection<Orders_Stats.ReduceResult>(
                    new PrimaryKeyComparer<Orders_Stats.ReduceResult>(
                        x => Tuple.Create(x.Date, x.Currency)));

            DateTime yearBack = LookAtDate.AddYears(-1);

            Session.Query<Orders_Stats.ReduceResult>("Orders/Stats")
                .Where(x => x.Date >= yearBack && x.Date < LookAtDate && x.Currency == "EUR")
                .ToListAsync()
                .ContinueOnSuccess(items => OrderStatsEuro.Match(items));

            Session.Query<Orders_Stats.ReduceResult>("Orders/Stats")
                 .Where(x => x.Date >= yearBack && x.Date < LookAtDate && x.Currency == "USD")
                .ToListAsync()
                .ContinueOnSuccess(items => OrderStatsUsd.Match(items));
        }
Beispiel #6
0
        protected override Task LoadedTimerTickedAsync()
        {
            if (IsLogsEnabled == false)
            {
                return(null);
            }

            return(DatabaseCommands.GetLogsAsync(showErrorsOnly)
                   .ContinueOnSuccess(logs =>
            {
                Logs.Match(logs.OrderByDescending(x => x.TimeStamp).ToList(), () =>
                {
                    if (DisplayedLogs.Count == 0)
                    {
                        DisplayedLogs.Match(Logs);
                    }
                });
                IsLogsEnabled = true;
            })
                   .CatchIgnore <WebException>(LogsIsNotEnabled));
        }
Beispiel #7
0
        public override void LoadModelParameters(string parameters)
        {
            var urlParser = new UrlParser(parameters);

            IndexName = urlParser.Path.Trim('/');

            DatabaseCommands.GetIndexAsync(IndexName)
            .ContinueOnSuccessInTheUIThread(definition =>
            {
                if (definition == null)
                {
                    IndexDefinitionModel.HandleIndexNotFound(IndexName);
                    return;
                }
                fields.Match(definition.Fields);

                foreach (var field in fields)
                {
                    var localterms = fieldsTermsDictionary[field] = new List <string>();
                    GetTermsForField(field, localterms);
                }
            }).Catch();
        }
Beispiel #8
0
 public ProductsListModel()
 {
     Products = new BindableCollection<Product>(new PrimaryKeyComparer<Product>(x => x.Id));
     Session.Query<Product>().ToListAsync()
         .ContinueOnSuccess(products => Products.Match(products));
 }