Пример #1
0
 public async Task Initiate(EAndonMessage msg)
 {
     lock (activeEandon)
     {
         activeEandon[msg.AlertId] = msg;
     }
     await msg.SendMqttMessage(mqttManager).ConfigureAwait(false);
 }
Пример #2
0
        public async Task Acknowledge(EAndonMessage eAndon)
        {
            EAndonMessage oldMsg;

            lock (activeEandon)
            {
                if (!activeEandon.TryGetValue(eAndon.AlertId, out oldMsg))
                {
                    oldMsg = eAndon;
                }
                oldMsg.Acknowledge(eAndon.InitiatedBy, eAndon.InitiateTime, eAndon.SlaLevel);
                activeEandon[eAndon.AlertId] = oldMsg;
            }
            await oldMsg.SendMqttMessage(mqttManager).ConfigureAwait(false);

            Console.WriteLine($"{oldMsg.AlertId} : {oldMsg.AcknowledgeBy} has raised been acknowledged");
        }
        private static (EandonStatus, EAndonMessage) ParseEmailBody(string body)
        {
            var bodyLines = body.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();
            var alertId   = bodyLines.GetValue("Alert ID:");
            var alert     = bodyLines.GetValue("Alert:");
            var alertType = bodyLines.GetValue("Alert Type:");
            var location  = bodyLines.GetValue("Location:");
            var status    = bodyLines.GetValue("Status:");
            var slaLevel  = int.Parse(bodyLines.GetValue("SLA Level:"), CultureInfo.InvariantCulture);

            var latestHistory = bodyLines[bodyLines.Count - 3]
                                .Split(new string[] { " / " }, StringSplitOptions.RemoveEmptyEntries);

            var userName  = latestHistory.Last().Split(':')[0];
            var timeStamp = latestHistory.First().GetTimeStamp();

            var stationMsg = new EAndonMessage(
                alertId: alertId,
                alert: alert,
                alertType: alertType,
                location: location,
                initiatedBy: userName,
                initiateTime: timeStamp,
                slaLevel: slaLevel);

            EandonStatus enumStatus = EandonStatus.Unknown;

            if (status.Contains("Initiated"))
            {
                enumStatus = EandonStatus.Initiated;
            }
            else if (status.Contains("Acknowledged"))
            {
                enumStatus = EandonStatus.Acknowledge;
            }
            else if (status.Contains("Resolved"))
            {
                enumStatus = EandonStatus.Resolved;
            }
            return(enumStatus, stationMsg);
        }
Пример #4
0
        public async Task ChangeStatus(EandonStatus status, EAndonMessage msg)
        {
            switch (status)
            {
            case EandonStatus.Initiated:
                await this.Initiate(msg).ConfigureAwait(false);

                this.dirty = true;
                break;

            case EandonStatus.Acknowledge:
                await this.Acknowledge(msg).ConfigureAwait(false);

                this.dirty = true;
                break;

            case EandonStatus.Resolved:
                await this.Resolve(msg).ConfigureAwait(false);

                this.dirty = true;
                break;
            }
        }