ow
This commit is contained in:
1 parent
9e79a6a67c
commit
7c8af2fb08
14 files changed
+328
-45
No files matched your search
@@ -5,8 +5,6 @@ VisualStudioVersion = 17.8.34316.72
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CloudBuilder.Topshelf", "CloudBuilder.Topshelf.csproj", "{63EB47F6-A616-4C64-B850-85ED294E2524}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudBuilder.Request", "..\CloudBuilder\CloudBuilder.Request\CloudBuilder.Request.csproj", "{8A0A5461-7F04-B87A-CE03-309E1D186FEC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -17,10 +15,6 @@ Global
|
||||
{63EB47F6-A616-4C64-B850-85ED294E2524}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{63EB47F6-A616-4C64-B850-85ED294E2524}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{63EB47F6-A616-4C64-B850-85ED294E2524}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8A0A5461-7F04-B87A-CE03-309E1D186FEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8A0A5461-7F04-B87A-CE03-309E1D186FEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8A0A5461-7F04-B87A-CE03-309E1D186FEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8A0A5461-7F04-B87A-CE03-309E1D186FEC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -2,7 +2,7 @@
|
||||
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<History>True|2026-09-21T03:59:35.1020536Z||;True|2026-09-21T11:50:47.8944224+08:00||;True|2026-09-21T11:30:52.9019631+08:00||;True|2026-09-21T10:47:01.8026331+08:00||;</History>
|
||||
<History>True|2026-09-21T07:29:51.3588778Z||;True|2026-09-21T15:18:10.5399306+08:00||;True|2026-09-21T14:59:51.6908938+08:00||;True|2026-09-21T14:49:11.2390264+08:00||;True|2026-09-21T14:17:57.4013084+08:00||;True|2026-09-21T14:00:14.9207890+08:00||;True|2026-09-21T11:59:35.1020536+08:00||;True|2026-09-21T11:50:47.8944224+08:00||;True|2026-09-21T11:30:52.9019631+08:00||;True|2026-09-21T10:47:01.8026331+08:00||;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,6 +1,12 @@
|
||||
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
||||
using CliWrap;
|
||||
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
||||
using CloudBuilder.Core.DependencyInjection.Task;
|
||||
using CloudBuilder.Core.Service;
|
||||
using CloudBuilder.Master.Entity;
|
||||
using CloudBuilder.Security.Entity;
|
||||
using CloudBuilder.Security.Service;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace CloudBuilder.Topshelf.Task
|
||||
{
|
||||
@@ -8,27 +14,75 @@ namespace CloudBuilder.Topshelf.Task
|
||||
public class RunTask : IScheduleTask
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly IConfiguration config;
|
||||
private FileLog log;
|
||||
|
||||
public RunTask(IApplicationService service, IConfiguration config)
|
||||
public RunTask(IApplicationService service)
|
||||
{
|
||||
this.service = service;
|
||||
this.config = config;
|
||||
log = new FileLog(service.Configuration);
|
||||
}
|
||||
|
||||
public void Run(Dictionary<string, string> bodyDict)
|
||||
{
|
||||
File.AppendAllText("log.txt", "RunTask:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n");
|
||||
log.WriteToFile("RunTask");
|
||||
|
||||
try
|
||||
{
|
||||
new FileLog(config).WriteToFile("RunTask");
|
||||
IRepository<SecurityScheduleTaskQueueEntity> taskRepository = service.GetRepository<IRepository<SecurityScheduleTaskQueueEntity>>();
|
||||
|
||||
|
||||
SecurityScheduleTaskQueueEntity task = taskRepository.DetachedEntities.OrderBy(x => x.QueueId).FirstOrDefault();
|
||||
|
||||
if (task == null) return;
|
||||
|
||||
|
||||
IRepository<DmsFileEntity> repositoryDmsFile = service.GetRepository<IRepository<DmsFileEntity>>();
|
||||
DmsFileEntity dmsFile = repositoryDmsFile.DetachedEntities.Where(x => x.OrderKey == task.DocumentId).FirstOrDefault();
|
||||
|
||||
if (dmsFile == null) return;
|
||||
|
||||
RunMyProcess(task.TaskId, task.TaskParam);
|
||||
|
||||
dmsFile.TranscodeIndc = YesNoPolicy.YES;
|
||||
repositoryDmsFile.UpdateNow(dmsFile);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
File.AppendAllText("log.txt", "RunTask:" + ex.Message);
|
||||
throw;
|
||||
log.WriteToFile(ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行cmd指令(异步不等待,await要求等待返回,转码太耗时)
|
||||
/// </summary>
|
||||
/// <param name="parameters"></param>
|
||||
public void RunMyProcess(string exePath, string parameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
parameters = parameters.Replace("/app/data", "/vol1/1000/Docker/NET8/DEV/data");
|
||||
|
||||
log.WriteToFile(exePath + parameters);
|
||||
|
||||
if (string.IsNullOrEmpty(exePath)) return;
|
||||
// 获取异步任务
|
||||
var commandTask = Cli.Wrap(exePath)
|
||||
.WithArguments(parameters)
|
||||
.WithValidation(CommandResultValidation.None) // 关键:允许非0退出码而不抛异常,以便我们能拿到错误输出
|
||||
.ExecuteAsync();
|
||||
|
||||
// 阻塞当前线程,等待任务完成(因为你的外层是同步的 void 方法)
|
||||
var result = commandTask.Task.GetAwaiter().GetResult();
|
||||
|
||||
// 记录退出码和标准错误输出
|
||||
log.WriteToFile($"FFmpeg ExitCode: {result.ExitCode}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.WriteToFile(ex.Message);
|
||||
throw new ValidatedException(ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user