Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>7.0.1</Version>
<Version>7.0.2</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ public void Scan(byte[] image)
/// <summary>
/// 识别增值税发票方法
/// </summary>
public Task<string> CheckVatInvoiceJsonAsync(byte[] image) => Task.Run(() =>
public Task<string> CheckVatInvoiceJsonAsync(byte[] image, CancellationToken token = default) => Task.Run(() =>
{
var client = new Ocr(Options.CurrentValue.ApiKey, Options.CurrentValue.Secret);
var resp = client.VatInvoice(image);
return resp.ToString();
});
}, token);

/// <summary>
/// 识别增值税发票方法
/// </summary>
public Task<BaiduOcrResult<InvoiceEntity>> CheckVatInvoiceAsync(byte[] image) => Task.Run(() =>
public Task<BaiduOcrResult<InvoiceEntity>> CheckVatInvoiceAsync(byte[] image, CancellationToken token = default) => Task.Run(() =>
{
var ret = new BaiduOcrResult<InvoiceEntity>();
var client = new Ocr(Options.CurrentValue.ApiKey, Options.CurrentValue.Secret);
Expand All @@ -57,5 +57,5 @@ public Task<BaiduOcrResult<InvoiceEntity>> CheckVatInvoiceAsync(byte[] image) =>
ret.ErrorMessage = resp.Value<string>("error_msg");
}
return ret;
});
}, token);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ public interface IBaiduOcr
/// 增值税发票识别
/// </summary>
/// <param name="image"></param>
Task<BaiduOcrResult<InvoiceEntity>> CheckVatInvoiceAsync(byte[] image);
/// <param name="token"></param>
Task<BaiduOcrResult<InvoiceEntity>> CheckVatInvoiceAsync(byte[] image, CancellationToken token = default);

/// <summary>
/// 增值税发票识别
/// </summary>
/// <param name="image"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<string> CheckVatInvoiceJsonAsync(byte[] image);
Task<string> CheckVatInvoiceJsonAsync(byte[] image, CancellationToken token = default);
}