private static void onRestAlarmChanged(RestEventArgs arg) { if (RestAlarmChanged != null) { RestAlarmChanged(null, arg); } }
private static void CheckNewRestAlarm() { RestEventArgs arg = new RestEventArgs(); //Func<int, int, bool> hasNewAlarm = hasNewAalrmChk; //Test using Predicate Predicate <int> hasNewAlarmChk = (newLastIndex) => newLastIndex > LastMaxAlarmRecIndex; if (hasNewAlarmChk(maxPkRecIndex.PkAlarmListID)) { //To Do LastAlarmRecIndex_of_Page LastMaxAlarmRecIndex = maxPkRecIndex.PkAlarmListID; PreviousAlarmRecIndex = LastAlarmRecIndex; //LastAlarmRecIndex = maxPkRecIndex.PkAlarmListID; LastAlarmRecIndex = RestAlarmListDump[0].PkAlarmListID; startNewRestItemArray = LastAlarmRecIndex - PreviousAlarmRecIndex - 1; arg.message = "hasNewAlarm"; Console.WriteLine(DateTime.Now.ToString() + " : Raise Event " + arg.message); onRestAlarmChanged(arg);//Raise Event } else //Database has been reset { //Restart Process PreviousAlarmRecIndex = 0; LastMaxAlarmRecIndex = 0; LastAlarmRecIndex = maxPkRecIndex.PkAlarmListID; startNewRestItemArray = RestAlarmListDump.Count - 1; arg.message = "Reset"; Console.WriteLine(DateTime.Now.ToString() + " : Raise Event " + arg.message); onRestAlarmChanged(arg);//Raise Event } }
public static async Task GetRestAlarmAct() { RestEventArgs arg = new RestEventArgs(); //Test Raise read "LoadStationName" RestAlarmListDump = await GetRestAlarmsAsync(); if (RestAlarmListDump.Count != 0) { LastAlarmRecIndex = RestAlarmListDump[0].PkAlarmListID; startNewRestItemArray = RestAlarmListDump.Count - 1; arg.message = "GetRestAlarm"; Console.WriteLine(DateTime.Now.ToString() + " : Raise Event " + arg.message); onRestAlarmChanged(arg);//Raise Event } else //filter result no item { arg.message = "GetRestAlarmNoResult"; LastAlarmRecIndex = -1; LastMaxAlarmRecIndex = -1; startNewRestItemArray = -1; Console.WriteLine(DateTime.Now.ToString() + " : Raise Event " + arg.message); onRestAlarmChanged(arg);//Raise Event } }
public static async Task TGetQueryAlarmAct() { RestEventArgs arg = new RestEventArgs(); //Test Raise read "LoadStationName" if (sortParseDeleg == null) { return; } QueryAlarmListDump = await TGetQueryAlarmsAsync(); if (QueryAlarmListDump.Count != 0) { LastQueryAlarmRecIndex = QueryAlarmListDump[0].PkAlarmListID; startNewQueryItemArray = QueryAlarmListDump.Count - 1; arg.message = "GetQueryAlarm"; Console.WriteLine(DateTime.Now.ToString() + " : Raise Event " + arg.message); onRestAlarmChanged(arg);//Raise Event } else //filter result no item { arg.message = "GetQueryAlarmNoResult"; LastQueryAlarmRecIndex = -1; startNewQueryItemArray = -1; Console.WriteLine(DateTime.Now.ToString() + " : Raise Event " + arg.message); onRestAlarmChanged(arg);//Raise Event } }
//Get All Data from SQL public static async Task GetInitDataRepositoryAsync() { RestEventArgs arg = new RestEventArgs(); try { RestAlarmListDump = await GetRestAlarmsAsync(); if (RestAlarmListDump.Count != 0) { LastAlarmRecIndex = RestAlarmListDump[0].PkAlarmListID; //Set Last PkAlarmList initializing } LastMaxAlarmRecIndex = LastAlarmRecIndex; QueryAlarmListDump = await TGetQueryAlarmsAsync(); if (QueryAlarmListDump.Count != 0) { LastQueryAlarmRecIndex = QueryAlarmListDump[0].PkAlarmListID; } StationsName = await GetStationNameAsync(); Priority = await GetPriorityAsync(); DeviceType = await GetDeviceTypeAsync(); Message = await GetMessageAsync(); AlarmListFields = GetAlarmListFields(); //Send Message to Subscriber arg.message = "Start Success"; onRestAlarmChanged(arg);//Raise Event Console.WriteLine(DateTime.Now.ToString() + " : Raise Event " + arg.message); } catch { //Send Message to Subscriber arg.message = "Start Fail"; onRestAlarmChanged(arg);//Raise Event Console.WriteLine(DateTime.Now.ToString() + " : Raise Event " + arg.message); } }
private static void CheckNewCustomRestAlarm() { RestEventArgs arg = new RestEventArgs(); //Func<int, int, bool> hasNewAlarm = hasNewAalrmChk; //Test using Predicate Predicate <List <RestorationAlarmLists> > hasAllNew = (alarm) => LastAlarmRecIndex <alarm[alarm.Count - 1].PkAlarmListID || LastAlarmRecIndex> alarm[0].PkAlarmListID; Predicate <int> isEqualLastCust = (Index) => Index == LastCustAlarmRecIndex; if (isEqualLastCust(CustAlarmListDump[0].PkAlarmListID)) { return; //No new custom filter alarm } if (hasAllNew(CustAlarmListDump)) //All New alarm or DB has been reset { LastCustAlarmRecIndex = CustAlarmListDump[0].PkAlarmListID; startNewCustItemArray = CustAlarmListDump.Count - 1; arg.message = "hasAllNewAlarmCust"; Console.WriteLine(DateTime.Now.ToString() + " : Raise Event " + arg.message); onRestAlarmChanged(arg);//Raise Event } else { //Finding Start last RecIndex Position int i = 0; foreach (RestorationAlarmLists alarm in CustAlarmListDump) { //Get Starting Position if (isEqualLastCust(alarm.PkAlarmListID)) { startNewCustItemArray = i - 1; break; } i++; } LastCustAlarmRecIndex = CustAlarmListDump[0].PkAlarmListID; arg.message = "hasNewAlarmCust"; Console.WriteLine(DateTime.Now.ToString() + " : Raise Event " + arg.message); onRestAlarmChanged(arg);//Raise Event } }