add Job Tasks to enable the execution of adhoc asynchronous site-based workloads
This commit is contained in:
46
Oqtane.Client/Services/JobTaskService.cs
Normal file
46
Oqtane.Client/Services/JobTaskService.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Oqtane.Models;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
using Oqtane.Documentation;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Service to manage tasks (<see cref="JobTask"/>)
|
||||
/// </summary>
|
||||
public interface IJobTaskService
|
||||
{
|
||||
/// <summary>
|
||||
/// Return a specific task
|
||||
/// </summary>
|
||||
/// <param name="jobTaskId"></param>
|
||||
/// <returns></returns>
|
||||
Task<JobTask> GetJobTaskAsync(int jobTaskId);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new task
|
||||
/// </summary>
|
||||
/// <param name="jobTask"></param>
|
||||
/// <returns></returns>
|
||||
Task<JobTask> AddJobTaskAsync(JobTask jobTask);
|
||||
}
|
||||
|
||||
[PrivateApi("Don't show in the documentation, as everything should use the Interface")]
|
||||
public class JobTaskService : ServiceBase, IJobTaskService
|
||||
{
|
||||
public JobTaskService(HttpClient http, SiteState siteState) : base(http, siteState) { }
|
||||
|
||||
private string Apiurl => CreateApiUrl("JobTask");
|
||||
|
||||
public async Task<JobTask> GetJobTaskAsync(int jobTaskId)
|
||||
{
|
||||
return await GetJsonAsync<JobTask>($"{Apiurl}/{jobTaskId}");
|
||||
}
|
||||
|
||||
public async Task<JobTask> AddJobTaskAsync(JobTask jobTask)
|
||||
{
|
||||
return await PostJsonAsync<JobTask>(Apiurl, jobTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,15 +161,6 @@ namespace Oqtane.Services
|
||||
/// <returns></returns>
|
||||
Task<string> GetPasswordRequirementsAsync(int siteId);
|
||||
|
||||
/// <summary>
|
||||
/// Bulk import of users
|
||||
/// </summary>
|
||||
/// <param name="siteId">ID of a <see cref="Site"/></param>
|
||||
/// <param name="fileId">ID of a <see cref="File"/></param>
|
||||
/// <param name="notify">Indicates if new users should be notified by email</param>
|
||||
/// <returns></returns>
|
||||
Task<Dictionary<string, string>> ImportUsersAsync(int siteId, int fileId, bool notify);
|
||||
|
||||
/// <summary>
|
||||
/// Get passkeys for a user
|
||||
/// </summary>
|
||||
@@ -351,11 +342,6 @@ namespace Oqtane.Services
|
||||
return string.Format(passwordValidationCriteriaTemplate, minimumlength, uniquecharacters, digitRequirement, uppercaseRequirement, lowercaseRequirement, punctuationRequirement);
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, string>> ImportUsersAsync(int siteId, int fileId, bool notify)
|
||||
{
|
||||
return await PostJsonAsync<Dictionary<string, string>>($"{Apiurl}/import?siteid={siteId}&fileid={fileId}¬ify={notify}", null);
|
||||
}
|
||||
|
||||
public async Task<List<UserPasskey>> GetPasskeysAsync(int userId)
|
||||
{
|
||||
return await GetJsonAsync<List<UserPasskey>>($"{Apiurl}/passkey?id={userId}");
|
||||
|
||||
Reference in New Issue
Block a user