Пример #1
0
        private string MakeJsonPayload(AlarmSystem.Core.Entity.DB.AlarmLog al)
        {
            string errorMessage = $"Machine {al.Machine.Name}, {al.Machine.Type} has triggered alarm with code {al.Alarm.Code}";
            string jsonPayload  = JsonConvert.SerializeObject(new { data = new { message = errorMessage } });

            return(jsonPayload);
        }
Пример #2
0
        private AlarmSystem.Core.Entity.DB.AlarmLog CreateAlarmLog(SendAlertModel sam)
        {
            AlarmSystem.Core.Entity.DB.Alarm   alarm   = _alarmService.GetAlarmByCode(sam.AlarmCode);
            AlarmSystem.Core.Entity.DB.Machine machine = _machineService.GetMachineById(sam.MachineId);
            var  date       = DateTime.UtcNow;
            long epochOfNow = new DateTimeOffset(date).ToUnixTimeMilliseconds();

            AlarmSystem.Core.Entity.DB.AlarmLog al = new AlarmSystem.Core.Entity.DB.AlarmLog()
            {
                Alarm = alarm, Machine = machine, Date = epochOfNow
            };

            _alarmLogService.CreateAlarmLog(al);

            return(al);
        }