コード例 #1
0
        public async Task GetChildLastLocation()
        {
            var requester      = new LocationsHttpRequester();
            var latestLocation = await requester.GetLocation();


            //TODO: >>Add user filtraton for multiple users

            if (latestLocation != null)
            {
                var position = new BasicGeoposition();
                position.Latitude     = latestLocation.Latitude;
                position.Longitude    = latestLocation.Longitude;
                this.CurrentSelection = position;

                var dbLocation = new SQLiteLocationModel()
                {
                    Latitude     = latestLocation.Latitude,
                    Longitude    = latestLocation.Longitude,
                    LocationDate = (DateTime)latestLocation.CreationDate,
                    UserId       = LocalData.USERNAME
                };

                ((ObservableCollection <SQLiteLocationModel>) this.LatestLocationReviews).Insert(0, dbLocation);
                await this._locationsDb.AddLocation(dbLocation);
            }
        }
コード例 #2
0
        private async void OnLogoutButtonClick(object sender, RoutedEventArgs e)
        {
            var passwordInput = this.PasswordBoxInput.Password.GetHashCode().ToString();
            var userPassword  = LocalData.PASSWORD;

            if (passwordInput == userPassword)
            {
                var requester = new LocationsHttpRequester();
                requester.Logout();
                this.Frame.Navigate(typeof(LoginSignupPage));
            }
            else
            {
                var popup = new MessageDialog("Wrong password!", "Incorrect data!");
                await popup.ShowAsync();
            }
        }
コード例 #3
0
        private async void SendLocation()
        {
            var locator = new Geolocator();

            locator.DesiredAccuracyInMeters = 50;
            var position = await locator.GetGeopositionAsync();

            var lat = position.Coordinate.Point.Position.Latitude;
            var lon = position.Coordinate.Point.Position.Longitude;

            var location = new LocationModel()
            {
                Latitude  = lat,
                Longitude = lon
            };

            var requester = new LocationsHttpRequester();

            requester.SendLocation(location);


            ////Background task
            //string taskName = "Localization task";
            //bool isRegistered = false;
            //// check if task is already registered
            //foreach (var cur in BackgroundTaskRegistration.AllTasks)
            //    if (cur.Value.Name == taskName)
            //    {
            //        isRegistered = true;
            //    }

            //if (!isRegistered)
            //{
            //    await BackgroundExecutionManager.RequestAccessAsync();
            //    BackgroundTaskBuilder taskBuilder = new BackgroundTaskBuilder { Name = taskName, TaskEntryPoint = "LocationSenderTask.LocationSender" };
            //    taskBuilder.SetTrigger(new TimeTrigger(30, false));
            //    BackgroundTaskRegistration myTask = taskBuilder.Register();

            //    await (new MessageDialog("Task registered")).ShowAsync();
            //}
        }
コード例 #4
0
        public void Logout()
        {
            var requester = new LocationsHttpRequester();

            requester.Logout();
        }