public void ProcessData(SpotsReqmOutput data, Run run, Scenario scenario) { try { _auditEventRepository.Insert(AuditEventFactory.CreateAuditEventForInformationMessage(0, 0, $"Start insert of recommendations. ScenarioId: {data.ScenarioId} Count: {data.Recommendations.Count}")); using (var innerScope = _repositoryFactory.BeginRepositoryScope()) { var recommendationBatchRepository = innerScope.CreateRepository <IRecommendationRepository>(); recommendationBatchRepository.Insert(data.Recommendations, false); recommendationBatchRepository.SaveChanges(); } _auditEventRepository.Insert(AuditEventFactory.CreateAuditEventForInformationMessage(0, 0, $"End insert of recommendations. ScenarioId: {data.ScenarioId}")); } catch (Exception e) { _auditEventRepository.Insert(AuditEventFactory.CreateAuditEventForException(0, 0, $"Error while processing scenario recommendations. ScenarioId: {scenario.Id}", e)); throw; } // do not generate report for scenario with smooth if (run.Smooth) { return; } var fileName = ReportFileNameHelper.RecommendationResult(run, scenario); PreGenerateReport(data.Recommendations, fileName, scenario.Id); }
private void PreGenerateReport(List <ScenarioCampaignLevelResultItem> data, Run run, Scenario scenario) { _auditEventRepository.Insert(AuditEventFactory.CreateAuditEventForInformationMessage(0, 0, $"Start scenario campaign level results report generation. ScenarioId: {scenario.Id} Count: {data.Count}")); try { _campaignResultReportCreator.EnablePerformanceKPIColumns(_includeScenarioPerformanceMeasurementKpIs); _campaignResultReportCreator.EnableCampaignLevel(!_saveData); string fileName = ReportFileNameHelper.ScenarioCampaignResult(scenario, run.ExecuteStartedDateTime.Value); using (var reportStream = _campaignResultReportCreator.GenerateReport(() => ScenarioCampaignResultReportHelper.MapToExtendedResults(data, scenario.CampaignPassPriorities, _mapper))) { _ = _cloudStorage.Upload(new S3UploadComment { BucketName = _awsSettings.S3Bucket, DestinationFilePath = fileName, FileStream = reportStream }); } } catch (Exception e) { _auditEventRepository.Insert( AuditEventFactory.CreateAuditEventForException( 0, 0, $"Error while generating report for scenario campaign level results. ScenarioId: {scenario.Id}", e ) ); throw; } _auditEventRepository.Insert(AuditEventFactory.CreateAuditEventForInformationMessage(0, 0, $"End scenario campaign level results report generation. ScenarioId: {scenario.Id}")); }
public IHttpActionResult GetExportScenarioCampaignResultsLink([FromUri] Guid scenarioId) { var engine = _storageClientFactory.GetEngine(); var run = _runRepository.FindByScenarioId(scenarioId); if (run is null) { return(this.Error().ResourceNotFound(RunNotFoundMessage)); } var scenario = _scenarioRepository.Get(scenarioId); var filePath = ReportFileNameHelper.ScenarioCampaignResult(scenario, run.ExecuteStartedDateTime.Value); var descriptor = new S3FileComment() { BucketName = _awsSettings.S3Bucket, FileNameWithPath = filePath }; if (!engine.FileExists(descriptor)) { using (var excelFileStream = _scenarioCampaignResultReportCreator.GenerateReport( ScenarioCampaignResultReportHelper.MapToExtendedResults( _scenarioCampaignResultRepository.Get(scenarioId)?.Items, scenario.CampaignPassPriorities, _mapper))) { engine.Upload(new S3UploadComment() { BucketName = descriptor.BucketName, DestinationFilePath = descriptor.FileNameWithPath, FileStream = excelFileStream }); } } return(Content(HttpStatusCode.OK, engine.GetPreSignedUrl(descriptor))); }