Exemple #1
0
        /// <summary>
        /// Metodo que se ejecuta toda vez que se manda a llamar al Activity ActividadInicial
        /// Este metodo inicia el renderizado de la pantalla con sus controles.
        /// </summary>
        /// <param name="bundle"></param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.Main);
            Servicio.ClsVariables.cuentaArrayId = 0;
            tieneEncuesta = Intent.GetBooleanExtra("tieneEncuesta", false);
            IdDispositivo = Intent.GetIntExtra("IdDispositivo", 0);
            Servicio.ClsVariables.IdDispositivo = IdDispositivo;
            arrayIds = Intent.GetStringArrayExtra("arrayIds");

            //LOCALIZACION POR GPS Ó TRIANGULACIÓN POR REDES
            //InicializaLocalizacion();
            preguntasTot = FindViewById <TextView>(Resource.Id.CountPregunta);
            pregunta     = FindViewById <TextView>(Resource.Id.lblPregunta);


            btnAceptar = FindViewById <ImageButton>(Resource.Id.btnAceptar);
            btnAtras   = FindViewById <ImageButton>(Resource.Id.btnAtras);
            btnInicio  = FindViewById <ImageButton>(Resource.Id.btnInicio);
            lista      = FindViewById <ListView>(Resource.Id.List);

            btnInicio.Click += (o, e) =>
            {
                this.Finish();
            };
            lista.ItemClick += (o, e) =>
            {
                IdRespuesta = ((CheckedTextView)e.View).ContentDescription;
                //Obtenemos el ID del RadioButton checkeado
                IDSeleccionado = int.Parse(((CheckedTextView)e.View).Hint.Split('|')[1]);
                semaforo       = 0;
            };
            btnAtras.Click += (o, e) =>
            {
                if (NumPreguntas > 1)
                {
                    indicePG--;
                    semaforo = 1;
                    int numceros = 0;
                    MuestraPreguntas(int.Parse(arrayIds[indicePG].ToString().Split('|')[0]), out IsFinal);
                    string[] arrayAux = new string[arrayIds.Length];
                    for (int iaux = 0; iaux < arrayAux.Length; iaux++)
                    {
                        if (arrayIds[iaux] != null)
                        {
                            numceros++;
                            if (indicePG != iaux)
                            {
                                arrayAux[iaux] = arrayIds[iaux];
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (numceros > 1)
                    {
                        arrayIds = arrayAux;
                    }
                    else
                    {
                        arrayIds = new string[FillEncuesta.Count];
                    }
                    NumPreguntas--;
                    preguntasTot.Text = "Pregunta:" + NumPreguntas + "/" + (FillEncuesta.Count - 1);
                }
                if (NumPreguntas == 1)
                {
                    btnAtras.Visibility = ViewStates.Invisible;
                }
                else
                {
                    btnAtras.Visibility = ViewStates.Visible;
                }
            };
            btnAceptar.Click += new EventHandler(btnAceptar_Click);

            try
            {
                asmxEM = new tva.WSEncuestaMovil();
            }
            catch
            { }

            try
            {
                tva.AuthHeader Credentials = new tva.AuthHeader();

                string settings     = "";
                string userpassword = "";
                try
                {
                    using (StreamReader sr = new StreamReader(Assets.Open("Validator.archive")))
                    {
                        settings = sr.ReadToEnd();
                        sr.Close();
                    }
                }
                catch (Exception exep)
                {
                }
                Servicio.ClsRijndaels _encript = new Servicio.ClsRijndaels();
                userpassword           = _encript.Transmute(settings, Servicio.ClsRijndaels.enmTransformType.intDecrypt);
                Credentials.UserName   = userpassword;
                asmxEM.PreAuthenticate = true;
                Credentials.Password   = userpassword;
                asmxEM.SoapVersion     = System.Web.Services.Protocols.SoapProtocolVersion.Soap11;
                asmxEM.UnsafeAuthenticatedConnectionSharing = true;
                asmxEM.AuthHeaderValue = Credentials;

                System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
                System.Net.ServicePointManager.SecurityProtocol  = SecurityProtocolType.Ssl3;

                System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) =>
                {
                    return(true);
                };
            }
            catch
            {}

            connection = Servicio.Comun.AbreBD();
            CargaEncuesta();
        }
Exemple #2
0
        //localhost.WSEncuestaMovil asmxEM = null;
        /// <summary>
        /// Metodo que se ejecuta toda vez que se manda a llamar al Activity ActividadFinal
        /// Este metodo inicia el renderizado de la pantalla con sus controles.
        /// </summary>
        /// <param name="bundle"></param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            IdDispositivo = Intent.GetIntExtra("IdDispositivo", 0);
            IdEncuesta    = Intent.GetIntExtra("IdEncuesta", 0);
            arrayIds      = Intent.GetStringArrayExtra("arrayIds");

            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.FinEncuesta);

            ImageButton btnEnviar = FindViewById <ImageButton>(Resource.Id.btnAceptarFin);

            btnEnviar.Click += new EventHandler(btnEnviar_Click);
            try
            {
                asmxEM = new tva.WSEncuestaMovil();
                //asmxEM = new localhost.WSEncuestaMovil();
                //asmxEM.Url = asmxEM.Url.Replace("localhost","10.0.2.2");
            }
            catch (WebException error)
            { }
            _receiver = new Servicio.Listening();

            var intentFilter = new IntentFilter(Intent.ActionBootCompleted);

            intentFilter.AddAction(Intent.ActionBootCompleted);
            RegisterReceiver(_receiver, intentFilter);
            StartService(new Intent(this, typeof(Servicio.ClsDemonio)));


            //Buscamos el directorio personal en el dispositivo
            var personalFolderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
            //Buscamos el directorio database en la carpeta personal
            var databaseFolderPath = string.Format(@"{0}/database", personalFolderPath.Substring(0, personalFolderPath.LastIndexOf('/')));

            if (!Directory.Exists(databaseFolderPath))
            {
                Directory.CreateDirectory(databaseFolderPath);//Si no existe la creamos
            }
            if (!Directory.Exists(databaseFolderPath))
            {
                throw new Exception(string.Format("{0} no existe!", databaseFolderPath));//Si no existe quiere decir que en el paso anterior no se creo correctamente el dir
            }
            //var paths = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim).ToString() + "/Encuestas.db3";
            //Agrega el nombre de la base de datos al path de la carpeta local y subcarpeta database
            string dbPath = Path.Combine(databaseFolderPath, "Encuestadb.db3");

            //Verifica si existe el archivo mencionado en la parte de arriba

            exists = System.IO.File.Exists(dbPath);
            if (!exists)
            {
                SqliteConnection.CreateFile(dbPath);                    //Si no existe crea la base de datos
                bandera = 0;                                            //Configura;
            }
            connection = new SqliteConnection("Data Source=" + dbPath); //Abre la cadena de conexion con la base de datos creado anteriormente

            if (connection.State == System.Data.ConnectionState.Open)
            {
                connection.Close();
            }

            connection.Open();//Abre la conexion a la base de datos creado con anterioridad
            try
            {
                tva.AuthHeader Credentials = new tva.AuthHeader();
                //localhost.AuthHeader Credentials = new localhost.AuthHeader();
                string settings     = "";
                string userpassword = "";
                try
                {
                    using (StreamReader sr = new StreamReader(Assets.Open("Validator.archive")))
                    {
                        settings = sr.ReadToEnd();
                        sr.Close();
                    }
                }
                catch (Exception exep)
                {
                }
                Servicio.ClsRijndaels _encript = new Servicio.ClsRijndaels();
                userpassword           = _encript.Transmute(settings, Servicio.ClsRijndaels.enmTransformType.intDecrypt);
                Credentials.UserName   = userpassword;
                asmxEM.PreAuthenticate = true;
                Credentials.Password   = userpassword;
                asmxEM.SoapVersion     = System.Web.Services.Protocols.SoapProtocolVersion.Soap11;
                asmxEM.UnsafeAuthenticatedConnectionSharing = true;
                asmxEM.AuthHeaderValue = Credentials;

                System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
                System.Net.ServicePointManager.SecurityProtocol  = SecurityProtocolType.Ssl3;

                System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) =>
                {
                    return(true);
                };
            }
            catch (WebException errorWS)
            { }
        }
Exemple #3
0
        private void DatosGenerales()
        {
            //if (!exists)
            //{
            tva.AuthHeader Credentials = new tva.AuthHeader();
            try
            {
                asmxEM = new tva.WSEncuestaMovil();

                string settings     = "";
                string userpassword = "";
                try
                {
                    using (StreamReader sr = new StreamReader(Assets.Open("Validator.archive")))
                    {
                        settings = sr.ReadToEnd();
                        sr.Close();
                    }
                }
                catch
                {
                }

                Servicio.ClsRijndaels _encript = new Servicio.ClsRijndaels();
                userpassword           = _encript.Transmute(settings, Servicio.ClsRijndaels.enmTransformType.intDecrypt);
                Credentials.UserName   = userpassword;
                asmxEM.PreAuthenticate = true;
                Credentials.Password   = userpassword;
                asmxEM.SoapVersion     = System.Web.Services.Protocols.SoapProtocolVersion.Soap11;
                asmxEM.UnsafeAuthenticatedConnectionSharing = true;
                asmxEM.AuthHeaderValue = Credentials;

                System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
                System.Net.ServicePointManager.SecurityProtocol  = SecurityProtocolType.Ssl3;

                System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) =>
                {
                    return(true);
                };
            }
            catch
            { }

            TelephonyManager tm = (TelephonyManager)GetSystemService(TelephonyService);
            var    deviceId     = tm.DeviceId;
            var    serialNumber = tm.SimSerialNumber;
            string numero       = tm.Line1Number;
            string imei         = tm.DeviceId;


            tva.THE_Dispositivo[] disp = null;

            try
            {
                if (numero != "")
                {
                    numetel       = Convert.ToDouble(numero.ToString());
                    disp          = asmxEM.ObtenerDispositivoNumero(Convert.ToDouble(imei));
                    idDispositivo = Convert.ToInt32(disp[0].IdDispositivo);
                }
                else
                {
                    disp          = asmxEM.ObtenerDispositivoNumero(Convert.ToDouble(imei));
                    numetel       = Convert.ToDouble(disp[0].NumerodelTelefono);
                    idDispositivo = Convert.ToInt32(disp[0].IdDispositivo);
                }

                //using (SqliteCommand com = connection.CreateCommand())
                //{
                //    if (numero != "")
                //    {
                //        String strQuery = "INSERT INTO [DatosDispositivo] ([NumTel],[IMEI]) values('" + Servicio.ClsVariables.NumeroTel.ToString() + "','" + imei + "');";
                //        com.CommandText = strQuery;
                //        com.ExecuteNonQuery();
                //    }
                //    else
                //    {

                //    }
                //}
            }
            catch
            { }
            //}
            //else
            //{

            //}
        }