fix:网络任务请求方法没存储到db

This commit is contained in:
不做码农 2022-12-06 18:15:35 +08:00
parent 5d1e503cf9
commit b6c47c3e01
2 changed files with 18 additions and 17 deletions

View File

@ -53,7 +53,7 @@ namespace ZR.Admin.WebApi.Controllers
m.AssemblyName.Contains(parm.QueryText));
predicate.AndIF(parm.TaskType != null, m => m.TaskType == parm.TaskType);
var response = _tasksQzService.GetPages(predicate.ToExpression(), pager, f => f.IsStart, OrderByType.Desc);
var response = _tasksQzService.GetPages(predicate.ToExpression(), pager);
return SUCCESS(response, TIME_FORMAT_FULL);
}
@ -99,11 +99,6 @@ namespace ZR.Admin.WebApi.Controllers
{
throw new CustomException($"sql语句不能为空");
}
if (parm.SqlText.IfNotEmpty() && parm.TaskType == 3)
{
parm.AssemblyName = "ZR.Tasks";
parm.ClassName = "TaskScheduler.Job_SqlExecute";
}
if (parm.TaskType == 1 && (parm.AssemblyName.IsEmpty() || parm.ClassName.IsEmpty()))
{
throw new CustomException($"程序集或者类名不能为空");
@ -143,16 +138,7 @@ namespace ZR.Admin.WebApi.Controllers
{
throw new CustomException($"api地址不能为空");
}
if (parm.ApiUrl.IfNotEmpty() && parm.TaskType == 2)
{
parm.AssemblyName = "ZR.Tasks";
parm.ClassName = "TaskScheduler.Job_HttpRequest";
}
if (parm.SqlText.IfNotEmpty() && parm.TaskType == 3)
{
parm.AssemblyName = "ZR.Tasks";
parm.ClassName = "TaskScheduler.Job_SqlExecute";
}
if (tasksQz.IsStart)
{
throw new CustomException($"该任务正在运行中,请先停止在更新");

View File

@ -21,12 +21,24 @@ namespace ZR.Service.System
{
parm.IsStart = false;
SetAssembleName(parm);
return Add(parm);
}
private void SetAssembleName(SysTasks parm)
{
if (parm.ApiUrl.IfNotEmpty() && parm.TaskType == 2)
{
parm.AssemblyName = "ZR.Tasks";
parm.ClassName = "TaskScheduler.Job_HttpRequest";
}
return Add(parm);
if (parm.SqlText.IfNotEmpty() && parm.TaskType == 3)
{
parm.AssemblyName = "ZR.Tasks";
parm.ClassName = "TaskScheduler.Job_SqlExecute";
}
}
/// <summary>
@ -36,6 +48,8 @@ namespace ZR.Service.System
/// <returns></returns>
public int UpdateTasks(SysTasks parm)
{
SetAssembleName(parm);
return Update(f => f.ID == parm.ID, f => new SysTasks
{
ID = parm.ID,
@ -54,6 +68,7 @@ namespace ZR.Service.System
TaskType = parm.TaskType,
ApiUrl = parm.ApiUrl,
SqlText = parm.SqlText,
RequestMethod = parm.RequestMethod,
});
}
}