Exemplo n.º 1
0
        public void FilterOrder()
        {
            var list = new List <MessageDisplay>();
            var msg  = new MessageDisplay();

            msg.Fill();
            msg.OccurredOn = new DateTime(2012, 01, 01);
            list.Add(msg);

            msg = new MessageDisplay();
            msg.Fill();
            msg.OccurredOn = new DateTime(2000, 01, 01);
            list.Add(msg);

            var query = new LogQuery();

            query.Initialize();
            var filtered = query.Filter <MessageDisplay>(list);

            Assert.AreEqual <int>(2, filtered.Count());
            var first = filtered.First();
            var last  = filtered.Last();

            Assert.IsTrue(first.OccurredOn > last.OccurredOn);
        }
Exemplo n.º 2
0
        public void FilterTop()
        {
            var list = new List <MessageDisplay>();
            var msg  = new MessageDisplay();

            msg.Fill();
            msg.OccurredOn = new DateTime(2000, 01, 01);
            list.Add(msg);

            msg = new MessageDisplay();
            msg.Fill();
            msg.OccurredOn = new DateTime(2012, 01, 01);
            list.Add(msg);

            var query = new LogQuery();

            query.Initialize();
            query.Top = 1;
            var filtered = query.Filter <MessageDisplay>(list);

            Assert.AreEqual <int>(1, filtered.Count());
            var item = filtered.First();

            Assert.AreEqual <Guid>(msg.Identifier, item.Identifier);
        }
Exemplo n.º 3
0
        public IEnumerable <ErrorDisplay> SelectErrors(LogQuery query)
        {
            Contract.Requires <ArgumentNullException>(null != query);
            Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != query.ApplicationIdentifier, "Application Identifier is empty.");

            Contract.Ensures(Contract.Result <IEnumerable <ErrorDisplay> >() != null);

            using (new PerformanceMonitor())
            {
                query.Initialize();
                var start = query.From.Value;
                var end   = query.To.Value;

                var list = new List <ErrorDisplay>();
                if (query.IsUnique)
                {
                    var item = this.errorTable.Get <ErrorDisplay, ErrorData>(query.PartitionKey, query.RowKey);
                    if (null != item)
                    {
                        list.Add(item);
                    }

                    return(list);
                }
                else if (start < DateTime.UtcNow.AddHours(-6))
                {
                    var history = this.Get <ErrorDisplay>(Error21DaysFormat.FormatWithCulture(query.PartitionKey));

                    if (null != history)
                    {
                        list.AddRange(history.Items);
                        start = history.MaximumDate.HasValue ? history.MaximumDate.Value : start;
                    }
                }

                if (start < end)
                {
                    using (var perf = new PerformanceMonitor())
                    {
                        perf.Append("Pulling from table storage.");
                        var results = this.errorTable.Query <ErrorData>(query);
                        var temp    = results.AsParallel().ToList().Select(d => d.Convert());
                        perf.Append("{0} pulled from table.", temp.Count());
                        list.AddRange(temp);
                    }
                }

                var items = query.Filter <ErrorDisplay>(list);
                if (query.Deep.HasValue && !query.Deep.Value && 1 < items.Count())
                {
                    foreach (var error in items)
                    {
                        error.StackTrace = null;
                    }
                }

                return(items);
            }
        }
Exemplo n.º 4
0
        public void FilterListNull()
        {
            var query = new LogQuery();

            query.Filter <MessageDisplay>(null);
        }