| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Collections.ObjectModel;
 
- using System.Windows.Controls;
 
- using System.Windows.Media;
 
- using Aitex.Core.RT.Event;
 
- using Aitex.Core.UI.View.Common;
 
- using Aitex.Core.Utilities;
 
- using MECF.Framework.Common.Alarms;
 
- using MECF.Framework.UI.Client.ClientBase;
 
- using System.Linq;
 
- using MECF.Framework.Common.OperationCenter;
 
- using Aitex.Core.Util;
 
- namespace MECF.Framework.UI.Client.CenterViews.Alarms.Alarm
 
- {
 
-     public class AlarmViewModel : UiViewModelBase
 
-     {
 
-         [Subscription("System.AlarmTableID")]
 
-         public string CurrentAlarmTable { get; set; }
 
-         [IgnorePropertyChange]
 
-         public List<AlarmItem> AlarmEvents { get; set; }
 
-         public int SelectedIndex { get; set; } = -1;
 
-         private AlarmProvider _alarmProvider = new AlarmProvider();
 
-         public Dictionary<string, Dictionary<string, EventItem>> AllGroupAlarmDic = new Dictionary<string, Dictionary<string, EventItem>>();
 
-         //public List<AlarmDefine> AlarmParameterList { get; set; } = new List<AlarmDefine>();
 
-         private string _txtAnalysisText;
 
-         private long _currentEventID;
 
-         private int _currentEventCount;
 
-         private string _currentEventName;
 
-         public string TxtAnalysisText
 
-         {
 
-             get
 
-             {
 
-                 return _txtAnalysisText;
 
-             }
 
-             set
 
-             {
 
-                 _txtAnalysisText = value;
 
-                 NotifyOfPropertyChange("TxtAnalysisText");
 
-             }
 
-         }
 
-         private bool _clearIsEnabled;
 
-         public bool ClearIsEnabled
 
-         {
 
-             get => _clearIsEnabled;
 
-             set
 
-             {
 
-                 _clearIsEnabled = value;
 
-                 NotifyOfPropertyChange("ClearIsEnabled");
 
-             }
 
-         }
 
-         private bool _abortIsEnabled;
 
-         public bool AbortIsEnabled
 
-         {
 
-             get => _abortIsEnabled;
 
-             set
 
-             {
 
-                 _abortIsEnabled = value;
 
-                 NotifyOfPropertyChange("AbortIsEnabled");
 
-             }
 
-         }
 
-         private bool _retryIsEnabled;
 
-         public bool RetryIsEnabled
 
-         {
 
-             get => _retryIsEnabled;
 
-             set
 
-             {
 
-                 _retryIsEnabled = value;
 
-                 NotifyOfPropertyChange("RetryIsEnabled");
 
-             }
 
-         }
 
-         private bool _continueIsEnabled;
 
-         public bool ContinueIsEnabled
 
-         {
 
-             get => _continueIsEnabled;
 
-             set
 
-             {
 
-                 _continueIsEnabled = value;
 
-                 NotifyOfPropertyChange("ContinueIsEnabled");
 
-             }
 
-         }
 
-         private bool _stopIsEnabled;
 
-         public bool StopIsEnabled
 
-         {
 
-             get => _stopIsEnabled;
 
-             set
 
-             {
 
-                 _stopIsEnabled = value;
 
-                 NotifyOfPropertyChange("StopIsEnabled");
 
-             }
 
-         }
 
-         private bool _removeIsEnabled;
 
-         public bool RemoveIsEnabled
 
-         {
 
-             get => _removeIsEnabled;
 
-             set
 
-             {
 
-                 _removeIsEnabled = value;
 
-                 NotifyOfPropertyChange("RemoveIsEnabled");
 
-             }
 
-         }
 
-         private bool _aGVRetryIsEnabled;
 
-         public bool AGVRetryIsEnabled
 
-         {
 
-             get => _aGVRetryIsEnabled;
 
-             set
 
-             {
 
-                 _aGVRetryIsEnabled = value;
 
-                 NotifyOfPropertyChange("AGVRetryIsEnabled");
 
-             }
 
-         }
 
-         private string _targetModule;
 
-         public string TargetModule
 
-         {
 
-             get
 
-             {
 
-                 return _targetModule;
 
-             }
 
-             set
 
-             {
 
-                 _targetModule = value;
 
-                 NotifyOfPropertyChange("TargetModule");
 
-             }
 
-         }
 
-         public void SetActionIsEnabled(string action)
 
-         {
 
-             if (action == null || action == "")
 
-             {
 
-                 ClearIsEnabled = false;
 
-                 AbortIsEnabled = false;
 
-                 RetryIsEnabled = false;
 
-                 ContinueIsEnabled = false;
 
-                 AGVRetryIsEnabled = false;
 
-                 RemoveIsEnabled = false;
 
-                 StopIsEnabled = false;
 
-             }
 
-             else
 
-             {
 
-                 ClearIsEnabled = action.Contains("Clear") ? true : false;
 
-                 AbortIsEnabled = action.Contains("Abort") ? true : false;
 
-                 RetryIsEnabled = action.Contains("Retry") ? true : false;
 
-                 ContinueIsEnabled = action.Contains("Continue") ? true : false;
 
-                 AGVRetryIsEnabled = action.Contains("AGV RETRY") ? true : false;
 
-                 StopIsEnabled = action.Contains("Stop") ? true : false;
 
-                 RemoveIsEnabled = action.Contains("Remove") ? true : false;
 
-             }
 
-         }
 
-         public void DGOnSelectionChanged()
 
-         {
 
-             //var e = (SelectionChangedEventArgs)obj;
 
-             if (SelectedIndex > -1)
 
-             {
 
-                 AlarmItem item = AlarmEvents[SelectedIndex];
 
-                 //var item = e.AddedItems[0] as AlarmItem;
 
-                 //var findAlarm = AllGroupAlarmDic[CurrentAlarmTable].Values.Where(x => x.EventEnum == item.EventEnum).FirstOrDefault();
 
-                 if (item != null)
 
-                 {
 
-                     SetActionIsEnabled(item.Action.ToString());
 
-                     TxtAnalysisText = string.Format("Event Type:{0}\r\n\r\nEvent ID:{1}\r\n\r\nTime:{2}\r\n\r\nDescription:{3}\r\n\r\nCause:{4}\r\n\r\nRecovery:{5}",
 
-                         item.Type,
 
-                         item.EventId,
 
-                         item.OccuringTime,
 
-                         item.Description,
 
-                         item.Explaination,
 
-                         item.Solution
 
-                     );
 
-                 }
 
-                 else
 
-                 {
 
-                     SetActionIsEnabled("");
 
-                     TxtAnalysisText = string.Format("Event Type:{0}\r\n\r\nEvent ID:{1}\r\n\r\nTime:{2}\r\n\r\nDescription:{3}",
 
-                         item.Type,
 
-                         item.EventId,
 
-                         item.OccuringTime,
 
-                         item.Description
 
-                     );
 
-                 }
 
-                 TargetModule = item.Source;
 
-                 _currentEventID = item.EventId;
 
-                 _currentEventCount = item.Count;
 
-                 _currentEventName = item.EventEnum;
 
-             }
 
-         }
 
-         public AlarmViewModel()
 
-         {
 
-             Subscribe("System.LiveAlarmEvent");
 
-         }
 
-         protected override void OnViewLoaded(object view)
 
-         {
 
-             //var alarmDict = _alarmProvider.GetXmlAlarmList();
 
-             //AllGroupAlarmDic = alarmDict;
 
-             //foreach (var item in AllGroupAlarmList.Keys)
 
-             //{
 
-             //    foreach (var subitem in AllGroupAlarmList[item].Keys)
 
-             //    {
 
-             //        AlarmParameterList.Add(AllGroupAlarmList[item][subitem]);
 
-             //    }
 
-             //}
 
-             base.OnViewLoaded(view);
 
-         }
 
-         protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
 
-         {
 
-             if (data.ContainsKey("System.LiveAlarmEvent"))
 
-                 UpdateAlarmEvent((List<EventItem>)data["System.LiveAlarmEvent"]);
 
-         }
 
-         public void UpdateAlarmEvent(List<EventItem> evItems)
 
-         {
 
-             var alarmEvents = new List<AlarmItem>();
 
-             foreach (EventItem item in evItems.OrderByDescending(p=>p.OccuringTime))
 
-             {
 
-                 var it = new AlarmItem()
 
-                 {
 
-                     Type = item.Level == EventLevel.Alarm ? "Alarm" : (item.Level == EventLevel.Information ? "Info" : "Warning"),
 
-                     OccuringTime = item.OccuringTime.ToString("yyyy/MM/dd HH:mm:ss"),
 
-                     Description = item.Description,
 
-                     EventEnum = item.EventEnum,
 
-                     EventId = item.Id,
 
-                     Explaination = item.Explaination,
 
-                     Solution = item.Solution,
 
-                     Source = item.Source,
 
-                     Count = item.Count,
 
-                     Action = item.Action,
 
-                 };
 
-                 switch (item.Level)
 
-                 {
 
-                     case EventLevel.Alarm: it.TextColor = Brushes.Red; break;
 
-                     case EventLevel.Warning: it.TextColor = Brushes.Yellow; break;
 
-                     default: it.TextColor = Brushes.White; break;
 
-                 }
 
-                 alarmEvents.Add(it);
 
-             }
 
-             if (AlarmEvents == null || (alarmEvents.Count != AlarmEvents.Count))
 
-             {
 
-                 AlarmEvents = alarmEvents;
 
-             }
 
-             else
 
-             {
 
-                 bool isEqual = true;
 
-                 if (alarmEvents.Count == AlarmEvents.Count)
 
-                 {
 
-                     for (int i = 0; i < alarmEvents.Count; i++)
 
-                     {
 
-                         if (!alarmEvents[i].IsEqualTo(AlarmEvents[i]))
 
-                         {
 
-                             isEqual = false;
 
-                             break;
 
-                         }
 
-                     }
 
-                 }
 
-                 if (!isEqual)
 
-                     AlarmEvents = alarmEvents;
 
-             }
 
-             NotifyOfPropertyChange("AlarmEvents");
 
-         }
 
-         public void AlarmAction(string target, string action)
 
-         {
 
-             InvokeClient.Instance.Service.DoOperation($"{target}.AlarmAction", action, _currentEventName);
 
-             TxtAnalysisText = "";
 
-             SetActionIsEnabled("");
 
-         }
 
-     }
 
- }
 
 
  |