|
@@ -29,7 +29,7 @@ namespace Common.system
|
29
|
29
|
|
30
|
30
|
private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
|
31
|
31
|
{
|
32
|
|
- return true; //总是接受
|
|
32
|
+ return true; //总是接受
|
33
|
33
|
}
|
34
|
34
|
|
35
|
35
|
public static System.Net.HttpWebRequest GetHttpWebRequest(string url)
|
|
@@ -47,6 +47,7 @@ namespace Common.system
|
47
|
47
|
}
|
48
|
48
|
return request;
|
49
|
49
|
}
|
|
50
|
+
|
50
|
51
|
public static WebResponse Download(string downloadUrl, long from, long to, string method)
|
51
|
52
|
{
|
52
|
53
|
for (int i = 0; i < 10; i++)
|
|
@@ -73,6 +74,7 @@ namespace Common.system
|
73
|
74
|
}
|
74
|
75
|
throw new Exception("已断开网络!请检查网络连接后重试下载!");
|
75
|
76
|
}
|
|
77
|
+
|
76
|
78
|
public static string Get(string url, IDictionary<string, string> param)
|
77
|
79
|
{
|
78
|
80
|
List<string> paramBuilder = new List<string>();
|
|
@@ -83,6 +85,7 @@ namespace Common.system
|
83
|
85
|
url = string.Format("{0}?{1}", url.TrimEnd('?'), string.Join(",", paramBuilder.ToArray()));
|
84
|
86
|
return Get(url);
|
85
|
87
|
}
|
|
88
|
+
|
86
|
89
|
public static string Get(string url)
|
87
|
90
|
{
|
88
|
91
|
try
|
|
@@ -104,10 +107,10 @@ namespace Common.system
|
104
|
107
|
}
|
105
|
108
|
catch
|
106
|
109
|
{
|
107
|
|
-
|
108
|
110
|
}
|
109
|
111
|
return null;
|
110
|
112
|
}
|
|
113
|
+
|
111
|
114
|
public static string Post(string url, string data)
|
112
|
115
|
{
|
113
|
116
|
try
|
|
@@ -139,7 +142,6 @@ namespace Common.system
|
139
|
142
|
}
|
140
|
143
|
catch
|
141
|
144
|
{
|
142
|
|
-
|
143
|
145
|
}
|
144
|
146
|
return null;
|
145
|
147
|
}
|
|
@@ -183,6 +185,7 @@ namespace Common.system
|
183
|
185
|
return "POST报错:" + ex.Message;
|
184
|
186
|
}
|
185
|
187
|
}
|
|
188
|
+
|
186
|
189
|
/// <summary>
|
187
|
190
|
/// Post Http请求
|
188
|
191
|
/// </summary>
|
|
@@ -240,6 +243,7 @@ namespace Common.system
|
240
|
243
|
}
|
241
|
244
|
return default(T);
|
242
|
245
|
}
|
|
246
|
+
|
243
|
247
|
private static string GetStreamReader(string url, Stream responseStream, Stream requestStream, StreamReader streamReader, WebResponse webResponse, int timeout, string encode, string postData, string contentType)
|
244
|
248
|
{
|
245
|
249
|
try
|
|
@@ -263,10 +267,12 @@ namespace Common.system
|
263
|
267
|
return null;
|
264
|
268
|
}
|
265
|
269
|
}
|
|
270
|
+
|
266
|
271
|
/// <summary>
|
267
|
272
|
/// Cookie
|
268
|
273
|
/// </summary>
|
269
|
274
|
public static CookieContainer cc = new CookieContainer();
|
|
275
|
+
|
270
|
276
|
/// <summary>
|
271
|
277
|
/// Get请求
|
272
|
278
|
/// </summary>
|
|
@@ -295,7 +301,7 @@ namespace Common.system
|
295
|
301
|
string encoding = response.ContentEncoding;
|
296
|
302
|
if (encoding == null || encoding.Length < 1)
|
297
|
303
|
{
|
298
|
|
- encoding = "UTF-8"; //默认编码
|
|
304
|
+ encoding = "UTF-8"; //默认编码
|
299
|
305
|
}
|
300
|
306
|
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
|
301
|
307
|
string retString = reader.ReadToEnd();
|
|
@@ -345,7 +351,7 @@ namespace Common.system
|
345
|
351
|
string encoding = response.ContentEncoding;
|
346
|
352
|
if (encoding == null || encoding.Length < 1)
|
347
|
353
|
{
|
348
|
|
- encoding = "UTF-8"; //默认编码
|
|
354
|
+ encoding = "UTF-8"; //默认编码
|
349
|
355
|
}
|
350
|
356
|
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
|
351
|
357
|
string retString = reader.ReadToEnd();
|
|
@@ -360,7 +366,6 @@ namespace Common.system
|
360
|
366
|
LogHelper.WriteErrLog("请求失败(若网络无问题,请重置winsock,解决方法:以管理员方式打开cmd执行 netsh winsock reset 后重启)", ex);
|
361
|
367
|
return null;
|
362
|
368
|
}
|
363
|
|
-
|
364
|
369
|
}
|
365
|
370
|
|
366
|
371
|
/// <summary>
|
|
@@ -575,8 +580,6 @@ namespace Common.system
|
575
|
580
|
jobResult = JObject.Parse(returnValue);
|
576
|
581
|
response.Close();
|
577
|
582
|
readStream.Close();
|
578
|
|
- //MessageWindow.Show(returnValue);
|
579
|
|
- //LogHelper.WriteInfoLog("【文件上传】" + returnValue);
|
580
|
583
|
}
|
581
|
584
|
return jobResult;
|
582
|
585
|
}
|
|
@@ -590,6 +593,7 @@ namespace Common.system
|
590
|
593
|
httpReq = null;
|
591
|
594
|
}
|
592
|
595
|
}
|
|
596
|
+
|
593
|
597
|
/// <summary>
|
594
|
598
|
/// Post Http请求
|
595
|
599
|
/// </summary>
|
|
@@ -690,4 +694,4 @@ namespace Common.system
|
690
|
694
|
}
|
691
|
695
|
}
|
692
|
696
|
}
|
693
|
|
-}
|
|
697
|
+}
|