completed background job scheduler
This commit is contained in:
@ -42,7 +42,7 @@ namespace Oqtane.Repository
|
||||
ChangeTracker.DetectChanges();
|
||||
|
||||
string username = "";
|
||||
if (accessor.HttpContext.User.Identity.Name != null)
|
||||
if (accessor.HttpContext != null && accessor.HttpContext.User.Identity.Name != null)
|
||||
{
|
||||
username = accessor.HttpContext.User.Identity.Name;
|
||||
}
|
||||
|
@ -18,15 +18,15 @@ namespace Oqtane.Repository
|
||||
public virtual DbSet<Alias> Alias { get; set; }
|
||||
public virtual DbSet<Tenant> Tenant { get; set; }
|
||||
public virtual DbSet<ModuleDefinition> ModuleDefinition { get; set; }
|
||||
public virtual DbSet<Schedule> Schedule { get; set; }
|
||||
public virtual DbSet<ScheduleLog> ScheduleLog { get; set; }
|
||||
public virtual DbSet<Job> Job { get; set; }
|
||||
public virtual DbSet<JobLog> JobLog { get; set; }
|
||||
|
||||
public override int SaveChanges()
|
||||
{
|
||||
ChangeTracker.DetectChanges();
|
||||
|
||||
string username = "";
|
||||
if (accessor.HttpContext.User.Identity.Name != null)
|
||||
if (accessor.HttpContext != null && accessor.HttpContext.User.Identity.Name != null)
|
||||
{
|
||||
username = accessor.HttpContext.User.Identity.Name;
|
||||
}
|
||||
|
14
Oqtane.Server/Repository/Interfaces/IJobLogRepository.cs
Normal file
14
Oqtane.Server/Repository/Interfaces/IJobLogRepository.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public interface IJobLogRepository
|
||||
{
|
||||
IEnumerable<JobLog> GetJobLogs();
|
||||
JobLog AddJobLog(JobLog JobLog);
|
||||
JobLog UpdateJobLog(JobLog JobLog);
|
||||
JobLog GetJobLog(int JobLogId);
|
||||
void DeleteJobLog(int JobLogId);
|
||||
}
|
||||
}
|
14
Oqtane.Server/Repository/Interfaces/IJobRepository.cs
Normal file
14
Oqtane.Server/Repository/Interfaces/IJobRepository.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public interface IJobRepository
|
||||
{
|
||||
IEnumerable<Job> GetJobs();
|
||||
Job AddJob(Job Job);
|
||||
Job UpdateJob(Job Job);
|
||||
Job GetJob(int JobId);
|
||||
void DeleteJob(int JobId);
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public interface IScheduleLogRepository
|
||||
{
|
||||
IEnumerable<ScheduleLog> GetScheduleLogs();
|
||||
ScheduleLog AddScheduleLog(ScheduleLog ScheduleLog);
|
||||
ScheduleLog UpdateScheduleLog(ScheduleLog ScheduleLog);
|
||||
ScheduleLog GetScheduleLog(int ScheduleLogId);
|
||||
void DeleteScheduleLog(int ScheduleLogId);
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public interface IScheduleRepository
|
||||
{
|
||||
IEnumerable<Schedule> GetSchedules();
|
||||
Schedule AddSchedule(Schedule Schedule);
|
||||
Schedule UpdateSchedule(Schedule Schedule);
|
||||
Schedule GetSchedule(int ScheduleId);
|
||||
void DeleteSchedule(int ScheduleId);
|
||||
}
|
||||
}
|
51
Oqtane.Server/Repository/JobLogRepository.cs
Normal file
51
Oqtane.Server/Repository/JobLogRepository.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Oqtane.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public class JobLogRepository : IJobLogRepository
|
||||
{
|
||||
private MasterDBContext db;
|
||||
|
||||
public JobLogRepository(MasterDBContext context)
|
||||
{
|
||||
db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<JobLog> GetJobLogs()
|
||||
{
|
||||
return db.JobLog
|
||||
.Include(item => item.Job) // eager load jobs
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public JobLog AddJobLog(JobLog JobLog)
|
||||
{
|
||||
db.JobLog.Add(JobLog);
|
||||
db.SaveChanges();
|
||||
return JobLog;
|
||||
}
|
||||
|
||||
public JobLog UpdateJobLog(JobLog JobLog)
|
||||
{
|
||||
db.Entry(JobLog).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
return JobLog;
|
||||
}
|
||||
|
||||
public JobLog GetJobLog(int JobLogId)
|
||||
{
|
||||
return db.JobLog.Include(item => item.Job) // eager load job
|
||||
.SingleOrDefault(item => item.JobLogId == JobLogId);
|
||||
}
|
||||
|
||||
public void DeleteJobLog(int JobLogId)
|
||||
{
|
||||
JobLog Joblog = db.JobLog.Find(JobLogId);
|
||||
db.JobLog.Remove(Joblog);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
49
Oqtane.Server/Repository/JobRepository.cs
Normal file
49
Oqtane.Server/Repository/JobRepository.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Oqtane.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public class JobRepository : IJobRepository
|
||||
{
|
||||
private MasterDBContext db;
|
||||
|
||||
public JobRepository(MasterDBContext context)
|
||||
{
|
||||
db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<Job> GetJobs()
|
||||
{
|
||||
return db.Job.ToList();
|
||||
}
|
||||
|
||||
public Job AddJob(Job Job)
|
||||
{
|
||||
db.Job.Add(Job);
|
||||
db.SaveChanges();
|
||||
return Job;
|
||||
}
|
||||
|
||||
public Job UpdateJob(Job Job)
|
||||
{
|
||||
db.Entry(Job).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
return Job;
|
||||
}
|
||||
|
||||
public Job GetJob(int JobId)
|
||||
{
|
||||
return db.Job.Find(JobId);
|
||||
}
|
||||
|
||||
public void DeleteJob(int JobId)
|
||||
{
|
||||
Job Job = db.Job.Find(JobId);
|
||||
db.Job.Remove(Job);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Oqtane.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public class ScheduleLogRepository : IScheduleLogRepository
|
||||
{
|
||||
private MasterDBContext db;
|
||||
|
||||
public ScheduleLogRepository(MasterDBContext context)
|
||||
{
|
||||
db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<ScheduleLog> GetScheduleLogs()
|
||||
{
|
||||
return db.ScheduleLog.ToList();
|
||||
}
|
||||
|
||||
public ScheduleLog AddScheduleLog(ScheduleLog ScheduleLog)
|
||||
{
|
||||
db.ScheduleLog.Add(ScheduleLog);
|
||||
db.SaveChanges();
|
||||
return ScheduleLog;
|
||||
}
|
||||
|
||||
public ScheduleLog UpdateScheduleLog(ScheduleLog ScheduleLog)
|
||||
{
|
||||
db.Entry(ScheduleLog).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
return ScheduleLog;
|
||||
}
|
||||
|
||||
public ScheduleLog GetScheduleLog(int ScheduleLogId)
|
||||
{
|
||||
return db.ScheduleLog.Find(ScheduleLogId);
|
||||
}
|
||||
|
||||
public void DeleteScheduleLog(int ScheduleLogId)
|
||||
{
|
||||
ScheduleLog schedulelog = db.ScheduleLog.Find(ScheduleLogId);
|
||||
db.ScheduleLog.Remove(schedulelog);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Oqtane.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public class ScheduleRepository : IScheduleRepository
|
||||
{
|
||||
private MasterDBContext db;
|
||||
|
||||
public ScheduleRepository(MasterDBContext context)
|
||||
{
|
||||
db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<Schedule> GetSchedules()
|
||||
{
|
||||
return db.Schedule.ToList();
|
||||
}
|
||||
|
||||
public Schedule AddSchedule(Schedule Schedule)
|
||||
{
|
||||
db.Schedule.Add(Schedule);
|
||||
db.SaveChanges();
|
||||
return Schedule;
|
||||
}
|
||||
|
||||
public Schedule UpdateSchedule(Schedule Schedule)
|
||||
{
|
||||
db.Entry(Schedule).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
return Schedule;
|
||||
}
|
||||
|
||||
public Schedule GetSchedule(int ScheduleId)
|
||||
{
|
||||
return db.Schedule.Find(ScheduleId);
|
||||
}
|
||||
|
||||
public void DeleteSchedule(int ScheduleId)
|
||||
{
|
||||
Schedule schedule = db.Schedule.Find(ScheduleId);
|
||||
db.Schedule.Remove(schedule);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
@ -92,6 +92,9 @@ namespace Oqtane.Repository
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Theme Management", Parent = "Admin", Path = "admin/themes", Icon = "brush", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Themes, Oqtane.Client", Title = "Theme Management", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Scheduled Jobs", Parent = "Admin", Path = "admin/jobs", Icon = "timer", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Jobs, Oqtane.Client", Title = "Scheduled Jobs", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Upgrade Service", Parent = "Admin", Path = "admin/upgrade", Icon = "aperture", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Upgrade, Oqtane.Client", Title = "Upgrade Service", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
|
@ -3,6 +3,7 @@ using System.Linq;
|
||||
using Oqtane.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
@ -12,12 +13,14 @@ namespace Oqtane.Repository
|
||||
private readonly string aliasname;
|
||||
private readonly IAliasRepository Aliases;
|
||||
private readonly ITenantRepository Tenants;
|
||||
private readonly SiteState sitestate;
|
||||
|
||||
public TenantResolver(MasterDBContext context, IHttpContextAccessor accessor, IAliasRepository Aliases, ITenantRepository Tenants)
|
||||
public TenantResolver(MasterDBContext context, IHttpContextAccessor accessor, IAliasRepository Aliases, ITenantRepository Tenants, SiteState sitestate)
|
||||
{
|
||||
db = context;
|
||||
this.Aliases = Aliases;
|
||||
this.Tenants = Tenants;
|
||||
this.sitestate = sitestate;
|
||||
aliasname = "";
|
||||
|
||||
// get alias based on request context
|
||||
@ -35,6 +38,13 @@ namespace Oqtane.Repository
|
||||
aliasname = aliasname.Substring(0, aliasname.Length - 1);
|
||||
}
|
||||
}
|
||||
else // background processes can pass in an alias using the SiteState service
|
||||
{
|
||||
if (sitestate != null)
|
||||
{
|
||||
aliasname = sitestate.Alias.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Alias GetAlias()
|
||||
|
Reference in New Issue
Block a user