新增 ,定时器自定义异常类

This commit is contained in:
alex
2023-08-09 14:20:50 +08:00
parent 3d66e60477
commit e4cbbe4bfb
4 changed files with 78 additions and 7 deletions

View File

@@ -45,6 +45,7 @@ using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Entity;
using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Entities.Exceptions;
using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
@@ -219,6 +220,7 @@ namespace Tnb.WarehouseMgr
public async Task GenTaskExecute(CancellationTokenSource? cts = default)
{
Stopwatch sw = Stopwatch.StartNew();
CancellationTokenSource agvCts = new();
var db = _db.CopyNew();
try
{
@@ -352,11 +354,15 @@ namespace Tnb.WarehouseMgr
reqBody.taskChainPriority = 0;
reqBody.taskList = v;
Log.Information($"请求参数:{JsonConvert.SerializeObject(reqBody)}");
var respBody = await HttpClientHelper.PostStreamAsync(url, reqBody, CancellationToken.None);
var respBody = await HttpClientHelper.PostStreamAsync(url, reqBody, agvCts.Token);
Log.Information($"调用Agv接口响应结果:{respBody}");
}
}
}
catch (Exception ex) when (ex is HttpRequestException hReqEx)
{
agvCts.Cancel();
}
catch (Exception ex)
{
Log.Error("生成预任务执行时出现错误", ex);
@@ -366,6 +372,7 @@ namespace Tnb.WarehouseMgr
}
finally
{
agvCts.Dispose();
cts?.Dispose();
}
}