|
@@ -56,8 +56,13 @@ namespace KdanCommon.DocAI
|
|
public async Task<VerifyUserResponse> VerifyUser()
|
|
public async Task<VerifyUserResponse> VerifyUser()
|
|
{
|
|
{
|
|
VerifyUserResponse response = null;
|
|
VerifyUserResponse response = null;
|
|
- var result = await _httpClient.PostAsync(_verifyUserUri, new MultipartFormDataContent());
|
|
|
|
- if (result.StatusCode == System.Net.HttpStatusCode.OK)
|
|
|
|
|
|
+ HttpResponseMessage result = null;
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ result = await _httpClient.PostAsync(_verifyUserUri, new MultipartFormDataContent());
|
|
|
|
+ }
|
|
|
|
+ catch { }
|
|
|
|
+ if (result != null && result.StatusCode == System.Net.HttpStatusCode.OK)
|
|
{
|
|
{
|
|
var jsonString = await result.Content.ReadAsStringAsync();
|
|
var jsonString = await result.Content.ReadAsStringAsync();
|
|
response = JsonTool.DeserializeJSON<VerifyUserResponse>(jsonString);
|
|
response = JsonTool.DeserializeJSON<VerifyUserResponse>(jsonString);
|
|
@@ -65,7 +70,7 @@ namespace KdanCommon.DocAI
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
|
|
- public async Task<RedactInfoExtractResponse> RedactInfoExtract(StorageFile file, string redactInfo, string docType, string pageRange = null, string redactCustomInfo = null)
|
|
|
|
|
|
+ public async Task<RedactInfoExtractResponse> RedactInfoExtract(StorageFile file, string fileName, string md5, string redactInfo, string docType, string pageRange = null, string redactCustomInfo = null)
|
|
{
|
|
{
|
|
RedactInfoExtractResponse response = null;
|
|
RedactInfoExtractResponse response = null;
|
|
using (var fileStream = await file.OpenStreamForReadAsync())
|
|
using (var fileStream = await file.OpenStreamForReadAsync())
|
|
@@ -74,8 +79,9 @@ namespace KdanCommon.DocAI
|
|
var streamContent = new StreamContent(fileStream);
|
|
var streamContent = new StreamContent(fileStream);
|
|
streamContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data");
|
|
streamContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data");
|
|
streamContent.Headers.ContentDisposition.Name = "redact_file";
|
|
streamContent.Headers.ContentDisposition.Name = "redact_file";
|
|
- streamContent.Headers.ContentDisposition.FileName = file.Name;
|
|
|
|
|
|
+ streamContent.Headers.ContentDisposition.FileName = fileName;
|
|
content.Add(streamContent);
|
|
content.Add(streamContent);
|
|
|
|
+ content.Add(CreateStringContent(md5, "md5"));
|
|
content.Add(CreateStringContent(redactInfo, "redact_info"));
|
|
content.Add(CreateStringContent(redactInfo, "redact_info"));
|
|
content.Add(CreateStringContent(_appName, "app_name"));
|
|
content.Add(CreateStringContent(_appName, "app_name"));
|
|
content.Add(CreateStringContent(_appVersion, "app_version"));
|
|
content.Add(CreateStringContent(_appVersion, "app_version"));
|
|
@@ -85,8 +91,13 @@ namespace KdanCommon.DocAI
|
|
content.Add(CreateStringContent(redactCustomInfo, "redact_custom_info"));
|
|
content.Add(CreateStringContent(redactCustomInfo, "redact_custom_info"));
|
|
if (!string.IsNullOrEmpty(pageRange))
|
|
if (!string.IsNullOrEmpty(pageRange))
|
|
content.Add(CreateStringContent(pageRange, "page_range"));
|
|
content.Add(CreateStringContent(pageRange, "page_range"));
|
|
- var result = await _httpClient.PostAsync(_redactInfoExtractUri, content);
|
|
|
|
- if (result.StatusCode == System.Net.HttpStatusCode.OK)
|
|
|
|
|
|
+ HttpResponseMessage result = null;
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ result = await _httpClient.PostAsync(_redactInfoExtractUri, content);
|
|
|
|
+ }
|
|
|
|
+ catch { }
|
|
|
|
+ if (result != null && result.StatusCode == System.Net.HttpStatusCode.OK)
|
|
{
|
|
{
|
|
var jsonString = await result.Content.ReadAsStringAsync();
|
|
var jsonString = await result.Content.ReadAsStringAsync();
|
|
response = JsonTool.DeserializeJSON<RedactInfoExtractResponse>(jsonString);
|
|
response = JsonTool.DeserializeJSON<RedactInfoExtractResponse>(jsonString);
|