public HttpResponseMessage GenerateCSV() { //Initialize service and model properties var connectionFactory = new HelperConnectionFactory(ConnectionHelper.Helper()); var sqlRepo = new SqlServerRepository(connectionFactory); var reportRepository = new LegacyRecoverabilityIntegrityReportRepository(connectionFactory); var svc = new BackupDbccService(sqlRepo, reportRepository); var qualityIndicatorService = new QualityIndicatorService(new QualityIndicatorConfigurationService(new ConfigurationRepository(connectionFactory))); var model = PopulateModelSettings(); 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("RecoveryObjectives-{0}.csv", DateTime.Now.ToString("yyyyMMdd-HHmmss")); return(message); }
public HttpResponseMessage Databases() { //Initialize service and model properties var connectionFactory = new HelperConnectionFactory(ConnectionHelper.Helper()); var sqlRepo = new SqlServerRepository(connectionFactory); var reportRepository = new LegacyRecoverabilityIntegrityReportRepository(connectionFactory); var svc = new BackupDbccService(sqlRepo, reportRepository); var model = PopulateModelSettings(); var qualityIndicatorService = new QualityIndicatorService(new QualityIndicatorConfigurationService(new ConfigurationRepository(connectionFactory))); var session = (HttpSessionState)GetSession(); session[DataTableSessionConstants.RecoveryObjectivesState] = model; //Get the data var dtResponse = FetchGridData(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 void Setup() { this.reportRepository = new LegacyRecoverabilityIntegrityReportRepository(ConnectionFactorySetup.ConnectionFactory); }