public async Task <GetLogChartsOutput> GetCharts <T>(IRepository <T> repository) where T : class, ILogModel { var now = DateTime.Now; var days = DateTime.DaysInMonth(now.Year, now.Month); var day = now.Day; var output = new GetLogChartsOutput(days); var date = new DateTime(now.Year, now.Month, 1); for (var i = 0; i < days; i++) { if (i > day) { output.All[i] = 0; output.Error[i] = 0; } else { var dayTime = date.AddDays(i); output.All[i] = await repository.CountAsync(x => x.LongDate >= dayTime && x.LongDate <= dayTime.AddHours(23).AddMinutes(59)); output.Error[i] = await repository.CountAsync(x => x.LongDate >= dayTime && x.LongDate <= dayTime.AddHours(23).AddMinutes(59) && x.Level == "ERROR"); } } return(output); }
public async Task <GetLogChartsOutput> GetCharts <T>(IRepository <T> repository) where T : class, ILogModel { var now = DateTime.Now; var hour = now.Hour; var output = new GetLogChartsOutput(24); var date = now.Date; for (var i = 0; i < 24; i++) { if (i > hour) { output.All[i] = 0; output.Error[i] = 0; } else { var startTime = date.AddHours(i); output.All[i] = await repository.Count(x => x.LongDate >= startTime && x.LongDate <= startTime.AddMinutes(59)); output.Error[i] = await repository.Count(x => x.LongDate >= startTime && x.LongDate <= startTime.AddMinutes(59) && x.Level == "ERROR"); } } return(output); }
public async Task <GetLogChartsOutput> GetCharts <T>(IRepository <T> repository) where T : class, ILogModel { var now = DateTime.Now; var dayOfWeek = (int)now.DayOfWeek; dayOfWeek = dayOfWeek == 0 ? 6 : dayOfWeek == 6 ? 0 : dayOfWeek; var output = new GetLogChartsOutput(7); for (var i = 0; i < 7; i++) { if (i > dayOfWeek) { output.All[i] = 0; output.Error[i] = 0; } else { var day = now.AddDays(0 - (dayOfWeek - i)); var weeHours = now.AddDays(i - dayOfWeek).Date.AddHours(23).AddMinutes(59); output.All[i] = await repository.Count(x => x.LongDate >= day.Date && x.LongDate <= weeHours); output.Error[i] = await repository.Count(x => x.LongDate >= day.Date && x.LongDate <= weeHours && x.Level == "ERROR"); } } return(output); }
public async Task <GetLogChartsOutput> GetCharts <T>(IRepository <T> repository) where T : class, ILogModel { var now = DateTime.Now; var dayOfWeek = (int)now.DayOfWeek; dayOfWeek = dayOfWeek == 0 ? 6 : dayOfWeek == 6 ? 0 : dayOfWeek; var output = new GetLogChartsOutput(7); for (var i = 0; i < 7; i++) { if (i > dayOfWeek) { output.All[i] = 0; output.Error[i] = 0; output.Info[i] = 0; output.Debug[i] = 0; output.Fatal[i] = 0; output.Trace[i] = 0; output.Warn[i] = 0; } else { var day = now.AddDays(0 - (dayOfWeek - i)); var weeHours = now.AddDays(i - dayOfWeek).Date.AddHours(23).AddMinutes(59).AddSeconds(59); output.All[i] = await repository.CountAsync(x => x.LongDate >= day.Date && x.LongDate <= weeHours); output.Error[i] = await CountAsync(LogLevelConst.Error, repository, day, weeHours); output.Info[i] = await CountAsync(LogLevelConst.Info, repository, day, weeHours); output.Debug[i] = await CountAsync(LogLevelConst.Debug, repository, day, weeHours); output.Fatal[i] = await CountAsync(LogLevelConst.Fatal, repository, day, weeHours); output.Trace[i] = await CountAsync(LogLevelConst.Trace, repository, day, weeHours); output.Warn[i] = await CountAsync(LogLevelConst.Warn, repository, day, weeHours); } } return(output); }
public async Task <GetLogChartsOutput> GetCharts <T>(IRepository <T> repository) where T : class, ILogModel { var now = DateTime.Now; var hour = now.Hour; var output = new GetLogChartsOutput(24); var date = now.Date; for (var i = 0; i < 24; i++) { if (i > hour) { output.All[i] = 0; output.Error[i] = 0; output.Info[i] = 0; output.Debug[i] = 0; output.Fatal[i] = 0; output.Trace[i] = 0; output.Warn[i] = 0; } else { var startTime = date.AddHours(i); output.All[i] = await repository.CountAsync(x => x.LongDate >= startTime && x.LongDate <= startTime.AddMinutes(59).AddSeconds(59)); output.Error[i] = await CountAsync(LogLevelConst.Error, repository, startTime, i); output.Info[i] = await CountAsync(LogLevelConst.Info, repository, startTime, i); output.Debug[i] = await CountAsync(LogLevelConst.Debug, repository, startTime, i); output.Fatal[i] = await CountAsync(LogLevelConst.Fatal, repository, startTime, i); output.Trace[i] = await CountAsync(LogLevelConst.Trace, repository, startTime, i); output.Warn[i] = await CountAsync(LogLevelConst.Warn, repository, startTime, i); } } return(output); }
public async Task <GetLogChartsOutput> GetCharts <T>(IRepository <T> repository) where T : class, ILogModel { var now = DateTime.Now; var days = DateTime.DaysInMonth(now.Year, now.Month); var day = now.Day; var output = new GetLogChartsOutput(days); var date = new DateTime(now.Year, now.Month, 1); for (var i = 0; i < days; i++) { if (i > day) { output.All[i] = 0; output.Error[i] = 0; output.Info[i] = 0; output.Debug[i] = 0; output.Fatal[i] = 0; output.Trace[i] = 0; output.Warn[i] = 0; } else { var dayTime = date.AddDays(i); output.All[i] = await repository.CountAsync(x => x.LongDate >= dayTime && x.LongDate <= dayTime.AddHours(23).AddMinutes(59).AddSeconds(59)); output.Error[i] = await CountAsync(LogLevelConst.Error, repository, dayTime); output.Info[i] = await CountAsync(LogLevelConst.Info, repository, dayTime); output.Debug[i] = await CountAsync(LogLevelConst.Debug, repository, dayTime); output.Fatal[i] = await CountAsync(LogLevelConst.Fatal, repository, dayTime); output.Trace[i] = await CountAsync(LogLevelConst.Trace, repository, dayTime); output.Warn[i] = await CountAsync(LogLevelConst.Warn, repository, dayTime); } } return(output); }
public async Task <GetLogChartsOutput> GetCharts <T>(IRepository <T> repository) where T : class, ILogModel { var now = DateTime.Now; var minute = now.Minute; var hourTime = DateTime.Now.Date.AddHours(now.Hour); var output = new GetLogChartsOutput(6); for (var i = 0; i < 60; i += 10) { if (i > minute) { output.All[i / 10] = 0; output.Error[i / 10] = 0; output.Info[i / 10] = 0; output.Debug[i / 10] = 0; output.Fatal[i / 10] = 0; output.Trace[i / 10] = 0; output.Warn[i / 10] = 0; } else { output.All[i / 10] = await repository.CountAsync(x => x.LongDate >= hourTime.AddMinutes(i) && x.LongDate <= hourTime.AddMinutes(i + 9).AddSeconds(59)); output.Error[i / 10] = await CountAsync(LogLevelConst.Error, repository, hourTime, i); output.Info[i / 10] = await CountAsync(LogLevelConst.Info, repository, hourTime, i); output.Debug[i / 10] = await CountAsync(LogLevelConst.Debug, repository, hourTime, i); output.Fatal[i / 10] = await CountAsync(LogLevelConst.Fatal, repository, hourTime, i); output.Trace[i / 10] = await CountAsync(LogLevelConst.Trace, repository, hourTime, i); output.Warn[i / 10] = await CountAsync(LogLevelConst.Warn, repository, hourTime, i); } } return(output); }
public async Task <GetLogChartsOutput> GetCharts <T>(IRepository <T> repository) where T : class, ILogModel { var now = DateTime.Now; var minute = now.Minute; var hourTime = DateTime.Now.Date.AddHours(now.Hour); var output = new GetLogChartsOutput(6); for (var i = 0; i < 60; i += 10) { if (i > minute) { output.All[i / 10] = 0; output.Error[i / 10] = 0; } else { output.All[i / 10] = await repository.Count(x => x.LongDate >= hourTime.AddMinutes(i) && x.LongDate <= hourTime.AddMinutes(i + 9)); output.Error[i / 10] = await repository.Count(x => x.LongDate >= hourTime.AddMinutes(i) && x.LongDate <= hourTime.AddMinutes(i + 9) && x.Level == "ERROR"); } } return(output); }