Beispiel #1
0
        private static ShortMessageService CreateSmsPacket(PrinterEvent newPrinterEvent, string emailAddress)
        {
            var newPacket = new ShortMessageService
            {
                ViaEmailAddress = emailAddress,
            };

            newPacket.Subject = newPrinterEvent.Status;

            while (newPacket.Subject.Contains("  "))
            {
                newPacket.Subject = newPacket.Subject.Replace("  ", " ");
            }
            newPacket.Message = newPrinterEvent.ToString();
            return(newPacket);
        }
Beispiel #2
0
        public PrinterEvent EventParse(List <string> queue)
        {
            var eventLines = new List <string>();

            eventLines.InsertRange(0, queue);

            if (eventLines[0].Length > 80)
            {
                if (eventLines[0].StartsWith("FIRE ALARM"))
                {
                    var tempString = eventLines[0].Substring(80);
                    eventLines[0] = tempString;
                }
            }

            eventLines[0] += new string(' ', 41);
            eventLines[1] += new string(' ', 80);

            var newPrinterEvent = new PrinterEvent();

            newPrinterEvent.Status = eventLines[0].Substring(0, 41).Trim();

            // time is missing the 'M'. Must be added for proper DateTime processing.
            string tempTime         = eventLines[1].Substring(41, 10).Trim();
            string ModifiedTempTime = $"{tempTime}M";

            // combine date and time into a DateTime
            string tempDate     = eventLines[1].Substring(55, 13).Trim();
            var    tempDateTime = DateTime.Parse($"{tempDate} {ModifiedTempTime}");

            newPrinterEvent.SourceAddress = eventLines[1].Substring(68).Trim();
            newPrinterEvent.SourceNode    = eventLines[1].Substring(68, 4).Trim();
            newPrinterEvent.FullDateTime  = tempDateTime;
            newPrinterEvent.RawEventData  = eventLines;

            SendToClients(newPrinterEvent.ToString(), newPrinterEvent.SourceNode);
            return(newPrinterEvent);
        }