Ejemplo n.º 1
0
        public HttpClient initClient()
        {
            client = new HttpClient(new NativeMessageHandler())
            {
                // BaseAddress = new Uri(webBase)
                BaseAddress = new Uri(getDatosConexionEmpresa(Preferencias.getEmpresaLiege()))
            };


            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/pdf"));

            return(client);
        }
Ejemplo n.º 2
0
        public async Task <List <MaquinaFirebase> > getListadoMaquinaFirebase(string empresa)
        {
            empre = empresa;
            try
            {
                if (empresa.Equals(" TRH Liege "))
                {
                    client = new HttpClient(new NativeMessageHandler())
                    {
                        // BaseAddress = new Uri(webBase)
                        BaseAddress = new Uri(getDatosConexionEmpresa(Preferencias.getEmpresaLiege()))
                    };
                }
                else
                {
                    client = new HttpClient(new NativeMessageHandler())
                    {
                        // BaseAddress = new Uri(webBase)
                        BaseAddress = new Uri(getDatosConexionEmpresa(Preferencias.getEmpresaSevilla()))
                    };
                }
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/pdf"));
                //client = initClient();
                var response = client.GetAsync(@"api/ListadoMonitorizacion");
                if (response.Result.IsSuccessStatusCode)
                {
                    var content = await response.Result.Content.ReadAsStringAsync();

                    var result = JsonConvert.DeserializeObject <List <MaquinaFirebase> >(content);
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Se ha producido una excipcion no controlada", ex.InnerException);
            }

            return(null);
        }