private void Initialize(RecoveryObjectivesViewModel model) { var json = new JavaScriptSerializer().Serialize(model); VarscatState.Value = json; TimezoneOffset.Value = RequestService.GetTimezoneOffset(this.Request).ToString(); SampleStart.Value = base.GlassInfo.MinSampleDate.GetValueOrDefault(DateTime.UtcNow).ToString("s"); }
/// <summary> /// Translates a Backup/DBCC view into grid data /// </summary> /// <param name="viewModel"></param> /// <returns></returns> private DataTableResponse FetchGridData(BackupDbccService svc, RecoveryObjectivesViewModel 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(BackupDbccService svc, RecoveryObjectivesViewModel viewModel, IQualityIndicatorService qualityIndicatorService) { var filterResult = FilterData(svc, viewModel, true, qualityIndicatorService); using (var sw = new System.IO.StringWriter()) { var heaaderArr = new string[] { "Server", "Database Name", "RPO Score", "RTO Score", "Potential Data Loss (Minutes)", "Estimated Time to Recover (Hours)" }; sw.WriteLine(string.Join(",", heaaderArr)); foreach (var row in filterResult.Data) { sw.WriteCsvSafeLine(row); } return(sw.ToString()); } }
private FilterResult FilterData(BackupDbccService svc, RecoveryObjectivesViewModel viewModel, bool isDownload, IQualityIndicatorService qualityIndicatorService) { var grid = svc.RecoveryObjectivesSummary(viewModel.GridConditions, viewModel.FilterConditions, viewModel.FilterOperands); var aaData = grid.Data.Select(d => new string[] { $"{d.ServerName} ({d.ServerId})", d.DatabaseName, isDownload ? d.RPOScore.ToString() : $"<span class='{qualityIndicatorService.GetCssClassForScore(d.RPOScore, false)}'>{d.RPOScore}</span>", isDownload ? d.RTOScore.ToString() :$"<span class='{qualityIndicatorService.GetCssClassForScore(d.RTOScore, false)}'>{d.RTOScore}</span>", d.PotentialDataLossMinutes.ToString(), d.EstimatedTimeToRecoverHours.ToString() }).ToArray(); return(new kCura.PDD.Web.Controllers.FilterResult() { Data = aaData, TotalRecordCount = grid.Count }); }