Can manually enqueue jobs

This commit is contained in:
Timothy Baldridge 2020-01-14 06:35:50 -07:00
parent 213df5bc0e
commit af9f0dbf89

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
@ -26,5 +27,15 @@ namespace Wabbajack.BuildServer.Controllers
.OrderByDescending(j => j.Priority)
.ToListAsync();
}
[HttpGet]
[Route("enqueue_job/{JobName}")]
public async Task<string> EnqueueJob(string JobName)
{
var jobtype = AJobPayload.NameToType[JobName];
var job = new Job{Priority = Job.JobPriority.High, Payload = (AJobPayload)jobtype.GetConstructor(new Type[0]).Invoke(new object?[0])};
await Db.Jobs.InsertOneAsync(job);
return job.Id;
}
}
}