public IActionResult Logs( DateTime start_Date , DateTime end_Date , string log_name , int selectedPeriod = 0 ) { StaticMethods.Check_dates(ref start_Date, ref end_Date, selectedPeriod); ViewBag.start_Date = start_Date; ViewBag.end_Date = end_Date; string tree = ""; switch (log_name) { case "ReportsRunHistory": var records = context.StgReportsUsage.Select(r => new { RemoteIp = r.RemoteIp.Trim() == ""? "Background" : r.RemoteIp, r.ReportName, r.AccessDate }) .Where(r => r.AccessDate <= end_Date && r.AccessDate >= start_Date) .OrderBy(r => r.RemoteIp).ThenBy(r => r.ReportName).ThenBy(r => r.AccessDate) .ToList(); tree = JsonConvert.SerializeObject(StaticMethods.BuildTree_Generic(records)); break; case "BackgroundTasks": tree = JsonConvert.SerializeObject(StaticMethods.BuildTree_Generic(context.StgBackgroundTasklogs.Select(r => new { r.TimerName, r.Type.Typename, r.LogDateTime , Message = r.Message != null?r.Message:"" }) .Where(r => r.LogDateTime <= end_Date && r.LogDateTime >= start_Date) .OrderBy(r => r.TimerName) .ThenBy(r => r.Typename) .ThenBy(r => r.LogDateTime) .ThenBy(r => r.LogDateTime) .ToList())); break; default: break; } ; ViewBag.Json = tree; ViewBag.JsTreePlugins = @"[""wholerow"", ""search""]"; return(View("Logs")); }