private static async void StopSOS(int retryCount) { if (IsRegisteredUser) { bool result = false; var retrier = new Retrier <Task <bool> >(); if (CurrentProfile.IsTrackingOn) { result = await retrier.TryWithDelay( () => LocationServiceWrapper.StopSOSOnlyAsync(CurrentProfile.SessionToken), retryCount, 0); if (result) { IsSOSJustStopped = true; } } else { result = await retrier.TryWithDelay( () => LocationServiceWrapper.StopPostingsAsync(CurrentProfile.SessionToken), retryCount, 0); } Deployment.Current.Dispatcher.BeginInvoke(() => { App.SosViewModel.UpdateErrorStatus(result ? false : true); if (!result) { DisplayToast(CustomMessage.StopSOSFailText, "basicWrap", "Server connection failed"); } else { DisplayToast(CustomMessage.StopSOSSuccessText, "basicWrap", "Guardian Tracking is active"); } }); if (!CurrentProfile.IsTrackingOn) { CurrentProfile.SessionToken = string.Empty; CurrentProfile.IsTrackingStatusSynced = result; App.MyProfiles.SaveCurrentProfileSetting(ProfileViewModel.ProfileSetting.TrackingStatusSynced, result.ToString()); } CurrentProfile.IsSOSStatusSynced = result; App.MyProfiles.SaveCurrentProfileSetting(ProfileViewModel.ProfileSetting.SosStatusSynced, result.ToString()); } }
public static async void StopEvents() { if (IsRegisteredUser && !(CurrentProfile.IsTrackingStatusSynced && CurrentProfile.IsSOSStatusSynced)) { bool result = false; if (!(CurrentProfile.IsSOSOn || CurrentProfile.IsTrackingOn)) { result = await LocationServiceWrapper.StopPostingsAsync("0");//Deletes all previous posts for the Profile } else if (!CurrentProfile.IsSOSStatusSynced && CurrentProfile.IsTrackingOn) { var retrier = new Retrier <Task <bool> >(); result = await retrier.TryWithDelay( () => LocationServiceWrapper.StopSOSOnlyAsync("0"), Constants.RetryMaxCount, 0); } else if (!CurrentProfile.IsTrackingStatusSynced && CurrentProfile.IsSOSOn) { //Do nothing result = true; } if (result) { if (!CurrentProfile.IsSOSStatusSynced) { CurrentProfile.IsSOSStatusSynced = true; App.MyProfiles.SaveCurrentProfileSetting(ProfileViewModel.ProfileSetting.SosStatusSynced, "true"); } if (!CurrentProfile.IsTrackingStatusSynced) { CurrentProfile.IsTrackingStatusSynced = true; App.MyProfiles.SaveCurrentProfileSetting(ProfileViewModel.ProfileSetting.TrackingStatusSynced, "true"); } } else { Deployment.Current.Dispatcher.BeginInvoke(() => { DisplayToast(CustomMessage.StopSOSFailText, "basicWrap", "Server connection failed"); }); } } }