|
@ -1,6 +1,7 @@ |
|
|
using JdShopListener.Models; |
|
|
using JdShopListener.Models; |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
|
|
|
using System.IO; |
|
|
using System.Net.Http; |
|
|
using System.Net.Http; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
using System.Threading; |
|
|
using System.Threading; |
|
@ -79,6 +80,7 @@ namespace Utils |
|
|
HttpClient http = new HttpClient(); |
|
|
HttpClient http = new HttpClient(); |
|
|
http.Timeout = new TimeSpan(0, 0, 35); |
|
|
http.Timeout = new TimeSpan(0, 0, 35); |
|
|
http.DefaultRequestHeaders.Add("Authorization", "Bearer " + JwtToken); |
|
|
http.DefaultRequestHeaders.Add("Authorization", "Bearer " + JwtToken); |
|
|
|
|
|
|
|
|
if (postData!=null) |
|
|
if (postData!=null) |
|
|
{ |
|
|
{ |
|
|
StringContent content = new StringContent(postData); |
|
|
StringContent content = new StringContent(postData); |
|
@ -100,10 +102,11 @@ namespace Utils |
|
|
//服务器挂掉
|
|
|
//服务器挂掉
|
|
|
if (res.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
if (res.StatusCode != System.Net.HttpStatusCode.OK) |
|
|
{ |
|
|
{ |
|
|
|
|
|
MessageBox.Show("非错误:" + res.StatusCode); |
|
|
if (isAgain) |
|
|
if (isAgain) |
|
|
return null; |
|
|
return null; |
|
|
|
|
|
|
|
|
Thread.Sleep(60000); |
|
|
Thread.Sleep(10000); |
|
|
return Http(api, postData, true); |
|
|
return Http(api, postData, true); |
|
|
} |
|
|
} |
|
|
return res.Content.ReadAsStringAsync().Result; |
|
|
return res.Content.ReadAsStringAsync().Result; |
|
@ -112,13 +115,18 @@ namespace Utils |
|
|
} |
|
|
} |
|
|
catch (HttpRequestException ex) |
|
|
catch (HttpRequestException ex) |
|
|
{ |
|
|
{ |
|
|
|
|
|
MessageBox.Show("错误:"+ex.Message); |
|
|
|
|
|
|
|
|
if (isAgain) |
|
|
if (isAgain) |
|
|
return null; |
|
|
return null; |
|
|
Thread.Sleep(60000); |
|
|
|
|
|
|
|
|
Thread.Sleep(20000); |
|
|
return Http(api, postData, true); |
|
|
return Http(api, postData, true); |
|
|
} |
|
|
} |
|
|
catch (Exception ex) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
{ |
|
|
|
|
|
MessageBox.Show("出错:"+ex.Message); |
|
|
|
|
|
|
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|