public static string GetDataByKuaidi100(string computer, string expressNo)
        {
            string      text     = "暂时没有此快递单号的信息";
            XmlDocument xmlNode  = ExpressHelper.GetXmlNode();
            XmlNode     xmlNode2 = xmlNode.SelectSingleNode("companys");
            string      text2    = "";
            string      text3    = "";

            if (xmlNode2 != null)
            {
                text2 = xmlNode2.Attributes["app_key"].Value;
                text3 = xmlNode2.Attributes["appSecret"].Value;
            }
            if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text3))
            {
                string text4 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                IDictionary <string, string> dictionary = new Dictionary <string, string>();
                dictionary.Add("app_key", text2);
                dictionary.Add("timestamp", text4);
                dictionary.Add("shipperCode", computer);
                dictionary.Add("logisticsCode", expressNo);
                string text5 = HiCryptographer.SignTopRequest(dictionary, text3);
                dictionary.Add("RequestUrl", $"http://wuliu.huz.cn/api/logistics?app_key={text2}&timestamp={text4}&shipperCode={computer}&logisticsCode={expressNo}&sign={text5}");
                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create($"http://wuliu.huz.cn/api/logistics?app_key={text2}&timestamp={text4}&shipperCode={computer}&logisticsCode={expressNo}&sign={text5}");
                httpWebRequest.Timeout = 8000;
                HttpWebResponse httpWebResponse;
                try
                {
                    httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                }
                catch (Exception ex)
                {
                    Globals.WriteExceptionLog(ex, dictionary, "GetDataByKuaidi100");
                    return(text);
                }
                if (httpWebResponse.StatusCode == HttpStatusCode.OK)
                {
                    Stream       responseStream = httpWebResponse.GetResponseStream();
                    StreamReader streamReader   = new StreamReader(responseStream, Encoding.GetEncoding("UTF-8"));
                    text = streamReader.ReadToEnd();
                    text = text.Replace("&amp;", "");
                    text = text.Replace("&nbsp;", "");
                    text = text.Replace("&", "");
                    if (!string.IsNullOrEmpty(text))
                    {
                        text = ExpressHelper.ConvertToObjectJson(text, computer, expressNo);
                    }
                }
                if (text == "" || text == "暂时没有此快递单号的信息")
                {
                    Globals.WriteLog(dictionary, "未获取到物流信息", "", "", "GetDataByKuaidi100");
                }
            }
            return(text);
        }
Exemple #2
0
        private void BindErpLink()
        {
            string text      = DateTime.Now.ToString("yyy-MM-dd HH:mm:ss");
            string checkCode = HiContext.Current.SiteSettings.CheckCode;
            string text2     = HiContext.Current.SiteSettings.AppKey;

            if (string.IsNullOrEmpty(text2))
            {
                text2 = this.CreateAppKey();
                SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                masterSettings.AppKey = text2;
                SettingsManager.Save(masterSettings);
                this.RegisterERP(text2, checkCode);
            }
            SortedDictionary <string, string> sortedDictionary = new SortedDictionary <string, string>();

            sortedDictionary.Add("app_key", text2);
            sortedDictionary.Add("timestamp", text);
            string text3 = HiCryptographer.SignTopRequest(sortedDictionary, checkCode);

            this.hplinkprint.NavigateUrl = "http://hierp.huz.cn/ExpressBill/Allot?app_key=" + text2 + "&timestamp=" + text + "&sign=" + text3;
        }