/// <summary> /// This is the click handler for the 'ProfileLocalUsageDataButton' button. You would replace this with your own handler /// if you have a button or buttons on this page. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ProfileLocalUsageData_Click(object sender, RoutedEventArgs e) { // //Get Internet Connection Profile and display local data usage for the profile for the past 1 hour // try { Granularity = ParseDataUsageGranularity(((ComboBoxItem)GranularityComboBox.SelectedItem).Content.ToString()); NetworkUsageStates.Roaming = ParseTriStates(((ComboBoxItem)RoamingComboBox.SelectedItem).Content.ToString()); NetworkUsageStates.Shared = ParseTriStates(((ComboBoxItem)SharedComboBox.SelectedItem).Content.ToString()); StartTime = (StartDatePicker.Date.Date + StartTimePicker.Time); EndTime = (EndDatePicker.Date.Date + EndTimePicker.Time); if (InternetConnectionProfile == null) { rootPage.NotifyUser("Not connected to Internet\n", NotifyType.StatusMessage); } else { InternetConnectionProfile.GetConnectivityIntervalsAsync(StartTime, EndTime, NetworkUsageStates).Completed = GetConnectivityIntervalsAsyncHandler; } } catch (Exception ex) { rootPage.NotifyUser("Unexpected exception occurred: " + ex.ToString(), NotifyType.ErrorMessage); } }
private static async Task <IReadOnlyList <ConnectivityInterval> > GetConnectivityIntervalsAsync(ConnectionProfile connectionProfile, DateTime startTime, DateTime endTime, NetworkUsageStates networkUsageStates) { try { DateTimeOffset StartTimeOffset = new DateTimeOffset(startTime); DateTimeOffset EndTimeOffset = new DateTimeOffset(endTime); return(await connectionProfile.GetConnectivityIntervalsAsync(StartTimeOffset, EndTimeOffset, networkUsageStates)); } catch (Exception ex) { throw ex; } }