/// <summary> /// Called when this app control event received. /// </summary> /// <param name="e">AppControlReceivedEventArgs</param> protected override async void OnAppControlReceived(AppControlReceivedEventArgs e) { Console.WriteLine("OnAppControlReceived"); base.OnAppControlReceived(e); AppControl appControl = e.ReceivedAppControl; var navi = app.MainPage as NavigationPage; var currentPage = navi.CurrentPage; try { if (appControl.ExtraData.Count() != 0) { string AlarmCreatedDate = appControl.ExtraData.Get <string>("AlarmRecord.UniqueIdentifier"); Console.WriteLine($"ExtraData.Count() != 0 AlarmCreatedDate:{AlarmCreatedDate}"); if (AlarmModel.AlarmRecordDictionary == null) { // Need to retrieve at the page creation time AlarmModel.AlarmRecordDictionary = AlarmPersistentHandler.DeserializeAlarmRecord(); } AlarmRecord retrievedRecord; if (AlarmModel.AlarmRecordDictionary != null) { if (AlarmModel.AlarmRecordDictionary.TryGetValue(AlarmCreatedDate, out retrievedRecord)) { if (retrievedRecord == null) { Console.WriteLine("[OnAppControlReceived] retrievedRecord is null!!"); } Console.WriteLine("retrievedRecord:" + retrievedRecord); if (retrievedRecord != null && retrievedRecord.AlarmState < AlarmStates.Inactive) { _alertPageModel = new AlertPageModel(retrievedRecord); await currentPage.Navigation.PushAsync(new AlarmAlertPage(_alertPageModel)); } } } } } catch (Exception ex) { Console.WriteLine("[OnAppControlReceived] Exception - Message: " + ex.Message + ", source: " + ex.Source + ", " + ex.StackTrace); } }
/// <summary> /// AlarmModel constructor /// </summary> public AlarmModel() { ObservableAlarmList = new ObservableCollection <AlarmRecord>(); AlarmRecordDictionary = AlarmPersistentHandler.DeserializeAlarmRecord(); BindableAlarmRecord = new AlarmRecord(); if (AlarmRecordDictionary == null) { AlarmRecordDictionary = new Dictionary <string, AlarmRecord>(); } else { foreach (var alarmItem in AlarmRecordDictionary) { Console.WriteLine("alarmItem key:" + alarmItem.Key); // Key is DateCreated var keyString = alarmItem.Key; // Retrieve alarm record AlarmRecord retrieved = alarmItem.Value; Console.WriteLine("retrieved:" + retrieved.ToString()); // Add the retrieved alarm to list for AlarmListUI ObservableAlarmList.Add(retrieved); } } }