Пример #1
0
        private static string BuildRequestParaToString(SortedDictionary <string, string> sParaTemp, Encoding code, Config config)
        {
            Dictionary <string, string> strs = new Dictionary <string, string>();

            strs = Submit.BuildRequestPara(sParaTemp, config);
            return(Core.CreateLinkStringUrlencode(strs, code));
        }
Пример #2
0
        public static string BuildRequest(SortedDictionary <string, string> sParaTemp, string strMethod, string strButtonValue, Config config)
        {
            Dictionary <string, string> strs = new Dictionary <string, string>();

            strs = Submit.BuildRequestPara(sParaTemp, config);
            StringBuilder stringBuilder = new StringBuilder();

            string[] gATEWAYNEW = new string[] { "<form id='alipaysubmit' name='alipaysubmit' action='", Submit.GATEWAY_NEW, "_input_charset=", Submit._input_charset, "' method='", strMethod.ToLower().Trim(), "'>" };
            stringBuilder.Append(string.Concat(gATEWAYNEW));
            foreach (KeyValuePair <string, string> str in strs)
            {
                gATEWAYNEW = new string[] { "<input type='hidden' name='", str.Key, "' value='", str.Value, "'/>" };
                stringBuilder.Append(string.Concat(gATEWAYNEW));
            }
            stringBuilder.Append(string.Concat("<input type='submit' value='", strButtonValue, "' style='display:none;'></form>"));
            stringBuilder.Append("<script>document.forms['alipaysubmit'].submit();</script>");
            return(stringBuilder.ToString());
        }
Пример #3
0
        public static string BuildRequest(SortedDictionary <string, string> sParaTemp, string strMethod, string fileName, byte[] data, string contentType, int lengthFile, Config config)
        {
            Stream responseStream;
            string str;
            Dictionary <string, string> strs = new Dictionary <string, string>();

            strs = Submit.BuildRequestPara(sParaTemp, config);
            string         str1           = string.Concat(Submit.GATEWAY_NEW, "_input_charset=", Submit._input_charset);
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(str1);

            httpWebRequest.Method = strMethod;
            string str2 = DateTime.Now.Ticks.ToString("x");
            string str3 = string.Concat("--", str2);

            httpWebRequest.ContentType = string.Concat("\r\nmultipart/form-data; boundary=", str2);
            httpWebRequest.KeepAlive   = true;
            StringBuilder stringBuilder = new StringBuilder();

            foreach (KeyValuePair <string, string> keyValuePair in strs)
            {
                string[] key = new string[] { str3, "\r\nContent-Disposition: form-data; name=\"", keyValuePair.Key, "\"\r\n\r\n", keyValuePair.Value, "\r\n" };
                stringBuilder.Append(string.Concat(key));
            }
            stringBuilder.Append(string.Concat(str3, "\r\nContent-Disposition: form-data; name=\"withhold_file\"; filename=\""));
            stringBuilder.Append(fileName);
            stringBuilder.Append(string.Concat("\"\r\nContent-Type: ", contentType, "\r\n\r\n"));
            string   str4     = stringBuilder.ToString();
            Encoding encoding = Encoding.GetEncoding(Submit._input_charset);

            byte[] bytes    = encoding.GetBytes(str4);
            byte[] numArray = Encoding.ASCII.GetBytes(string.Concat("\r\n", str3, "--\r\n"));
            long   length   = (int)bytes.Length + lengthFile + (int)numArray.Length;

            httpWebRequest.ContentLength = length;
            Stream requestStream = httpWebRequest.GetRequestStream();

            try
            {
                try
                {
                    requestStream.Write(bytes, 0, bytes.Length);
                    requestStream.Write(data, 0, lengthFile);
                    requestStream.Write(numArray, 0, numArray.Length);
                    responseStream = ((HttpWebResponse)httpWebRequest.GetResponse()).GetResponseStream();
                }
                catch (WebException webException)
                {
                    str = webException.ToString();
                    return(str);
                }
            }
            finally
            {
                if (requestStream != null)
                {
                    requestStream.Close();
                }
            }
            StreamReader  streamReader   = new StreamReader(responseStream, encoding);
            StringBuilder stringBuilder1 = new StringBuilder();

            while (true)
            {
                string str5 = streamReader.ReadLine();
                string str6 = str5;
                if (str5 == null)
                {
                    break;
                }
                stringBuilder1.Append(str6);
            }
            responseStream.Close();
            str = stringBuilder1.ToString();
            return(str);
        }