public HistoryDBManagerService(StatefulServiceContext context) : base(context) { this.logger = CloudLoggerFactory.GetLogger(ServiceEventSource.Current, context); this.baseLogString = $"{this.GetType()} [{this.GetHashCode()}] =>{Environment.NewLine}"; Logger.LogDebug($"{baseLogString} Ctor => Logger initialized"); try { this.historyDBManagerProvider = new HistoryDBManager(this.StateManager); this.reportServiceProvider = new ReportService(); this.outageModelAccessProvider = new OutageModelAccess(); this.consumerAccessProvider = new ConsumerAccess(); this.equipmentAccessProvider = new EquipmentAccess(); this.notifyNetworkModelUpdateProvider = new OmsHistoryNotifyNetworkModelUpdate(this.StateManager); this.transactionActorProvider = new OmsHistoryTransactionActor(this.StateManager); this.historySubscriber = new HistorySubscriber(this.StateManager, this.historyDBManagerProvider); string infoMessage = $"{baseLogString} Ctor => Contract providers initialized."; Logger.LogInformation(infoMessage); } catch (Exception e) { string errorMessage = $"{baseLogString} Ctor => Exception caught: {e.Message}."; Logger.LogError(errorMessage, e); } }
public async Task <ReportViewModel> Handle(GenerateReportCommand request, CancellationToken cancellationToken) { IReportingContract reportingClient = ReportingClient.CreateClient(); try { Logger.LogInformation("[ReportCommandHandler::GenerateReport] Sending a Generate command to Outage service."); var options = new ReportOptions { Type = (ReportType)request.Options.Type, ElementId = request.Options.ElementId, StartDate = request.Options.StartDate, EndDate = request.Options.EndDate }; var report = await reportingClient.GenerateReport(options); return(new ReportViewModel { Data = report.Data, Type = report.Type }); } catch (Exception ex) { Logger.LogError("[ReportCommandHandler::GenerateReport] Failed to generate active outages from Outage service.", ex); throw ex; } }