// Code to execute on Unhandled Exceptions private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { App.AnalyticsInstance.saveObject(); if (System.Diagnostics.Debugger.IsAttached) { // An unhandled exception has occurred; break into the debugger System.Diagnostics.Debugger.Break(); } if (!IS_MARKETPLACE) { //Running on a device / emulator without debugging e.Handled = true; Error.Exception = e.ExceptionObject; Debug.WriteLine("UNHANDLED EXCEPTION : {0}", e.ExceptionObject.StackTrace); Deployment.Current.Dispatcher.BeginInvoke(() => { MessageBox.Show(e.ExceptionObject.ToString(), "Exception", MessageBoxButton.OK); //(RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Source = new Uri("/View/Error.xaml", UriKind.Relative); }); } if (IS_VIEWMODEL_LOADED) { int convs = 0; appSettings.TryGetValue <int>(HikeViewModel.NUMBER_OF_CONVERSATIONS, out convs); if (convs != 0 && App.ViewModel.ConvMap.Count == 0) { return; } ConversationTableUtils.saveConvObjectList(); } }
// Code to execute when the application is deactivated (sent to background) // This code will not execute when the application is closing private void Application_Deactivated(object sender, DeactivatedEventArgs e) { NetworkManager.turnOffNetworkManager = true; App.AnalyticsInstance.saveObject(); PhoneApplicationService.Current.State[LAUNCH_STATE] = _appLaunchState; if (IS_VIEWMODEL_LOADED) { int convs = 0; appSettings.TryGetValue <int>(HikeViewModel.NUMBER_OF_CONVERSATIONS, out convs); if (convs != 0 && App.ViewModel.ConvMap.Count == 0) { return; } ConversationTableUtils.saveConvObjectList(); } }
private void MenuItem_Click_Delete(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Are you sure about deleting conversation.", "Delete Conversation ?", MessageBoxButton.OKCancel); if (result == MessageBoxResult.Cancel) { return; } ListBoxItem selectedListBoxItem = this.myListBox.ItemContainerGenerator.ContainerFromItem((sender as MenuItem).DataContext) as ListBoxItem; if (selectedListBoxItem == null) { return; } ConversationListObject convObj = selectedListBoxItem.DataContext as ConversationListObject; convMap.Remove(convObj.Msisdn); // removed entry from map App.ViewModel.MessageListPageCollection.Remove(convObj); // removed from observable collection ConversationTableUtils.deleteConversation(convObj.Msisdn); // removed entry from conversation table MessagesTableUtils.deleteAllMessagesForMsisdn(convObj.Msisdn); //removed all chat messages for this msisdn }
private void LoadMessages() { List <Conversation> conversationList = ConversationTableUtils.getAllConversations(); if (conversationList == null) { return; } for (int i = 0; i < conversationList.Count; i++) { Conversation conv = conversationList[i]; ConvMessage lastMessage = MessagesTableUtils.getLastMessageForMsisdn(conv.Msisdn); // why we are not getting only lastmsg as string ContactInfo contact = UsersTableUtils.getContactInfoFromMSISDN(conv.Msisdn); Thumbnails thumbnail = MiscDBUtil.getThumbNailForMSisdn(conv.Msisdn); ConversationListObject mObj = new ConversationListObject((contact == null) ? conv.Msisdn : contact.Msisdn, (contact == null) ? conv.Msisdn : contact.Name, lastMessage.Message, (contact == null) ? conv.OnHike : contact.OnHike, TimeUtils.getTimeString(lastMessage.Timestamp), thumbnail == null ? null : thumbnail.Avatar); convMap.Add(conv.Msisdn, mObj); App.ViewModel.MessageListPageCollection.Add(mObj); } }
// Code to execute if a navigation fails private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) { //MessageBoxResult result = MessageBox.Show("Exception :: ", e.ToString(), MessageBoxButton.OK); //if (result == MessageBoxResult.OK) if (System.Diagnostics.Debugger.IsAttached) { // A navigation has failed; break into the debugger System.Diagnostics.Debugger.Break(); } App.AnalyticsInstance.saveObject(); if (IS_VIEWMODEL_LOADED) { int convs = 0; appSettings.TryGetValue <int>(HikeViewModel.NUMBER_OF_CONVERSATIONS, out convs); if (convs != 0 && App.ViewModel.ConvMap.Count == 0) { return; } ConversationTableUtils.saveConvObjectList(); } }
/// <summary> /// this function is used as an upgrade function too. /// </summary> /// <returns></returns> private static List <ConversationListObject> GetConversations() { List <ConversationListObject> convList = null; appSettings.TryGetValue <string>(HikeConstants.FILE_SYSTEM_VERSION, out _currentVersion); if (_currentVersion == null) { _currentVersion = "1.0.0.0"; } // this will ensure that we will show tutorials in case of app upgrade from any version to version later that 1.5.0.8 if (Utils.compareVersion(_currentVersion, "1.5.0.8") != 1) // current version is less than equal to 1.5.0.8 { WriteToIsoStorageSettings(App.SHOW_FAVORITES_TUTORIAL, true); WriteToIsoStorageSettings(App.SHOW_NUDGE_TUTORIAL, true); } if (_currentVersion == "1.0.0.0") // user is upgrading from version 1.0.0.0 to latest { /* * 1. Read from individual files. * 2. Overite old files as they are written in a wrong format */ convList = ConversationTableUtils.getAllConversations(); // this function will read according to the old logic of Version 1.0.0.0 ConversationTableUtils.saveConvObjectListIndividual(convList); WriteToIsoStorageSettings(HikeViewModel.NUMBER_OF_CONVERSATIONS, convList != null ? convList.Count : 0); // there was no country code in first version, and as first version was released in India , we are setting value to +91 WriteToIsoStorageSettings(COUNTRY_CODE_SETTING, "+91"); App.WriteToIsoStorageSettings(App.SHOW_FREE_SMS_SETTING, true); return(convList); } else if (Utils.compareVersion(_currentVersion, "1.5.0.0") != 1) // current version is less than equal to 1.5.0.0 and greater than 1.0.0.0 { /* * 1. Read from Convs File * 2. Store each conv in an individual file. */ convList = ConversationTableUtils.getAllConvs(); ConversationTableUtils.saveConvObjectListIndividual(convList); WriteToIsoStorageSettings(HikeViewModel.NUMBER_OF_CONVERSATIONS, convList != null ? convList.Count : 0); string country_code = null; App.appSettings.TryGetValue <string>(App.COUNTRY_CODE_SETTING, out country_code); if (string.IsNullOrEmpty(country_code) || country_code == "+91") { App.WriteToIsoStorageSettings(App.SHOW_FREE_SMS_SETTING, true); } else { App.WriteToIsoStorageSettings(App.SHOW_FREE_SMS_SETTING, false); } return(convList); } else // this corresponds to the latest version and is called everytime except update launch { int convs = 0; appSettings.TryGetValue <int>(HikeViewModel.NUMBER_OF_CONVERSATIONS, out convs); convList = ConversationTableUtils.getAllConvs(); int convListCount = convList == null ? 0 : convList.Count; // This shows something failed while reading from Convs , so move to backup plan i.e read from individual files if (convListCount != convs) { convList = ConversationTableUtils.GetConvsFromIndividualFiles(); } return(convList); } }
public void updateAddressBook_Callback(JObject patchJsonObj) { if (stopContactScanning) { stopContactScanning = false; return; } if (patchJsonObj == null) { Thread.Sleep(1000); App.MqttManagerInstance.connect(); NetworkManager.turnOffNetworkManager = false; scanningComplete(); canGoBack = true; return; } List <ContactInfo> updatedContacts = ContactUtils.contactsMap == null ? null : AccountUtils.getContactList(patchJsonObj, ContactUtils.contactsMap, true); List <ContactInfo.DelContacts> hikeIds = null; // Code to delete the removed contacts if (ContactUtils.hike_contactsMap != null && ContactUtils.hike_contactsMap.Count != 0) { hikeIds = new List <ContactInfo.DelContacts>(ContactUtils.hike_contactsMap.Count); // This loop deletes all those contacts which are removed. foreach (string id in ContactUtils.hike_contactsMap.Keys) { ContactInfo.DelContacts dCn = new ContactInfo.DelContacts(id, ContactUtils.hike_contactsMap[id][0].Msisdn); hikeIds.Add(dCn); if (App.ViewModel.ConvMap.ContainsKey(dCn.Msisdn)) // check convlist map to remove the { try { // here we are removing name so that Msisdn will be shown instead of Name App.ViewModel.ConvMap[dCn.Msisdn].ContactName = null; } catch (Exception e) { Debug.WriteLine("REFRESH CONTACTS :: Delete contact exception " + e.StackTrace); } } else // if this contact is in favourite or pending and not in convMap update this also { ConversationListObject obj; obj = App.ViewModel.GetFav(id); if (obj == null) // this msisdn is not in favs , check in pending { obj = App.ViewModel.GetPending(id); } if (obj != null) { obj.ContactName = null; } } } } if (stopContactScanning) { stopContactScanning = false; return; } if (hikeIds != null && hikeIds.Count > 0) { /* Delete ids from hike user DB */ UsersTableUtils.deleteMultipleRows(hikeIds); // this will delete all rows in HikeUser DB that are not in Addressbook. } if (updatedContacts != null && updatedContacts.Count > 0) { UsersTableUtils.updateContacts(updatedContacts); ConversationTableUtils.updateConversation(updatedContacts); } allContactsList = UsersTableUtils.getAllContactsByGroup(); App.MqttManagerInstance.connect(); NetworkManager.turnOffNetworkManager = false; Deployment.Current.Dispatcher.BeginInvoke(() => { filteredJumpList = null; jumpList = getGroupedList(allContactsList); // this logic handles the case where hide sms contacts is there and user refreshed the list if (!hideSmsContacts) { MakeFilteredJumpList(); contactsListBox.ItemsSource = filteredJumpList; } else { contactsListBox.ItemsSource = jumpList; } progressIndicator.Hide(LayoutRoot); enableAppBar(); }); canGoBack = true; }