| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528 | 
							- using Aitex.Core.RT.Event;
 
- using Caliburn.Micro.Core;
 
- using MECF.Framework.Common.Alarms;
 
- using MECF.Framework.Common.OperationCenter;
 
- using MECF.Framework.UI.Client.CenterViews.Alarms;
 
- using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
 
- using MECF.Framework.UI.Client.ClientBase;
 
- using OpenSEMI.ClientBase;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Collections.ObjectModel;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Windows;
 
- namespace MECF.Framework.UI.Client.CenterViews.Parameter
 
- {
 
-     public class AlarmtableParameterViewModel : ModuleUiViewModelBase
 
-     {
 
-         public bool IsPermission { get => this.Permission == 3; }
 
-         private AlarmProvider _alarmProvider = new AlarmProvider();
 
-         public ObservableCollection<AlarmParameterOperation> AlarmParameterOperations { get; set; } = new ObservableCollection<AlarmParameterOperation>();
 
-         public ObservableCollection<string> AlarmGroups { get; set; } = new ObservableCollection<string>();
 
-         public ObservableCollection<string> TableList { get; set; } = new ObservableCollection<string>();
 
-         private int _alarmGroupsWidth = 285;
 
-         public string SelectedAlarmGroup { get; set; }
 
-         public int AlarmGroupsWidth
 
-         {
 
-             get => _alarmGroupsWidth;
 
-             set
 
-             {
 
-                 _alarmGroupsWidth = value;
 
-                 NotifyOfPropertyChange("AlarmGroupsWidth");
 
-             }
 
-         }
 
-         private List<string> _groupNames = new List<string>
 
-            (new string[] {
 
-             "Group1",
 
-             "Group2",
 
-             "Group3",
 
-             "Group4",
 
-             "Group5",
 
-             "Group6",
 
-             "Group7",
 
-             "Group8",
 
-             "Group9",
 
-             "Group10"
 
-            });
 
-         public Dictionary<string, Dictionary<string, EventItem>> AllGroupAlarmList = new Dictionary<string, Dictionary<string, EventItem>>();
 
-         public List<string> GroupNames
 
-         {
 
-             get => _groupNames;
 
-             set
 
-             {
 
-                 _groupNames = value;
 
-                 NotifyOfPropertyChange("GroupNames");
 
-             }
 
-         }
 
-         public int SelectedAlarmTableIndex = 0;
 
-         public string EntryValue;
 
-         public Visibility _alarmTableVisibility = Visibility.Collapsed;
 
-         public Visibility AlarmTableVisibility
 
-         {
 
-             get => _alarmTableVisibility;
 
-             set
 
-             {
 
-                 _alarmTableVisibility = value;
 
-                 NotifyOfPropertyChange("AlarmTableVisibility");
 
-             }
 
-         }
 
-         public Visibility _alarmGroupsVisibility = Visibility.Collapsed;
 
-         public Visibility AlarmGroupsVisibility
 
-         {
 
-             get => _alarmGroupsVisibility;
 
-             set
 
-             {
 
-                 _alarmGroupsVisibility = value;
 
-                 if (_alarmGroupsVisibility == Visibility.Visible)
 
-                 { AlarmGroupsWidth = 235; }
 
-                 else
 
-                 {
 
-                     AlarmGroupsWidth = 0;
 
-                 }
 
-                 NotifyOfPropertyChange("AlarmGroupsVisibility");
 
-             }
 
-         }
 
-         protected override void OnViewLoaded(object view)
 
-         {
 
-             base.OnViewLoaded(view);
 
-             var alarmDict = _alarmProvider.GetXmlAlarmList();
 
-             AllGroupAlarmList = alarmDict;
 
-             SetVisibility();
 
-         }
 
-         private void SetVisibility()
 
-         {
 
-             if (AllGroupAlarmList != null)
 
-             {
 
-                 if (AllGroupAlarmList.Count < 2)
 
-                 {
 
-                     AlarmTableVisibility = Visibility.Collapsed;
 
-                     if (AllGroupAlarmList.Count != 0)
 
-                     {
 
-                         AlarmParameterOperations.Clear();
 
-                         foreach (var subitem in AllGroupAlarmList[AllGroupAlarmList.Keys.FirstOrDefault()].Keys)
 
-                         {
 
-                             AlarmParameterOperations.Add(new AlarmParameterOperation(subitem, AllGroupAlarmList[AllGroupAlarmList.Keys.FirstOrDefault()][subitem]));
 
-                         }
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     AlarmTableVisibility = Visibility.Visible;
 
-                     TableList.Clear();
 
-                     foreach (var item in AllGroupAlarmList.Keys)
 
-                     {
 
-                         TableList.Add(item);
 
-                     }
 
-                     AlarmParameterOperations.Clear();
 
-                     foreach (var subitem in AllGroupAlarmList[AllGroupAlarmList.Keys.FirstOrDefault()].Keys)
 
-                     {
 
-                         AlarmParameterOperations.Add(new AlarmParameterOperation(subitem, AllGroupAlarmList[AllGroupAlarmList.Keys.FirstOrDefault()][subitem]));
 
-                     }
 
-                 }
 
-                 SetAlarmGroup(AllGroupAlarmList.Keys.FirstOrDefault());
 
-             }
 
-             else
 
-             {
 
-                 AlarmTableVisibility = Visibility.Hidden;
 
-             }
 
-         }
 
-         public void AlarmTableSelected(string index)
 
-         {
 
-             SaveAlarmGroup();
 
-             int tempValue = int.Parse(index);
 
-             SelectedAlarmTableIndex = tempValue;
 
-             SelectedAlarmGroup = string.Empty;
 
-             AlarmParameterOperations.Clear();
 
-             SetAlarmGroup(index);
 
-         }
 
-         private void SetAlarmGroup(string index)
 
-         {
 
-             AlarmGroups.Clear();
 
-             var categoryList = AllGroupAlarmList[index].Values.Select(x => x.Category);
 
-             foreach (var item in categoryList)
 
-             {
 
-                 if (!AlarmGroups.Contains(item))
 
-                 {
 
-                     AlarmGroups.Add(item);
 
-                 }
 
-             }
 
-             if (AlarmGroups.Count < 2)
 
-             {
 
-                 AlarmGroupsVisibility = Visibility.Collapsed;
 
-                 AlarmParameterOperations.Clear();
 
-                 foreach (var subitem in AllGroupAlarmList[AllGroupAlarmList.Keys.FirstOrDefault()].Keys)
 
-                 {
 
-                     AlarmParameterOperations.Add(new AlarmParameterOperation(subitem, AllGroupAlarmList[AllGroupAlarmList.Keys.FirstOrDefault()][subitem]));
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 AlarmGroupsVisibility = Visibility.Visible;
 
-                 AlarmParameterOperations.Clear();
 
-                 foreach (var subitem in AllGroupAlarmList[index].Keys)
 
-                 {
 
-                     AlarmParameterOperations.Add(new AlarmParameterOperation(subitem, AllGroupAlarmList[index][subitem]));
 
-                 }
 
-             }
 
-         }
 
-         private void SaveAlarmGroup()
 
-         {
 
-             foreach (var item in AlarmParameterOperations)
 
-             {
 
-                 AllGroupAlarmList[SelectedAlarmTableIndex.ToString()][item.AlarmName].Id = item.ID;
 
-                 AllGroupAlarmList[SelectedAlarmTableIndex.ToString()][item.AlarmName].Source = item.Source;
 
-                 AllGroupAlarmList[SelectedAlarmTableIndex.ToString()][item.AlarmName].Description = item.Description;
 
-                 AllGroupAlarmList[SelectedAlarmTableIndex.ToString()][item.AlarmName].Solution = item.Solution;
 
-                 AllGroupAlarmList[SelectedAlarmTableIndex.ToString()][item.AlarmName].Explaination = item.Explaination;
 
-                 AllGroupAlarmList[SelectedAlarmTableIndex.ToString()][item.AlarmName].Bypass = item.Bypass;
 
-                 AllGroupAlarmList[SelectedAlarmTableIndex.ToString()][item.AlarmName].Group = (EventGroup)Enum.Parse(typeof(EventGroup), item.Group);
 
-                 AllGroupAlarmList[SelectedAlarmTableIndex.ToString()][item.AlarmName].Editable = item.IsEdit;
 
-             }
 
-         }
 
-         public void AlarmTableSave()
 
-         {
 
-             SaveAlarmGroup();
 
-             InvokeClient.Instance.Service.DoOperation($"System.UpdateAlarmTable", AllGroupAlarmList);
 
-         }
 
-         /// <summary>
 
-         /// 按照Id号或者Alarm文本查找
 
-         /// </summary>
 
-         /// <param name="alarmId"></param>
 
-         /// <param name="alarmText"></param>
 
-         public void AlarmValueFind(string alarmId, string alarmText)
 
-         {
 
-             if (!string.IsNullOrWhiteSpace(alarmId) || !string.IsNullOrWhiteSpace(alarmText))
 
-             {
 
-                 AlarmParameterOperations.Clear();
 
-                 bool b1, b2, b3, b4;
 
-                 if (!string.IsNullOrEmpty(SelectedAlarmGroup))
 
-                 {
 
-                     foreach(var alarmOperation in AllGroupAlarmList[SelectedAlarmTableIndex.ToString()])
 
-                     {
 
-                         b1 = alarmOperation.Value.Category == SelectedAlarmGroup;
 
-                         b2 = string.IsNullOrWhiteSpace(alarmId) && alarmOperation.Value.Description.ToLower().Contains(alarmText.ToLower());
 
-                         b3 = string.IsNullOrWhiteSpace(alarmText) && alarmOperation.Value.Id.ToString() == alarmId;
 
-                         b4 = !string.IsNullOrWhiteSpace(alarmId) && !string.IsNullOrWhiteSpace(alarmText) && alarmOperation.Value.Id.ToString() == alarmId && alarmOperation.Value.Description.ToLower().Contains(alarmText.ToLower());
 
-                         if (b1 && (b2 || b3 || b4))
 
-                         {
 
-                             AlarmParameterOperations.Add(new AlarmParameterOperation(alarmOperation.Key, alarmOperation.Value));
 
-                         }
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     foreach (var alarmOperation in AllGroupAlarmList[SelectedAlarmTableIndex.ToString()])
 
-                     {
 
-                         b2 = string.IsNullOrWhiteSpace(alarmId) && alarmOperation.Value.Description.ToLower().Contains(alarmText.ToLower());
 
-                         b3 = string.IsNullOrWhiteSpace(alarmText) && alarmOperation.Value.Id.ToString() == alarmId;
 
-                         b4 = !string.IsNullOrWhiteSpace(alarmId) && !string.IsNullOrWhiteSpace(alarmText) && alarmOperation.Value.Id.ToString() == alarmId && alarmOperation.Value.Description.ToLower().Contains(alarmText.ToLower());
 
-                         if (b2 || b3 || b4)
 
-                         {
 
-                             AlarmParameterOperations.Add(new AlarmParameterOperation(alarmOperation.Key, alarmOperation.Value));
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 DialogBox.ShowWarning("Please input condition!");
 
-             }
 
-         }
 
-         public void AlarmTableAllOn()
 
-         {
 
-             if (DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No, DialogType.CONFIRM, "Whether all switches are turned on?") == DialogButton.Yes)
 
-             {
 
-                 EntryValue = "AllOn";
 
-                 GetAlarmParameterOperations();
 
-             }
 
-         }
 
-         public void AlarmTableAllOff()
 
-         {
 
-             if (DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No, DialogType.CONFIRM, "Whether all switches are turned off?") == DialogButton.Yes)
 
-             {
 
-                 EntryValue = "AllOff";
 
-                 GetAlarmParameterOperations();
 
-             }
 
-         }
 
-         public void AlarmTableCancel()
 
-         {
 
-         }
 
-         public void GetAlarmParameterOperations()
 
-         {
 
-             if (AllGroupAlarmList == null || AllGroupAlarmList.Count == 0) return;
 
-             foreach (var item in AllGroupAlarmList[SelectedAlarmTableIndex.ToString()])
 
-             {
 
-                 if (AlarmGroups.Count < 2)
 
-                 {
 
-                     if (EntryValue == "AllOn")
 
-                         item.Value.Bypass = true;
 
-                     else if (EntryValue == "AllOff")
 
-                         item.Value.Bypass = false;
 
-                 }
 
-                 else
 
-                 {
 
-                     if (SelectedAlarmGroup != null)
 
-                     {
 
-                         if (item.Value.Category == SelectedAlarmGroup)
 
-                         {
 
-                             if (EntryValue == "AllOn")
 
-                                 item.Value.Bypass = true;
 
-                             else if (EntryValue == "AllOff")
 
-                                 item.Value.Bypass = false;
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             AlarmParameterOperations.Clear();
 
-             IEnumerable<KeyValuePair<string, EventItem>> findGroupAlarm;
 
-             if (SelectedAlarmGroup != null)
 
-             {
 
-                 findGroupAlarm = AllGroupAlarmList[SelectedAlarmTableIndex.ToString()].Where(x => x.Value.Category == SelectedAlarmGroup);
 
-             }
 
-             else
 
-             {
 
-                 findGroupAlarm = AllGroupAlarmList[SelectedAlarmTableIndex.ToString()];
 
-             }
 
-             foreach (var item in findGroupAlarm)
 
-             {
 
-                 AlarmParameterOperations.Add(new AlarmParameterOperation(item.Key, item.Value));
 
-             }
 
-         }
 
-         public void AlarmTypeSelected(object obj)
 
-         {
 
-             var tempobj = obj;
 
-             var selectedAlarmGroup = (string)tempobj;
 
-             SelectedAlarmGroup = selectedAlarmGroup;
 
-             SaveAlarmGroup();
 
-             AlarmParameterOperations.Clear();
 
-             var findGroupAlarm = AllGroupAlarmList[SelectedAlarmTableIndex.ToString()].Where(x => x.Value.Category == selectedAlarmGroup);
 
-             foreach (var item in findGroupAlarm)
 
-             {
 
-                 AlarmParameterOperations.Add(new AlarmParameterOperation(item.Key, item.Value));
 
-             }
 
-         }
 
-         public class AlarmParameterOperation : PropertyChangedBase
 
-         {
 
-             public AlarmParameterOperation()
 
-             { }
 
-             private string _alarmName;
 
-             public string AlarmName
 
-             {
 
-                 get => _alarmName;
 
-                 set
 
-                 {
 
-                     _alarmName = value;
 
-                     NotifyOfPropertyChange("AlarmName");
 
-                 }
 
-             }
 
-             private string _source;
 
-             public string Source
 
-             {
 
-                 get => _source;
 
-                 set
 
-                 {
 
-                     _source = value;
 
-                     NotifyOfPropertyChange("Source");
 
-                 }
 
-             }
 
-             private long _id;
 
-             public long ID
 
-             {
 
-                 get => _id;
 
-                 set
 
-                 {
 
-                     _id = value;
 
-                     NotifyOfPropertyChange("ID");
 
-                 }
 
-             }
 
-             private string _description;
 
-             public string Description
 
-             {
 
-                 get => _description;
 
-                 set
 
-                 {
 
-                     _description = value;
 
-                     NotifyOfPropertyChange("Description");
 
-                 }
 
-             }
 
-             private string _solution;
 
-             public string Solution
 
-             {
 
-                 get => _solution;
 
-                 set
 
-                 {
 
-                     _solution = value;
 
-                     NotifyOfPropertyChange("Solution");
 
-                 }
 
-             }
 
-             private string _explaination;
 
-             public string Explaination
 
-             {
 
-                 get => _explaination;
 
-                 set
 
-                 {
 
-                     _explaination = value;
 
-                     NotifyOfPropertyChange("Explaination");
 
-                 }
 
-             }
 
-             private bool _bypass;
 
-             public bool Bypass
 
-             {
 
-                 get => _bypass;
 
-                 set
 
-                 {
 
-                     _bypass = value;
 
-                     NotifyOfPropertyChange("Bypass");
 
-                 }
 
-             }
 
-             private string _group;
 
-             public string Group
 
-             {
 
-                 get => _group;
 
-                 set
 
-                 {
 
-                     _group = value;
 
-                     NotifyOfPropertyChange("Group");
 
-                 }
 
-             }
 
-             private bool _isEdit;
 
-             public bool IsEdit
 
-             {
 
-                 get => _isEdit;
 
-                 set
 
-                 {
 
-                     _isEdit = value;
 
-                     NotifyOfPropertyChange("IsEdit");
 
-                 }
 
-             }
 
-             private int _selectedIndex;
 
-             public int SelectedIndex
 
-             {
 
-                 get => _selectedIndex;
 
-                 set
 
-                 {
 
-                     _selectedIndex = value;
 
-                     NotifyOfPropertyChange("SelectedIndex");
 
-                 }
 
-             }
 
-             public AlarmParameterOperation(string key, EventItem eventItem)
 
-             {
 
-                 AlarmName = key;
 
-                 if (eventItem != null)
 
-                 {
 
-                     ID = eventItem.Id;
 
-                     Source = eventItem.Source;
 
-                     Description = eventItem.Description;
 
-                     Solution = eventItem.Solution;
 
-                     Explaination = eventItem.Explaination;
 
-                     Bypass = eventItem.Bypass;
 
-                     if (eventItem.Group == EventGroup.Group0)
 
-                         eventItem.Group = EventGroup.Group1;
 
-                     Group = eventItem.Group.ToString();
 
-                     IsEdit = eventItem.Editable;
 
-                 }
 
-             }
 
-             public AlarmParameterOperation(string alarmParameterStr)
 
-             {
 
-                 if (alarmParameterStr != null)
 
-                 {
 
-                     var alarmPar = alarmParameterStr.Split(',');
 
-                     if (alarmPar != null && alarmPar.Length > 0)
 
-                     {
 
-                         _id = int.Parse(alarmPar[0]);
 
-                         //_isSave = bool.Parse(alarmPar[1]);
 
-                         _group = alarmPar[2];
 
-                         _isEdit = bool.Parse(alarmPar[3]);
 
-                     }
 
-                 }
 
-             }
 
-             public override string ToString()
 
-             {
 
-                 string rtnString = $"{_id},{_group},{_isEdit}";
 
-                 return rtnString;
 
-             }
 
-         }
 
-         public class ShowAlarmGroup : PropertyChangedBase
 
-         {
 
-             private string _name;
 
-             public string Name
 
-             {
 
-                 get => _name; set
 
-                 {
 
-                     _name = value;
 
-                     NotifyOfPropertyChange("Name");
 
-                 }
 
-             }
 
-             private string _display;
 
-             public string Display
 
-             {
 
-                 get => _display; set
 
-                 {
 
-                     _display = value;
 
-                     NotifyOfPropertyChange("Display");
 
-                 }
 
-             }
 
-             private bool _bvalue = false;
 
-             public bool AlarmBoolValue
 
-             {
 
-                 get { return _bvalue; }
 
-                 set { _bvalue = value; NotifyOfPropertyChange("AlarmBoolValue"); }
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |