public static void UpdateAlarm(AlarmRecord record) { var obj = record; // Update native alarm DependencyService.Get <IAlarm>().UpdateAlarm(ref obj); record = obj; string alarmUID = record.GetUniqueIdentifier(); // Update list for (int i = 0; i < ObservableAlarmList.Count; i++) { AlarmRecord item = ObservableAlarmList[i]; //AlarmModel.Compare(record, item); if (item.GetUniqueIdentifier() == alarmUID) { DependencyService.Get <ILog>().Debug(" Found AlarmRecord(UID: " + item.GetUniqueIdentifier() + ") in ObservableAlarmList."); AlarmRecordDictionary.Remove(alarmUID); item.DeepCopy(record); AlarmRecordDictionary.Add(alarmUID, item); SaveDictionary(); break; } } }
/// <summary> /// Create native alarm /// </summary> public static void CreateAlarm() { // create a native alarm using AlarmModel.BindableAlarmRecord // After then, update Native alarm ID. BindableAlarmRecord.NativeAlarmID = AlarmNativeHandler.CreateAlarm(BindableAlarmRecord); AlarmRecord record = new AlarmRecord(); record.DeepCopy(BindableAlarmRecord); ObservableAlarmList.Add(record); AlarmRecordDictionary.Add(record.GetUniqueIdentifier(), record); SaveDictionary(); }
/// <summary> /// Create native alarm /// </summary> public static void CreateAlarmAndSave() { // create a native alarm using AlarmModel.BindableAlarmRecord // After then, update Native alarm ID. BindableAlarmRecord.NativeAlarmID = DependencyService.Get <IAlarm>().CreateAlarm(BindableAlarmRecord); DependencyService.Get <ILog>().Debug("====== AlarmModel.CreateAlarm >> BindableAlarmRecord.NativeAlarmID : " + BindableAlarmRecord.NativeAlarmID); // ObservableAlarmList is ItemsSource for AlarmList view. This is bindable so this model // should be changed to reflect record change (adding a new alarm) AlarmRecord record = new AlarmRecord(); record.DeepCopy(BindableAlarmRecord); //AlarmModel.Compare(BindableAlarmRecord, record); ObservableAlarmList.Add(record); AlarmRecordDictionary.Add(record.GetUniqueIdentifier(), record); SaveDictionary(); }
/// <summary> /// Update alarm record /// </summary> /// <param name="record">AlarmRecord</param> public static void UpdateAlarm(AlarmRecord record) { var obj = record; // Update native alarm AlarmNativeHandler.UpdateAlarm(ref obj); record = obj; string alarmUID = record.GetUniqueIdentifier(); // Update list for (int i = 0; i < ObservableAlarmList.Count; i++) { AlarmRecord item = ObservableAlarmList[i]; if (item.GetUniqueIdentifier() == alarmUID) { Console.WriteLine("Found AlarmRecord(UID: " + item.GetUniqueIdentifier() + ") in ObservableAlarmList."); AlarmRecordDictionary.Remove(alarmUID); item.DeepCopy(record); AlarmRecordDictionary.Add(alarmUID, item); SaveDictionary(); break; } } }