Exemplo n.º 1
0
        public App()
        {
            MessagingCenter.Subscribe <Views.Menu.MainPage>(this, "noAutenticado", (sender) =>
            {
                MainPage = new LoginPage();
            });

            MessagingCenter.Subscribe <LoginPage>(this, "Autenticado", (sender) =>
            {
                MainPage = new MainPage();
                MessagingCenter.Send <App>(this, "Autenticado");
            });

            MessagingCenter.Subscribe <Registro>(this, "Autenticado", (sender) =>
            {
                MainPage = new MainPage();
                MessagingCenter.Send <App>(this, "Autenticado");
            });

            MessagingCenter.Subscribe <Forget>(this, "Autenticado", (sender) =>
            {
                MainPage = new MainPage();
                MessagingCenter.Send <App>(this, "Autenticado");
            });

            ManejadorDatos = new ManejadorDatos(new DataStore());
            Task.Run(() => CargaInicial());
            if (!string.IsNullOrEmpty(Settings.session_access_token))
            {
                MainPage = new MainPage();
            }
            else
            {
                MainPage = new TutorialPage();
            }


            DependencyService.Get <IService>().Start();
            Constants.FechaInicio = DateTime.Now;
            Constants.FechaFinal  = DateTime.Now.AddMinutes(5);


            MessagingCenter.Subscribe <string>(this, "hello", async sender =>
            {
                System.Diagnostics.Debug.WriteLine(sender);
                RegistarIncidente Peticion = new RegistarIncidente()
                {
                    duracion     = new Random().Next(1, 100),
                    fechaInicio  = Constants.fechaInicioIncidencia,
                    idaccion     = new Random().Next(1, 5),
                    idaplicacion = Constants.idAplicacionIncidencia,
                    idevento     = 16,
                };
                RegistarIncidenteResponse Respuesta = await ManejadorDatos.RegistrarIncidenteAsync(Peticion);
            });
        }
Exemplo n.º 2
0
        public async Task <RegistarIncidenteResponse> RegistrarIncidenteAsync(RegistarIncidente peticion)
        {
            Incidencia = new RegistarIncidenteResponse();
            try
            {
                var solicitud = await EGuardianAPI.PostAsync(
                    Constants.Endpoint_Evento_RegistarIncidente,
                    new StringContent(JObject.FromObject(peticion).ToString(), Encoding.UTF8, "application/json"));

                solicitud.EnsureSuccessStatusCode();
                string respuesta = await solicitud.Content.ReadAsStringAsync();

                Incidencia = JsonConvert.DeserializeObject <RegistarIncidenteResponse>(respuesta);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("ERROR: " + e.Message);
            }
            return(Incidencia);
        }
Exemplo n.º 3
0
 public Task <RegistarIncidenteResponse> RegistrarIncidenteAsync(RegistarIncidente peticion)
 {
     return(ServicioWeb.RegistrarIncidenteAsync(peticion));
 }