@namespace Oqtane.Modules.Admin.Jobs @inherits ModuleBase @inject IJobService JobService @inject IStringLocalizer Localizer @if (_jobs == null) {

@Localizer["Loading"]

} else {

      @Localizer["Name"] @Localizer["Status"] @Localizer["Frequency"] @Localizer["NextExecution"]  
@context.Name @DisplayStatus(context.IsEnabled, context.IsExecuting) @DisplayFrequency(context.Interval, context.Frequency) @context.NextExecution @if (context.IsStarted) { } else { }
} @code { private List _jobs; public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } } protected override async Task OnParametersSetAsync() { _jobs = await JobService.GetJobsAsync(); } private string DisplayStatus(bool isEnabled, bool isExecuting) { var status = string.Empty; if (!isEnabled) { status = Localizer["Disabled"]; } else { if (isExecuting) { status = Localizer["Executing"]; } else { status = Localizer["Idle"]; } } return status; } private string DisplayFrequency(int interval, string frequency) { var result = $"{Localizer["Every"]} {interval.ToString()} "; switch (frequency) { case "m": result += Localizer["Minute"]; break; case "H": result += Localizer["Hour"]; break; case "d": result += Localizer["Day"]; break; case "M": result += Localizer["Month"]; break; } if (interval > 1) { result += Localizer["s"]; } return result; } private async Task DeleteJob(Job job) { try { await JobService.DeleteJobAsync(job.JobId); await logger.LogInformation("Job Deleted {Job}", job); StateHasChanged(); } catch (Exception ex) { await logger.LogError(ex, "Error Deleting Job {Job} {Error}", job, ex.Message); AddModuleMessage(Localizer["Error.Job.Delete"], MessageType.Error); } } private async Task StartJob(int jobId) { await JobService.StartJobAsync(jobId); } private async Task StopJob(int jobId) { await JobService.StopJobAsync(jobId); } private async Task Refresh() { _jobs = await JobService.GetJobsAsync(); StateHasChanged(); } }