コード例 #1
0
 public Putaway()
 {
     _putawayDao      = new PutawayDAO();
     _locationService = new LocationServiceWrapper();
     _putawayService  = new PutawayServiceWrapper();
     _cmsService      = new CmsServiceWrapper();
 }
コード例 #2
0
ファイル: Globals.cs プロジェクト: weddingjuma/Guardian
 /// <summary>
 /// If user doesnt move, but app is open, then keep his session Live with the last available position
 /// </summary>
 public static void KeepLive()
 {
     if ((CurrentProfile.IsSOSOn || CurrentProfile.IsTrackingOn) && RecentLocation.CapturedTime.AddMinutes(5) < DateTime.Now)
     {
         //RecentLocation.CapturedTime = DateTime.Now;
         LocationServiceWrapper.PostMyLocationAsync(RecentLocation.Coordinate, null);
     }
 }
コード例 #3
0
ファイル: MainPage.xaml.cs プロジェクト: weddingjuma/Guardian
 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);
     }
 }
コード例 #4
0
ファイル: Globals.cs プロジェクト: weddingjuma/Guardian
        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;
                }
            }
        }
コード例 #5
0
ファイル: Globals.cs プロジェクト: weddingjuma/Guardian
        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());
            }
        }
コード例 #6
0
ファイル: Globals.cs プロジェクト: weddingjuma/Guardian
        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");
                    });
                }
            }
        }
コード例 #7
0
        protected async void InitiateSosEventsAsync()
        {
            bool initiateSMS = false;

            if (!Globals.IsRegisteredUser || !Globals.IsDataNetworkAvailable)
            {
                initiateSMS = true;
            }
            else
            {
                try
                {
                    LocationServiceWrapper.PostMyLocationAsync(await Utility.GetLocationQuick(), null);
                }
                catch
                {
                    initiateSMS = true;
                }
            }
            if (initiateSMS)
            {
                await SendOfflineMessagesAsync();
            }

            try
            {
                if (App.MyBuddies.Buddies != null && App.MyBuddies.Buddies.Count > 0)
                {
                    Callee           defaultCallee = new Callee();
                    BuddyTableEntity buddyEntity   = App.MyBuddies.GetPrimeBuddy(Globals.CurrentProfile.ProfileId);
                    if (buddyEntity != null)
                    {
                        defaultCallee.PhoneNumber = buddyEntity.PhoneNumber;
                        defaultCallee.DisplayName = buddyEntity.Name;
                        Utility.InitiateCall(defaultCallee);
                    }
                }
            }
            catch
            {
                //Ignore if exception raised while calling the default caller
            }
        }
コード例 #8
0
ファイル: MainPage.xaml.cs プロジェクト: weddingjuma/Guardian
        private async void GetLiveTileCountsAsync()
        {
            if (Globals.IsRegisteredUser && SOSCountTextBlockData.Contains("NA"))
            {
                SOSCountTextBlock.Text      = "SOS: 00";
                TrackingCountTextBlock.Text = "Tracking: 00";
            }
            if (Globals.IsRegisteredUser && Globals.IsDataNetworkAvailable)
            {
                try
                {
                    ProgressBarLocate.Visibility = Visibility.Visible;
                    Dictionary <string, string> liveCounts = await LocationServiceWrapper.GetLocateLiveTileCountAsync();

                    string sosCount = "00", trackCount = "00";

                    if (liveCounts != null)
                    {
                        liveCounts.TryGetValue("SOSCount", out sosCount);
                        SOSCountTextBlock.Text = "SOS: " + (sosCount.Length == 1 ? "0" + sosCount : sosCount);

                        liveCounts.TryGetValue("TrackCount", out trackCount);
                        TrackingCountTextBlock.Text = "Tracking: " + (trackCount.Length == 1 ? "0" + trackCount : trackCount);
                        SOSCountTextBlockData       = SOSCountTextBlock.Text;
                        TrackingCountTextBlockData  = TrackingCountTextBlock.Text;
                    }
                    ProgressBarLocate.Visibility = Visibility.Collapsed;
                }
                catch (Exception ex)
                {
                    ProgressBarLocate.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                SOSCountTextBlock.Text      = "SOS: NA";
                TrackingCountTextBlock.Text = "Tracking: NA";
            }
        }
コード例 #9
0
        private async void EvidenceCameraCaptureTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                try
                {
                    if (Globals.CurrentProfile.IsSOSOn || Globals.CurrentProfile.IsTrackingOn)
                    {
                        GeoCoordinate gc = await Utility.GetLocationQuick();

                        await LocationServiceWrapper.PostMyLocationAsync(gc, e.ChosenPhoto);
                    }
                    else
                    {
                        Deployment.Current.Dispatcher.BeginInvoke(() => Globals.DisplayToast(CustomMessage.InvalidPhotoCapture, "basicWrap", "Evidence upload failed!"));
                    }
                }
                catch (Exception ex)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() => Globals.DisplayToast(CustomMessage.EvidenceUploadFailText, "basicWrap", "Evidence upload failed!"));
                }
            }
        }
コード例 #10
0
        public async Task <bool> RefreshLocateBuddies()
        {
            try
            {
                this.Message = string.Empty;

                if (Globals.IsDataNetworkAvailable && Globals.IsRegisteredUser)
                {
                    IsInProgress = true;
                    await LocationServiceWrapper.GetLocateMembersAsync(this.GetLocateMembersList);

                    if (LocationServiceWrapper.IsErrorOccured == true)
                    {
                        Message = "Unable to retrieve latest information about your Locate Buddies...";
                    }
                }
            }
            catch (Exception)
            {
                this.Message = "Unable to retrieve latest information about your Locate Buddies...";
            }
            IsInProgress = false;
            return(true);
        }
コード例 #11
0
ファイル: Globals.cs プロジェクト: weddingjuma/Guardian
        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;
            }
        }
コード例 #12
0
ファイル: MainPage.xaml.cs プロジェクト: weddingjuma/Guardian
        async void PhoneApplicationPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (Globals.CurrentProfile.IsSOSOn || Globals.CurrentProfile.IsTrackingOn)
            {
                e.Cancel = true;
                if (!isBackMsgBoxDisplayed)
                {
                    this.isBackMsgBoxDisplayed = true;
                    ThreadPool.RunAsync(delegate
                    {
                        Dispatcher.BeginInvoke(async() =>
                        {
                            if (MessageBox.Show(CustomMessage.ExitApplication, "Are you sure to quit Guardian?", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                            {
                                //Call the code you would normally call in the functions OnNavigatedFrom and Application_Closing
                                //as none of them would be fired once App.Terminate is called
                                m_ProgressBar.Visibility          = Visibility.Visible;
                                Globals.LocationServiceGeolocator = null;

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

                                bool result = await(new Retrier <Task <bool> >()).TryWithDelay(() => LocationServiceWrapper.StopPostingsAsync(Globals.CurrentProfile.SessionToken), 2, 0);
                                if (result)
                                {
                                    App.MyProfiles.SaveCurrentProfileSetting(SOS.Phone.ProfileViewModel.ProfileSetting.SOSStatus, "false");
                                    App.MyProfiles.SaveCurrentProfileSetting(SOS.Phone.ProfileViewModel.ProfileSetting.TrackingStatus, "false");
                                    App.MyProfiles.SaveCurrentProfileSetting(ProfileViewModel.ProfileSetting.SosStatusSynced, "true");
                                    App.MyProfiles.SaveCurrentProfileSetting(ProfileViewModel.ProfileSetting.TrackingStatusSynced, "true");
                                }
                                //if (Globals.CurrentProfile.IsSOSOn)
                                //{
                                //    App.MyProfiles.SaveCurrentProfileSetting(SOS.Phone.ProfileViewModel.ProfileSetting.SOSStatus, "false");
                                //    await Globals.InitiateStopSOSEventsAsync(true);
                                //}
                                //App.MyProfiles.SaveCurrentProfileSetting(SOS.Phone.ProfileViewModel.ProfileSetting.TrackingStatus, "false");
                                //await StopTrackingEventsAsync(true);

                                ClearBackEntries();

                                //This will also have a side effect that every time, your app will be termed as terminated instead of being called by user
                                App.Current.Terminate();
                            }

                            this.isBackMsgBoxDisplayed = false;
                        });
                    });
                }
            }
            else
            {
                bool            hasRated = false;
                DispatcherTimer dt       = new DispatcherTimer();
                dt.Interval = new TimeSpan(0, 0, 5);
                dt.Tick    += dt_Tick;
                dt.Start();
                if (IsolatedStorageSettings.ApplicationSettings.Contains("count"))
                {
                    //Retrieve the value
                    hasRated = (bool)IsolatedStorageSettings.ApplicationSettings["count"];
                }
                if (hasRated == false)
                {
                    //Globals.hasRated = false;

                    // Store the value
                    IsolatedStorageSettings.ApplicationSettings["count"] = hasRated;
                    MessageBoxResult result = MessageBox.Show("If you liked the app, please rate and review it on the store to help us improve it", "Rate & Review the app", MessageBoxButton.OKCancel);
                    if (result == MessageBoxResult.OK)
                    {
                        hasRated = true;
                        IsolatedStorageSettings.ApplicationSettings["count"] = hasRated;
                        MarketplaceReviewTask mrTask = new MarketplaceReviewTask();
                        mrTask.Show();
                    }
                    else if (result == MessageBoxResult.Cancel)
                    {
                        App.Current.Terminate();
                    }
                }
                else
                {
                    hasRated = false;
                    // Store the value
                    IsolatedStorageSettings.ApplicationSettings["count"] = hasRated;
                    App.Current.Terminate();
                }
            }
        }
コード例 #13
0
        private async Task ReportTeaseToServer(GeoCoordinate gc, PhotoResult e)
        {
            string serverSyncStatus = string.Empty;

            try
            {
                PanelCategory.Visibility = Visibility.Collapsed;
                ButtonReportIncidentProceed.Visibility = Visibility.Collapsed;
                AddInfoStkPanel.Visibility             = Visibility.Collapsed;
                PanelReportMessage.Visibility          = Visibility.Visible;
                if (Globals.IsDataNetworkAvailable && Globals.IsRegisteredUser)
                {
                    byte[] b = null;

                    if (e.ChosenPhoto != null)
                    {
                        using (BinaryReader br = new BinaryReader(Phone.Utilites.PhotoResizer.ReduceSize(e.ChosenPhoto)))
                        {
                            b = br.ReadBytes((Int32)e.ChosenPhoto.Length);
                        }
                    }

                    GeoServiceRef.IncidentTag tag = new GeoServiceRef.IncidentTag()
                    {
                        Name           = Globals.User.Name,
                        MobileNumber   = Globals.CurrentProfile.MobileNumber,
                        Lat            = (gc == null) ? string.Empty : gc.Latitude.ToString(),
                        Long           = (gc == null) ? string.Empty : gc.Longitude.ToString(),
                        ProfileID      = Convert.ToInt64(Globals.CurrentProfile.ProfileId),
                        SessionID      = string.Empty,
                        Alt            = gc.Altitude.ToString(),
                        GeoDirection   = "1",//"TODO"
                        Speed          = (gc == null || double.IsNaN(gc.Speed)) ? 0 : Convert.ToInt32(gc.Speed),
                        Accuracy       = Math.Round(gc.HorizontalAccuracy),
                        TimeStamp      = DateTime.Now.Ticks,
                        Command        = Category.ToUpper(),
                        MediaContent   = b,
                        AdditionalInfo = AdditionalInfoTB.Text
                    };
                    await LocationServiceWrapper.ReportIncident(tag);

                    PanelReportMessage.Visibility = Visibility.Visible;
                    serverSyncStatus = "Success";
                }
            }
            catch (Exception ex)
            {
                PanelReportMessage.Visibility = Visibility.Collapsed;
                serverSyncStatus = "Fail";
            }
            finally
            {
                if (NavigationService.BackStack != null && NavigationService.BackStack.Count() > 0)
                {
                    NavigationService.RemoveBackEntry();
                }

                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    if (serverSyncStatus == "Success")
                    {
                        Globals.DisplayToast(CustomMessage.ReportTeaseToServerSuccessText, "basicWrap", "Report incident successful!");
                    }
                    else if (serverSyncStatus == "Fail")
                    {
                        Globals.DisplayToast("Reasons could be " + Environment.NewLine + "  1. GPS is turned off  " + Environment.NewLine + "  2. Unable to reach Guardian Server", "basicWrap", "Report incident failed!");
                    }
                });
            }
        }