Пример #1
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();
            string UsuarioID     = Convert.ToString(Application.Current.Properties["UsuarioId"]);
            string URlService    = Service.Authority + Methods.Login + "UsuarioID=" + UsuarioID;
            var    resposeString = await client.GetStringAsync(URlService);

            try
            {
                string resp = Convert.ToString(resposeString);
                var    obj  = JsonConvert.DeserializeObject <object>(resp);
                string data = Convert.ToString(obj);

                info = JsonConvert.DeserializeObject <M_Usuario>(data);

                try
                {
                    NombreUsuario.Text = info.Nombre;
                    Area.Text          = info.Zona;
                    RPE.Text           = info.RPE;
                    Division.Text      = info.Division;
                    Area.Text          = info.Area;
                    Application.Current.Properties["ZonaID"] = info.ZonaID;;
                }
                catch (Exception ex)
                {
                    await Application.Current.MainPage.DisplayAlert("CFE Mensaje", ex.Message, "Ok");
                }

                //for (int i = 0; i < Cuadrillas.Count; i++)
                //{
                //    //string valueResponsableCuadrilla = $"{Cuadrillas[i].rpeResponsable} / {Cuadrillas[i].Nombre}";
                //    RPE.Text = Convert.ToString(Cuadrillas[i].RPE);
                //    NombreUsuario.Text = Convert.ToString(Cuadrillas[i].Nombre);
                //    Division.Text = Convert.ToString(Cuadrillas[i].Division);
                //    Zona.Text = Convert.ToString(Cuadrillas[i].Zona);
                //    Area.Text = Convert.ToString(Cuadrillas[i].Area);
                //    NoEconomico.Text = Convert.ToString(Cuadrillas[i].NoEconomico);
                //    Application.Current.Properties["ZonaID"] = Cuadrillas[i].Zona;
                //}
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("CFE Mensaje:", ex.Message, "Ok");
            }
        }
Пример #2
0
        public HomePageViewModel()
        {
            TextHeader = "Perfil";
            TapMenuHamburguerCommand = new Command(TapMenuHamburguer);

            try
            {
                M_Usuario      info       = new M_Usuario();
                string         UsuarioID  = Convert.ToString(Application.Current.Properties["UsuarioId"]);
                string         URlService = Service.Authority + Methods.Login + "UsuarioID=" + UsuarioID;
                HttpWebRequest request    = WebRequest.Create(URlService) as HttpWebRequest;

                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                string          data     = "";
                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                {
                    string resp = reader.ReadToEnd();
                    var    obj  = JsonConvert.DeserializeObject <object>(resp);
                    data = Convert.ToString(obj);
                    info = JsonConvert.DeserializeObject <M_Usuario>(data);
                    try
                    {
                        nombre   = info.Nombre;
                        zona     = info.Zona;
                        rpe      = info.RPE;
                        division = info.Division;
                        area     = info.Area;
                        Application.Current.Properties["ZonaID"] = info.ZonaID;;
                    }
                    catch (Exception ex)
                    {
                        Application.Current.MainPage.DisplayAlert("CFE Mensaje", ex.Message, "Ok");
                    }
                }
            }
            catch (Exception ex)
            {
                Application.Current.MainPage.DisplayAlert("CFE Mensaje", ex.Message, "Ok");
            }
        }