public void Can_Generate_Google_Json_String_Table() { var config = JsonConfigReader<SqlReportConfig>.GetConfig(@"C:\Projects\JsonHtmlTable\json\sqlReportConfig.json"); config.ReportName = "jobFiles"; var jsonTableGenerator = new JsonHtmlTableGenerator(config); var jsonReport = jsonTableGenerator.GetJsonTable(JsonHtmlTableType.Google); Assert.IsTrue(jsonReport.Length > 0); }
public ContentResult Report() { var s = new JsonSerializer<List<ConnectionStringConfig>>(); var x = s.DeserializeFromReader(new StreamReader(HttpContext.Server.MapPath("../json") + "\\" + "ConnectionStrings.json")); var reportConfig = new SqlReportConfig { ReportTemplateRoot = HttpContext.Server.MapPath("../sql") + "\\", ReportName = "employeeList", ConnectionString = "Data Source=CORPSPLRPTDB1;Initial Catalog=ApplicationLog;Persist Security Info=True;Trusted_Connection=True;" }; var jsonHtmlTableGenerator = new JsonHtmlTableGenerator(reportConfig); var jsonHtmlTable = jsonHtmlTableGenerator.GetJsonTable(JsonHtmlTableType.DataTables); return new ContentResult { Content = jsonHtmlTable, ContentType = "application/json" }; }
public ContentResult Table(SqlReportRequest sqlReportRequest) { var sqlReportConfig = BaseReportConfig(); var connectionStringConfig = ConnectionStrings().Where( cs => cs.DB.ToLower().Equals(sqlReportRequest.DB.ToLower()) && cs.Server.ToLower().Equals(sqlReportRequest.Server.ToLower())).FirstOrDefault(); if (connectionStringConfig == null) throw new Exception("No Valid Connection String Exists for: Server = " + sqlReportRequest.Server + " and DB = " + sqlReportRequest.DB); sqlReportConfig.ConnectionString = connectionStringConfig.ConnectionString; sqlReportConfig.ReportName = sqlReportRequest.DB + "." + sqlReportRequest.Report; var jsonHtmlTableGenerator = new JsonHtmlTableGenerator(sqlReportConfig); string jsonHtmlTable = jsonHtmlTableGenerator.GetJsonTable(JsonHtmlTableType.DataTables); return new ContentResult {Content = jsonHtmlTable, ContentType = "application/json"}; }