Beispiel #1
0
        public static string getHttp(IDictionary <string, string> parameters, Encoding charset)
        {
            string    retString = null;
            Hashtable ht        = new Hashtable();

            foreach (string key in parameters.Keys)
            {
                if (!key.Equals("orderText"))
                {
                    ht.Add(key.ToLower(), parameters[key]);
                }
            }
            string mac = EncryptionMD5.MD5(ht, SysConfigHelper.readerNode("macKey"));

            if (!parameters.ContainsKey("mac"))
            {
                parameters.Add("mac".ToLower(), mac);
            }
            else
            {
                parameters["mac"] = mac;
            }
            string url = SysConfigHelper.readerNode("mechineSign");

            url = url + "?";
            StringBuilder buffer = new StringBuilder();

            //如果需要POST数据
            if (!(parameters == null || parameters.Count == 0))
            {
                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++;
                }
            }
            retString = getHttp2(url, buffer.ToString(), charset);
            return(retString);
        }