Beispiel #1
0
 public async Task<bool> SaveRouteAsync(Route route)
 {
     bool IsSuccesful = true;
     //If the name is used, disregard
     List<int> IsTaken = await Database.QueryAsync<int>("SELECT RouteID FROM DatabaseRoute WHERE Name = ?", new object[] { route.Name });
     if (IsTaken.Count != 0)
         return false; //IsSuccesful = false;
     //Otherwise insert it.
     DatabaseRoute forDatabase = DatabaseRoute.ToDatabaseRoute(route);
     await Database.InsertAsync(forDatabase);
     foreach (Waypoint w in route.WayPoints)
     {
         int existingID = await Database.ExecuteScalarAsync<int>("SELECT WaypointID FROM DatabasePOI WHERE Latitude = ? AND Longitude = ?", new object[] {w.Latitude, w.Longitude});
         if (existingID == 0)
         {
             int waypointID = await SaveWaypoint(w);
             await Database.ExecuteAsync("INSERT INTO RouteBinds VALUES(?, ?)", new object[] { forDatabase.RouteID, waypointID });
         }
         else
         {
             await Database.ExecuteAsync("INSERT INTO RouteBinds VALUES(?, ?)", new object[] { forDatabase.RouteID, existingID });
         }
     }
     return IsSuccesful;
 }
Beispiel #2
0
        public async void standardRoute()
        {
            List<Waypoint> waypoints = new List<Waypoint>();

            GTec.User.Model.Route route = await GTec.User.Controller.Control.GetInstance().DatabaseConnnector.GetCurrentRoute();

            #region hard-coded waypoints
            List<string> routeNameList = await GTec.User.Controller.DatabaseConnector.INSTANCE.GetRouteNamesAsync();

            bool found = false;
            foreach (string str in routeNameList)
                if (str == "HKtest1")
                    found = true;

            if (!found)
            {
                waypoints.Add(new PointOfInterest(51.59380, 4.77963, false, "VVV", "VVV", "ms-appx:///Assets/BadgeLogo.scale-100.png", " "));
                waypoints.Add(new Waypoint(51.59307, 4.77969));
                waypoints.Add(new Waypoint(51.59250, 4.77969));
                waypoints.Add(new PointOfInterest(51.59250, 4.77968, false, "NassauMonument", "NassauMonument", "ms-appx:///Assets/images/NassauMonument.jpg", " "));
                waypoints.Add(new PointOfInterest(51.59256, 4.77889, false, "Valkenberg", "Valkenberg", " ", " "));
                waypoints.Add(new Waypoint(51.59265, 4.77844));
                waypoints.Add(new Waypoint(51.59258, 4.77806));
                waypoints.Add(new Waypoint(51.59059, 4.77707));
                waypoints.Add(new PointOfInterest(51.59061, 4.77624, false, "Kasteel", "Kasteel", "ms-appx:///Assets/images/kasteel.jpg", " "));
                waypoints.Add(new Waypoint(51.58992, 4.77634));
                waypoints.Add(new Waypoint(51.59033, 4.77623));
                waypoints.Add(new Waypoint(51.59043, 4.77518));
                waypoints.Add(new Waypoint(51.59000, 4.77429));
                waypoints.Add(new PointOfInterest(51.59010, 4.77336, false, "Vishal", "Vishal", "ms-appx:///Assets/images/Vishal.jpg", " "));
                waypoints.Add(new Waypoint(51.58982, 4.77321));
                waypoints.Add(new Waypoint(51.58932, 4.77444));
                waypoints.Add(new PointOfInterest(51.58872, 4.77501, false, "Stadhuis", "Stadhuis", "ms-appx:///Assets/images/stadhuis.jpg", " "));
                waypoints.Add(new PointOfInterest(51.58878, 4.77549, false, "AntoniusKerk", "AntoniusKerk", "ms-appx:///Assets/images/stAntoniuskerk.jpg", " "));
                waypoints.Add(new Waypoint(51.58864, 4.77501));
                waypoints.Add(new PointOfInterest(51.58822, 4.77525, false, "Kloosterkazerne", "Kloosterkazerne", "ms-appx:///Assets/images/kloosterKazerne.jpg", " "));
                waypoints.Add(new Waypoint(51.58716, 4.77582));
                waypoints.Add(new Waypoint(51.58747, 4.77662));
                waypoints.Add(new Waypoint(51.58771, 4.77652));
                waypoints.Add(new Waypoint(51.58797, 4.77638));
                waypoints.Add(new Waypoint(51.58885, 4.77616));
                waypoints.Add(new Waypoint(51.58883, 4.77617));
                waypoints.Add(new Waypoint(51.58889, 4.77659));
                waypoints.Add(new Waypoint(51.58883, 4.77618));
                waypoints.Add(new Waypoint(51.58747, 4.77663));
                waypoints.Add(new Waypoint(51.58761, 4.77712));
                waypoints.Add(new Waypoint(51.58828, 4.77858));
                waypoints.Add(new Waypoint(51.58773, 4.77948));
                waypoints.Add(new PointOfInterest(51.58752, 4.77994, false, "Bibliotheek", "Bibliotheek", "ms-appx:///Assets/images/bibliotheek.jpg", " "));
                waypoints.Add(new Waypoint(51.58794, 4.78105));
                waypoints.Add(new Waypoint(51.58794, 4.78218));
                waypoints.Add(new Waypoint(51.58794, 4.78106));
                waypoints.Add(new Waypoint(51.58862, 4.78079));
                waypoints.Add(new Waypoint(51.58955, 4.78038));
                waypoints.Add(new Waypoint(51.58966, 4.78076));
                waypoints.Add(new Waypoint(51.58939, 4.77982));
                waypoints.Add(new Waypoint(51.58905, 4.77981));
                waypoints.Add(new Waypoint(51.58846, 4.77830));
                waypoints.Add(new Waypoint(51.58905, 4.77801));
                waypoints.Add(new Waypoint(51.58918, 4.77841));
                waypoints.Add(new Waypoint(51.58905, 4.77802));
                waypoints.Add(new Waypoint(51.58960, 4.77770));
                waypoints.Add(new Waypoint(51.58965, 4.77830));
                waypoints.Add(new Waypoint(51.58997, 4.77810));
                waypoints.Add(new Waypoint(51.58965, 4.77831));
                waypoints.Add(new Waypoint(51.58950, 4.77649));

                Route route1 = new Route("HKtest1", "bleh.wav", waypoints);

                await Controller.DatabaseConnector.INSTANCE.SaveRouteAsync(route1);
            }
            #endregion

            //if (route == null)
            //{
            //    MessageDialog makeAdminWork = new MessageDialog("Admin, work.", "Make admin work.");
            //    await makeAdminWork.ShowAsync();
            //    return;
            //}

            showRoute();
        }
Beispiel #3
0
 private void AddPointsOfInterest(Route currentRoute)
 {
     GeofenceMonitor.Current.Geofences.Clear();
     for (int i = 0; i < currentRoute.WayPoints.Count; ++i)
     {
         AddPushpin(currentRoute.WayPoints[i], i);
     }
 }
Beispiel #4
0
 private async void saveTraversedRoute()
 {
       Route traversedRoute = new Route(Controller.Control.GetInstance().CurrentRoute.Name,
                                        Controller.Control.GetInstance().CurrentRoute.SystemSoundPath,
                                        new List<Waypoint>());
       foreach(Waypoint wp in Controller.Control.GetInstance().CurrentRoute.WayPoints)
       {
           if (wp.Visited)
               traversedRoute.WayPoints.Add(wp);
       }
       await Controller.Control.GetInstance().DatabaseConnnector.SaveVisitedRouteAsync(traversedRoute);
 }
Beispiel #5
0
        private async void SaveEditedRoute_Button_Click(object sender, RoutedEventArgs e)
        {
            if (EditedRouteWayPoints.Count == 0 || RouteName2.Text == "" || EditedRouteWayPoints.Count < 2)
                return;
            if (CurrentRoute.SelectedItem != null)
                return;
            var currentLanguage = User.Controller.Control.GetInstance().LanguageManager.CurrentLanguage;
            MessageDialog msgDialog = new MessageDialog("bleh");
            if (currentLanguage == User.Controller.Language.English)
            {
                msgDialog.Content = "Please wait a second, while we take a few seconds to set things up for you.";
                msgDialog.Title = "Please be patient!";
            }
            else if (currentLanguage == User.Controller.Language.Dutch)
            {
                msgDialog.Content = "Graag een moment geduld, terwijl alles in gereedheid wordt gebracht";
                msgDialog.Title = "Een moment geduld aub!";
            }
            IAsyncOperation<IUICommand> asyncCommand = msgDialog.ShowAsync();  //No need to wait for this.

            Route oldRoute = await GTec.User.Controller.DatabaseConnector.INSTANCE.GetRouteAsync(CurrentRoute2.SelectedItem as string);      

            List<Waypoint> waypoints = new List<Waypoint>();
            foreach (PointOfInterest poi in EditedRouteWayPoints)
            {
                if(poi.Name == String.Empty)
                    waypoints.Add(poi as Waypoint);
                else
                    waypoints.Add(poi);
            }
            Route newRoute = new Route(RouteName2.Text, "", waypoints);

            await GTec.User.Controller.Control.GetInstance().DatabaseConnnector.EditRouteAsync(oldRoute.Name, newRoute);
            asyncCommand.Cancel();
        }
Beispiel #6
0
        private async void SaveRoute_Button_Click(object sender, RoutedEventArgs e)
        {
            if (WayPoints.Count == 0 || RouteName.Text == "" || WayPoints.Count < 2)
            {
                if (CurrentRoute.SelectedItem != null)
                {
                    var currentLanguage = User.Controller.Control.GetInstance().LanguageManager.CurrentLanguage;
                    MessageDialog msgDialog = new MessageDialog("bleh");
                    if (currentLanguage == User.Controller.Language.English)
                    {
                        msgDialog.Content = "Please wait a second, while we take a few seconds to set things up for you.";
                        msgDialog.Title = "Please be patient!";
                    }
                    else if (currentLanguage == User.Controller.Language.Dutch)
                    {
                        msgDialog.Content = "Graag een moment geduld, terwijl alles in gereedheid wordt gebracht";
                        msgDialog.Title = "Een moment geduld aub!";
                    }
                    IAsyncOperation<IUICommand> asyncCommand = msgDialog.ShowAsync();  //No need to wait for this.

                    Route r = await GTec.User.Controller.DatabaseConnector.INSTANCE.GetRouteAsync(CurrentRoute.SelectedItem as string);
                    await GTec.User.Controller.DatabaseConnector.INSTANCE.SaveCurrentRouteAsync(r);
                    GTec.User.Controller.Control.GetInstance().CurrentRoute = r;

                    asyncCommand.Cancel();
                    if (Frame.CanGoBack)
                    {
                        Frame.GoBack();
                    }
                }
                return;
            }

            List<Waypoint> waypoints = new List<Waypoint>();
            foreach (Waypoint waypoint in WayPoints)
            {
                if(waypoint is PointOfInterest)
                    waypoints.Add(waypoint as PointOfInterest);
                else
                    waypoints.Add(waypoint as Waypoint);               
            }
            Route route = new Route(RouteName.Text, "", waypoints);

            await GTec.User.Controller.Control.GetInstance().DatabaseConnnector.SaveRouteAsync(route);

            if ((bool)SetAsCurrentRouteCheckBox.IsChecked)
            {
                GTec.User.Controller.Control.GetInstance().CurrentRoute = route;
                await GTec.User.Controller.DatabaseConnector.INSTANCE.SaveCurrentRouteAsync(route);
            }
            else
            {
                if (CurrentRoute.SelectedItem != null)
                {
                    await GTec.User.Controller.DatabaseConnector.INSTANCE.SaveCurrentRouteAsync(route);
                    GTec.User.Controller.Control.GetInstance().CurrentRoute = await GTec.User.Controller.DatabaseConnector.INSTANCE.GetRouteAsync(CurrentRoute.SelectedItem as string);
                }
            }
            if (Frame.CanGoBack)
            {
                Frame.GoBack();
            }
        }
Beispiel #7
0
        public async void standardRoute()
        {
            List <Waypoint> waypoints = new List <Waypoint>();

            GTec.User.Model.Route route = await GTec.User.Controller.Control.GetInstance().DatabaseConnnector.GetCurrentRoute();

            #region hard-coded waypoints
            List <string> routeNameList = await GTec.User.Controller.DatabaseConnector.INSTANCE.GetRouteNamesAsync();

            bool found = false;
            foreach (string str in routeNameList)
            {
                if (str == "HKtest1")
                {
                    found = true;
                }
            }

            if (!found)
            {
                waypoints.Add(new PointOfInterest(51.59380, 4.77963, false, "VVV", "VVV", "ms-appx:///Assets/BadgeLogo.scale-100.png", " "));
                waypoints.Add(new Waypoint(51.59307, 4.77969));
                waypoints.Add(new Waypoint(51.59250, 4.77969));
                waypoints.Add(new PointOfInterest(51.59250, 4.77968, false, "NassauMonument", "NassauMonument", "ms-appx:///Assets/images/NassauMonument.jpg", " "));
                waypoints.Add(new PointOfInterest(51.59256, 4.77889, false, "Valkenberg", "Valkenberg", " ", " "));
                waypoints.Add(new Waypoint(51.59265, 4.77844));
                waypoints.Add(new Waypoint(51.59258, 4.77806));
                waypoints.Add(new Waypoint(51.59059, 4.77707));
                waypoints.Add(new PointOfInterest(51.59061, 4.77624, false, "Kasteel", "Kasteel", "ms-appx:///Assets/images/kasteel.jpg", " "));
                waypoints.Add(new Waypoint(51.58992, 4.77634));
                waypoints.Add(new Waypoint(51.59033, 4.77623));
                waypoints.Add(new Waypoint(51.59043, 4.77518));
                waypoints.Add(new Waypoint(51.59000, 4.77429));
                waypoints.Add(new PointOfInterest(51.59010, 4.77336, false, "Vishal", "Vishal", "ms-appx:///Assets/images/Vishal.jpg", " "));
                waypoints.Add(new Waypoint(51.58982, 4.77321));
                waypoints.Add(new Waypoint(51.58932, 4.77444));
                waypoints.Add(new PointOfInterest(51.58872, 4.77501, false, "Stadhuis", "Stadhuis", "ms-appx:///Assets/images/stadhuis.jpg", " "));
                waypoints.Add(new PointOfInterest(51.58878, 4.77549, false, "AntoniusKerk", "AntoniusKerk", "ms-appx:///Assets/images/stAntoniuskerk.jpg", " "));
                waypoints.Add(new Waypoint(51.58864, 4.77501));
                waypoints.Add(new PointOfInterest(51.58822, 4.77525, false, "Kloosterkazerne", "Kloosterkazerne", "ms-appx:///Assets/images/kloosterKazerne.jpg", " "));
                waypoints.Add(new Waypoint(51.58716, 4.77582));
                waypoints.Add(new Waypoint(51.58747, 4.77662));
                waypoints.Add(new Waypoint(51.58771, 4.77652));
                waypoints.Add(new Waypoint(51.58797, 4.77638));
                waypoints.Add(new Waypoint(51.58885, 4.77616));
                waypoints.Add(new Waypoint(51.58883, 4.77617));
                waypoints.Add(new Waypoint(51.58889, 4.77659));
                waypoints.Add(new Waypoint(51.58883, 4.77618));
                waypoints.Add(new Waypoint(51.58747, 4.77663));
                waypoints.Add(new Waypoint(51.58761, 4.77712));
                waypoints.Add(new Waypoint(51.58828, 4.77858));
                waypoints.Add(new Waypoint(51.58773, 4.77948));
                waypoints.Add(new PointOfInterest(51.58752, 4.77994, false, "Bibliotheek", "Bibliotheek", "ms-appx:///Assets/images/bibliotheek.jpg", " "));
                waypoints.Add(new Waypoint(51.58794, 4.78105));
                waypoints.Add(new Waypoint(51.58794, 4.78218));
                waypoints.Add(new Waypoint(51.58794, 4.78106));
                waypoints.Add(new Waypoint(51.58862, 4.78079));
                waypoints.Add(new Waypoint(51.58955, 4.78038));
                waypoints.Add(new Waypoint(51.58966, 4.78076));
                waypoints.Add(new Waypoint(51.58939, 4.77982));
                waypoints.Add(new Waypoint(51.58905, 4.77981));
                waypoints.Add(new Waypoint(51.58846, 4.77830));
                waypoints.Add(new Waypoint(51.58905, 4.77801));
                waypoints.Add(new Waypoint(51.58918, 4.77841));
                waypoints.Add(new Waypoint(51.58905, 4.77802));
                waypoints.Add(new Waypoint(51.58960, 4.77770));
                waypoints.Add(new Waypoint(51.58965, 4.77830));
                waypoints.Add(new Waypoint(51.58997, 4.77810));
                waypoints.Add(new Waypoint(51.58965, 4.77831));
                waypoints.Add(new Waypoint(51.58950, 4.77649));

                Route route1 = new Route("HKtest1", "bleh.wav", waypoints);

                await Controller.DatabaseConnector.INSTANCE.SaveRouteAsync(route1);
            }
            #endregion

            //if (route == null)
            //{
            //    MessageDialog makeAdminWork = new MessageDialog("Admin, work.", "Make admin work.");
            //    await makeAdminWork.ShowAsync();
            //    return;
            //}

            showRoute();
        }
Beispiel #8
0
 public async Task<bool> SaveCurrentRouteAsync(Route route)
 {
     bool IsSuccesful = true;
     DatabaseRoute forDatabase = DatabaseRoute.ToDatabaseRoute(route);
     forDatabase.Name = "DF%Yyw54ye54yfw5u6ujtrhjw6hw45w4%HW$%HWT$GFWt4hft4th4wvhwtrg";
     await DeleteCurrentRoute();
     forDatabase.RouteID = 999; //Set to reserved ID
     await Database.InsertAsync(forDatabase);
     foreach (Waypoint w in route.WayPoints)
     {
         int existingID = await Database.ExecuteScalarAsync<int>("SELECT WaypointID FROM DatabasePOI WHERE Latitude = ? AND Longitude = ?", new object[] { w.Latitude, w.Longitude });
         await Database.ExecuteAsync("INSERT INTO RouteBinds VALUES(?, ?)", new object[] { forDatabase.RouteID, existingID });
     }
     return IsSuccesful;
 }
Beispiel #9
0
 public static DatabaseRoute ToDatabaseRouteIDless(Route toConvert, int id)
 {
     return new DatabaseRoute(toConvert.Name, toConvert.SystemSoundPath, id);
 }
Beispiel #10
0
 public static DatabaseRoute ToDatabaseRoute(Route toConvert)
 {
     return new DatabaseRoute(toConvert.Name, toConvert.SystemSoundPath, DatabaseConnector.INSTANCE.generateRouteID());
 }
Beispiel #11
0
 public async Task EditRouteAsync(string oldRouteName, Route newRoute)
 {
     //Remember the Database ID of the route
     int id = Database.QueryAsync<DatabaseRoute>("SELECT * FROM \"DatabaseRoute\" WHERE \"Name\" = ? AND RouteID <> 999 AND RouteID <> 998", new object[] { oldRouteName }).Result[0].RouteID;
     //And remove it
     await DeleteRouteAsync(oldRouteName);
     //Now create & insert the new route 
     DatabaseRoute forDatabase = DatabaseRoute.ToDatabaseRouteIDless(newRoute, id);
     await Database.InsertAsync(forDatabase);
     //Then bind the waypoints
     foreach (Waypoint newWaypoint in newRoute.WayPoints)
     {
         int existingID = await Database.ExecuteScalarAsync<int>("SELECT WaypointID FROM DatabasePOI WHERE Latitude = ? AND Longitude = ?", new object[] { newWaypoint.Latitude, newWaypoint.Longitude });
         if (existingID == 0)
         {
             //In the case it's a new waypoint, save and bind to this route 
             int waypointID = await SaveWaypoint(newWaypoint);
             await Database.ExecuteAsync("INSERT INTO RouteBinds VALUES(?, ?)", new object[] { forDatabase.RouteID, waypointID });
         }
         else
         {
             //But if it exists, edit waypoint if neccesary, check if the bind persisted and then insert
             await EditWaypointAsync(DatabasePOI.ToWaypoint(
                 Database.QueryAsync<DatabasePOI>("SELECT * FROM DatabasePOI WHERE Latitude = ? AND Longitude = ?", new object[] { newWaypoint.Latitude, newWaypoint.Longitude }).Result[0])
                 , newWaypoint);
             List<RouteBind> binds = await Database.QueryAsync<RouteBind>("SELECT WaypointID FROM RouteBinds WHERE RouteID = ? AND RouteID <> 999 AND RouteID <> 998 AND WaypointID = ?", new object[] { id, existingID });
             if(binds.Count == 0)
                 await Database.ExecuteAsync("INSERT INTO RouteBinds VALUES(?, ?)", new object[] { forDatabase.RouteID, existingID });
         }
     }
     //In the case this is the active route, replace.
     Route currentRoute = await GetCurrentRoute();
     
     if (currentRoute != null && currentRoute.Name == oldRouteName)
         await SaveCurrentRouteAsync(newRoute);
 }
Beispiel #12
0
 public async Task DeleteRouteAsync(Route route)
 {
     await DeleteRouteAsync(route.Name);
 }
Beispiel #13
0
 public async Task<bool> SaveVisitedRouteAsync(Route route)
 {
     bool IsSuccesful = true;
     DatabaseRoute forDatabase = DatabaseRoute.ToDatabaseRoute(route);
     forDatabase.Name = "FWGFETY^Rufw4r6ue6fyue46YGE^GU#EÛE6gue6guef6ug6eg6gue46gue6EU^GUE^FUEG%Ê";
     await DeleteVisitedRoute();
     forDatabase.RouteID = 998; //Set to reserved ID
     await Database.InsertAsync(forDatabase);
     foreach (Waypoint w in route.WayPoints)
     {
         int existingID = await Database.ExecuteScalarAsync<int>("SELECT WaypointID FROM DatabasePOI WHERE Latitude = ? AND Longitude = ?", new object[] { w.Latitude, w.Longitude });
         await Database.ExecuteAsync("INSERT INTO RouteBinds VALUES(?, ?)", new object[] { forDatabase.RouteID, existingID });
     }
     return IsSuccesful;
 }