private void onRestAlarmCSVChanged(RestEventArgs arg) { if (RestAlarmCSVChanged != null) { RestAlarmCSVChanged(null, arg); } }
public async Task <List <RestorationAlarmList> > GetRestorationAlarmListTimeDscAsync() { RestEventArgs args = new RestEventArgs(); try { args.message = "Read DB Success"; args.TimeStamp = DateTime.Now; return(await this._RestAlarmContext.RestorationAlarmList .OrderByDescending(c => c.DateTime) .Take(1) .ToListAsync <RestorationAlarmList>()); } catch { args.message = "Read DB Fail"; args.TimeStamp = DateTime.Now; return(null); } finally { //Send Event after Get All DigitalInfo onRestAlarmDBChanged(args); //Raise the Event } }
private void OnRestAlarmChanged(object source, RestEventArgs arg) { if (arg.message == "Start Success") { CustAlarmViewModel = _queryAlarmViewModel; } }
//Auto Get Station Name when DB has been loaded. private void OnRestAlarmChanged(object source, RestEventArgs arg) { if (arg.message == "hasLoaded") { // Adding Station ComboBox items foreach (var Station in RestAlarmsRepo.StationsName) { mstationItems.Add(new Item(Station.ToString(), "StationName")); } // Adding Priority ComboBox items foreach (var Priority in RestAlarmsRepo.Priority) { mpriorityItems.Add(new Item(Priority.ToString(), "Priority")); } // Adding Priority ComboBox items mpfieldItems.Add(new Item("PointName", "FieldName")); mpfieldItems.Add(new Item("Message", "FieldName")); //mpfieldItems.Add(new Item("Priority", "FieldName")); mpfieldItems.Add(new Item("GroupPointName", "FieldName")); mpfieldItems.Add(new Item("GroupDescription", "FieldName")); } }
public async Task <List <DigitalPointInfo> > GetAllDigitalPointInfoAsync() { RestEventArgs args = new RestEventArgs(); try { args.message = "Read DB Success"; args.TimeStamp = DateTime.Now; return(await _RestAlarmContext.DigitalPointInfoes .Where(c => !(string.IsNullOrEmpty(c.MACName))) .ToListAsync <DigitalPointInfo>()); } catch { args.message = "Read DB Fail"; args.TimeStamp = DateTime.Now; return(null); } finally { //Send Event after Get All DigitalInfo onRestAlarmDBChanged(args); //Raise the Event } }
private void OnRestAlarmChanged(object source, RestEventArgs arg) { if (arg.message == "Start Success") { // Adding AlarmListFields ComboBox items //foreach (var AlarmListField in RestAlarmsRepo.AlarmListFields) //{ // if (AlarmListField != null) // AlarmListFields.Add(new AlarmFieldModel { FieldName = AlarmListField.ToString() }); //} //AlarmListFields = CollectionViewSource.GetDefaultView(m_AlarmListFields); } }
private bool exeCheckNewAlarmListCSV() { RestEventArgs args = new RestEventArgs(); int iStartIndex = 0; if (this._nLastAlarmRecIndex >= 0) //If Start program m_nLastAlarmRecIndex is set to -1 see also Alarm4Restoration() { for (int iIndex = 0; iIndex < this._listAlarm.Count; iIndex++) { var al = this._listAlarm[iIndex]; if (al.RecIndex != this._nLastAlarmRecIndex) { continue; } iStartIndex = (iIndex) % this._listAlarm.Count; // New Incoming Alarm Star here. ListAlarm.Count = 20,000 if (this._nStartIndex == iStartIndex) { args.message = "No New Alarm"; args.TimeStamp = DateTime.Now; onRestAlarmCSVChanged(args); //this._listAlarm.Clear(); //Clear Data after using break;//Same Position in CSV Has no New Alarm } this._nStartIndex = iStartIndex; //this._nLastAlarmRecIndex = (int)this._listAlarm[this._listAlarm.Count-1].RecIndex; //Update LastAlarm Index args.message = "Has New Alarm"; args.TimeStamp = DateTime.Now; onRestAlarmCSVChanged(args); //Raise the Event when has new event break; } } else { //if(!(this._listAlarm == null || this._listAlarm.Count == 0)) //this._nLastAlarmRecIndex = (int)this._listAlarm[this._listAlarm.Count-1].RecIndex; //Update LastAlarm Index args.message = "Start Process"; args.TimeStamp = DateTime.Now; onRestAlarmCSVChanged(args); //Raise the Event when has new event } return(iStartIndex != 0); }
public bool GetDBStatus() { RestEventArgs args = new RestEventArgs(); var isExist = this._RestAlarmContext.Database.Exists(); if (isExist) { args.message = "Connected"; } else { args.message = "Disconnected"; } args.TimeStamp = DateTime.Now; onRestAlarmDBChanged(args); //Raise the Event return(isExist); }
//Auto Get Station Name when DB has been loaded. private void OnRestAlarmChanged(object source, RestEventArgs arg) { if (arg.message == "hasLoaded") { // Adding Station ComboBox items foreach (var Station in RestAlarmsRepo.StationsName) { mstationItems.Add(new Item(Station.ToString(), "StationName")); } // Adding Priority ComboBox items foreach (var Priority in RestAlarmsRepo.Priority) { mpriorityItems.Add(new Item(Priority.ToString(), "Priority")); } // Adding GoupDescription ComboBox items foreach (var GroupDescription in RestAlarmsRepo.DeviceType) { mgroupDescItems.Add(new Item(GroupDescription.ToString(), "GroupDescription")); } } }
private void OnRestAlarmChanged(object source, RestEventArgs arg) { if (arg.message == "Start Success") { // Adding Station ComboBox items foreach (var Station in RestAlarmsRepo.StationsName) { if(Station != null) mfltStationItems.Add(new Item(Station.ToString(), "StationName")); } // Adding Priority ComboBox items foreach (var Priority in RestAlarmsRepo.Priority) { if (Priority != null) mfltPriorityItems.Add(new Item(Priority.ToString(), "Priority")); } // Adding GoupDescription ComboBox items foreach (var DeviceType in RestAlarmsRepo.DeviceType) { if (DeviceType != null) mfltGroupDescItems.Add(new Item(DeviceType.ToString(), "GroupDescription")); } // Adding Message ComboBox items foreach (var Message in RestAlarmsRepo.Message) { if (Message != null) mfltMessageItems.Add(new Item(Message.ToString(), "Message")); } } }
public List <AlarmList> exeGetListCSV() { RestEventArgs args = new RestEventArgs(); args.UpdatePost = (int)EventLogPosition.CSV_STATUS; this._listAlarm.Clear(); try { //_CSVFile = @"\\10.20.86.210\ExportDB\AlarmList.csv"; // string csvFile = @"c:\ExportDB\AlarmList.csv"; #if true FileInfo file = new FileInfo(this._connCfg.CsvFile); var DateModification = file.LastWriteTime; if (_CSVLastModify == DateModification) { Console.WriteLine("CSV not Update"); return(null); } _CSVLastModify = DateModification; Console.WriteLine("CSV Last Modification : " + DateModification); int nRetry_read = 0; do //Retry tor Read CSV File { Thread.Sleep(TimeSpan.FromSeconds(1)); if (nRetry_read++ >= 10) { args.message = "Read CSV Fail"; args.TimeStamp = DateTime.Now; //args.UpdatePost = (int)EventLogPosition.CSV_STATUS; //this.m_dLastReadCSV = args.TimeStamp; onRestAlarmCSVChanged(args); //Raise the Event return(null); } } while (IsFileLocked(this._connCfg.CsvFile)); this._listAlarm = File.ReadLines(this._connCfg.CsvFile) .Skip(1) .Select(line => AlarmList.GetLineAlarmListCsv(line)) .ToList(); dLastReadCSV = DateTime.Now; args.message = "Read CSV Success"; args.TimeStamp = this.dLastReadCSV; onRestAlarmCSVChanged(args); //Raise the Event return(this._listAlarm); #else //Oldcode DataTable dt = new DataTable("AlarmList"); using (TextFieldParser parser = new TextFieldParser(csvFile)) { parser.Delimiters = new string[] { "," }; int iLine = 0; while (true) { string[] parts = parser.ReadFields(); if (parts == null) { break; } if (iLine++ == 0) { for (int iCol = 0; iCol < parts.Length; iCol++) { dt.Columns.Add(parts[iCol]); } continue; } dt.Rows.Add(parts); } //dt.DefaultView.Sort = "DATETIME"; dt = dt.DefaultView.ToTable(); for (int iRow = 0; iRow < dt.Rows.Count; iRow++) { DataRow row = dt.Rows[iRow]; DigitalAlarm al = new DigitalAlarm(row); this.m_listAlarm.Add(al); } this.m_dLastReadCSV = DateTime.Now; return(true); } #endif } catch (Exception e) { Console.WriteLine(e.ToString()); args.message = "Read CSV Fail"; args.TimeStamp = DateTime.Now; //this.m_dLastReadCSV = args.TimeStamp; onRestAlarmCSVChanged(args); //Raise the Event return(null); } }
//New alarm Process private void OnQueryRepoChanged(object source, RestEventArgs arg) { switch (arg.message) { //case "hasNewAlarm": // Console.WriteLine(DateTime.Now.ToString() + " : Main Alarm List Recieved New Alarm"); // if (RestAlarmsRepo.PreviousAlarmRecIndex < 0) break; // for (int i = RestAlarmsRepo.startNewRestItemArray; i >= 0; i--) // { // RestorationAlarms.Insert(0,RestAlarmsRepo.RestAlarmListDump[i]); // if (RestorationAlarms.Count > RestAlarmsRepo.pageSize) RestorationAlarms.RemoveAt(RestAlarmsRepo.pageSize); // } // pageCount = RestAlarmsRepo.pageCount; // restAlarmCount = RestAlarmsRepo.restAlarmCount; // NotificationMessage = "Has New Alarm : " + DateTime.Now.ToLocalTime(); // break; case "Start Success": Console.WriteLine(DateTime.Now.ToString() + " : Query Alarm List" + arg.message); QueryRestAlarms = new ObservableCollection <RestorationAlarmLists>(RestAlarmsRepo.QueryAlarmListDump); pageCount = RestAlarmsRepo.queryPageCount; queryAlarmCount = RestAlarmsRepo.queryAlarmCount; NotificationMessage = "Database has been Loaded : " + DateTime.Now.ToLocalTime(); break; case "Start Fail": Console.WriteLine(DateTime.Now.ToString() + " : Query Alarm List" + arg.message); NotificationMessage = "Can't Loaded Database : " + DateTime.Now.ToLocalTime(); break; case "Reset": Console.WriteLine(DateTime.Now.ToString() + " : Query Alarm List Recieved Reset"); QueryRestAlarms.Clear(); for (int i = RestAlarmsRepo.startNewQueryItemArray; i >= 0; i--) { QueryRestAlarms.Insert(0, RestAlarmsRepo.QueryAlarmListDump[i]); } pageCount = RestAlarmsRepo.queryPageCount; queryAlarmCount = RestAlarmsRepo.queryAlarmCount; NotificationMessage = "Database has been reset : " + DateTime.Now.ToLocalTime(); break; case "GetQueryAlarm": Console.WriteLine(DateTime.Now.ToString() + " : Query Alarm List Execute Navigation"); QueryRestAlarms.Clear(); for (int i = RestAlarmsRepo.startNewQueryItemArray; i >= 0; i--) { QueryRestAlarms.Insert(0, RestAlarmsRepo.QueryAlarmListDump[i]); } pageCount = RestAlarmsRepo.queryPageCount; queryAlarmCount = RestAlarmsRepo.queryAlarmCount; break; case "GetQueryAlarmNoResult": Console.WriteLine(DateTime.Now.ToString() + " : Query Alarm List has been Executed but no data"); QueryRestAlarms.Clear(); pageCount = RestAlarmsRepo.queryPageCount; queryAlarmCount = RestAlarmsRepo.queryAlarmCount; NotificationMessage = "Main Alarm List No : " + DateTime.Now.ToLocalTime(); break; default: Console.WriteLine(DateTime.Now.ToString() + " : Query Alarm List no Msg. match"); break; } }
//New alarm Process private void OnCustAlarmChanged(object source, RestEventArgs arg) { switch (arg.message) { case "Start Success": Console.WriteLine(DateTime.Now.ToString() + " : Custom Alarm List" + arg.message); CustomAlarms = new ObservableCollection <RestorationAlarmLists>(RestAlarmsRepo.CustAlarmListDump); custPageCount = RestAlarmsRepo.custPageCount; custAlarmCount = RestAlarmsRepo.custAlarmCount; NotificationMessage = "Database has been Loaded : " + DateTime.Now.ToLocalTime(); break; case "Start Fail": Console.WriteLine(DateTime.Now.ToString() + " : Custom Alarm List" + arg.message); NotificationMessage = "Can't Loaded Database : " + DateTime.Now.ToLocalTime(); break; case "hasNewAlarmCust": Console.WriteLine(DateTime.Now.ToString() + " : Custom Alarm List Recieved New Alarm"); if (RestAlarmsRepo.PreviousAlarmRecIndex < 0) { break; } for (int i = RestAlarmsRepo.startNewCustItemArray; i >= 0; i--) { CustomAlarms.Insert(0, RestAlarmsRepo.CustAlarmListDump[i]); if (CustomAlarms.Count > pageSize) { CustomAlarms.RemoveAt(pageSize); } } custPageCount = RestAlarmsRepo.custPageCount; custAlarmCount = RestAlarmsRepo.custAlarmCount; NotificationMessage = "Has New Alarm : " + DateTime.Now.ToLocalTime(); break; case "hasAllNewAlarmCust": Console.WriteLine(DateTime.Now.ToString() + " : Custom Alarm List Recieved All new or Reset"); CustomAlarms.Clear(); for (int i = RestAlarmsRepo.startNewCustItemArray; i >= 0; i--) { CustomAlarms.Insert(0, RestAlarmsRepo.CustAlarmListDump[i]); } custPageCount = RestAlarmsRepo.custPageCount; custAlarmCount = RestAlarmsRepo.custAlarmCount; NotificationMessage = "Database has been reset : " + DateTime.Now.ToLocalTime(); break; case "filterAlarmCust": Console.WriteLine(DateTime.Now.ToString() + " : Custom Alarm List has been Filtered/Searched"); CustomAlarms.Clear(); for (int i = RestAlarmsRepo.startNewCustItemArray; i >= 0; i--) { CustomAlarms.Insert(0, RestAlarmsRepo.CustAlarmListDump[i]); } custPageCount = RestAlarmsRepo.custPageCount; custAlarmCount = RestAlarmsRepo.custAlarmCount; //NotificationMessage = "Filtering : " + DateTime.Now.ToLocalTime(); break; case "GetFilterAlarmCust": Console.WriteLine(DateTime.Now.ToString() + " : Custom Alarm List Execute Navigation"); CustomAlarms.Clear(); for (int i = RestAlarmsRepo.startNewCustItemArray; i >= 0; i--) { CustomAlarms.Insert(0, RestAlarmsRepo.CustAlarmListDump[i]); } custPageCount = RestAlarmsRepo.custPageCount; custAlarmCount = RestAlarmsRepo.custAlarmCount; //NotificationMessage = "Filtering : " + DateTime.Now.ToLocalTime(); break; case "filterAlarmCustNoResult": Console.WriteLine(DateTime.Now.ToString() + " : Custom Alarm List has been Filtered/Searched but no data"); CustomAlarms.Clear(); custPageCount = RestAlarmsRepo.custPageCount; custAlarmCount = RestAlarmsRepo.custAlarmCount; NotificationMessage = "No Filtering/Searching result : " + DateTime.Now.ToLocalTime(); break; default: Console.WriteLine(DateTime.Now.ToString() + " : Custom Alarm List no Msg. match"); break; } }