예제 #1
0
        private void GetUsuarioInfoResult(FBResult result)
        {
            if (!string.IsNullOrEmpty(result.Error))
            {
                Debug.LogError(result.Error);
            }
            else
            {
                var json = new JSONObject(result.Text);
                var user = new Usuario(json);

                var modelPool = ModelPoolManager.GetInstance();

                if (!modelPool.Contains("Usuario"))
                {
                    user.email = user.email.Replace("\\u0040", "@");
                    ModelPoolManager.GetInstance().Add("Usuario", user);

                    using (var sqliteService = new SQLiteService())
                    {
                        bool isInDB = false;
                        var  query  = "SELECT * FROM Usuario WHERE idUsuarioFacebook = " + user.idUsuarioFacebook.Value;
                        using (var reader = sqliteService.SelectQuery(query))
                        {
                            if (reader.Read())
                            {
                                isInDB = true;
                            }
                            else
                            {
                                isInDB = false;
                            }
                        }

                        if (!isInDB)
                        {
                            query = "SELECT MAX(id) as id FROM Usuario";

                            int id = 0;
                            using (var reader = sqliteService.SelectQuery(query))
                            {
                                int temp;
                                if (int.TryParse(Convert.ToString(reader["id"]), out temp))
                                {
                                    id = temp;
                                }
                            }

                            id++;
                            sqliteService.TransactionalQuery(
                                "INSERT INTO Usuario VALUES (" + id + ",'" + user.idUsuarioFacebook + "','" + user.nombre + "','" + user.apellido + "','" + user.email + "','" + user.gender + "');"
                                );
                        }
                    }

                    FB.API("/me/picture?width=128&height=128", Facebook.HttpMethod.GET, GetUsuarioInfoPhotoResult);
                    StartCoroutine(SendUserFacebookId(user));
                }
            }
        }
예제 #2
0
        private void ProcessRequest(object obj)
        {
            using (var service = new SQLiteService())
            {
                var idNodo = Convert.ToInt32(obj.GetType().GetProperty("nodo").GetValue(obj, null));

                var sql = "SELECT idUbicacion, edificio, nombre " +
                          "FROM Nodo " +
                          "WHERE idNodo = " + idNodo;

                using (var reader = service.SelectQuery(sql))
                {
                    while (reader.Read())
                    {
                        this.modelNode = new ModelNode()
                        {
                            name        = Convert.ToString(reader["nombre"]),
                            idNodo      = idNodo,
                            idUbicacion = Convert.ToInt32(reader["idUbicacion"])
                        };

                        var edificio = Convert.ToInt32(reader["edificio"]);
                        modelNode.isBuilding = (edificio == modelNode.idUbicacion ? true : false);
                    }
                }
            }

            UIUtils.FindGUI(name + "/TextBoxUbicacion/Label").GetComponent <UILabel>().text = modelNode.name;

            var mensaje = Convert.ToString(obj.GetType().GetProperty("mensaje").GetValue(obj, null));

            UIUtils.FindGUI(name + "/TextBoxMessage/Label").GetComponent <UILabel>().text = mensaje;
        }
예제 #3
0
        private void UpdateCreateScrollView()
        {
            var scrollView = UIUtils.FindGUI("MenuUsuarioTourSelection/ScrollView").transform;

            //Delete ScrollView Childrens
            UIUtils.DestroyChilds("MenuUsuarioTourSelection/ScrollView", true);

            using (var sqlService = new SQLiteService())
            {
                for (int i = 0; i < detalleUsuarioTourList.Count; i++)
                {
                    //Creando el item del Tree View con world coordinates
                    var item = (GameObject.Instantiate(scrollViewItemTemplate.gameObject) as GameObject).transform;

                    item.name = "DetalleUsuarioTourItem" + i;

                    //Agregando relacion de padre (Tree View List) - hijo (item del Tree View List)
                    item.parent = scrollView;

                    //Agregando la posicion relativa del hijo con relacion al padre
                    item.transform.localPosition = new Vector3(
                        scrollViewItemTemplate.localPosition.x,
                        scrollViewItemTemplate.localPosition.y - 65f * i,
                        scrollViewItemTemplate.localPosition.z
                        );

                    //Agregando la escala relativa del hijo con relacion al padre
                    item.localScale = scrollViewItemTemplate.localScale;

                    //Encontrando texto del un item (su hijo)
                    var itemText = item.FindChild("Label").GetComponent <UILabel>();

                    var sql = "SELECT NOD.nombre FROM PuntoReunionTour PUN, Nodo NOD " +
                              "WHERE PUN.id = " + detalleUsuarioTourList[i].idPuntoReunionTour + " AND PUN.idNodo = NOD.idNodo";

                    using (var result = sqlService.SelectQuery(sql))
                    {
                        if (result.Read())
                        {
                            itemText.text = Convert.ToString(result["nombre"]);
                        }
                    }

                    item.FindChild("checkImg").gameObject.SetActive(false);

                    if (detalleUsuarioTourList[i].fechaLlegada.HasValue || (i == 0 && detalleUsuarioTourList[i].fechaInicio.HasValue))
                    {
                        item.FindChild("checkImg").gameObject.SetActive(true);
                    }
                }
            }
        }
예제 #4
0
        private List <Tour> GetTourList()
        {
            List <Tour> tourList = new List <Tour>();

            using (var sqlService = new SQLiteService())
            {
                using (var result = sqlService.SelectQuery("SELECT id, nombreTour FROM Tour"))
                {
                    while (result.Read())
                    {
                        tourList.Add(new Tour()
                        {
                            idTour     = Convert.ToInt32(result["id"]),
                            nombreTour = Convert.ToString(result["nombreTour"])
                        });
                    }
                }
            }

            return(tourList);
        }
예제 #5
0
        private void GetUsuarioInfoPhotoResult(FBResult result)
        {
            if (!string.IsNullOrEmpty(result.Error))
            {
                Debug.LogError(result.Error);
            }
            else
            {
                var logeado = UIUtils.FindGUI("MenuMain/Sidebar/ButtonUsuario").transform.FindChild("Logeado");
                logeado.GetComponent <UITexture>().mainTexture = result.Texture;

                using (var sqliteService = new SQLiteService())
                {
                    using (var reader = sqliteService.SelectQuery("SELECT nombre, apellido FROM Usuario WHERE idUsuarioFacebook = " + FB.UserId))
                    {
                        if (reader.Read())
                        {
                            logeado.transform.FindChild("Label").GetComponent <UILabel>().text = Convert.ToString(reader["nombre"]) + " " + Convert.ToString(reader["apellido"]);
                        }
                    }
                }
            }
        }
예제 #6
0
        private void FillButtonListWithLocations()
        {
            var sql = "SELECT idNodo, nombre FROM Nodo WHERE edificio is null AND idUbicacion = " + modelNode.idUbicacion;

            using (var service = new SQLiteService())
            {
                using (var result = service.SelectQuery(sql))
                {
                    while (result.Read())
                    {
                        var idNodo = Convert.ToInt32(result["idNodo"]);
                        var nombre = Convert.ToString(result["nombre"]);
                        //var planta = Convert.ToInt32(result["planta"]);

                        Button button = new Button(nombre);
                        button.OnTouchEvent += new OnTouchEventHandler(OnTouchLocationInsideBuilding);
                        button.ObjectTag     = new ModelNode {
                            idNodo = idNodo, name = nombre
                        };
                        buttonList.Add(button);
                    }
                }
            }
        }
예제 #7
0
        private void OpenScrollTreeView(string searchText, Transform Parent, GameObject Template)
        {
            //Activando el ScrollTreeView
            //UIUtils.FindGUI("MenuMain/TreeView/ScrollView").SetActive(true);

            UIUtils.ActivateCameraLabels(false);

            var textList = new List <object>();

            //Obteniendo de la Base de datos
            using (var sqlService = new SQLiteService())
            {
                var sql = "SELECT nombre, idUbicacion, idNodo, edificio " +
                          "FROM Nodo " +
                          "WHERE idUbicacion is not null and nombre not like '%Nodo%' and nombre LIKE '%" + searchText + "%' " +
                          "ORDER BY idUbicacion, idNodo";

                using (var reader = sqlService.SelectQuery(sql))
                {
                    while (reader.Read())
                    {
                        var lugar = new
                        {
                            nombre    = Convert.ToString(reader["nombre"]),
                            ubicacion = Convert.ToString(reader["idUbicacion"]),
                            node      = Convert.ToString(reader["idNodo"]),
                            edificio  = Convert.ToString(reader["edificio"])
                        };

                        textList.Add(lugar);
                    }
                }
            }

            //Eliminando los hijos del Tree View List
            UIUtils.DestroyChilds("MenuMain/TreeView/ScrollView", true);

            //Eliminando los item del tree view de la lista de botones de MenuMain
            DeleteScrollTreeViewItem();

            Parent.GetComponent <UIScrollView>().ResetPosition();
            Parent.GetComponent <UIPanel>().clipOffset = new Vector2(2, -4.5f);
            Parent.localPosition = new Vector3(Parent.localPosition.x, 95.5f, Parent.localPosition.z);

            string edificioName = string.Empty;

            //Agregando los hijos al Tree View List
            for (int i = 0; i < textList.Count; i++)
            {
                //Creando el item del Tree View con world coordinates
                var item = GameObject.Instantiate(Template) as GameObject;

                item.transform.name = "ScrollTreeViewItem" + i;

                //Agregando relacion de padre (Tree View List) - hijo (item del Tree View List)
                item.transform.parent = Parent;

                //Agregando la posicion relativa del hijo con relacion al padre
                item.transform.localPosition = new Vector3(
                    Template.transform.localPosition.x,
                    Template.transform.localPosition.y - 65f * i,
                    Template.transform.localPosition.z
                    );

                //Agregando la escala relativa del hijo con relacion al padre
                item.transform.localScale = Template.transform.localScale;

                //Encontrando texto del un item (su hijo)
                var itemText = item.transform.FindChild("Label").GetComponent <UILabel>();

                var nombre    = Convert.ToString(textList[i].GetType().GetProperty("nombre").GetValue(textList[i], null));
                var ubicacion = Convert.ToInt32(textList[i].GetType().GetProperty("ubicacion").GetValue(textList[i], null));
                var node      = Convert.ToInt32(textList[i].GetType().GetProperty("node").GetValue(textList[i], null));
                int edificio;
                int.TryParse(Convert.ToString(textList[i].GetType().GetProperty("edificio").GetValue(textList[i], null)), out edificio);

                //Si son iguales la localizacion es un nombre de un edificio
                if (edificio != 0)
                {
                    itemText.text = nombre;
                    edificioName  = nombre;
                }
                //De lo contrario esta dentro del edificio
                else
                {
                    //Se agrega un padding de 5 espacios
                    itemText.text = edificioName + " - " + nombre;
                }

                var button = new Button(item.name);
                button.OnTouchEvent += new OnTouchEventHandler(OnTouchScrollTreeViewItem);
                button.ObjectTag     = new ModelNode()
                {
                    idNodo = node, idUbicacion = ubicacion, name = nombre, isBuilding = (edificio != 0 ? true : false)
                };

                buttonList.Add(button);
                treeView.ButtonCount++;
            }
        }
예제 #8
0
        public static void PushFollowingNotification(bool active)
        {
            var gui = UIUtils.Find("/GUI").transform;
            var notificationButtonMain             = gui.FindChild("MenuMain").FindChild("Bar").FindChild("ButtonMain").FindChild("Notification");
            var notificationButtonUsuario          = gui.FindChild("MenuMain").FindChild("Sidebar").FindChild("ButtonUsuario").FindChild("Logeado").FindChild("Notification");
            var notificationButtonPendingFollowing = gui.FindChild("MenuUsuarioSettings").FindChild("ButtonPendingFollowingRequest").FindChild("Notification");

            if (active)
            {
                using (var sqlite = new SQLiteService())
                {
                    int notificationCount = 0;

                    var query = "SELECT COUNT(id) as count FROM UserFollowingNotification";
                    using (var reader = sqlite.SelectQuery(query))
                    {
                        while (reader.Read())
                        {
                            notificationCount = Convert.ToInt32(reader["count"]);
                        }
                    }

                    if (notificationCount == 0)
                    {
                        active = false;
                    }
                    else
                    {
                        notificationPendingFollowCount = notificationCount;
                        //Main Button
                        notificationButtonMain.gameObject.SetActive(true);
                        notificationButtonMain.FindChild("Label").GetComponent <UILabel>().text = notificationCount.ToString();

                        //SideBar
                        notificationButtonUsuario.FindChild("Label").GetComponent <UILabel>().text = notificationCount.ToString();
                        notificationButtonUsuario.gameObject.SetActive(true);


                        //MenuUsuario
                        notificationButtonPendingFollowing.FindChild("Label").GetComponent <UILabel>().text = notificationCount.ToString();
                        notificationButtonPendingFollowing.gameObject.SetActive(true);
                    }
                }
            }

            if (!active)
            {
                //Main Button
                notificationButtonMain.FindChild("Label").GetComponent <UILabel>().text = "";
                notificationButtonMain.gameObject.SetActive(false);

                //SideBar
                notificationButtonUsuario.FindChild("Label").GetComponent <UILabel>().text = "";
                notificationButtonUsuario.gameObject.SetActive(false);


                //MenuUsuario
                notificationButtonPendingFollowing.FindChild("Label").GetComponent <UILabel>().text = "";
                notificationButtonPendingFollowing.gameObject.SetActive(false);
            }
        }
예제 #9
0
        public void Update()
        {
            State.ChangeState(eState.Tour);


            using (var sqlService = new SQLiteService())
            {
                //Verificar si el tour se completó
                var tourCtrl = ModelPoolManager.GetInstance().GetValue("tourCtrl") as TourController;

                if (tourCtrl.isEndTour)
                {
                    sqlService.TransactionalQuery(
                        "UPDATE UsuarioTour SET estado = 'finalizado' AND fechaFin = '" + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "' WHERE id = " + this.idUsuarioTour
                        );
                }
                else
                {
                    sqlService.TransactionalQuery(
                        "UPDATE UsuarioTour SET estado = 'inconcluso' AND fechaFin = null WHERE id = " + this.idUsuarioTour
                        );
                }

                ModelPoolManager.GetInstance().Remove("tourCtrl");

                this.detalleUsuarioTourList.Clear();
                var sql = "SELECT * FROM DetalleUsuarioTour WHERE idUsuarioTour = " + idUsuarioTour;

                using (var resultDetalleUsuarioTour = sqlService.SelectQuery(sql))
                {
                    while (resultDetalleUsuarioTour.Read())
                    {
                        DateTime?updatedDate = null, startDate = null, endDate = null;
                        DateTime temp;

                        var obj = resultDetalleUsuarioTour["fechaInicio"];
                        if (obj != null)
                        {
                            var fechaInicio = Convert.ToString(obj);
                            if (DateTime.TryParseExact(fechaInicio, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out temp))
                            {
                                startDate = temp;
                            }
                        }

                        obj = resultDetalleUsuarioTour["fechaLlegada"];
                        if (obj != null)
                        {
                            var fechaFin = Convert.ToString(obj);
                            if (DateTime.TryParseExact(fechaFin, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out temp))
                            {
                                endDate = temp;
                            }
                        }

                        obj = resultDetalleUsuarioTour["fechaFin"];
                        if (obj != null)
                        {
                            var fechaActualizacion = Convert.ToString(obj);
                            if (DateTime.TryParseExact(fechaActualizacion, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out temp))
                            {
                                updatedDate = temp;
                            }
                        }

                        this.detalleUsuarioTourList.Add(
                            new DetalleUsuarioTour()
                        {
                            idDetalleUsuarioTour = Convert.ToInt32(resultDetalleUsuarioTour["id"]),
                            idPuntoReunionTour   = Convert.ToInt32(resultDetalleUsuarioTour["idPuntoReunionTour"]),
                            idUsuarioTour        = idUsuarioTour,
                            fechaInicio          = startDate,
                            fechaLlegada         = endDate,
                            fechaFin             = updatedDate
                        }
                            );
                    }
                }
            }

            UpdateCreateScrollView();
        }
예제 #10
0
        private void BuildingInitializer()
        {
            //Seleccionando desde la Base de datos los localidades
            var sql = "SELECT UBI.abreviacion, UBI.idUbicacion, NOD.edificio, NOD.idNodo, NOD.nombre, UBI.cantidadPlantas " +
                      "FROM Ubicacion UBI, Nodo NOD " +
                      "WHERE UBI.idUbicacion = NOD.edificio";

            List <object> list = new List <object>();

            using (var service = new SQLiteService())
            {
                using (var reader = service.SelectQuery(sql))
                {
                    while (reader.Read())
                    {
                        list.Add(new
                        {
                            abreviacion     = Convert.ToString(reader["abreviacion"]),
                            nombre          = Convert.ToString(reader["nombre"]),
                            idNodo          = Convert.ToInt32(reader["idNodo"]),
                            idUbicacion     = Convert.ToInt32(reader["idUbicacion"]),
                            edificio        = Convert.ToInt32(reader["edificio"]),
                            cantidadPlantas = Convert.ToInt32(reader["cantidadPlantas"])
                        });
                    }
                }
            }

            sql = "SELECT UBI.abreviacion, COUNT(NOD.idNodo) as insideNodesCount " +
                  "FROM Ubicacion UBI, Nodo NOD " +
                  "WHERE UBI.idUbicacion = NOD.idUbicacion " +
                  "GROUP BY UBI.abreviacion";

            Dictionary <string, int> buildingInsideNodeslist = new Dictionary <string, int>();

            using (var service = new SQLiteService())
            {
                using (var reader = service.SelectQuery(sql))
                {
                    while (reader.Read())
                    {
                        var abreviacion      = Convert.ToString(reader["abreviacion"]);
                        var insideNodosCount = Convert.ToInt32(reader["insideNodesCount"]);

                        buildingInsideNodeslist.Add(abreviacion, insideNodosCount);
                    }
                }
            }

            //Encontrando todos los edificios con el Tag Building
            var model = GameObject.FindGameObjectsWithTag("Building");

            foreach (GameObject child in model)
            {
                var textHeader = child.transform.FindChild("Text").GetComponent <TextMesh>();

                foreach (object item in list)
                {
                    string abreviacion = Convert.ToString(item.GetType().GetProperty("abreviacion").GetValue(item, null));

                    if (child.name.Equals(abreviacion))
                    {
                        var localizacion = child.GetComponent <ModelObject>();

                        string nombre          = Convert.ToString(item.GetType().GetProperty("nombre").GetValue(item, null));
                        int    idUbicacion     = Convert.ToInt32(item.GetType().GetProperty("idUbicacion").GetValue(item, null));
                        int    idNodo          = Convert.ToInt32(item.GetType().GetProperty("idNodo").GetValue(item, null));
                        int    edificio        = Convert.ToInt32(item.GetType().GetProperty("edificio").GetValue(item, null));
                        int    cantidadPlantas = Convert.ToInt32(item.GetType().GetProperty("cantidadPlantas").GetValue(item, null));

                        var modelNode = new ModelNode()
                        {
                            idNodo          = idNodo,
                            name            = nombre,
                            idUbicacion     = idUbicacion,
                            abreviacion     = abreviacion,
                            cantidadPlantas = cantidadPlantas
                        };

                        modelNode.isBuilding   = (edificio == idUbicacion ? true : false);
                        localizacion.ObjectTag = modelNode;
                        localizacion.Id        = idNodo;

                        bool containsInsideNodes = false;
                        foreach (var building in buildingInsideNodeslist)
                        {
                            if (abreviacion == building.Key && building.Value > 1)
                            {
                                containsInsideNodes = true;
                                break;
                            }
                        }

                        localizacion.ContainsInsideNodes = containsInsideNodes;

                        if (nombre.Length < 20)
                        {
                            if (nombre.Split(' ').Length == 1)
                            {
                                textHeader.transform.localScale = new Vector3(1, 3f, 0);
                            }
                            else
                            {
                                textHeader.transform.localScale = new Vector3(1, 2f, 0);
                            }

                            textHeader.text = UIUtils.FormatStringLabel(nombre, ' ', 12);
                        }
                        else
                        {
                            textHeader.transform.localScale = new Vector3(1, 2.15f, 0);
                            textHeader.text = UIUtils.FormatStringLabel(nombre, ' ', 20);
                        }
                    }
                }
            }
        }
예제 #11
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);
        }
예제 #12
0
        public void CreateGraph()
        {
            graph = new Graph();

            using (var sqlService = new SQLiteService())
            {
                string sql = "SELECT NOD.activo, NOD.nombre, NOD.planta, NOD.idNodo, NOD.idUbicacion, COO.latitud, COO.longitud " +
                             "FROM Nodo NOD LEFT JOIN CoordenadaNodo COO ON NOD.idNodo = COO.idNodo " +
                             "ORDER BY NOD.idNodo";

                using (var reader = sqlService.SelectQuery(sql))
                {
                    while (reader.Read())
                    {
                        bool active = (Convert.ToInt32(reader["activo"]) == 0 ? false : true);

                        if (active)
                        {
                            string nombre = Convert.ToString(reader["nombre"]);
                            int    idNode = Convert.ToInt32(reader["idNodo"]);

                            float valueFloat, latitud = 0, longitud = 0;

                            string obj = Convert.ToString(reader["latitud"]);
                            if (float.TryParse(obj, out valueFloat))
                            {
                                latitud = valueFloat;
                            }

                            obj = Convert.ToString(reader["longitud"]);
                            if (float.TryParse(obj, out valueFloat))
                            {
                                longitud = valueFloat;
                            }

                            bool   isInsideBuilding = false;
                            string buildingName     = null;
                            int    planta           = 0;

                            string strObject = Convert.ToString(reader["planta"]);
                            int    value;
                            if (int.TryParse(strObject, out value))
                            {
                                planta           = value;
                                isInsideBuilding = true;

                                obj = Convert.ToString(reader["idUbicacion"]);
                                int idUbicacion;
                                if (int.TryParse(obj, out idUbicacion))
                                {
                                    sql = "SELECT abreviacion FROM Ubicacion WHERE idUbicacion = " + idUbicacion;
                                    using (var readerUbication = sqlService.SelectQuery(sql))
                                    {
                                        if (readerUbication.Read())
                                        {
                                            buildingName = Convert.ToString(readerUbication["abreviacion"]);
                                        }
                                    }
                                }
                            }

                            bool isBuilding = false;

                            if (!isInsideBuilding)
                            {
                                sql = "SELECT NOD.edificio, UBI.abreviacion FROM Nodo NOD, Ubicacion UBI " +
                                      "WHERE NOD.idNodo = " + idNode + " AND NOD.idUbicacion = UBI.idUbicacion";
                                using (var readerNodoUbicacion = sqlService.SelectQuery(sql))
                                {
                                    if (readerNodoUbicacion.Read())
                                    {
                                        string edificio = Convert.ToString(readerNodoUbicacion["edificio"]);
                                        if (int.TryParse(edificio, out value))
                                        {
                                            isBuilding   = true;
                                            buildingName = Convert.ToString(readerNodoUbicacion["abreviacion"]);
                                        }
                                    }
                                }
                            }

                            graph.Nodes.Add(new NodeDijkstra()
                            {
                                IdNode           = idNode,
                                Active           = active,
                                Name             = nombre,
                                Latitude         = latitud,
                                Longitude        = longitud,
                                IsInsideBuilding = isInsideBuilding,
                                BuildingName     = buildingName,
                                PlantaBuilding   = planta,
                                IsBuilding       = isBuilding
                            });
                        }
                    }
                }

                sql = "SELECT NEI.idNodo, NEI.idNodoNeighbor " +
                      "FROM Neighbor NEI, Nodo NOD1, Nodo NOD2 " +
                      "WHERE NOD1.activo = 1 AND NOD2.activo = 1 AND NOD1.idNodo = NEI.idNodo AND NOD2.idNodo = NEI.idNodoNeighbor";

                using (var reader = sqlService.SelectQuery(sql))
                {
                    while (reader.Read())
                    {
                        int idNodo         = System.Convert.ToInt32(reader["idNodo"]);
                        int idNodoNeighbor = System.Convert.ToInt32(reader["idNodoNeighbor"]);

                        graph.AddNeighbor(idNodo, idNodoNeighbor);
                    }
                }
            }
        }
예제 #13
0
        private void Process(Tour tour, out UsuarioTour usuarioTour, out List <DetalleUsuarioTour> detalleUsuarioTourList)
        {
            UsuarioTour userTour = null;
            List <DetalleUsuarioTour> detailsList = new List <DetalleUsuarioTour>();

            using (var sqlService = new SQLiteService())
            {
                var user = ModelPoolManager.GetInstance().GetValue("Usuario") as Usuario;

                //Del tour seleccionado verificar si el usuario esta suscrito
                var sqlQuery = "SELECT * FROM UsuarioTour WHERE idUsuarioFacebook = '" + user.idUsuarioFacebook + "' AND idTour = " + tour.idTour;
                using (var resultUsuarioTour = sqlService.SelectQuery(sqlQuery))
                {
                    //El UsuarioTour ya ha sido creado
                    if (resultUsuarioTour.HasRows == true)
                    {
                        #region Recuperacion UsuarioTour

                        DateTime?startDate = null, endDate = null;
                        DateTime temp;

                        var obj = resultUsuarioTour["fechaInicio"];
                        if (obj != null)
                        {
                            string fechaInicio = Convert.ToString(obj);
                            if (DateTime.TryParseExact(fechaInicio, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out temp))
                            {
                                startDate = temp;
                            }
                        }

                        obj = resultUsuarioTour["fechaFin"];
                        if (obj != null)
                        {
                            string fechaFin = Convert.ToString(obj);
                            if (DateTime.TryParseExact(fechaFin, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out temp))
                            {
                                endDate = temp;
                            }
                        }

                        userTour = new UsuarioTour()
                        {
                            idUsuarioFacebook = user.idUsuarioFacebook,
                            idUsuarioTour     = Convert.ToInt32(resultUsuarioTour["id"]),
                            idTour            = Convert.ToInt32(resultUsuarioTour["idTour"]),
                            estado            = Convert.ToString(resultUsuarioTour["estado"]),
                            fechaInicio       = startDate,
                            fechaFin          = endDate
                        };

                        #endregion

                        #region Recuperacion DetalleUsuarioTour

                        var sql = "SELECT * FROM DetalleUsuarioTour WHERE idUsuarioTour = " + userTour.idUsuarioTour;

                        using (var resultDetalleUsuarioTour = sqlService.SelectQuery(sql))
                        {
                            while (resultDetalleUsuarioTour.Read())
                            {
                                DateTime?updatedDate = null;
                                startDate = endDate = null;

                                obj = resultDetalleUsuarioTour["fechaInicio"];
                                if (obj != null)
                                {
                                    var fechaInicio = Convert.ToString(obj);
                                    if (DateTime.TryParseExact(fechaInicio, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out temp))
                                    {
                                        startDate = temp;
                                    }
                                }

                                obj = resultDetalleUsuarioTour["fechaLlegada"];
                                if (obj != null)
                                {
                                    var fechaFin = Convert.ToString(obj);
                                    if (DateTime.TryParseExact(fechaFin, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out temp))
                                    {
                                        endDate = temp;
                                    }
                                }

                                obj = resultDetalleUsuarioTour["fechaFin"];
                                if (obj != null)
                                {
                                    var fechaActualizacion = Convert.ToString(obj);
                                    if (DateTime.TryParseExact(fechaActualizacion, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out temp))
                                    {
                                        updatedDate = temp;
                                    }
                                }

                                detailsList.Add(
                                    new DetalleUsuarioTour()
                                {
                                    idDetalleUsuarioTour = Convert.ToInt32(resultDetalleUsuarioTour["id"]),
                                    idPuntoReunionTour   = Convert.ToInt32(resultDetalleUsuarioTour["idPuntoReunionTour"]),
                                    idUsuarioTour        = userTour.idUsuarioTour,
                                    fechaInicio          = startDate,
                                    fechaLlegada         = endDate,
                                    fechaFin             = updatedDate
                                }
                                    );
                            }
                        }

                        #endregion
                    }
                    //Se creará un nuevo registro de UsuarioTour y sus repectivos DetalleUsuarioTour
                    else
                    {
                        #region Creacion UsuarioTour

                        //Buscando el ultimo id
                        int idUsuarioTour = 0;

                        using (var result = sqlService.SelectQuery("SELECT MAX(id) as id FROM UsuarioTour"))
                        {
                            while (result.Read())
                            {
                                int.TryParse(Convert.ToString(result["id"]), out idUsuarioTour);
                            }
                        }

                        idUsuarioTour++;
                        var fechaInicio = DateTime.Now;

                        //Creacion del UsuarioTour

                        //Insertando en la base de datos
                        sqlService.TransactionalQuery(
                            "INSERT INTO UsuarioTour (id, idTour, idUsuarioFacebook, fechaInicio, request) " +
                            "VALUES (" + idUsuarioTour + "," + tour.idTour + ",'" + user.idUsuarioFacebook + "','" + fechaInicio.ToString("dd/MM/yyyy HH:mm:ss") + "','create')"
                            );

                        //sqlService.TransactionalQuery(
                        //    "INSERT INTO UsuarioTour (id, idTour, fechaInicio, request) " +
                        //    "VALUES (" + idUsuarioTour + "," + tour.idTour + ",'" + fechaInicio.ToString("dd/MM/yyyy HH:mm:ss") + "','create')"
                        //);

                        //Creacion del objeto de UsuarioTour
                        userTour = new UsuarioTour()
                        {
                            idUsuarioTour     = idUsuarioTour,
                            fechaInicio       = fechaInicio,
                            idTour            = tour.idTour,
                            estado            = "activo",
                            idUsuarioFacebook = user.idUsuarioFacebook
                        };

                        //userTour = new UsuarioTour()
                        //{
                        //    idUsuarioTour = idUsuarioTour,
                        //    fechaInicio = fechaInicio,
                        //    idTour = tour.idTour,
                        //    estado = "activo",
                        //};

                        #endregion

                        #region Creacion DetalleUsuarioTourList

                        //Obtener los puntos de reunion del tour selecionado
                        var puntoReuionList = new List <PuntoReunionTour>();

                        using (var result = sqlService.SelectQuery("SELECT * FROM PuntoReunionTour WHERE idTour = " + tour.idTour))
                        {
                            while (result.Read())
                            {
                                var puntoReunion = new PuntoReunionTour()
                                {
                                    idPuntoReunionTour = Convert.ToInt32(result["id"]),
                                    secuencia          = Convert.ToInt32(result["secuencia"]),
                                    idNodo             = Convert.ToInt32(result["idNodo"]),
                                    idTour             = Convert.ToInt32(result["idTour"])
                                };

                                puntoReuionList.Add(puntoReunion);
                            }
                        }

                        //Creacion del DetalleUsuarioTour

                        //Buscando el ultimo id
                        int idDetalleUsuarioTour = 0;

                        using (var result = sqlService.SelectQuery("SELECT MAX(id) as id FROM DetalleUsuarioTour"))
                        {
                            if (result.Read())
                            {
                                int.TryParse(Convert.ToString(result["id"]), out idDetalleUsuarioTour);
                            }
                        }

                        StringBuilder sqlBuilder = new StringBuilder();

                        foreach (var puntoReunion in puntoReuionList)
                        {
                            idDetalleUsuarioTour++;

                            //Insertando en la base de datos
                            sqlBuilder.Append(
                                "INSERT INTO DetalleUsuarioTour (id, idPuntoReunionTour, idUsuarioTour) " +
                                "VALUES (" + idDetalleUsuarioTour + "," + puntoReunion.idPuntoReunionTour + "," + idUsuarioTour + ");"
                                );

                            //Creacion del objeto de DetalleUsuarioTour
                            detailsList.Add(
                                new DetalleUsuarioTour()
                            {
                                idDetalleUsuarioTour = idDetalleUsuarioTour,
                                idPuntoReunionTour   = puntoReunion.idPuntoReunionTour,
                                idUsuarioTour        = idUsuarioTour
                            }
                                );
                        }

                        sqlService.TransactionalQuery(sqlBuilder.ToString());

                        #endregion
                    }
                }
            }

            usuarioTour            = userTour;
            detalleUsuarioTourList = detailsList;
        }
예제 #14
0
        public IEnumerator UserFriendsPendingToFollow()
        {
            var idUser = "";

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                idUser = "******";
            }
            else
            {
                idUser = FB.UserId;
            }

            Dictionary <long, string> usuarioFriendsFacebook = new Dictionary <long, string>();

            using (var sqlite = new SQLiteService())
            {
                var query = "SELECT idFollower, nombre FROM UserFollowingNotification WHERE idUsuarioFacebook = '" + idUser + "'";
                using (var reader = sqlite.SelectQuery(query))
                {
                    while (reader.Read())
                    {
                        var id     = Convert.ToInt64(Convert.ToString(reader["idFollower"]));
                        var nombre = Convert.ToString(reader["nombre"]);

                        usuarioFriendsFacebook.Add(id, nombre);
                    }
                }
            }

            Transform itemTemplate = (Resources.Load("GUI/PendingFriendFollowingItem") as GameObject).transform;

            //Get Parent
            Transform parent = UIUtils.FindGUI("MenuReceiveFollowingRequest/ScrollView").transform;

            int k = 0;

            foreach (var usuario in usuarioFriendsFacebook)
            {
                var       id      = usuario.Key;
                var       url     = ("https://graph.facebook.com/" + id + "/picture?width=128&height=128&access_token=" + FB.AccessToken);
                WWW       photo   = new WWW(url);
                Texture2D textFb2 = new Texture2D(128, 128, TextureFormat.DXT5, false); //TextureFormat must be DXT5

                yield return(photo);

                photo.LoadImageIntoTexture(textFb2);

                var friendItem = GameObject.Instantiate(itemTemplate.gameObject) as GameObject;

                friendItem.name                 = "ItemFriend" + k;
                friendItem.transform.parent     = parent;
                friendItem.transform.localScale = itemTemplate.localScale;

                //Agregando la posicion relativa del hijo con relacion al padre
                friendItem.transform.localPosition = new Vector3(
                    itemTemplate.localPosition.x,
                    itemTemplate.position.y - 60f * k,
                    itemTemplate.localPosition.z
                    );

                friendItem.transform.FindChild("Image").GetComponent <UITexture>().mainTexture = textFb2;
                friendItem.transform.FindChild("Label").GetComponent <UILabel>().text          = usuario.Value;

                var menu = MenuManager.GetInstance().GetCurrentMenu() as MenuReceiveFollowingRequest;

                var button = new Button(friendItem.name);
                button.OnTouchEvent += new OnTouchEventHandler(menu.OnTouchButton);


                button.ObjectTag = new { follower = id, name = usuario.Value, texture = textFb2, index = k };

                menu.GetButtonList().Add(button);

                k++;
            }
        }