Ejemplo n.º 1
0
        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());
            }
        }
Ejemplo n.º 2
0
 private async void StopButtonAppBarItem_Click(object sender, EventArgs e)
 {
     if (Globals.CurrentProfile.IsSOSOn)
     {
         App.MyProfiles.SaveCurrentProfileSetting(SOS.Phone.ProfileViewModel.ProfileSetting.SOSStatus, "false");
         Globals.InitiateStopSOSEventsAsync(false);
         RenderTrackingControlsUIAsync();
     }
     else
     {
         //Deletes all previous posts for the Profile
         var  retrier = new Retrier <Task <bool> >();
         bool result  = await retrier.TryWithDelay(
             () => LocationServiceWrapper.StopPostingsAsync("0"), Constants.RetryMaxCount, 0);
     }
 }
Ejemplo n.º 3
0
        public static async void PostMyLocationWrapperAsync(GeoCoordinate pos)
        {
            var  retrier = new Retrier <Task <bool> >();
            bool result  = await retrier.TryWithDelay(
                () => LocationServiceWrapper.PostMyLocationArrayAsync(), Constants.RetryMaxCount, 0);

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                App.SosViewModel.UpdateErrorStatus(result ? false : true);
            });
            if (result)
            {
                if (!IsSyncedFirstTime && CurrentProfile.IsSOSOn)
                {
                    IsSyncedFirstTime = true;
                }
            }
        }
Ejemplo n.º 4
0
        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");
                    });
                }
            }
        }
Ejemplo n.º 5
0
        public static async void StopTracking(bool isForceStop = false)
        {
            if (!isForceStop && CurrentProfile.IsSOSOn)
            {
                return;
            }

            App.MyProfiles.SaveCurrentProfileSetting(ProfileViewModel.ProfileSetting.TrackingStatus, "false");

            if (Config.UseGeoLocator)
            {
                App.Geolocator.PositionChanged -= Geolocator_PositionChanged;
                App.Geolocator = null;
            }
            else
            {
                App.geoCoordinateWatcher.PositionChanged -= Watcher_PositionChanged;
                App.geoCoordinateWatcher = null;
            }

            if (!CurrentProfile.IsSOSOn)
            {
                var  retrier = new Retrier <Task <bool> >();
                bool result  = await retrier.TryWithDelay(
                    () => LocationServiceWrapper.StopPostingsAsync(CurrentProfile.SessionToken), Constants.RetryMaxCount, 0);

                CurrentProfile.IsTrackingStatusSynced = result;
                App.MyProfiles.SaveCurrentProfileSetting(ProfileViewModel.ProfileSetting.TrackingStatusSynced, result.ToString());
                CurrentProfile.IsSOSStatusSynced = result;
                App.MyProfiles.SaveCurrentProfileSetting(ProfileViewModel.ProfileSetting.SosStatusSynced, result.ToString());

                TagList.Clear();
                PostedLocationIndex         = 0;
                CurrentProfile.SessionToken = string.Empty;
            }
        }