public ArchivedOutageMessage MapOutageEntityToArchived(OutageEntity outage) { ArchivedOutageMessage outageMessage; if (outage.OutageState == OutageState.ARCHIVED) { outageMessage = new ArchivedOutageMessage { OutageId = outage.OutageId, ReportTime = outage.ReportTime, IsolatedTime = outage.IsolatedTime, RepairedTime = outage.RepairedTime, ArchivedTime = outage.ArchivedTime ?? DateTime.UtcNow, OutageElementGid = outage.OutageElementGid, DefaultIsolationPoints = equipmentMapper.MapEquipments(outage.DefaultIsolationPoints), OptimumIsolationPoints = equipmentMapper.MapEquipments(outage.OptimumIsolationPoints), AffectedConsumers = consumerMapper.MapConsumers(outage.AffectedConsumers) }; } else { throw new ArgumentException($"MapOutageEntityToArchived => Outage state: {outage.OutageState}, but {OutageState.ARCHIVED} was expected."); } return(outageMessage); }
public ArchivedOutageViewModel MapArchivedOutage(ArchivedOutageMessage outage) => new ArchivedOutageViewModel { Id = outage.OutageId, ReportedAt = outage.ReportTime, IsolatedAt = outage.IsolatedTime, RepairedAt = outage.RepairedTime, ArchivedAt = outage.ArchivedTime, ElementId = outage.OutageElementGid, DefaultIsolationPoints = _equipmentMapper.MapEquipments(outage.DefaultIsolationPoints), OptimalIsolationPoints = _equipmentMapper.MapEquipments(outage.OptimumIsolationPoints), AffectedConsumers = _consumerMapper.MapConsumers(outage.AffectedConsumers), };
public async Task NotifyArchiveOutageUpdate(ArchivedOutageMessage archivedOutage) { try { Logger.LogDebug($"{baseLogString} NotifyArchiveOutageUpdate => archived outage data => gid: 0x{archivedOutage.OutageElementGid:X16}"); var jsonOutput = JsonConvert.SerializeObject(this.mapper.MapArchivedOutage(archivedOutage)); await this.connection.InvokeAsync("NotifyArchiveOutageUpdate", jsonOutput); Logger.LogDebug($"{baseLogString} NotifyArchiveOutageUpdate => json output sent to outage hub: {jsonOutput}"); } catch (Exception e) { Logger.LogError($"{baseLogString} NotifyArchiveOutageUpdate => Exception: {e.Message}", e); } }
public OutageMessage MapOutageEntity(OutageEntity outage) { OutageMessage outageMessage; if (outage.OutageState != OutageState.ARCHIVED) { outageMessage = new ActiveOutageMessage() { OutageId = outage.OutageId, OutageState = outage.OutageState, ReportTime = outage.ReportTime, IsolatedTime = outage.IsolatedTime, RepairedTime = outage.RepairedTime, OutageElementGid = outage.OutageElementGid, DefaultIsolationPoints = equipmentMapper.MapEquipments(outage.DefaultIsolationPoints), OptimumIsolationPoints = equipmentMapper.MapEquipments(outage.OptimumIsolationPoints), AffectedConsumers = consumerMapper.MapConsumers(outage.AffectedConsumers), IsResolveConditionValidated = outage.IsResolveConditionValidated, }; } else { outageMessage = new ArchivedOutageMessage { OutageId = outage.OutageId, ReportTime = outage.ReportTime, IsolatedTime = outage.IsolatedTime, RepairedTime = outage.RepairedTime, ArchivedTime = outage.ArchivedTime ?? DateTime.UtcNow, OutageElementGid = outage.OutageElementGid, DefaultIsolationPoints = equipmentMapper.MapEquipments(outage.DefaultIsolationPoints), OptimumIsolationPoints = equipmentMapper.MapEquipments(outage.OptimumIsolationPoints), AffectedConsumers = consumerMapper.MapConsumers(outage.AffectedConsumers) }; } return(outageMessage); }
public void NotifyArchiveOutageUpdate(ArchivedOutageMessage archivedOutage) { Console.WriteLine($"Sending archived outage update to Outage Hub. ArchivedOutage[ID: {archivedOutage.OutageId}, ElementGid: {archivedOutage.OutageElementGid}, ArchivedAt: {archivedOutage.ArchivedTime}]"); _proxy.Invoke <string>("NotifyArchiveOutageUpdate", _mapper.MapArchivedOutage(archivedOutage)).Wait(); }