/// <summary> /// Search for contacts /// </summary> /// <param name="text"></param> /// <returns></returns> internal async Task SearchForTextAsync(string text) { if (!String.IsNullOrWhiteSpace(text)) { ContactQueryOptions option = new ContactQueryOptions(text, ContactQuerySearchFields.All); ContactReader reader = store.GetContactReader(option); await DisplayContactsFromReaderAsync(reader); } // A null query string is beeing treated as query for "*" else { ContactReader reader = store.GetContactReader(); await DisplayContactsFromReaderAsync(reader); } }
/// <summary> /// Loads up the contact store using the contactsRT APIs. /// Checks to make sure the store can be loaded and errors out accordingly /// </summary> private async Task LoadContactsFromStoreAsync() { //Try loading the contact atore try { store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadOnly); } catch (Exception ex) { ContactsStatusText = "We couldn't load the contact store."; Debug.WriteLine("Potential contact store bug: " + ex, "error"); } //If we can access the store without crashing (There seems to be a bug with the store). //Check to make sure we actually have access. if (store == null) { //Launch the settings app to fix the security settings Debug.WriteLine("Could not open contact store, is app access disabled in privacy settings?", "error"); return; } Debug.WriteLine("Contact store opened for reading successfully.", "informational"); //Load the contacts into the ListView on the page ContactReader reader = store.GetContactReader(); await DisplayContactsFromReaderAsync(reader, true); return; }
private async Task LoadContactsFromStoreAsync() { try { store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadOnly); } catch (Exception ex) { Debug.WriteLine("Potential contact store bug: " + ex, "error"); } if (store == null) { MessageDialog connectionWarning = new MessageDialog("The app needs access to your contacts in order to function correctly. " + "Please grant it access using the options in the settings menu ", "Lost Connection to Store"); await connectionWarning.ShowAsync(); await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-contacts")); return; } store.ChangeTracker.Enable(); ContactReader reader = store.GetContactReader(); await DisplayContactsFromReaderAsync(reader, true); return; }
private async Task SearchForTextAsync(string ContactFilter) { if (store == null) { await LoadContactsFromStoreAsync(); return; } if (!string.IsNullOrWhiteSpace(ContactFilter)) { ContactQueryOptions option = new ContactQueryOptions(ContactFilter, ContactQuerySearchFields.All); ContactReader reader = store.GetContactReader(option); await DisplayContactsFromReaderAsync(reader, false); } else { ContactReader reader = store.GetContactReader(); await DisplayContactsFromReaderAsync(reader, true); } return; }
/// <summary> /// Processes contact search. /// </summary> /// <param name="ContactFilter">Takes in the string inputed by the user</param> private async Task SearchForTextAsync(string ContactFilter) { if (store == null) { //Shouldn't happen, and I don't want to deal with opening the store in multiple locations await LoadContactsFromStoreAsync(); return; } //A null query string is being treated as a query for "*" if (!string.IsNullOrWhiteSpace(ContactFilter)) { ContactQueryOptions option = new ContactQueryOptions(ContactFilter, ContactQuerySearchFields.All); ContactReader reader = store.GetContactReader(option); await DisplayContactsFromReaderAsync(reader, false); } else { ContactReader reader = store.GetContactReader(); await DisplayContactsFromReaderAsync(reader, true); } return; }
/// <summary> /// Load contacts from contact manager. /// Add <uap:Capability Name="contacts" /> to manifest /// </summary> /// <returns></returns> public async Task LoadContactsAsync() { store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadOnly); if (store == null) // check every time because user can deactivate access at any time { LostConnectionToStore(this, new EventArgs()); return; } Debug.WriteLine("Contact store opend for writing successfully.", "information"); // Load contacts into ListView on the page ContactReader reader = store.GetContactReader(); await DisplayContactsFromReaderAsync(reader); // Start tracking changes to the store once the list is loaded into memory store.ChangeTracker.Enable(); store.ContactChanged += Store_ContactChanged; }
/// <summary> /// Loads up the contact store using the contactsRT APIs. /// Checks to make sure the store can be loaded and errors out accordingly /// </summary> private async Task LoadContactsFromStoreAsync() { //Try loading the contact atore try { store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadOnly); } catch (Exception ex) { ContactsStatusText = "We couldn't load the contact store."; Debug.WriteLine("Potential contact store bug: " + ex, "error"); } //If we can access the store without crashing (There seems to be a bug with the store). //Check to make sure we actually have access. if (store == null) { //Launch the settings app to fix the security settings Debug.WriteLine("Could not open contact store, is app access disabled in privacy settings?", "error"); return; } Debug.WriteLine("Contact store opened for reading successfully.", "informational"); //Load the contacts into the ListView on the page ContactReader reader = store.GetContactReader(); await DisplayContactsFromReaderAsync(reader, true); return; }