private async void TimerDownload(EventArgs e) { System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString()); if (!IsExistUserData) { return; } UserDataModel downloadModel; try { downloadModel = await httpDataService.GetUserAsync(current); if (downloadModel == null) { return; } } catch (Exception ex) { Crashes.TrackError(ex); return; } var hasNotification = downloadModel.LastNotificationTime != current.LastNotificationTime; if (hasNotification) { // Pull Notification. try { var newModel = new UserDataModel() { UserUuid = current.UserUuid, LastNotificationTime = downloadModel.LastNotificationTime }; var result = await httpDataService.GetNotificationPullAsync(newModel); foreach (var notify in result.Messages) { // TODO Positive Notify // notificationService.ReceiveNotification(notify.Title, notify.Message); } await SetAsync(newModel); } catch (Exception ex) { Crashes.TrackError(ex); } } }
private async void TimerDownload(EventArgs e) { System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString()); if (!IsExistUserData) { return; } UserDataModel downloadModel; try { downloadModel = await httpDataService.GetUserAsync(current); if (downloadModel == null) { return; } } catch (Exception ex) { Crashes.TrackError(ex); return; } var hasNotification = downloadModel.LastNotificationTime != current.LastNotificationTime; var hasStatusChange = downloadModel.UserStatus != current.UserStatus; if (hasStatusChange) { // Notification Contacted /* * if (downloadModel.UserStatus == UserStatus.Contactd) * { * // TOOD Change to Resouce String * notificationService.ScheduleNotification("TEST", "MESSAGE"); * } */ var newModel = new UserDataModel() { UserUuid = current.UserUuid, Major = current.Major, Minor = current.Minor, UserStatus = downloadModel.UserStatus, LastNotificationTime = current.LastNotificationTime }; await SetAsync(newModel); } if (hasNotification) { // Pull Notification. try { var newModel = new UserDataModel() { UserUuid = current.UserUuid, Major = current.Major, Minor = current.Minor, UserStatus = current.UserStatus, LastNotificationTime = downloadModel.LastNotificationTime }; var result = await httpDataService.GetNotificationPullAsync(newModel); foreach (var notify in result.Messages) { notificationService.ReceiveNotification(notify.Title, notify.Message); } await SetAsync(newModel); } catch (Exception ex) { Crashes.TrackError(ex); } } }