private void Agregar_Click(object sender, EventArgs e)
        {
            try
            {
                servicioCheckDB coneccion = new servicioCheckDB();

                EditText observaciones = Activity.FindViewById <EditText>(Resource.Id.txtObservaciones);

                servicioCheckDB.ReintentoNotificacion reintento = new servicioCheckDB.ReintentoNotificacion();

                reintento.Descripcion     = observaciones.Text;
                reintento.CodNotificacion = Convert.ToInt32(codigoNotificacionReintento);

                DateTime localDate = DateTime.Now;
                string   output    = localDate.ToString("o");
                Console.WriteLine("HORA de reintento" + output);

                reintento.Fecha = Convert.ToDateTime(output);
                //reintento.Fecha = Convert.ToDateTime("2016 - 09 - 26T17: 06:03.537");


                servicioCheckDB.OficialNotificador oficial = new servicioCheckDB.OficialNotificador();
                oficial.CodNotificador       = FragmentLogin.codNotificador;
                reintento.OficialNotificador = oficial;

                servicioCheckDB.GeoLocalizacion ubicacion = new servicioCheckDB.GeoLocalizacion();
                ubicacion.Latitud    = servicioLocalizacion.latitud;
                ubicacion.Longitud   = servicioLocalizacion.longitud;
                ubicacion.Aproximado = true;
                reintento.Ubicacion  = ubicacion;

                string json      = Newtonsoft.Json.JsonConvert.SerializeObject(reintento);
                bool   respuesta = coneccion.envioDatosWeb("https://pjgestionnotificacionmovilservicios.azurewebsites.net/api/ReintentoNotificacion/GuardarReintentoNotificacion", json, Activity);

                if (respuesta)
                {
                    observaciones.Text = "";
                    Toast.MakeText(Activity, "Registro guardado correctamente.", ToastLength.Short).Show();
                }
                else
                {
                    Toast.MakeText(Activity, "Error al guardar el registro.", ToastLength.Short).Show();
                }
            }
            catch (Exception ex)
            {
                //Se guarda el detalle del error
                Logs.saveLogError("ReintentoNotificacion.Agregar_click " + ex.Message + " " + ex.StackTrace);
            }
        }
Esempio n. 2
0
        private void HandleButtonClick(object sender, DialogClickEventArgs e)
        {
            try
            {
                //Se procede a cerrar la sesion, primero se procede a determinar la lista de las
                //notificaciones que se encuentran en estado notificandose.
                string          consulta   = @"https://pjgestionnotificacionmovilservicios.azurewebsites.net/api/Notificaciones/ListarNotificacionesPorNotificadorEstado?POficina=" + FragmentLogin.codOficina + "&PCodNotificador=" + FragmentLogin.codNotificador + "&PEstado=2&PJornada=3";
                servicioCheckDB coneccion  = new servicioCheckDB();
                var             resultados = coneccion.ObtenerListaStrings(consulta, this);

                if (resultados != null)
                {
                    string   fechaApertura = "";
                    DateTime localDate     = DateTime.Now;
                    //string fechalineal = localDate.ToString("yyyyMMdd");
                    string fechaCompleja = localDate.ToString("o");

                    List <string> notificacionesPendientes = new List <string>();
                    for (int k = 0; k < resultados.Count; k++)
                    {
                        notificacionesPendientes.Add(resultados[k]["CodNotificacion"].ToString());
                    }

                    // se extrae de la base de datos la fecha de apertura
                    ManejoBaseDatos.Abrir();

                    ICursor mCursor = ManejoBaseDatos.Seleccionar("SELECT FechaHoraApertura FROM Autenticacion");
                    if (mCursor.MoveToFirst() && mCursor.Count == 1)
                    {
                        do
                        {
                            fechaApertura = mCursor.GetString(0);
                            Console.WriteLine("fecha de Apertura: " + fechaApertura);
                        }while (mCursor.MoveToNext());
                    }
                    else
                    {
                        //Se genera una fecha de apertura
                        fechaApertura = fechaCompleja;
                    }

                    mCursor.Close();
                    ManejoBaseDatos.Cerrar();
                    //se crea la instancial de la clase cierreJornada

                    CierreJornada cierre = new CierreJornada()
                    {
                        codigo             = Guid.NewGuid().ToString(),
                        Apertura           = fechaApertura,
                        OficialNotificador = new OficialNotificador
                        {
                            CodNotificador = FragmentLogin.codNotificador,
                        },
                        Notificaciones = new List <NotificacionFisica>(),
                        Justificacion  = "",
                        Cierre         = fechaCompleja,
                    };

                    foreach (var codigoNotificacion in notificacionesPendientes)
                    {
                        cierre.Notificaciones.Add(new NotificacionFisica {
                            CodNotificacion = Convert.ToInt32(codigoNotificacion)
                        });
                    }

                    string requestCierre = @"https://pjgestionnotificacionmovilservicios.azurewebsites.net/api/OficialNotificador/CierreJornadaOficialNotificador";
                    string json          = Newtonsoft.Json.JsonConvert.SerializeObject(cierre);
                    Console.WriteLine("JSON: " + json);

                    bool respuesta = coneccion.envioDatosWeb(requestCierre, json, this);
                    if (respuesta)
                    {
                        //observaciones.Text = "";
                        Toast.MakeText(this, "Cierre de apertura exitoso.", ToastLength.Short).Show();
                        //Se dirige al usuario a la pagina de buzones donde podra realizar el inicio de apertura.
                    }
                    else
                    {
                        Toast.MakeText(this, "Error al intentar cerar apertura.", ToastLength.Short).Show();
                    }
                }
            }
            catch (Exception ex) { Console.WriteLine("Error en manejo de boton positivo: " + ex.ToString()); }
        }