public async Task <bool> PublishOutageAsync(Topic topic, OutageMessage outageMessage) { bool success; try { OutagePublication outagePublication = new OutagePublication(topic, outageMessage); var publisherClient = PublisherClient.CreateClient(); await publisherClient.Publish(outagePublication, MicroserviceNames.OmsOutageLifecycleService); Logger.LogInformation($"{baseLogString} PublishOutage => Outage service published data to topic: {outagePublication.Topic}"); success = true; } catch (Exception e) { string message = $"{baseLogString} PublishOutage => exception: {e.Message}"; Logger.LogError(message, e); success = false; } return(success); }
private async Task PublishScadaData(Topic topic, ScadaMessage scadaMessage) { string verboseMessage = $"{baseLogString} entering PublishScadaData method."; Logger.LogVerbose(verboseMessage); try { ScadaPublication scadaPublication = new ScadaPublication(topic, scadaMessage); IPublisherContract publisherClient = PublisherClient.CreateClient(); await publisherClient.Publish(scadaPublication, MicroserviceNames.ScadaModelProviderService); Logger.LogInformation($"{baseLogString} PublishScadaData => SCADA service published data of topic: {scadaPublication.Topic}, publisher name: {MicroserviceNames.ScadaModelProviderService}"); } catch (Exception e) { string errorMessage = $"{baseLogString} PublishScadaData => exception {e.Message}"; Logger.LogError(errorMessage, e); throw e; } StringBuilder sb = new StringBuilder(); sb.AppendLine($"{baseLogString} PublishScadaData => MeasurementCache content: "); var enumerableMeasurementCache = await MeasurementsCache.GetEnumerableDictionaryAsync(); foreach (long gid in enumerableMeasurementCache.Keys) { ModbusData data = enumerableMeasurementCache[gid]; if (data is AnalogModbusData analogModbusData) { sb.AppendLine($"Analog data line: [gid] 0x{gid:X16}, [value] {analogModbusData.Value}, [alarm] {analogModbusData.Alarm}"); } else if (data is DiscreteModbusData discreteModbusData) { sb.AppendLine($"Discrete data line: [gid] 0x{gid:X16}, [value] {discreteModbusData.Value}, [alarm] {discreteModbusData.Alarm}"); } else { sb.AppendLine($"UNKNOWN data type: {data.GetType()}"); } } Logger.LogDebug(sb.ToString()); }
public ImapEmailClient CreateClient() => new ImapEmailClient( new ImapEmailMapper(), new OutageEmailParser(), PublisherClient.CreateClient(), new GraphHubDispatcher());
public ImapIdleEmailClient CreateClient() => new ImapIdleEmailClient( new ImapEmailMapper(), new OutageEmailParser(), PublisherClient.CreateClient());