Ejemplo n.º 1
0
        public ActiveOutageMessage MapOutageEntityToActive(OutageEntity outage)
        {
            ActiveOutageMessage 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
            {
                throw new ArgumentException($"MapOutageEntityToActive => Outage state: { OutageState.ARCHIVED}.");
            }


            return(outageMessage);
        }
Ejemplo n.º 2
0
 public ActiveOutageViewModel MapActiveOutage(ActiveOutageMessage outage)
 => new ActiveOutageViewModel
 {
     Id         = outage.OutageId,
     State      = (OutageLifecycleState)outage.OutageState,
     ReportedAt = outage.ReportTime,
     IsolatedAt = outage.IsolatedTime,
     RepairedAt = outage.RepairedTime,
     ElementId  = outage.OutageElementGid,
     IsResolveConditionValidated = outage.IsResolveConditionValidated,
     DefaultIsolationPoints      = _equipmentMapper.MapEquipments(outage.DefaultIsolationPoints),
     OptimalIsolationPoints      = _equipmentMapper.MapEquipments(outage.OptimumIsolationPoints),
     AffectedConsumers           = _consumerMapper.MapConsumers(outage.AffectedConsumers),
 };
        public async Task NotifyActiveOutageUpdate(ActiveOutageMessage activeOutage)
        {
            try
            {
                Logger.LogDebug($"{baseLogString} NotifyActiveOutageUpdate => active outage data => gid: 0x{activeOutage.OutageElementGid:X16}");

                var jsonOutput = JsonConvert.SerializeObject(this.mapper.MapActiveOutage(activeOutage));
                await this.connection.InvokeAsync("NotifyActiveOutageUpdate", jsonOutput);

                Logger.LogDebug($"{baseLogString} NotifyActiveOutageUpdate => json output sent to outage hub: {jsonOutput}");
            }
            catch (Exception e)
            {
                Logger.LogError($"{baseLogString} NotifyActiveOutageUpdate => Exception: {e.Message}", e);
            }
        }
Ejemplo n.º 4
0
        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 NotifyActiveOutageUpdate(ActiveOutageMessage activeOutage)
 {
     Console.WriteLine($"Sending active outage update to Outage Hub. ActiveOutage[ID: {activeOutage.OutageId}, State: {activeOutage.OutageState}, ElementGid: {activeOutage.OutageElementGid}, ReportedAt: {activeOutage.ReportTime} IsolatedAt: {activeOutage.IsolatedTime} RepairedAt {activeOutage.RepairedTime}]");
     _proxy.Invoke <string>("NotifyActiveOutageUpdate", _mapper.MapActiveOutage(activeOutage)).Wait();
 }