Пример #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
 /// <summary>
 /// Patrón Singlenton
 /// </summary>
 /// <returns></returns>
 public static ModelPoolManager GetInstance()
 {
     if (_modelManager == null)
     {
         _modelManager = new ModelPoolManager();
     }
     return(_modelManager);
 }
Пример #3
0
        void Start()
        {
            MenuManager.GetInstance();
            using (var service = new SQLiteService()) { }
            ModelPoolManager.GetInstance();

            GUIInitializer();
            BuildingInitializer();
            ModelPoolInit();

            UIUtils.ActivateCameraLabels(true);
            State.ChangeState(eState.Exploring);
        }
Пример #4
0
        private IEnumerator UpdateModelService()
        {
            bool   IsConnectionAvailable = false;
            string responseJson          = string.Empty;

            //Obtener la ultima actualizacion del servidor
            yield return(WebService.GET(
                             SERVER_URL + "/nodo/actualizar",
                             (status, response) =>
            {
                if (status)
                {
                    responseJson = response;
                }
                IsConnectionAvailable = status;
            }
                             ));

            //Esperar que se refresque el valor de responseJson
            yield return(new WaitForSeconds(0.5f));

            if (IsConnectionAvailable)
            {
                IsEnterToUpdateModel = false;

                //Enconding de string a Json
                JSONObject json = new JSONObject(responseJson);
                Debug.Log(responseJson);

                //Hacer un update a la base de datos
                using (var sqlService = new SQLiteService())
                {
                    sqlService.UpdateModel(json);
                }

                var navigation = ModelPoolManager.GetInstance().GetValue("navigationCtrl") as NavigationController;

                //Crear el grafo con la base de datos actualizada.
                navigation.CreateGraph();
            }
            else
            {
                if (!IsEnterToUpdateModel)
                {
                    StartCoroutine(CountDown(600f, value => IsEnterToUpdateModel = value));
                    yield return(new WaitForSeconds(0.5f));
                }
            }
        }
Пример #5
0
        private void ModelPoolInit()
        {
            NavigationController navigationCtrl = new NavigationController();

            ModelPoolManager.GetInstance().Add("navigationCtrl", navigationCtrl);
        }