Пример #1
0
        public static void setStatus(Despacho ent, StreamWriter w)
        {
            Uri address = new Uri("https://www.diabetrics.tienda/ChangeStatus.php");

              HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
              request.Method = "POST";
              request.ContentType = "application/x-www-form-urlencoded";
              // Create the data we want to send
              string appId = conf["appId"];

              StringBuilder data = new StringBuilder();
              data.Append("appId=" + HttpUtility.UrlEncode(appId));
              data.Append("&order=" + HttpUtility.UrlEncode(ent.id_cart));
              data.Append("&state=" + HttpUtility.UrlEncode(((int)ent.Estado).ToString()));
              if (!string.IsNullOrEmpty(ent.Guia))
            data.Append("&shipping=" + HttpUtility.UrlEncode(ent.Guia));
              if (!string.IsNullOrEmpty(ent.Factura_SAP))
            data.Append("&invoice=" + HttpUtility.UrlEncode(ent.Factura_SAP));

              // Create a byte array of the data we want to send
              byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());

              // Set the content length in the request headers
              request.ContentLength = byteData.Length;

              // Write data
              using (Stream postStream = request.GetRequestStream())
              {
            postStream.Write(byteData, 0, byteData.Length);
              }

              // Get response
              using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
              {
            // Get the response stream
            StreamReader reader = new StreamReader(response.GetResponseStream());

            // Console application output
            Log(reader.ReadToEnd(), w);
              }
        }
Пример #2
0
 static void realizarAcciones(string linea, StreamWriter w)
 {
     PropertyInfo[] props = typeof(Despacho).GetProperties();
       string[] datos = linea.Split(conf["separador"][0]);
       int cont = 0;
       Despacho ent = new Despacho();
       foreach (PropertyInfo p in props)
       {
     if (p.Name != "Estado")
       p.SetValue(ent, datos[cont], null);
     cont++;
       }
       ent.Estado = Estados.Preparacion;
       if (!string.IsNullOrEmpty(ent.Fecha_Recibido))
       {
     ent.Estado = Estados.Entregado;
       }
       else if (!string.IsNullOrEmpty(ent.Fecha_Envio))
       {
     ent.Estado = Estados.Enviado;
       }
       setStatus(ent, w);
 }