public static RunSummary SuccessfulRunSummary( string runId, TimeSpan elapsed, ProcessingNotificationsCollector processingNotificationsCollector, ProcessLogSetResult processLogSetResult, WorkbookGeneratorResults workbookGeneratorResults, PublisherResults publisherResults) { return(new RunSummary( runId, elapsed, processingNotificationsCollector, processLogSetResult, workbookGeneratorResults, publisherResults, null, ExitReason.CompletedSuccessfully)); }
private RunSummary( string runId, TimeSpan elapsed, ProcessingNotificationsCollector processingNotificationsCollector, ProcessLogSetResult processLogSetResult, WorkbookGeneratorResults workbookGeneratorResults, PublisherResults publisherResults, string reasonForFailure, ExitReason exitReason) { RunId = runId; Elapsed = elapsed; ExitReason = exitReason; ProcessingNotificationsCollector = processingNotificationsCollector; WorkbookGeneratorResults = workbookGeneratorResults; ProcessLogSetResult = processLogSetResult; PublisherResults = publisherResults; ReasonForFailure = reasonForFailure; }
public static RunSummary FailedRunSummary( string runId, string errorMessage, ExitReason exitReason = ExitReason.UnclassifiedError, ProcessingNotificationsCollector processingNotificationsCollector = null, TimeSpan?elapsed = null, ProcessLogSetResult processLogSetResult = null, WorkbookGeneratorResults workbookGeneratorResults = null, PublisherResults publisherResults = null) { return(new RunSummary( runId, elapsed ?? TimeSpan.Zero, processingNotificationsCollector, processLogSetResult, workbookGeneratorResults, publisherResults, errorMessage, exitReason)); }
public WorkbookGeneratorResults CompleteWorkbooksWithResults(WritersStatistics writersStatistics) { _logger.LogInformation("Starting to generate workbooks with results..."); var availableTemplates = WorkbookGeneratorCommon.GenerateWorkbookTemplatesList(_config.WorkbookTemplatesDirectory, _config.CustomWorkbookTemplatesDirectory, _logger); var applicableTemplates = WorkbookGeneratorCommon.SelectTemplatesApplicableToThisRun(availableTemplates, writersStatistics); var nonEmptyExtractNames = WorkbookGeneratorCommon.GetNonEmptyExtractNames(writersStatistics); var results = new WorkbookGeneratorResults(new List <CompletedWorkbookInfo>(), availableTemplates); foreach (var template in applicableTemplates) { var templateWorkbookPath = template.Path; var hasAnyData = WorkbookGeneratorCommon.HasAnyData(template, nonEmptyExtractNames); var baseWorkbookName = template.Name + _config.CustomWorkbookSuffix; var finalWorkbookName = hasAnyData ? baseWorkbookName : $"{baseWorkbookName} [No Data]"; var destinationWorkbookPath = Path.Combine(_workbooksOutputDir, $"{finalWorkbookName}.twb"); try { CopyWorkbookToOutput(templateWorkbookPath, destinationWorkbookPath); ReplaceConnectionInWorkbook(destinationWorkbookPath); results.CompletedWorkbooks.Add(new CompletedWorkbookInfo(template.Name, finalWorkbookName, destinationWorkbookPath, hasAnyData)); } catch (Exception ex) { var message = $"Exception occurred while generating workbook {template.Name}. Exception: {ex.Message}"; _logger.LogError(message); results.CompletedWorkbooks.Add(new CompletedWorkbookInfo(template.Name, finalWorkbookName, workbookPath: null, hasAnyData: false, new WorkbookGeneratingException("", ex))); } } return(results); }