public static async Task <IDataGroup> GetGroupAsync(INotifyPage page, string uniqueId) { if (uniqueId != Constants.NotesGroupName) { throw (new NotImplementedException()); } var now = DateTime.UtcNow; if (DataState.IsDataLoadDue()) { DataState.LastDataLoadAt = now; try { //page.NotifyUser(Constants.PivotLocalData, NotifyType.StatusMessage); await DataSource.LoadDenormalizeNotificationsAsync(); DataState.LastDataLoadSuccess = true; page.NotifyUser(Constants.PivotLocalDataSuccess, NotifyType.StatusMessage); } catch { DataState.LastDataLoadSuccess = false; page.NotifyUser(Constants.PivotLocalDataError, NotifyType.ErrorMessage); } } if (DataState.IsDataFetchDue()) { DataState.LastDataFetchAt = now; try { page.NotifyUser(Constants.PivotFetchData, NotifyType.StatusMessage); await DataSource.FetchDenormalizedNotificationsAsync(page); DataState.LastDataFetchSuccess = true; page.NotifyUser(Constants.PivotFetchDataSuccess, NotifyType.StatusMessage); } catch { DataState.LastDataFetchSuccess = false; page.NotifyUser(Constants.PivotFetchDataError, NotifyType.ErrorMessage); } } return(GetDenormalizedNotificationGroup()); }
private static async Task FetchDenormalizedNotificationsAsync(INotifyPage page, string login, string password) { var client = new GitHubWrapper(login, password); var notes = client.GetNotifications(); if (page != null) { page.NotifyUser(Constants.FetchingGithubNotificationDetails, NotifyType.StatusMessage); } await _dataSource.ProcessFetchedDataAsync(notes); }
public static async Task FetchDenormalizedNotificationsAsync(INotifyPage page) { if (credentials.Login != "" && credentials.Password != "") { try { if (page != null) { page.NotifyUser(Constants.FetchingGithubNotifications, NotifyType.StatusMessage); } await FetchDenormalizedNotificationsAsync(page, credentials.Login, credentials.Password); } catch (Exception Error) { if (page != null) { page.NotifyUser(String.Format("{0}\n{1}", Constants.FetchingGithubNotificationsError, Error.Message), NotifyType.ErrorMessage); } throw (Error); } } }