private FilterResult FilterData(SystemLoadService svc, SystemLoadWaitsViewModel viewModel, bool isDownload, IQualityIndicatorService qualityIndicatorService) { var grid = svc.Waits(viewModel.GridConditions, viewModel.FilterConditions, viewModel.FilterOperands); var sysInfo = svc.ReadSystemInformation().ToList(); var aaData = grid.Data.Select(d => new string[] { $"{d.SummaryDayHour.ToShortDateString()} {d.SummaryDayHour.ToString("t")}", $"{d.Server} ({d.ServerId})", isDownload ? d.OverallScore.ToString() :$"<span class='{qualityIndicatorService.GetCssClassForScore(d.OverallScore, false)}'>{d.OverallScore}</span>", $"{d.SignalWaitsRatio}%", d.PercentOfCPUThreshold.ToString("f2"), isDownload ? d.WaitType : $"<div style='display:inline-block;' title='{d.WaitDescription}'>{d.WaitType}</div>", d.SignalWaitTime.ToString(), d.TotalWaitTime.ToString(), d.DifferentialWaitingTasksCount.ToString(), d.IsPoisonWait ? "Yes" : "No", d.IsActiveWeeklySample ? "Yes" : "No" }).ToArray(); return(new kCura.PDD.Web.Controllers.FilterResult() { Data = aaData, TotalRecordCount = grid.Count }); }
private FilterResult FilterData(SystemLoadService svc, SystemLoadServerViewModel viewModel, bool IsDownload, IQualityIndicatorService qualityIndicatorService) { var grid = svc.ServerHours(viewModel.GridConditions, viewModel.FilterConditions, viewModel.FilterOperands); var sysInfo = svc.ReadSystemInformation().ToList(); var aaData = grid.Data.Select(d => new string[] { IsDownload ? $"{d.SummaryDayHour.ToShortDateString()} {d.SummaryDayHour.ToString("t")}" : $"<a href='{GetPageUrl(Names.Tab.ServerHealth, "ServerHealth", $"startDate={d.SummaryDayHour.ToShortDateString()}&endDate={d.SummaryDayHour.ToShortDateString()}")}' target='_parent'>{ d.SummaryDayHour.ToShortDateString()} {d.SummaryDayHour.ToString("t")} </a>", IsDownload ? string.Format("{0} ({1})", d.Server, d.ServerId) : string.Format(@"<div style=""display:inline-block"" title=""{0}"" data-placement=""right"">{1}</div>", (sysInfo.FirstOrDefault(i => i.ServerArtifactId == d.ServerId) ?? new SystemInformation()).SummaryHtml, string.Format("{0} ({1})", d.Server, d.ServerId) ), d.ServerType, IsDownload ? d.OverallScore.ToString() : $"<span class='{qualityIndicatorService.GetCssClassForScore(d.OverallScore, false)}'>{d.OverallScore}</span>", IsDownload ? d.CPUScore.ToString() : $"<a href='{GetPageUrl(Names.Tab.ServerHealth, "ServerHealth", $"startDate={d.SummaryDayHour.ToShortDateString()}&endDate={d.SummaryDayHour.ToShortDateString()}&measureType={(int)MeasureTypes.Processor}")}' target='_parent'>" + $"<span class='{qualityIndicatorService.GetCssClassForScore(d.CPUScore, false)}'>{d.CPUScore}</span>" + $"</a>", IsDownload ? d.RAMScore.ToString() : $"<a href='{GetPageUrl(Names.Tab.ServerHealth, "ServerHealth", $"startDate={d.SummaryDayHour.ToShortDateString()}&endDate={d.SummaryDayHour.ToShortDateString()}&measureType={(int)MeasureTypes.Ram}")}' target='_parent'>" + $"<span class='{qualityIndicatorService.GetCssClassForScore(d.RAMScore, false)}'>{d.RAMScore}</span>" + $"</a>", IsDownload || d.ServerType != "SQL" ? d.FriendlyMemorySignalStateScore : $"<div style='display:inline-block' title='{d.MemorySignalStateRatio}% occurence of low memory<br/>{d.Pageouts} pageout(s)' data-placement='right'>" + $"<span class='{qualityIndicatorService.GetCssClassForScore(d.MemorySignalStateScore, false)}'>{d.MemorySignalStateScore}</span>" + $"</div>", IsDownload || d.ServerType != "SQL" ? d.FriendlyWaitsScore : $"<a href='{GetPageUrl(d.ServerId, "Waits", $"Server={d.ServerId}&Hour={d.SummaryDayHour.ToString("s")}")}' target='_self'>" + $"<b class='{qualityIndicatorService.GetCssClassForScore(d.WaitsScore, false)}'>{d.FriendlyWaitsScore}</b>" + $"</a>", IsDownload || d.ServerType != "SQL" ? d.FriendlyVirtualLogFilesScore :$"<div style='display:inline-block' title='{(d.MaxVirtualLogFiles > 0 ? d.MaxVirtualLogFiles + "virtual log file(s)" : string.Empty)}' data-placement='right'>" + $"<b class='{qualityIndicatorService.GetCssClassForScore(d.VirtualLogFilesScore, false)}'>{d.FriendlyVirtualLogFilesScore}</b>" + $"</div>", IsDownload || d.ServerType != "SQL" ? d.FriendlyLatencyScore : $"<div style='display:inline-block' " + $"title='{(!string.IsNullOrEmpty(d.HighestLatencyDatabase) ? string.Format("{0} ({1} File)<br/>Read Latency: {2} ms<br/>Write Latency: {3} ms", d.HighestLatencyDatabase, d.DatabaseFileType, d.ReadLatencyMs, d.WriteLatencyMs) : string.Empty)} ' data-placement='right'>" + $"<b class='{qualityIndicatorService.GetCssClassForScore(d.LatencyScore, false)}'>{d.FriendlyLatencyScore}</b>" + $"</div>", d.IsActiveWeeklySample ? "Yes" : "No" }).ToArray(); return(new kCura.PDD.Web.Controllers.FilterResult() { Data = aaData, TotalRecordCount = grid.Count }); }
/// <summary> /// Translates a Server view into grid data /// </summary> /// <param name="viewModel"></param> /// <returns></returns> private DataTableResponse FetchServerGridData(SystemLoadService svc, SystemLoadWaitsViewModel viewModel, IQualityIndicatorService qualityIndicatorService) { var data = FilterData(svc, viewModel, false, qualityIndicatorService); var dtResponse = new DataTableResponse() { sEcho = string.IsNullOrEmpty(viewModel.GridConditions.sEcho) ? "1" : viewModel.GridConditions.sEcho, aaData = data.Data, recordsTotal = data.Data.Count(), recordsFiltered = data.TotalRecordCount }; return(dtResponse); }
private string FetchFileData(SystemLoadService svc, SystemLoadWaitsViewModel viewModel, IQualityIndicatorService qualityIndicatorService) { var filterResult = FilterData(svc, viewModel, true, qualityIndicatorService); using (var sw = new System.IO.StringWriter()) { var heaaderArr = new string[] { "Hour", "Server", "Waits Score", "Signal Waits Ratio", "Processor Time Utilization", "Wait Type", "Signal Wait Time (ms)", "Total Wait Time (ms)", "Waiting Task Count", "Poison Wait", "Weekly Sample" }; sw.WriteLine(string.Join(",", heaaderArr)); foreach (var row in filterResult.Data) { sw.WriteCsvSafeLine(row); } return(sw.ToString()); } }
private string FetchFileData(SystemLoadService svc, SystemLoadServerViewModel viewModel, IQualityIndicatorService qualityIndicatorService) { var filterResult = FilterData(svc, viewModel, true, qualityIndicatorService); using (var sw = new System.IO.StringWriter()) { var heaaderArr = new string[] { "Hour", "Server", "Server Type", "Overall Score", "CPU Utilization Score", "RAM Utilization Score", "SQL Memory Signal Score", "SQL Waits Score", "Virtual Log Files Score", "Latency Score", "Weekly Sample" }; sw.WriteLine(string.Join(",", heaaderArr)); foreach (var row in filterResult.Data) { sw.WriteCsvSafeLine(row); } return(sw.ToString()); } }
public HttpResponseMessage Waits() { //Initialize service and model properties var connectionFactory = new HelperConnectionFactory(ConnectionHelper.Helper()); var sqlRepo = new SqlServerRepository(connectionFactory); var svc = new SystemLoadService(sqlRepo); var model = PopulateServerModelSettings(); var qualityIndicatorService = new QualityIndicatorService(new QualityIndicatorConfigurationService(new ConfigurationRepository(connectionFactory))); var session = (HttpSessionState)GetSession(); session[DataTableSessionConstants.SystemLoadWaitsState] = model; //Get the data var dtResponse = FetchServerGridData(svc, model, qualityIndicatorService); //Serialize response var json = dtResponse.ToJson(); var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json"); return(response); }
public HttpResponseMessage GenerateCSV() { //Initialize service and model properties var connectionFactory = new HelperConnectionFactory(ConnectionHelper.Helper()); var sqlRepo = new SqlServerRepository(connectionFactory); var svc = new SystemLoadService(sqlRepo); var qualityIndicatorService = new QualityIndicatorService(new QualityIndicatorConfigurationService(new ConfigurationRepository(connectionFactory))); var model = PopulateServerModelSettings(); model.GridConditions.StartRow = 1; model.GridConditions.EndRow = int.MaxValue; //Get the data var fetchedData = FetchFileData(svc, model, qualityIndicatorService); //Serialize response HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK); message.Content = new StringContent(fetchedData); message.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/csv"); message.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); message.Content.Headers.ContentDisposition.FileName = string.Format("SystemLoadWaits-{0}.csv", DateTime.Now.ToString("yyyyMMdd-HHmmss")); return(message); }
public Waits() : base(lookingGlassDependency: true) { _systemLoad = new SystemLoadService(this.SqlRepo); _indicatorService = new QualityIndicatorService(new QualityIndicatorConfigurationService(this.SqlRepo.ConfigurationRepository)); }
public SystemLoadServers() : base(true) { _systemLoad = new SystemLoadService(this.SqlRepo); _indicatorService = new QualityIndicatorService(new QualityIndicatorConfigurationService(this.SqlRepo.ConfigurationRepository)); }