public ActionResult Manage(string Period, string LoggerProviderName, string LogLevel, int? page, int? PageSize) { string defaultPeriod = Session["Period"] == null ? "Today" : Session["Period"].ToString(); string defaultLogType = Session["LoggerProviderName"] == null ? "All" : Session["LoggerProviderName"].ToString(); string defaultLogLevel = Session["LogLevel"] == null ? "Error" : Session["LogLevel"].ToString(); LoggingManageModel model = new LoggingManageModel(); model.Period = (Period == null) ? defaultPeriod : Period; model.LoggerProviderName = (LoggerProviderName == null) ? defaultLogType : LoggerProviderName; model.LogLevel = (LogLevel == null) ? defaultLogLevel : LogLevel; model.CurrentPageIndex = page.HasValue ? page.Value - 1 : 0; model.PageSize = PageSize.HasValue ? PageSize.Value : 20; TimePeriod timePeriod = TimePeriodHelper.GetUtcTimePeriod(model.Period); model.LogEvents = loggingRepository.GetByDateRangeAndType(model.CurrentPageIndex, model.PageSize, timePeriod.Start, timePeriod.End, model.LoggerProviderName, model.LogLevel); ViewData["Period"] = model.Period; ViewData["LoggerProviderName"] = model.LoggerProviderName; ViewData["LogLevel"] = model.LogLevel; ViewData["PageSize"] = model.PageSize; //ViewData["Message"] = ""; //Session["Message"] = "";// if it exists... Session["Period"] = model.Period; Session["LoggerProviderName"] = model.LoggerProviderName; Session["LogLevel"] = model.LogLevel; return View(model); }
public ActionResult btnDelete(string Period, string LoggerProviderName, string LogLevel) { try { string defaultPeriod = Session["Period"] == null ? "Today" : Session["Period"].ToString(); string defaultLogType = Session["LoggerProviderName"] == null ? "All" : Session["LoggerProviderName"].ToString(); string defaultLogLevel = Session["LogLevel"] == null ? "Error" : Session["LogLevel"].ToString(); LoggingManageModel model = new LoggingManageModel(); model.LogSourceName = LoggerProviderName; model.Period = (Period == null) ? defaultPeriod : Period; model.LoggerProviderName = (LoggerProviderName == null) ? defaultLogType : LoggerProviderName; model.LogLevel = (LogLevel == null) ? defaultLogLevel : LogLevel; //model.CurrentPageIndex = page.HasValue ? page.Value - 1 : 0; //model.PageSize = PageSize.HasValue ? PageSize.Value : 20; string[] logLevels = new string[] { }; if (LogLevel == "All") { logLevels = new string[] { "All", "Debug", "Info", "Warn", "Error", "Fatal" }; } else { logLevels = new string[] { LogLevel }; } TimePeriod timePeriod = TimePeriodHelper.GetUtcTimePeriod(Period); model.StartDate = timePeriod.Start; model.EndDate = timePeriod.End; // all of them or only one if (LoggerProviderName == "All") { foreach (string providerName in loggingRepository.GetLogProviders().Keys) { loggingRepository.ClearLog(providerName, model.StartDate, model.EndDate, logLevels); } } else { loggingRepository.ClearLog(model.LogSourceName, model.StartDate, model.EndDate, logLevels); } // show a message that it was successfull. Session["Message"] = "The Log Has Been Cleared";// had to use session I couldn't get it to pass between views return RedirectToAction("Manage"); } catch (Exception ex) { //ViewData["Message"] = ex.Message.ToString(); Session["Message"] = ex.Message.ToString(); //NLogLogger logger = new NLogLogger(); //logger.Error(ex); //Log4NetLogger logger2 = new Log4NetLogger(); //logger2.Error(ex); return RedirectToAction("Manage"); } }
public ActionResult btnFilter(string Period, string LoggerProviderName, string LogLevel, int? page, int? PageSize) { // NOTE: Might be able to polish this out more and abstract this to something more common // because it's used by three different ActionResult method calls on this page. // These values may or not already exist in the grand scheme. string defaultPeriod = Session["Period"] == null ? "Today" : Session["Period"].ToString(); string defaultLogType = Session["LoggerProviderName"] == null ? "All" : Session["LoggerProviderName"].ToString(); string defaultLogLevel = Session["LogLevel"] == null ? "Error" : Session["LogLevel"].ToString(); LoggingManageModel model = new LoggingManageModel(); model.Period = (Period == null) ? defaultPeriod : Period; model.LoggerProviderName = (LoggerProviderName == null) ? defaultLogType : LoggerProviderName; model.LogLevel = (LogLevel == null) ? defaultLogLevel : LogLevel; model.CurrentPageIndex = page.HasValue ? page.Value - 1 : 0; model.PageSize = PageSize.HasValue ? PageSize.Value : 20; TimePeriod timePeriod = TimePeriodHelper.GetUtcTimePeriod(model.Period);// Slick... model.LogEvents = loggingRepository.GetByDateRangeAndType(model.CurrentPageIndex, model.PageSize, timePeriod.Start, timePeriod.End, model.LoggerProviderName, model.LogLevel); ViewData["Period"] = model.Period; ViewData["LoggerProviderName"] = model.LoggerProviderName; ViewData["LogLevel"] = model.LogLevel; ViewData["PageSize"] = model.PageSize; ViewData["Message"] = ""; Session["Message"] = "";// if it exists... Session["Period"] = model.Period; Session["LoggerProviderName"] = model.LoggerProviderName; Session["LogLevel"] = model.LogLevel; return View(model); }