Ejemplo n.º 1
0
 /// <summary>
 /// 查询获取订单信息
 /// </summary>
 /// <param name="receiptCode">订单号</param>
 /// <param name="PrefCode">入库首选项</param>
 private void getOrderInfo(string receiptCode, string PrefCode)
 {
     string name = @"/receipt";
     string url  = string.Format("{0}{1}{2}?receiptCode={3}&prefCode={4}", loginUser.server, controlReceiptApi, name, receiptCode, PrefCode);
     string Rstr = TTX_WebAPI_Helper.getReturnJson(url);
     ResponseReceiptEntity rsp = JsonToolEx.ToObject <ResponseReceiptEntity>(Rstr);
 }
Ejemplo n.º 2
0
        public static string postReturnJson(string url, IDictionary <string, string> parameters)
        {
            StreamReader   streamReader = null;
            string         Rstring      = "";
            HttpWebRequest request      = (HttpWebRequest)WebRequest.Create(url);

            request.Method = "POST";
            // request.Accept = "text/html, application/xhtml+xml, */*";
            request.ContentType = "application/json";
            //request.ContentType = "application/x-www-form-urlencoded";
            WarehouseCode warehousecode = new WarehouseCode(warehouse);

            request.Headers.Add("X-User", user);
            request.Headers.Add("X-DB", db);
            request.Headers.Add("x-params", JsonToolEx.ToJson(warehousecode));
            //如果需要POST数据
            if (!(parameters == null || parameters.Count == 0))
            {
                StringBuilder buffer = new StringBuilder();
                int           i      = 0;
                foreach (string key in parameters.Keys)
                {
                    if (i > 0)
                    {
                        buffer.AppendFormat("&{0}={1}", key, parameters[key]);
                    }
                    else
                    {
                        buffer.AppendFormat("{0}={1}", key, parameters[key]);
                    }
                    i++;
                }
                byte[] data = Encoding.UTF8.GetBytes(buffer.ToString());
                using (Stream stream = request.GetRequestStream())
                {
                    stream.Write(data, 0, data.Length);
                    stream.Close();
                }
            }

            WebResponse response = (WebResponse)request.GetResponse();

            //  Stream myResponseStream = response.GetResponseStream();
            streamReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(streamReader.ReadToEnd());
            string str = JsonConvert.SerializeXmlNode(doc);

            Rstring = JsonConvert.SerializeXmlNode(doc);
            return(Rstring);
        }
Ejemplo n.º 3
0
        private void frmLogincs_Load(object sender, EventArgs e)
        {
            string file = Path.Combine(Application.StartupPath, "config\\config.ini");

            cfg          = new ConfigSetting(file);
            txtUser.Text = cfg.User;
            string url = cfg.Server + controllApi;
            string str = TTX_WebAPI_Helper.getReturnJson(url);
            ResponseWarehouseEntity rsp = JsonToolEx.ToObject <ResponseWarehouseEntity>(str.Replace("default", "flag"));

            if (rsp != null && rsp.data != null)
            {
                rsm = rsp;
                if (rsm.data != null && rsm.data.Count > 0)
                {
                    cbxWarehouse.DataSource    = null;
                    cbxWarehouse.DataSource    = rsm.data;
                    cbxWarehouse.DisplayMember = "name";
                    cbxWarehouse.ValueMember   = "code";
                }
            }
        }