Beispiel #1
0
 private void OnDataChange(ConveyorBasicInfo info, string name)
 {
     try
     {
         if (info != null)
         {
             if (info.ActiveAlarms != null)
             {
                 var alarmToDel = from a in AlarmList
                                  where a.Unit == name && !info.ActiveAlarms.Contains(Convert.ToInt32(a.AlarmID))
                                  select a;
                 alarmToDel.ToList().ForEach(p => AlarmList.Remove(p));
                 var alarmToAdd = from a in info.ActiveAlarms
                                  where  AlarmList.FirstOrDefault(p => p.Unit == name && p.AlarmID == a.ToString("000000")) == null
                                  select new AlarmViewModel
                 {
                     AlarmID     = a.ToString("000000"),
                     Unit        = name,
                     Severity    = EnumAlarmSeverity.Error,
                     Status      = EnumAlarmStatus.Active,
                     Text        = ResourceReader.GetString(string.Format("ALARM_{0}", a.ToString("000000"))),
                     ArrivedTime = DateTime.Now,
                     AckTime     = null
                 };
                 alarmToAdd.ToList().ForEach(p => AlarmList.Add(p));
             }
         }
     }
     catch (Exception e)
     {
         _warehouse.AddEvent(Database.Event.EnumSeverity.Error, Database.Event.EnumType.Exception, e.Message);
         throw new Exception(string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message));
     }
 }
Beispiel #2
0
        public async Task ExecuteRefresh()
        {
            try
            {
                var si = SelectedItem;

                var al  = AlarmList;
                var als = await _warehouse.DBService.GetAlarms(DateFrom.TimeStamp, DateTo.TimeStamp, Unit, ID, Status);

                al.Clear();
                foreach (var a in als)
                {
                    al.Add(new AlarmViewModel
                    {
                        Alarm = a,
                        Text  = ResourceReader.GetString(string.Format("ALARM_{0}", a.AlarmID.PadLeft(6, '0')))
                    });
                }
                AlarmList = al;

                if (si != null)
                {
                    SelectedItem = AlarmList.FirstOrDefault(p => p.ArrivedTime == si.ArrivedTime &&
                                                            p.AlarmID == si.AlarmID &&
                                                            p.Unit == si.Unit &&
                                                            p.Status == si.Status);
                }

                Records = AlarmList.Count;
            }
            catch (Exception e)
            {
                _warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception,
                                    string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message));
            }
        }