|
|
@ -74,15 +74,30 @@ namespace SparkClient.Model.Services |
|
|
|
// 提前读取内容并存储 |
|
|
|
// 提前读取内容并存储 |
|
|
|
string responseBody = await result.Content.ReadAsStringAsync(); |
|
|
|
string responseBody = await result.Content.ReadAsStringAsync(); |
|
|
|
int statusCode = (int)result.StatusCode; |
|
|
|
int statusCode = (int)result.StatusCode; |
|
|
|
|
|
|
|
|
|
|
|
// 记录日志 |
|
|
|
// 记录日志 |
|
|
|
Logger.Info($"Response: Status={statusCode}, Body={responseBody}"); |
|
|
|
Logger.Info($"Response: Status={statusCode}, Body={responseBody}"); |
|
|
|
|
|
|
|
var tempEntity = JsonConvert.DeserializeObject<ResponseStatus>(responseBody); |
|
|
|
|
|
|
|
if ("S007".Equals(tempEntity.Status)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Logger.Info($"S007 请求重试"); |
|
|
|
|
|
|
|
await Task.Delay(50); |
|
|
|
|
|
|
|
return await SendGetRequestAsync(url); |
|
|
|
|
|
|
|
} |
|
|
|
result.Content = new StringContent(responseBody); |
|
|
|
result.Content = new StringContent(responseBody); |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async Task<HttpResponseMessage> SendGetRequestImageAsync(string url) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
using (var client = new HttpClient()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Logger.Info($"Request sent to URL: {url}"); |
|
|
|
|
|
|
|
client.DefaultRequestHeaders.Add("Authorization", "Basic " + _authToken); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await client.GetAsync(url); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// 启动图片收集任务。 |
|
|
|
/// 启动图片收集任务。 |
|
|
@ -172,7 +187,7 @@ namespace SparkClient.Model.Services |
|
|
|
string url = $"{_baseUrl}/retrieve_image/{imageIndex}"; |
|
|
|
string url = $"{_baseUrl}/retrieve_image/{imageIndex}"; |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
var response = await SendGetRequestAsync(url); |
|
|
|
var response = await SendGetRequestImageAsync(url); |
|
|
|
int status = (int)response.StatusCode; |
|
|
|
int status = (int)response.StatusCode; |
|
|
|
|
|
|
|
|
|
|
|
switch (status) |
|
|
|
switch (status) |
|
|
|