Пример #1
0
        public void StartTourNavigation(string tourName, List <DetalleUsuarioTour> detalleUsuarioTourList)
        {
            var tourController = new TourController(detalleUsuarioTourList);

            List <PathDataDijkstra> tourPath       = new List <PathDataDijkstra>();
            bool   isSelectCurrentIndexSectionTour = false;
            int    indexCurrentTourPathData        = 0;
            string startTourNode = string.Empty;

            using (var sqlService = new SQLiteService())
            {
                for (int i = 0; i < detalleUsuarioTourList.Count; ++i)
                {
                    if (i + 1 != detalleUsuarioTourList.Count && !detalleUsuarioTourList[i + 1].fechaFin.HasValue)
                    {
                        //Buscar en la base de dato el desde y el hasta
                        string desde = string.Empty, hasta = string.Empty;

                        var sql =
                            "SELECT NODA.nombre as desde, NODB.nombre as hasta " +
                            "FROM PuntoReunionTour PUNA, Nodo NODA, PuntoReunionTour PUNB, Nodo NODB " +
                            "WHERE PUNA.id = " + detalleUsuarioTourList[i].idPuntoReunionTour + " AND PUNA.idNodo = NODA.idNodo " +
                            "AND PUNB.id = " + detalleUsuarioTourList[i + 1].idPuntoReunionTour + " AND PUNB.idNodo = NODB.idNodo " +
                            "ORDER BY PUNA.id";

                        using (var result = sqlService.SelectQuery(sql))
                        {
                            if (result.Read())
                            {
                                desde = System.Convert.ToString(result["desde"]);
                                hasta = System.Convert.ToString(result["hasta"]);
                            }
                        }

                        List <PathDataDijkstra> bestPath = graph.Dijkstra(desde, hasta);
                        tourPath.AddRange(bestPath);

                        tourController.AddSectionTour(new SectionTourData()
                        {
                            Desde = desde,
                            IdPuntoReuionNodoDesde = detalleUsuarioTourList[i].idPuntoReunionTour.Value,
                            Hasta = hasta,
                            IdPuntoReuionNodoHasta = detalleUsuarioTourList[i + 1].idPuntoReunionTour.Value,
                        });

                        if (!isSelectCurrentIndexSectionTour)
                        {
                            isSelectCurrentIndexSectionTour = true;
                            tourController.SetStartSectionTour(i);

                            indexCurrentTourPathData = tourPath.FindIndex(path => path.StartNode.Name == desde);
                            startTourNode            = desde;
                        }
                    }
                }
            }

            var userPath = GetBestPathData(startTourNode);

            userPath.AddRange(tourPath);

            ModelPoolManager.GetInstance().Add("tourCtrl", tourController);

            //Mostrar el menu de direciones
            MenuNavigation menuNavigation = new MenuNavigation("MenuNavigation", userPath, indexCurrentTourPathData, tourName);

            MenuManager.GetInstance().AddMenu(menuNavigation);

            State.ChangeState(eState.MenuNavigation);
        }