Example #1
0
        public override IEnumerable <HistoryLogReport> CountByDate(HistoryLogSpecification specification)
        {
            var key = string.Concat(Keyspace, specification.ToKeyString());

            return(m_cache.Get(key, () => base.CountByDate(specification), HistoryLifetime,
                               HistoryDependency(specification.Username)));
        }
Example #2
0
 public IPagedList <HistoryLogItem> SearchHistory(HistoryLogSpecification specification, int?pageIndex, int?pageSize)
 {
     return(WithValid(specification, () =>
     {
         var result = m_historyLogRepository.RetrieveMultiple <HistoryLogSpecification, HistoryLogItem>(
             specification, pageIndex, pageSize, HistoryLogPagingSettings);
         var map = EventMap;
         result.ForEach(x => x.Event = map[x.EventId]);
         return result;
     }));
 }
Example #3
0
 public IEnumerable <HistoryLogReport> CountByDate(HistoryLogSpecification specification)
 {
     return(AllItems()
            .Satisfy(specification)
            .GroupBy(item => item.Timestamp.Date)
            .Select(x => new HistoryLogReport()
     {
         Timestamp = x.Key,
         Count = x.Count()
     })
            .OrderByDescending(x => x.Timestamp)
            .ToList());
 }
Example #4
0
        public static void Specification_DateRange(string expected, string from, string to)
        {
            // Arrange
            var spec = new HistoryLogSpecification()
            {
                DateRange = new Range <DateTime>(DateTime.Parse(from, CultureInfo.InvariantCulture), DateTime.Parse(to, CultureInfo.InvariantCulture))
            };

            // Act
            var result = HistoryLogKeyHelper.Specification(spec);

            // Assert
            Assert.Equal(expected, result);
        }
Example #5
0
 public HistoryLogSpecificationTest()
 {
     m_spec  = new HistoryLogSpecification();
     m_items = new[]
     {
         new HistoryLogItem()
         {
             Timestamp = DateTime.Today, Username = "******", EventId = 1001
         },
         new HistoryLogItem()
         {
             Timestamp = DateTime.Today.AddDays(-2), Username = "******", RelatedTo = "x", EventId = 1005
         }
     };
 }
Example #6
0
        public static void Specification_Events(string expected, string events)
        {
            // Arrange
            var spec = new HistoryLogSpecification()
            {
                DateRange = new Range <DateTime>(new DateTime(2011, 02, 13), new DateTime(2011, 02, 14)),
                Events    = events.Split(';').Translate(s => Int16.Parse(s, CultureInfo.InvariantCulture)).ToArray()
            };

            // Act
            var result = HistoryLogKeyHelper.Specification(spec);

            // Assert
            Assert.Equal(expected, result);
        }
Example #7
0
        public static void Specification_EventId(string expected, int eventid)
        {
            // Arrange
            var spec = new HistoryLogSpecification()
            {
                DateRange = new Range <DateTime>(new DateTime(2011, 02, 13), new DateTime(2011, 02, 14)),
                EventId   = (short)eventid
            };

            // Act
            var result = HistoryLogKeyHelper.Specification(spec);

            // Assert
            Assert.Equal(expected, result);
        }
Example #8
0
        public static void Specification_Username(string expected, string username)
        {
            // Arrange
            var spec = new HistoryLogSpecification()
            {
                Username  = username,
                DateRange = new Range <DateTime>(new DateTime(2011, 02, 13), new DateTime(2011, 02, 14))
            };

            // Act
            var result = HistoryLogKeyHelper.Specification(spec);

            // Assert
            Assert.Equal(expected, result);
        }
Example #9
0
 public virtual IEnumerable <HistoryLogReport> CountByDate(HistoryLogSpecification specification)
 {
     return(m_innerRepository.CountByDate(specification));
 }