Exemple #1
0
        public bool SetEnviado(string id_order, AnyTransito transito)
        {
            bool ret            = true;
            var  url            = $"{baseUrl}orders/{id_order}?gumgaToken={token}";
            var  httpWebRequest = (HttpWebRequest)WebRequest.Create(url);

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "PUT";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = JsonConvert.SerializeObject(transito);

                streamWriter.Write(json);
            }
            try
            {
                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                }
            }
            catch (Exception ex)
            {
                ret = false;
                string msg = ex.Message;
                Log.Set($"Erro Set Transito: {ex.Message}");
            }
            return(ret);
        }
Exemple #2
0
        private void Enviado_Thread()
        {
            Db        db = new Db();
            DataTable dt = db.LoadEnviados();

            foreach (DataRow dr in dt.Rows)
            {
                Invoice invoice = new Invoice();
                // SELECT b.id_ANY, 'PAID_WAITING_DELIVERY', c.dt_Lanc, a.dt_Exped, b.dt_Prev,
                //                            d.ds_Responsavel, d.ds_Comentario
                AnyTransito transito = new AnyTransito();
                transito.order_id = dr["id_ANY"].ToString();
                transito.status   = "PAID_WAITING_DELIVERY";

                Tracking tracking = new Tracking();
                tracking.date         = dr["dt_Lanc"].ToString();
                tracking.number       = dr["id_any"].ToString();
                tracking.shippedDate  = dr["dt_Exped"].ToString();
                tracking.estimateDate = dr["dt_Prev"].ToString();
                tracking.carrier      = dr["ds_Responsavel"].ToString();
                tracking.url          = dr["ds_Comentario"].ToString();

                transito.tracking = tracking;
                AnyMarket anyMarket = new AnyMarket();
                if (anyMarket.SetEnviado(transito.order_id, transito))
                {
                    db.setEnviado(dr["id_nfs01"].ToString(), "200", "sucesso", "1");
                }
                else
                {
                    db.setEnviado(dr["id_nfs01"].ToString(), "400", "erro", "2");
                }
            }
        }