Beispiel #1
0
        private int ValidaToken(string sToken)
        {
            int iRespuesta = 0;

            XDocument xmlToken = XDocument.Parse(sToken);
            var       Valores  = from Elemento in xmlToken.Descendants("APP")
                                 select new
            {
                Matricula       = Elemento.Element("Matricula").Value,
                Nombre          = Elemento.Element("Nombre").Value,
                Paterno         = Elemento.Element("Paterno").Value,
                Materno         = Elemento.Element("Materno").Value,
                FechaNacimiento = Elemento.Element("FechaNacimiento").Value,
                Estatus         = Elemento.Element("Estatus").Value
            };

            foreach (var Elemento in Valores)
            {
                ViewState["sMatricula"]       = Elemento.Matricula;
                ViewState["sNombre"]          = Elemento.Nombre;
                ViewState["sPaterno"]         = Elemento.Paterno;
                ViewState["sMaterno"]         = Elemento.Materno;
                ViewState["sFechaNacimiento"] = Elemento.FechaNacimiento;
                ViewState["sEstatus"]         = Elemento.Estatus;
            }
            iRespuesta = 1;
            return(iRespuesta);
        }
Beispiel #2
0
        private int ValidaToken(string sToken)
        {
            int iRespuesta = 0;

            XDocument xmlToken = XDocument.Parse(sToken);
            var       Valores  = from Elemento in xmlToken.Descendants("APP")
                                 select new
            {
                IDAgente   = Elemento.Element("IDAgente").Value,
                IDProducto = Elemento.Element("IDProducto").Value,
                Producto   = Elemento.Element("Producto").Value,
                IDPromotor = Elemento.Element("IDPromotor").Value
            };

            foreach (var Elemento in Valores)
            {
                ViewState["sIDAgente"]       = Elemento.IDAgente;
                ViewState["sIDPromotor"]     = Elemento.IDPromotor;
                ViewState["sIDProducto"]     = Elemento.IDProducto;
                ViewState["sNombreProducto"] = Elemento.Producto;
            }

            iRespuesta = 1;

            return(iRespuesta);
        }
Beispiel #3
0
        private int ValidaToken(string sToken)
        {
            int iRespuesta = 0;

            XDocument xmlToken = XDocument.Parse(sToken);
            var       Valores  = from Elemento in xmlToken.Descendants("APP")
                                 select new
            {
                IDGrupo = Elemento.Element("IDGrupo").Value,
                IDGrado = Elemento.Element("IDGrado").Value,
                Grado   = Elemento.Element("Grado").Value,
                Grupo   = Elemento.Element("Grupo").Value,
                IDCiclo = Elemento.Element("IDCiclo").Value
            };

            foreach (var Elemento in Valores)
            {
                ViewState["sIDGrado"] = Elemento.IDGrado;
                ViewState["sIDGrupo"] = Elemento.IDGrupo;
                ViewState["sGrado"]   = Elemento.Grado;
                ViewState["sGrupo"]   = Elemento.Grupo;
                ViewState["sIDCiclo"] = Elemento.IDCiclo;
            }

            iRespuesta = 1;

            return(iRespuesta);
        }
Beispiel #4
0
        private async void BtnGetXML_Click(object sender, RoutedEventArgs e)
        {
            // Scarica XML dalla rete
            HttpClient clientXML = new HttpClient();
            var        streamXML = await clientXML.GetStreamAsync(@"http://www.piattoforte.it/feed-rss/rss-ricette-giunti.html");

            // Lo trasforma in oggetti Lasagna
            var tutte = (from Elemento in XElement.Load(streamXML).Element("channel").Elements("item")
                         select new Lasagna {
                Nome = Elemento.Element("title").Value,
                UrlImmagine = Elemento.Element("description").Value
            }).ToList();

            // Normalizza gli elementi
            foreach (var l in tutte)
            {
                int inizio, fine;
                inizio = l.UrlImmagine.IndexOf('"') + 1;
                fine   = l.UrlImmagine.IndexOf('"', inizio);

                string s = l.UrlImmagine.Substring(inizio, fine - inizio);
                l.UrlImmagine = s;
            }

            // POSTa gli oggetti sulla WEBApi
            try
            {
                using (var client = new HttpClient())
                {
                    // baseAddress è l'URL della WebAPI
                    client.BaseAddress = new Uri("https://flr.azurewebsites.net");

                    foreach (var lasagna in tutte)
                    {
                        // Per usare PostAsJsonAsync, è necessario includere il pacchetto NuGet Microsoft.AspNet.WebApi.Client
                        // HTTP POST è il verbo per aggiungere un record (è la 'C' del CRUD)
                        HttpResponseMessage response = await client.PostAsJsonAsync("/api/lasagna", lasagna);
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show($"Ocio!! {err.Message}");
            }
        }
Beispiel #5
0
        private int ValidaToken(string sToken)
        {
            int iRespuesta = 0;

            XDocument xmlToken = XDocument.Parse(sToken);
            var       Valores  = from Elemento in xmlToken.Descendants("APP")
                                 select new
            {
                Matricula = Elemento.Element("Matricula").Value
            };

            foreach (var Elemento in Valores)
            {
                ViewState["sMatricula"] = Elemento.Matricula;
            }
            iRespuesta = 1;
            return(iRespuesta);
        }
Beispiel #6
0
        private int ValidaToken(string sToken)
        {
            int iRespuesta = 0;

            XDocument xmlToken = XDocument.Parse(sToken);
            var       Valores  = from Elemento in xmlToken.Descendants("APP")
                                 select new
            {
                IDAgente = Elemento.Element("IDAlumno").Value
            };

            foreach (var Elemento in Valores)
            {
                ViewState["sIDAlumno"] = Elemento.IDAgente;
            }

            iRespuesta = 1;

            return(iRespuesta);
        }
Beispiel #7
0
        private int ValidaToken(string sToken)
        {
            int iRespuesta = 0;

            XDocument xmlToken = XDocument.Parse(sToken);
            var       Valores  = from Elemento in xmlToken.Descendants("APP")
                                 select new
            {
                FechaInicial = Elemento.Element("FechaInicial").Value,
                FechaFinal   = Elemento.Element("FechaFinal").Value
            };

            foreach (var Elemento in Valores)
            {
                ViewState["sFechaInicial"] = Elemento.FechaInicial;
                ViewState["sFechaFinal"]   = Elemento.FechaFinal;
            }

            iRespuesta = 1;

            return(iRespuesta);
        }