删除作业已不存在的任务
This commit is contained in:
parent
39fa220bba
commit
ae24ba9964
|
@ -4,6 +4,7 @@ using NewLife;
|
|||
using NewLife.Data;
|
||||
using NewLife.Threading;
|
||||
using XCode;
|
||||
using XCode.DataAccessLayer;
|
||||
|
||||
namespace AntJob.Data.Entity;
|
||||
|
||||
|
|
|
@ -150,14 +150,14 @@ public partial class JobTask : EntityBase<JobTask>
|
|||
var exp = new WhereExpression();
|
||||
|
||||
if (id > 0) exp &= _.ID == id;
|
||||
if (appid > 0) exp &= _.AppID == appid;
|
||||
if (jobid > 0) exp &= _.JobID == jobid;
|
||||
if (appid >= 0) exp &= _.AppID == appid;
|
||||
if (jobid >= 0) exp &= _.JobID == jobid;
|
||||
if (status >= JobStatus.就绪) exp &= _.Status == status;
|
||||
if (!client.IsNullOrEmpty()) exp &= _.Client == client;
|
||||
if (!key.IsNullOrEmpty()) exp &= _.Data.Contains(key) | _.Message.Contains(key) | _.Key == key;
|
||||
|
||||
exp &= _.DataTime.Between(dataStart, dataEnd);
|
||||
exp &= _.DataTime.Between(start, end);
|
||||
exp &= _.UpdateTime.Between(start, end);
|
||||
|
||||
return FindAll(exp, p);
|
||||
}
|
||||
|
@ -207,6 +207,10 @@ public partial class JobTask : EntityBase<JobTask>
|
|||
|
||||
//public static Int32 DeleteByAppId(Int32 appid) => Delete(_.AppID == appid);
|
||||
|
||||
/// <summary>删除作业已不存在的任务</summary>
|
||||
/// <returns></returns>
|
||||
public static Int32 DeleteNoJob() => Delete(_.JobID.NotIn(Entity.Job.FindSQLWithKey()));
|
||||
|
||||
/// <summary>转模型类</summary>
|
||||
/// <returns></returns>
|
||||
public TaskModel ToModel()
|
||||
|
|
|
@ -18,8 +18,9 @@ namespace AntJob.Data.Entity;
|
|||
[DataObject]
|
||||
[Description("作业任务。计算作业在执行过程中生成的任务实例,具有该次执行所需参数")]
|
||||
[BindIndex("IX_JobTask_JobID_DataTime", false, "JobID,DataTime")]
|
||||
[BindIndex("IX_JobTask_AppID_Client_Status", false, "AppID,Client,Status")]
|
||||
[BindIndex("IX_JobTask_JobID_CreateTime", false, "JobID,CreateTime")]
|
||||
[BindIndex("IX_JobTask_JobID_UpdateTime", false, "JobID,UpdateTime")]
|
||||
[BindIndex("IX_JobTask_AppID_Client_Status", false, "AppID,Client,Status")]
|
||||
[BindTable("JobTask", Description = "作业任务。计算作业在执行过程中生成的任务实例,具有该次执行所需参数", ConnName = "Ant", DbType = DatabaseType.None)]
|
||||
public partial class JobTask
|
||||
{
|
||||
|
|
|
@ -195,8 +195,9 @@
|
|||
</Columns>
|
||||
<Indexes>
|
||||
<Index Columns="JobID,DataTime" />
|
||||
<Index Columns="AppID,Client,Status" />
|
||||
<Index Columns="JobID,CreateTime" />
|
||||
<Index Columns="JobID,UpdateTime" />
|
||||
<Index Columns="AppID,Client,Status" />
|
||||
</Indexes>
|
||||
</Table>
|
||||
<Table Name="JobError" Description="作业错误。计算作业在执行过程中所发生的错误">
|
||||
|
|
|
@ -145,6 +145,9 @@ public class Worker : IHostedService
|
|||
p += list.Count;
|
||||
}
|
||||
|
||||
// 删除作业已不存在的任务
|
||||
rs += JobTask.DeleteNoJob();
|
||||
|
||||
if (rs > 0)
|
||||
{
|
||||
sw.Stop();
|
||||
|
|
Loading…
Reference in New Issue