예제 #1
0
        public WSLog Imponer(DB.ViewModels.ImponerWSRequest data)
        {
            DateTime fechaInicio = DateTime.Now;
            DateTime fechaFin    = DateTime.Now;
            string   USER        = ConfigurationManager.AppSettings["USER_WSOCASA"];

            string PASSWORD = ConfigurationManager.AppSettings["PASSWORD_WSOCASA"];

            string json = "{\"security\":{\"login\":\""
                          + USER + "\",\"password\":\""
                          + PASSWORD + "\"},\"pedidos\":[" + this.GetPedidoJSON(data) + "]}";

            string url = ConfigurationManager.AppSettings["WSOCASA"] + "imponer";

            string response = "";

            WSLog wsExternos = new WSLog()
            {
                FechaLlamada   = fechaInicio,
                FechaRespuesta = fechaFin,
                JSONRequest    = json,
                JSONResponse   = response,
                Servicio       = "Imponer",
                Url            = url
            };

            try
            {
                ServiceCaller sc = new ServiceCaller();

                HttpWebResponse webResponse = sc.POST(url, json);

                using (var reader = new System.IO.StreamReader(webResponse.GetResponseStream()))
                {
                    response = reader.ReadToEnd();
                }

                if (response == "")
                {
                    response = "(Vacio)";
                }

                wsExternos.JSONResponse   = response;
                wsExternos.FechaRespuesta = DateTime.Now;
                wsExternos.Estado         = "OK";

                return(wsExternos);
            }
            catch (Exception ex)
            {
                wsExternos.JSONResponse = ex.Message;
                wsExternos.Estado       = "ERROR";
                return(wsExternos);
            }
        }
예제 #2
0
        public WSLog Consultar(string nroSeguimiento)
        {
            try
            {
                string USER = ConfigurationManager.AppSettings["USER_WSOCASA"];

                DateTime fechaInicio = DateTime.Now;

                string PASSWORD = ConfigurationManager.AppSettings["PASSWORD_WSOCASA"];

                string json = "{\"security\":{\"login\":\""
                              + USER + "\",\"password\":\""
                              + PASSWORD + "\"},\"pedidos\":[{\"nroseguimiento\":\""
                              + nroSeguimiento + "\"}]}";

                string url = ConfigurationManager.AppSettings["WSOCASA"] + "consultar";

                string response = "";

                ServiceCaller sc = new ServiceCaller();

                HttpWebResponse webResponse = sc.POST(url, json);

                using (var reader = new System.IO.StreamReader(webResponse.GetResponseStream()))
                {
                    response = reader.ReadToEnd();
                }

                DateTime fechaFin = DateTime.Now;

                WSLog wsExternos = new WSLog()
                {
                    FechaLlamada   = fechaInicio,
                    FechaRespuesta = fechaFin,
                    JSONRequest    = json,
                    JSONResponse   = response,
                    Servicio       = "Consultar",
                    Url            = url
                };

                return(wsExternos);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }