diff --git a/VideoAnalysis/Components/Pages/VideoTaskPage.razor.cs b/VideoAnalysis/Components/Pages/VideoTaskPage.razor.cs index 676c712..bf3070c 100644 --- a/VideoAnalysis/Components/Pages/VideoTaskPage.razor.cs +++ b/VideoAnalysis/Components/Pages/VideoTaskPage.razor.cs @@ -38,7 +38,7 @@ namespace Learn.VideoAnalysis.Components.Pages async void ReStart(VideoTaskDto query) { var lastEnum = (await RedisExpand.Redis.HMGetAsync(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 lastQuery = null; diff --git a/VideoAnalysis/Controllers/ApiController.cs b/VideoAnalysis/Controllers/ApiController.cs index 5585689..15060a4 100644 --- a/VideoAnalysis/Controllers/ApiController.cs +++ b/VideoAnalysis/Controllers/ApiController.cs @@ -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); } } diff --git a/VideoAnalysis/Program.cs b/VideoAnalysis/Program.cs index c3ca055..13476c8 100644 --- a/VideoAnalysis/Program.cs +++ b/VideoAnalysis/Program.cs @@ -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(); diff --git a/VideoAnalysisCore/Common/DownloadFile.cs b/VideoAnalysisCore/Common/DownloadFile.cs index f40ed51..0f86a0b 100644 --- a/VideoAnalysisCore/Common/DownloadFile.cs +++ b/VideoAnalysisCore/Common/DownloadFile.cs @@ -129,9 +129,12 @@ namespace VideoAnalysisCore.Common .WithFileName(task + fileExtension) .WithConfiguration(Opt) .Build(); + var pI = 0; download.DownloadProgressChanged += (object? sender, Downloader.DownloadProgressChangedEventArgs e) => { - RedisExpand.SetTaskProgress(task, e.ProgressPercentage); + pI++; + if(pI%20==0) + RedisExpand.SetTaskProgress(task, e.ProgressPercentage); }; download.DownloadFileCompleted +=async (object? sender, AsyncCompletedEventArgs e) => { diff --git a/VideoAnalysisCore/Common/RedisExpand.cs b/VideoAnalysisCore/Common/RedisExpand.cs index b10f999..5455e83 100644 --- a/VideoAnalysisCore/Common/RedisExpand.cs +++ b/VideoAnalysisCore/Common/RedisExpand.cs @@ -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() .SetColumns(it => it.ErrorMessage == error)//SetColumns是可以叠加的 写2个就2个字段赋值 .Where(it => it.Id == taskID)