Ejemplo n.º 1
0
        private DataTableResponse FetchDatabaseCheckGridData(EnvironmentCheckService svc, EnvironmentCheckViewModel viewModel)
        {
            var grid = svc.DatabaseDetails(viewModel.GridConditions, viewModel.DatabaseFilterConditions, viewModel.DatabaseFilterOperands);

            var aaDataRel = grid.Data.Select(d => new String[] {
                d.ServerName, d.SQLVersion, d.AdHocWorkLoad.ToString(), d.MaxServerMemory.ToString("f2"),
                d.MaxDegreeOfParallelism.ToString(), d.TempDBDataFiles.ToString(), d.LastSQLRestart.ToString("MMM dd, yyyy")
            }).ToArray();

            var data = new FilterResult()
            {
                Data = aaDataRel, TotalRecordCount = grid.Count
            };

            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);
        }
Ejemplo n.º 2
0
        private string FetchFileDatabaseData(EnvironmentCheckService svc, EnvironmentCheckViewModel viewModel)
        {
            var grid = svc.DatabaseDetails(viewModel.GridConditions, viewModel.DatabaseFilterConditions, viewModel.DatabaseFilterOperands);

            var aaDataRel = grid.Data.Select(d => new String[] {
                d.ServerName, d.SQLVersion, d.AdHocWorkLoad.ToString(), d.MaxServerMemory.ToString("f2"),
                d.MaxDegreeOfParallelism.ToString(), d.TempDBDataFiles.ToString(), d.LastSQLRestart.ToString("MMM dd, yyyy")
            }).ToArray();

            var filterResult = new FilterResult()
            {
                Data = aaDataRel, TotalRecordCount = grid.Count
            };

            using (var sw = new System.IO.StringWriter())
            {
                var heaaderArr = new string[]
                {
                    "Server Name", "SQL Version", "Ad Hoc Workload", "Max Server Memory (GB)", "Max Degree of Parallelism", "TempDB Data Files", "Last SQL Restart",
                };
                sw.WriteLine(string.Join(",", heaaderArr));
                foreach (var row in filterResult.Data)
                {
                    sw.WriteCsvSafeLine(row);
                }
                return(sw.ToString());
            }
        }