/// <summary> /// Gets a filtered list of log events /// </summary> /// <param name="pageIndex">0 based page index</param> /// <param name="pageSize">max number of records to return</param> /// <param name="start">start date</param> /// <param name="end">end date</param> /// <param name="logLevel">The level of the log messages</param> /// <returns>A filtered list of log events</returns> public IQueryable <LogEvent> GetByDateRangeAndType(int pageIndex, int pageSize, DateTime start, DateTime end, string logLevel = "All") { IQueryable <LogEvent> list = from a in _context.ELMAH_Error where a.TimeUtc >= start && a.TimeUtc <= end select new LogEvent { IdType = "guid", Id = "", IdAsInteger = 0, IdAsGuid = a.ErrorId, LoggerProviderName = "Elmah", LogDate = EntityFunctions.AddHours(a.TimeUtc, 8).Value, MachineName = a.Host, Message = a.Message, Type = a.Type, Level = "Error", Source = a.Source, StackTrace = "" }; if (!logLevel.Equals("All", StringComparison.OrdinalIgnoreCase)) { list = list.Where(x => x.Level == logLevel); } return(list.OrderByDescending(d => d.LogDate)); }
/// <summary> /// Gets a filtered list of log events /// </summary> /// <param name="pageIndex">0 based page index</param> /// <param name="pageSize">max number of records to return</param> /// <param name="start">start date</param> /// <param name="end">end date</param> /// <param name="logLevel">The level of the log messages</param> /// <returns>A filtered list of log events</returns> public IQueryable <LogEvent> GetByDateRangeAndType(int pageIndex, int pageSize, DateTime start, DateTime end, string logLevel = "All") { IQueryable <LogEvent> list = (from b in _context.NLog_Record where b.time_stamp >= start && b.time_stamp <= end select new LogEvent { IdType = "number", Id = "", IdAsInteger = b.sequence_id, IdAsGuid = Guid.NewGuid(), LoggerProviderName = "NLog", LogDate = EntityFunctions.AddHours(b.time_stamp, 8).Value, MachineName = b.host, Message = b.message, Type = b.type, Level = b.level, Source = b.source, StackTrace = b.stacktrace }); if (!logLevel.Equals("All", StringComparison.OrdinalIgnoreCase)) { list = list.Where(x => x.Level == logLevel); } return(list.OrderByDescending(d => d.LogDate)); }
public void TimeAddHours() { TimeSpan time = stored.Add(TimeSpan.FromHours(-1)); #if !EFOLD var q = this.Entities .Where(x => DbFunctions.AddHours(x.Time, -1) == time); #else var q = this.Entities .Where(x => EntityFunctions.AddHours(x.Time, -1) == time); #endif q.Should().NotBeEmpty(); }
public void DateTimeAddHours() { DateTime date = stored.AddHours(-1); #if !EFOLD var q = this.Entities .Where(x => DbFunctions.AddHours(x.DateTime, -1) == date); #else var q = this.Entities .Where(x => EntityFunctions.AddHours(x.DateTime, -1) == date); #endif q.Should().NotBeEmpty(); }
public void DateTimeOffsetAddHours() { DateTimeOffset offset = stored.AddHours(-1); #if !EFOLD var q = this.Entities .Where(x => DbFunctions.AddHours(x.Offset, -1) == offset); #else var q = this.Entities .Where(x => EntityFunctions.AddHours(x.Offset, -1) == offset); #endif q.Should().NotBeEmpty(); }