修复 新增任务流程异常问题

This commit is contained in:
小肥羊 2024-11-14 17:10:26 +08:00
parent 79d024f9f6
commit c597adf48f
5 changed files with 11 additions and 4 deletions

View File

@ -38,7 +38,7 @@ namespace Learn.VideoAnalysis.Components.Pages
async void ReStart(VideoTaskDto query)
{
var lastEnum = (await RedisExpand.Redis.HMGetAsync<RedisChannelEnum>(RedisExpandKey.Task(query.Id), "LastEnum")).FirstOrDefault() ;
await RedisExpand.SetTaskErrorMessage(query.Id, string.Empty);
await RedisExpand.SetTaskErrorMessage(query.Id, null);
RedisExpand.InsertChannel(lastEnum, query.Id);
}
private QueryModel<VideoTaskDto> lastQuery = null;

View File

@ -94,7 +94,7 @@ namespace Learn.VideoAnalysis.Controllers
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
.ToDictionary(s => s.Name, s => s.GetValue(task));
RedisExpand.Redis.HMSet(RedisExpandKey.Task(task.Id), hashEntries);
RedisExpand.Redis.Set(RedisExpandKey.ChannelKey, task.Id);
RedisExpand.Redis.LPush(RedisExpandKey.ChannelKey, task.Id);
return Ok(task.Id);
}
}

View File

@ -51,6 +51,7 @@ namespace Learn.VideoAnalysis
builder.Configuration.GetSection("AppConfig").Bind(AppCommon.Config);
//³õʼ»¯ ²å¼þ
builder.Services.InitSqlSugar();
RedisExpand.Init();
Speaker.Init();
//SenseVoice.Init();
@ -72,7 +73,6 @@ namespace Learn.VideoAnalysis
//VideoAnalysisRazor.Program.AddClientServices(builder.Services);
builder.Services.AddAntDesign();
builder.Services.InitSqlSugar();
builder.Services.AddMapster();

View File

@ -129,8 +129,11 @@ namespace VideoAnalysisCore.Common
.WithFileName(task + fileExtension)
.WithConfiguration(Opt)
.Build();
var pI = 0;
download.DownloadProgressChanged += (object? sender, Downloader.DownloadProgressChangedEventArgs e) =>
{
pI++;
if(pI%20==0)
RedisExpand.SetTaskProgress(task, e.ProgressPercentage);
};
download.DownloadFileCompleted +=async (object? sender, AsyncCompletedEventArgs e) =>

View File

@ -255,9 +255,13 @@ namespace VideoAnalysisCore.Common
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
Console.WriteLine("==============================================");
//清除失败任务 重新接收任务
await Redis.DelAsync(RedisExpandKey.IDTask);
await ReceivingTaskAsync();
}
Redis.HMSet(RedisExpandKey.Task(taskID), "ErrorMessage", error);
return await DbScoped.SugarScope.Updateable<VideoTask>()
.SetColumns(it => it.ErrorMessage == error)//SetColumns是可以叠加的 写2个就2个字段赋值
.Where(it => it.Id == taskID)