Skip to content

Commit e70118f

Browse files
authored
feat: add CancellationToken parameter on CheckVatInvoiceJsonAsync method (#331)
* refactor: 增加 CancellationToken 参数 * chore: bump version 7.0.2
1 parent 0ab5d1c commit e70118f

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/Extensions/Components/BootstrapBlazor.BaiduOcr/BootstrapBlazor.BaiduOcr.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>7.0.1</Version>
4+
<Version>7.0.2</Version>
55
</PropertyGroup>
66

77
<PropertyGroup>

src/Extensions/Components/BootstrapBlazor.BaiduOcr/Services/BaiduOcr.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ public void Scan(byte[] image)
3232
/// <summary>
3333
/// 识别增值税发票方法
3434
/// </summary>
35-
public Task<string> CheckVatInvoiceJsonAsync(byte[] image) => Task.Run(() =>
35+
public Task<string> CheckVatInvoiceJsonAsync(byte[] image, CancellationToken token = default) => Task.Run(() =>
3636
{
3737
var client = new Ocr(Options.CurrentValue.ApiKey, Options.CurrentValue.Secret);
3838
var resp = client.VatInvoice(image);
3939
return resp.ToString();
40-
});
40+
}, token);
4141

4242
/// <summary>
4343
/// 识别增值税发票方法
4444
/// </summary>
45-
public Task<BaiduOcrResult<InvoiceEntity>> CheckVatInvoiceAsync(byte[] image) => Task.Run(() =>
45+
public Task<BaiduOcrResult<InvoiceEntity>> CheckVatInvoiceAsync(byte[] image, CancellationToken token = default) => Task.Run(() =>
4646
{
4747
var ret = new BaiduOcrResult<InvoiceEntity>();
4848
var client = new Ocr(Options.CurrentValue.ApiKey, Options.CurrentValue.Secret);
@@ -57,5 +57,5 @@ public Task<BaiduOcrResult<InvoiceEntity>> CheckVatInvoiceAsync(byte[] image) =>
5757
ret.ErrorMessage = resp.Value<string>("error_msg");
5858
}
5959
return ret;
60-
});
60+
}, token);
6161
}

src/Extensions/Components/BootstrapBlazor.BaiduOcr/Services/IBaiduOcr.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ public interface IBaiduOcr
1313
/// 增值税发票识别
1414
/// </summary>
1515
/// <param name="image"></param>
16-
Task<BaiduOcrResult<InvoiceEntity>> CheckVatInvoiceAsync(byte[] image);
16+
/// <param name="token"></param>
17+
Task<BaiduOcrResult<InvoiceEntity>> CheckVatInvoiceAsync(byte[] image, CancellationToken token = default);
1718

1819
/// <summary>
1920
/// 增值税发票识别
2021
/// </summary>
2122
/// <param name="image"></param>
23+
/// <param name="token"></param>
2224
/// <returns></returns>
23-
Task<string> CheckVatInvoiceJsonAsync(byte[] image);
25+
Task<string> CheckVatInvoiceJsonAsync(byte[] image, CancellationToken token = default);
2426
}

0 commit comments

Comments
 (0)