|
@@ -209,46 +209,49 @@ namespace DataSharing.Province
|
|
|
byte[] fileContentBytes = null;
|
|
|
//try
|
|
|
//{
|
|
|
- string url = string.Format("{0}{1}?Source={2}&Id={3}", businessFile.BaseUrl, businessFile.DownloadUrlAddress, "hotline", fileId);
|
|
|
- _logger.LogWarning("请求附件服务器组装地址:--------------" + url);
|
|
|
- using (var client = _httpClientFactory.CreateClient())
|
|
|
- using (var response = await client.GetAsync(url))
|
|
|
+ string url = string.Format("{0}{1}?Source={2}&Id={3}", businessFile.BaseUrl, businessFile.DownloadUrlAddress, "hotline", fileId);
|
|
|
+ _logger.LogWarning("请求附件服务器组装地址:--------------" + url);
|
|
|
+ using (var client = _httpClientFactory.CreateClient())
|
|
|
+ using (var response = await client.GetAsync(url))
|
|
|
+ {
|
|
|
+
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
+ _logger.LogWarning("请求附件服务器返回状态:--------------获取成功");
|
|
|
|
|
|
- if (response.StatusCode == HttpStatusCode.OK)
|
|
|
- {
|
|
|
- _logger.LogWarning("请求附件服务器返回状态:--------------获取成功");
|
|
|
- using var memoryStream = new MemoryStream();
|
|
|
- await response.Content.CopyToAsync(memoryStream);
|
|
|
- memoryStream.Seek(0, SeekOrigin.Begin);
|
|
|
- fileContentBytes = memoryStream.ToArray();
|
|
|
- }
|
|
|
+ fileName = response.Content.Headers.ContentDisposition.FileNameStar;
|
|
|
+ using var memoryStream = new MemoryStream();
|
|
|
+ await response.Content.CopyToAsync(memoryStream);
|
|
|
+ memoryStream.Seek(0, SeekOrigin.Begin);
|
|
|
+
|
|
|
+ fileContentBytes = memoryStream.ToArray();
|
|
|
}
|
|
|
- if (fileContentBytes != null)
|
|
|
- {
|
|
|
- //获取附件上传Token
|
|
|
- string strToken = await _xieTongClient.GetTokenAsync(cancellationToken);
|
|
|
- _logger.LogWarning("附件上传Token:--------------" + strToken);
|
|
|
- Dictionary<string, object> dicParam = new()
|
|
|
+ }
|
|
|
+ if (fileContentBytes != null)
|
|
|
+ {
|
|
|
+ //获取附件上传Token
|
|
|
+ string strToken = await _xieTongClient.GetTokenAsync(cancellationToken);
|
|
|
+ _logger.LogWarning("附件上传Token:--------------" + strToken);
|
|
|
+ Dictionary<string, object> dicParam = new()
|
|
|
{
|
|
|
{ "params", request } // 第一个接口参数,json格式字符串
|
|
|
};
|
|
|
|
|
|
- // 构造字典文件数据
|
|
|
- // 接口参数名称为files
|
|
|
- CFormUpload.FileParameter fileParameter = new CFormUpload.FileParameter("files", fileContentBytes, fileName, null);
|
|
|
- dicParam.Add(fileName, fileParameter);
|
|
|
+ // 构造字典文件数据
|
|
|
+ // 接口参数名称为files
|
|
|
+ CFormUpload.FileParameter fileParameter = new CFormUpload.FileParameter("files", fileContentBytes, fileName, null);
|
|
|
+ dicParam.Add(fileName, fileParameter);
|
|
|
|
|
|
- string strUrl = configProvince.HuiJu + "get_case_material_info";
|
|
|
- // 上传附件
|
|
|
- string strResult = CFormUpload.MultipartFormDataPost(strUrl, null, dicParam, strToken);
|
|
|
+ string strUrl = configProvince.HuiJu + "get_case_material_info";
|
|
|
+ // 上传附件
|
|
|
+ string strResult = CFormUpload.MultipartFormDataPost(strUrl, null, dicParam, strToken);
|
|
|
|
|
|
- _logger.LogWarning("省接口上传附件返回:--------------" + strResult);
|
|
|
+ _logger.LogWarning("省接口上传附件返回:--------------" + strResult);
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(strResult))
|
|
|
- return JsonConvert.DeserializeObject<ProvinceResponse>(strResult);
|
|
|
- }
|
|
|
- return new ProvinceResponse();
|
|
|
+ if (!string.IsNullOrEmpty(strResult))
|
|
|
+ return JsonConvert.DeserializeObject<ProvinceResponse>(strResult);
|
|
|
+ }
|
|
|
+ return new ProvinceResponse();
|
|
|
//}
|
|
|
//catch (Exception ex)
|
|
|
//{
|