Exemple #1
0
        /// <summary>
        /// Esta función se ejecuta cuando algun proceso se manda en segundo plano
        /// para no interrumpir las actividades que tiene prioridad el telefono.
        /// La finalidad de esta función es enviar los resultados de las encuestas contestadas.
        /// </summary>
        public void Run()
        {
            //System.Console.WriteLine("Inicio Run");
            Looper.Prepare();
            if (bandera == 1)
            {
                bool result   = false;
                int  intentos = 0;
                while (result == false)
                {
                    try
                    {
                        this.MoveTaskToBack(true);
                        int idDisp = IdDispositivo;
                        int idEnc  = Servicio.ClsVariables.IdEncuesta;
                        result = asmxEM.GuardaEncuestaContestada(idDisp, idEnc, Servicio.ClsVariables.arrayIds, Servicio.ClsVariables.NumeroTel);
                        //System.Console.WriteLine("Valores IDDISP= " + idDisp + "Valores IDENC= " + idEnc + "Resultado: "  + result);
                    }
                    catch (WebException catchExep)
                    {
                        //System.Console.WriteLine("Error: " + catchExep.Message);
                        int    cuentapr = 0;
                        string pr       = "";
                        foreach (string presp in Servicio.ClsVariables.arrayIds)
                        {
                            cuentapr++;
                            int totalResp = Servicio.ClsVariables.arrayIds.Length;
                            if (presp != null)
                            {
                                if (totalResp == cuentapr)
                                {
                                    pr += presp.ToString();
                                }
                                else
                                {
                                    pr += presp.ToString() + "&";
                                }
                            }
                        }
                        SqliteCommand contentsInsert = connection.CreateCommand();
                        String        strQuery       = "INSERT INTO [DatosEncuestaEnvia] ([IdDispositivo],[IdEncuesta],[IdsPreguntaRespuesta]) values('" + Servicio.ClsVariables.IdDispositivo.ToString() + "','" + Servicio.ClsVariables.IdEncuesta.ToString() + "','" + pr + "');";
                        contentsInsert.CommandText = strQuery;
                        contentsInsert.ExecuteNonQuery();
                        int codigo = this.GetHashCode();
                        StartService(new Intent(this, typeof(Servicio.ClsEnviaDatosProgramados)));
                        threadEnviaDatos.Stop();
                        result = true;

                        this.Finish();
                    }
                    if (result == true)
                    {
                        SqliteCommand contents = connection.CreateCommand();
                        contents.CommandText = "DELETE from [DatosEncuesta]";
                        contents.ExecuteNonQuery();
                        threadEnviaDatos.Stop();
                        this.Finish();
                    }
                    intentos++;
                    if (intentos == 3)
                    {
                        //System.Console.WriteLine("Se programo envio automatico");
                        int    cuentapr = 0;
                        string pr       = "";
                        foreach (string presp in Servicio.ClsVariables.arrayIds)
                        {
                            cuentapr++;
                            int totalResp = Servicio.ClsVariables.arrayIds.Length;
                            if (presp != null)
                            {
                                if (totalResp == cuentapr)
                                {
                                    pr += presp.ToString();
                                }
                                else
                                {
                                    pr += presp.ToString() + "&";
                                }
                            }
                        }
                        SqliteCommand contentsInsert = connection.CreateCommand();
                        String        strQuery       = "INSERT INTO [DatosEncuestaEnvia] ([IdDispositivo],[IdEncuesta],[IdsPreguntaRespuesta]) values('" + Servicio.ClsVariables.IdDispositivo.ToString() + "','" + Servicio.ClsVariables.IdEncuesta.ToString() + "','" + pr + "');";
                        contentsInsert.CommandText = strQuery;
                        contentsInsert.ExecuteNonQuery();
                        int codigo = this.GetHashCode();
                        StartService(new Intent(this, typeof(Servicio.ClsEnviaDatosProgramados)));
                        threadEnviaDatos.Stop();
                        result = true;
                        this.Finish();
                    }
                }
            }
            Looper.Loop();
            Looper.MyLooper().Quit();
        }
Exemple #2
0
 /// <summary>
 /// Esta función se ejecuta cuando algun proceso se manda en segundo plano
 /// para no interrumpir las actividades que tiene prioridad el telefono.
 /// La finalidad de esta función es enviar los resultados de las encuestas contestadas.
 /// </summary>
 public void Run()
 {
     Java.Lang.Thread.Sleep(10000);
     threadConfiguraInicial.Stop();
     configuraInicio.Dismiss();
 }