completed background job scheduler
This commit is contained in:
137
Oqtane.Client/Modules/Admin/Jobs/Add.razor
Normal file
137
Oqtane.Client/Modules/Admin/Jobs/Add.razor
Normal file
@ -0,0 +1,137 @@
|
||||
@namespace Oqtane.Modules.Admin.Jobs
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IJobService JobService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Type: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@jobtype" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Enabled? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isenabled">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Runs Every: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@interval" />
|
||||
<select class="form-control" @bind="@frequency">
|
||||
<option value="m">Minute(s)</option>
|
||||
<option value="H">Hour(s)</option>
|
||||
<option value="d">Day(s)</option>
|
||||
<option value="M">Month(s)</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Starting: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@startdate" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Ending: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@enddate" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Retention Log (Items): </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@retentionhistory" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="SaveJob">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
string name = "";
|
||||
string jobtype = "";
|
||||
string isenabled = "True";
|
||||
string interval = "";
|
||||
string frequency = "";
|
||||
string startdate = "";
|
||||
string enddate = "";
|
||||
string retentionhistory = "10";
|
||||
|
||||
private async Task SaveJob()
|
||||
{
|
||||
if (name != "" && !string.IsNullOrEmpty(jobtype) && frequency != "" && interval != "" && retentionhistory != "")
|
||||
{
|
||||
Job job = new Job();
|
||||
job.Name = name;
|
||||
job.JobType = jobtype;
|
||||
job.IsEnabled = Boolean.Parse(isenabled);
|
||||
job.Frequency = frequency;
|
||||
job.Interval = int.Parse(interval);
|
||||
if (startdate == "")
|
||||
{
|
||||
job.StartDate = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
job.StartDate = DateTime.Parse(startdate);
|
||||
}
|
||||
if (enddate == "")
|
||||
{
|
||||
job.EndDate = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
job.EndDate = DateTime.Parse(enddate);
|
||||
}
|
||||
job.RetentionHistory = int.Parse(retentionhistory);
|
||||
job.IsStarted = false;
|
||||
job.IsExecuting = false;
|
||||
job.NextExecution = null;
|
||||
|
||||
try
|
||||
{
|
||||
job = await JobService.AddJobAsync(job);
|
||||
await logger.LogInformation("Job Added {Job}", job);
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Adding Job {Job} {Error}", job, ex.Message);
|
||||
AddModuleMessage("Error Adding Job", MessageType.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddModuleMessage("You Must Provide The Job Name, Type, Frequency, and Retention", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
160
Oqtane.Client/Modules/Admin/Jobs/Edit.razor
Normal file
160
Oqtane.Client/Modules/Admin/Jobs/Edit.razor
Normal file
@ -0,0 +1,160 @@
|
||||
@namespace Oqtane.Modules.Admin.Jobs
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IJobService JobService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Type: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@jobtype" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Enabled? </label>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" @bind="@isenabled">
|
||||
<option value="True">Yes</option>
|
||||
<option value="False">No</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Runs Every: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@interval" />
|
||||
<select class="form-control" @bind="@frequency">
|
||||
<option value="m">Minute(s)</option>
|
||||
<option value="H">Hour(s)</option>
|
||||
<option value="d">Day(s)</option>
|
||||
<option value="M">Month(s)</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Starting: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@startdate" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Ending: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@enddate" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Retention Log (Items): </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@retentionhistory" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="SaveJob">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
int jobid;
|
||||
string name = "";
|
||||
string jobtype = "";
|
||||
string isenabled = "True";
|
||||
string interval = "";
|
||||
string frequency = "";
|
||||
string startdate = "";
|
||||
string enddate = "";
|
||||
string retentionhistory = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
jobid = Int32.Parse(PageState.QueryString["id"]);
|
||||
Job job = await JobService.GetJobAsync(jobid);
|
||||
if (job != null)
|
||||
{
|
||||
name = job.Name;
|
||||
jobtype = job.JobType;
|
||||
isenabled = job.IsEnabled.ToString();
|
||||
interval = job.Interval.ToString();
|
||||
frequency = job.Frequency;
|
||||
startdate = (job.StartDate != null) ? job.StartDate.ToString() : "";
|
||||
enddate = (job.EndDate != null) ? job.EndDate.ToString() : "";
|
||||
retentionhistory = job.RetentionHistory.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading Job {JobId} {Error}", jobid, ex.Message);
|
||||
AddModuleMessage("Error Loading Job", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveJob()
|
||||
{
|
||||
if (name != "" && !string.IsNullOrEmpty(jobtype) && frequency != "" && interval != "" && retentionhistory != "")
|
||||
{
|
||||
Job job = await JobService.GetJobAsync(jobid);
|
||||
job.Name = name;
|
||||
job.JobType = jobtype;
|
||||
job.IsEnabled = Boolean.Parse(isenabled);
|
||||
job.Frequency = frequency;
|
||||
job.Interval = int.Parse(interval);
|
||||
if (startdate == "")
|
||||
{
|
||||
job.StartDate = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
job.StartDate = DateTime.Parse(startdate);
|
||||
}
|
||||
if (enddate == "")
|
||||
{
|
||||
job.EndDate = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
job.EndDate = DateTime.Parse(enddate);
|
||||
}
|
||||
job.RetentionHistory = int.Parse(retentionhistory);
|
||||
|
||||
try
|
||||
{
|
||||
job = await JobService.UpdateJobAsync(job);
|
||||
await logger.LogInformation("Job Updated {Job}", job);
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Udate Job {Job} {Error}", job, ex.Message);
|
||||
AddModuleMessage("Error Updating Job", MessageType.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddModuleMessage("You Must Provide The Job Name, Type, Frequency, and Retention", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
137
Oqtane.Client/Modules/Admin/Jobs/Index.razor
Normal file
137
Oqtane.Client/Modules/Admin/Jobs/Index.razor
Normal file
@ -0,0 +1,137 @@
|
||||
@namespace Oqtane.Modules.Admin.Jobs
|
||||
@inherits ModuleBase
|
||||
@inject IJobService JobService
|
||||
|
||||
@if (Jobs == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ActionLink Action="Add" Text="Add Job" />
|
||||
<ActionLink Action="Log" Class="btn btn-secondary" Text="View Logs" />
|
||||
<button type="button" class="btn btn-secondary" @onclick="(async () => await Refresh())">Refresh</button>
|
||||
<br /><br />
|
||||
|
||||
<Pager Items="@Jobs">
|
||||
<Header>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th>Name</th>
|
||||
<th>Status</th>
|
||||
<th>Frequency</th>
|
||||
<th>Next Execution</th>
|
||||
<th> </th>
|
||||
</Header>
|
||||
<Row>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.JobId.ToString())" /></td>
|
||||
<td><ActionDialog Header="Delete Job" Message="@("Are You Sure You Wish To Delete This Job?")" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteJob(context))" /></td>
|
||||
<td><ActionLink Action="Log" Class="btn btn-secondary" Parameters="@($"id=" + context.JobId.ToString())" /></td>
|
||||
<td>@context.Name</td>
|
||||
<td>@DisplayStatus(context.IsEnabled, context.IsExecuting)</td>
|
||||
<td>@DisplayFrequency(context.Interval, context.Frequency)</td>
|
||||
<td>@context.NextExecution</td>
|
||||
<td>
|
||||
@if (context.IsStarted)
|
||||
{
|
||||
<button type="button" class="btn btn-danger" @onclick="(async () => await StopJob(context.JobId))">Stop</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="button" class="btn btn-success" @onclick="(async () => await StartJob(context.JobId))">Start</button>
|
||||
}
|
||||
</td>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
List<Job> Jobs;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
Jobs = await JobService.GetJobsAsync();
|
||||
}
|
||||
|
||||
private string DisplayStatus(bool IsEnabled, bool IsExecuting)
|
||||
{
|
||||
string status = "";
|
||||
if (!IsEnabled)
|
||||
{
|
||||
status = "Disabled";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsExecuting)
|
||||
{
|
||||
status = "Executing";
|
||||
}
|
||||
else
|
||||
{
|
||||
status = "Idle";
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
private string DisplayFrequency(int Interval, string Frequency)
|
||||
{
|
||||
string frequency = "Every " + Interval.ToString() + " ";
|
||||
switch (Frequency)
|
||||
{
|
||||
case "m":
|
||||
frequency += "Minute";
|
||||
break;
|
||||
case "H":
|
||||
frequency += "Hour";
|
||||
break;
|
||||
case "d":
|
||||
frequency += "Day";
|
||||
break;
|
||||
case "M":
|
||||
frequency += "Month";
|
||||
break;
|
||||
}
|
||||
if (Interval > 1)
|
||||
{
|
||||
frequency += "s";
|
||||
}
|
||||
return frequency;
|
||||
}
|
||||
|
||||
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("Error Deleting Job", 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();
|
||||
}
|
||||
}
|
64
Oqtane.Client/Modules/Admin/Jobs/Log.razor
Normal file
64
Oqtane.Client/Modules/Admin/Jobs/Log.razor
Normal file
@ -0,0 +1,64 @@
|
||||
@namespace Oqtane.Modules.Admin.Jobs
|
||||
@inherits ModuleBase
|
||||
@inject IJobLogService JobLogService
|
||||
|
||||
@if (JobLogs == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Pager Items="@JobLogs">
|
||||
<Header>
|
||||
<th>Name</th>
|
||||
<th>Status</th>
|
||||
<th>Started</th>
|
||||
<th>Finished</th>
|
||||
<th>Notes</th>
|
||||
</Header>
|
||||
<Row>
|
||||
<td>@context.Job.Name</td>
|
||||
<td>@DisplayStatus(context.Job.IsExecuting, context.Succeeded)</td>
|
||||
<td>@context.StartDate</td>
|
||||
<td>@context.FinishDate</td>
|
||||
<td><ActionDialog Header="Job Notes" Message="@context.Notes" Text="View" Security="SecurityAccessLevel.Host" /></td>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
List<JobLog> JobLogs;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
JobLogs = await JobLogService.GetJobLogsAsync();
|
||||
if (PageState.QueryString.ContainsKey("id"))
|
||||
{
|
||||
JobLogs = JobLogs.Where(item => item.JobId == Int32.Parse(PageState.QueryString["id"])).ToList();
|
||||
}
|
||||
JobLogs = JobLogs.OrderByDescending(item => item.JobLogId).ToList();
|
||||
}
|
||||
|
||||
private string DisplayStatus(bool IsExecuting, bool? Succeeded)
|
||||
{
|
||||
string status = "";
|
||||
if (IsExecuting)
|
||||
{
|
||||
status = "Executing";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Succeeded.Value)
|
||||
{
|
||||
status = "Succeeded";
|
||||
}
|
||||
else
|
||||
{
|
||||
status = "Failed";
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
}
|
@ -56,14 +56,15 @@
|
||||
|
||||
private async Task SaveRole()
|
||||
{
|
||||
Role role = new Role();
|
||||
role.SiteId = PageState.Page.SiteId;
|
||||
role.Name = name;
|
||||
role.Description = description;
|
||||
role.IsAutoAssigned = (isautoassigned == null ? false : Boolean.Parse(isautoassigned));
|
||||
role.IsSystem = (issystem == null ? false : Boolean.Parse(issystem));
|
||||
|
||||
try
|
||||
{
|
||||
Role role = new Role();
|
||||
role.SiteId = PageState.Page.SiteId;
|
||||
role.Name = name;
|
||||
role.Description = description;
|
||||
role.IsAutoAssigned = (isautoassigned == null ? false : Boolean.Parse(isautoassigned));
|
||||
role.IsSystem = (issystem == null ? false : Boolean.Parse(issystem));
|
||||
role = await RoleService.AddRoleAsync(role);
|
||||
await logger.LogInformation("Role Added {Role}", role);
|
||||
|
||||
@ -71,8 +72,8 @@
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Adding Role", ex.Message);
|
||||
AddModuleMessage(ex.Message, MessageType.Error);
|
||||
await logger.LogError(ex, "Error Adding Role {Role} {Error}", role, ex.Message);
|
||||
AddModuleMessage("Error Adding Role", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,20 +78,21 @@
|
||||
|
||||
private async Task SaveRole()
|
||||
{
|
||||
Role role = await RoleService.GetRoleAsync(roleid);
|
||||
role.Name = name;
|
||||
role.Description = description;
|
||||
role.IsAutoAssigned = (isautoassigned == null ? false : Boolean.Parse(isautoassigned));
|
||||
role.IsSystem = (issystem == null ? false : Boolean.Parse(issystem));
|
||||
|
||||
try
|
||||
{
|
||||
Role role = await RoleService.GetRoleAsync(roleid);
|
||||
role.Name = name;
|
||||
role.Description = description;
|
||||
role.IsAutoAssigned = (isautoassigned == null ? false : Boolean.Parse(isautoassigned));
|
||||
role.IsSystem = (issystem == null ? false : Boolean.Parse(issystem));
|
||||
role = await RoleService.UpdateRoleAsync(role);
|
||||
await logger.LogInformation("Role Saved {Role}", role);
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Saving Role {RoleId} {Error}", roleid, ex.Message);
|
||||
await logger.LogError(ex, "Error Saving Role {Role} {Error}", role, ex.Message);
|
||||
AddModuleMessage("Error Saving Role", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,10 @@
|
||||
<p>@Message</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="@Class" @onclick="Confirm">@Action</button>
|
||||
@if (!string.IsNullOrEmpty(Action))
|
||||
{
|
||||
<button type="button" class="@Class" @onclick="Confirm">@Action</button>
|
||||
}
|
||||
<button type="button" class="btn btn-secondary" @onclick="DisplayModal">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -36,29 +39,25 @@
|
||||
public string Message { get; set; } // required
|
||||
|
||||
[Parameter]
|
||||
public string Action { get; set; } // defaults to Ok if not specified
|
||||
public string Text { get; set; } // optional - defaults to Action if not specified
|
||||
|
||||
[Parameter]
|
||||
public string Action { get; set; } // optional
|
||||
|
||||
[Parameter]
|
||||
public SecurityAccessLevel? Security { get; set; } // optional - can be used to explicitly specify SecurityAccessLevel
|
||||
|
||||
[Parameter]
|
||||
public string Text { get; set; } // optional - defaults to Action if not specified
|
||||
|
||||
[Parameter]
|
||||
public string Class { get; set; } // optional
|
||||
|
||||
[Parameter]
|
||||
public Action OnClick { get; set; } // required - executes a method in the calling component
|
||||
public Action OnClick { get; set; } // required if an Action is specified - executes a method in the calling component
|
||||
|
||||
bool visible = false;
|
||||
bool authorized = false;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Action))
|
||||
{
|
||||
Action = "Ok";
|
||||
}
|
||||
if (string.IsNullOrEmpty(Text))
|
||||
{
|
||||
Text = Action;
|
||||
|
19
Oqtane.Client/Services/Interfaces/IJobLogService.cs
Normal file
19
Oqtane.Client/Services/Interfaces/IJobLogService.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface IJobLogService
|
||||
{
|
||||
Task<List<JobLog>> GetJobLogsAsync();
|
||||
|
||||
Task<JobLog> GetJobLogAsync(int JobLogId);
|
||||
|
||||
Task<JobLog> AddJobLogAsync(JobLog JobLog);
|
||||
|
||||
Task<JobLog> UpdateJobLogAsync(JobLog JobLog);
|
||||
|
||||
Task DeleteJobLogAsync(int JobLogId);
|
||||
}
|
||||
}
|
23
Oqtane.Client/Services/Interfaces/IJobService.cs
Normal file
23
Oqtane.Client/Services/Interfaces/IJobService.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface IJobService
|
||||
{
|
||||
Task<List<Job>> GetJobsAsync();
|
||||
|
||||
Task<Job> GetJobAsync(int JobId);
|
||||
|
||||
Task<Job> AddJobAsync(Job Job);
|
||||
|
||||
Task<Job> UpdateJobAsync(Job Job);
|
||||
|
||||
Task DeleteJobAsync(int JobId);
|
||||
|
||||
Task StartJobAsync(int JobId);
|
||||
|
||||
Task StopJobAsync(int JobId);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface IScheduleLogService
|
||||
{
|
||||
Task<List<ScheduleLog>> GetScheduleLogsAsync();
|
||||
|
||||
Task<ScheduleLog> GetScheduleLogAsync(int ScheduleLogId);
|
||||
|
||||
Task<ScheduleLog> AddScheduleLogAsync(ScheduleLog ScheduleLog);
|
||||
|
||||
Task<ScheduleLog> UpdateScheduleLogAsync(ScheduleLog ScheduleLog);
|
||||
|
||||
Task DeleteScheduleLogAsync(int ScheduleLogId);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public interface IScheduleService
|
||||
{
|
||||
Task<List<Schedule>> GetSchedulesAsync();
|
||||
|
||||
Task<Schedule> GetScheduleAsync(int ScheduleId);
|
||||
|
||||
Task<Schedule> AddScheduleAsync(Schedule Schedule);
|
||||
|
||||
Task<Schedule> UpdateScheduleAsync(Schedule Schedule);
|
||||
|
||||
Task DeleteScheduleAsync(int ScheduleId);
|
||||
}
|
||||
}
|
54
Oqtane.Client/Services/JobLogService.cs
Normal file
54
Oqtane.Client/Services/JobLogService.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using Oqtane.Models;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public class JobLogService : ServiceBase, IJobLogService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
|
||||
public JobLogService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "JobLog"); }
|
||||
}
|
||||
|
||||
public async Task<List<JobLog>> GetJobLogsAsync()
|
||||
{
|
||||
List<JobLog> Joblogs = await http.GetJsonAsync<List<JobLog>>(apiurl);
|
||||
return Joblogs.OrderBy(item => item.StartDate).ToList();
|
||||
}
|
||||
|
||||
public async Task<JobLog> GetJobLogAsync(int JobLogId)
|
||||
{
|
||||
return await http.GetJsonAsync<JobLog>(apiurl + "/" + JobLogId.ToString());
|
||||
}
|
||||
|
||||
public async Task<JobLog> AddJobLogAsync(JobLog Joblog)
|
||||
{
|
||||
return await http.PostJsonAsync<JobLog>(apiurl, Joblog);
|
||||
}
|
||||
|
||||
public async Task<JobLog> UpdateJobLogAsync(JobLog Joblog)
|
||||
{
|
||||
return await http.PutJsonAsync<JobLog>(apiurl + "/" + Joblog.JobLogId.ToString(), Joblog);
|
||||
}
|
||||
public async Task DeleteJobLogAsync(int JobLogId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + JobLogId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
64
Oqtane.Client/Services/JobService.cs
Normal file
64
Oqtane.Client/Services/JobService.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using Oqtane.Models;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public class JobService : ServiceBase, IJobService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
|
||||
public JobService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Job"); }
|
||||
}
|
||||
|
||||
public async Task<List<Job>> GetJobsAsync()
|
||||
{
|
||||
List<Job> Jobs = await http.GetJsonAsync<List<Job>>(apiurl);
|
||||
return Jobs.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Job> GetJobAsync(int JobId)
|
||||
{
|
||||
return await http.GetJsonAsync<Job>(apiurl + "/" + JobId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Job> AddJobAsync(Job Job)
|
||||
{
|
||||
return await http.PostJsonAsync<Job>(apiurl, Job);
|
||||
}
|
||||
|
||||
public async Task<Job> UpdateJobAsync(Job Job)
|
||||
{
|
||||
return await http.PutJsonAsync<Job>(apiurl + "/" + Job.JobId.ToString(), Job);
|
||||
}
|
||||
public async Task DeleteJobAsync(int JobId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + JobId.ToString());
|
||||
}
|
||||
|
||||
public async Task StartJobAsync(int JobId)
|
||||
{
|
||||
await http.GetAsync(apiurl + "/start/" + JobId.ToString());
|
||||
}
|
||||
|
||||
public async Task StopJobAsync(int JobId)
|
||||
{
|
||||
await http.GetAsync(apiurl + "/stop/" + JobId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
using Oqtane.Models;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public class ScheduleLogService : ServiceBase, IScheduleLogService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
|
||||
public ScheduleLogService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "ScheduleLog"); }
|
||||
}
|
||||
|
||||
public async Task<List<ScheduleLog>> GetScheduleLogsAsync()
|
||||
{
|
||||
List<ScheduleLog> schedulelogs = await http.GetJsonAsync<List<ScheduleLog>>(apiurl);
|
||||
return schedulelogs.OrderBy(item => item.StartDate).ToList();
|
||||
}
|
||||
|
||||
public async Task<ScheduleLog> GetScheduleLogAsync(int ScheduleLogId)
|
||||
{
|
||||
return await http.GetJsonAsync<ScheduleLog>(apiurl + "/" + ScheduleLogId.ToString());
|
||||
}
|
||||
|
||||
public async Task<ScheduleLog> AddScheduleLogAsync(ScheduleLog schedulelog)
|
||||
{
|
||||
return await http.PostJsonAsync<ScheduleLog>(apiurl, schedulelog);
|
||||
}
|
||||
|
||||
public async Task<ScheduleLog> UpdateScheduleLogAsync(ScheduleLog schedulelog)
|
||||
{
|
||||
return await http.PutJsonAsync<ScheduleLog>(apiurl + "/" + schedulelog.ScheduleLogId.ToString(), schedulelog);
|
||||
}
|
||||
public async Task DeleteScheduleLogAsync(int ScheduleLogId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + ScheduleLogId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
using Oqtane.Models;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
public class ScheduleService : ServiceBase, IScheduleService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
|
||||
public ScheduleService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Schedule"); }
|
||||
}
|
||||
|
||||
public async Task<List<Schedule>> GetSchedulesAsync()
|
||||
{
|
||||
List<Schedule> schedules = await http.GetJsonAsync<List<Schedule>>(apiurl);
|
||||
return schedules.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Schedule> GetScheduleAsync(int ScheduleId)
|
||||
{
|
||||
return await http.GetJsonAsync<Schedule>(apiurl + "/" + ScheduleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Schedule> AddScheduleAsync(Schedule schedule)
|
||||
{
|
||||
return await http.PostJsonAsync<Schedule>(apiurl, schedule);
|
||||
}
|
||||
|
||||
public async Task<Schedule> UpdateScheduleAsync(Schedule schedule)
|
||||
{
|
||||
return await http.PutJsonAsync<Schedule>(apiurl + "/" + schedule.ScheduleId.ToString(), schedule);
|
||||
}
|
||||
public async Task DeleteScheduleAsync(int ScheduleId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + ScheduleId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
@ -54,8 +54,8 @@ namespace Oqtane.Client
|
||||
services.AddScoped<IFileService, FileService>();
|
||||
services.AddScoped<IPackageService, PackageService>();
|
||||
services.AddScoped<ILogService, LogService>();
|
||||
services.AddScoped<IScheduleService, ScheduleService>();
|
||||
services.AddScoped<IScheduleLogService, ScheduleLogService>();
|
||||
services.AddScoped<IJobService, JobService>();
|
||||
services.AddScoped<IJobLogService, JobLogService>();
|
||||
|
||||
// dynamically register module contexts and repository services
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
|
Reference in New Issue
Block a user