08-12-2022

This commit is contained in:
Jonathan Jenne
2022-12-08 16:43:22 +01:00
parent 7b7147eeee
commit 0a25b0925c
43 changed files with 1740 additions and 378 deletions

View File

@@ -0,0 +1,67 @@
using DigitalData.Modules.Logging;
using ECM.JobRunner.Common.JobRunnerReference;
namespace ECM.JobRunner.Web.Data
{
public class ImportService
{
private readonly Logger logger;
private readonly IEDMIServiceChannel channel;
public ImportService(LoggingService Logging, WcfService Wcf)
{
logger = Logging.LogConfig.GetLogger();
channel = Wcf.Channel;
}
public async Task<List<ImportProfile>> GetProfiles()
{
var resp = await channel.GetJobConfigAsync();
if (resp == null) return new();
if (resp.OK == false) return new();
var profiles = resp.ProfileDefinitions.ImportProfiles.ToList();
return profiles;
}
public async Task<ImportProfile?> GetProfile(int pProfileId)
{
var resp = await channel.GetJobConfigAsync();
if (resp == null) return new();
if (resp.OK == false) return new();
var jobs = resp.JobDefinitions.ToList();
var profiles = resp.ProfileDefinitions.ImportProfiles.ToList();
return profiles.
Where(p => p.Id == pProfileId).
SingleOrDefault();
}
public async Task<bool> CreateProfile(ImportProfile profile) =>
await DoUpdateProfile(profile, UpdateProfileUpdateProfileRequest.UpdateProfileAction.Create);
public async Task<bool> UpdateProfile(ImportProfile profile) =>
await DoUpdateProfile(profile, UpdateProfileUpdateProfileRequest.UpdateProfileAction.Update);
public async Task<bool> DeleteProfile(ImportProfile profile) =>
await DoUpdateProfile(profile, UpdateProfileUpdateProfileRequest.UpdateProfileAction.Delete);
private async Task<bool> DoUpdateProfile(ImportProfile profile, UpdateProfileUpdateProfileRequest.UpdateProfileAction action)
{
var req = new UpdateProfileUpdateProfileRequest()
{
ImportProfile = profile,
Action = action
};
var resp = await channel.UpdateProfileAsync(req);
if (resp == null) return false;
if (resp.OK == false) return false;
return true;
}
}
}

View File

@@ -1,13 +1,12 @@
using DigitalData.Modules.Logging;
using ECM.JobRunner.Common.JobRunnerReference;
using System.Threading.Channels;
namespace ECM.JobRunner.Web.Data
{
public class JobService
{
private readonly Logger logger;
private readonly Common.JobRunnerReference.IEDMIServiceChannel channel;
private readonly IEDMIServiceChannel channel;
public JobService(LoggingService Logging, WcfService Wcf)
{
@@ -15,48 +14,46 @@ namespace ECM.JobRunner.Web.Data
channel = Wcf.Channel;
}
public async Task<List<Common.JobRunnerReference.JobDefinition>> GetJobs()
public async Task<List<JobDefinition>> GetJobs()
{
var resp = await channel.GetJobConfigAsync();
if (resp != null && resp.OK)
{
return resp.JobDefinitions.ToList();
}
else
{
return new();
}
if (resp == null) return new();
if (resp.OK == false) return new();
return resp.JobDefinitions.ToList();
}
public async Task<List<Common.JobRunnerReference.JobType>> GetJobTypes()
public async Task<List<ObjectType>> GetObjectTypes()
{
var resp = await channel.GetJobConfigAsync();
if (resp != null && resp.OK)
{
return resp.JobTypes.ToList();
}
else
{
return new();
}
if (resp == null) return new();
if (resp.OK == false) return new();
return resp.WindreamObjectTypes.ToList();
}
public async Task<Common.JobRunnerReference.JobDefinition?> GetJob(int pJobId)
public async Task<List<JobType>> GetJobTypes()
{
var resp = await channel.GetJobConfigAsync();
if (resp != null && resp.OK)
{
return resp.JobDefinitions.
if (resp == null) return new();
if (resp.OK == false) return new();
return resp.JobTypes.ToList();
}
public async Task<JobDefinition?> GetJob(int pJobId)
{
var resp = await channel.GetJobConfigAsync();
if (resp == null) return null;
if (resp.OK == false) return null;
return resp.JobDefinitions.
Where(j => j.Id == pJobId).
FirstOrDefault();
}
else
{
return null;
}
}
public async Task<bool> UpdateJob(JobDefinition job)
@@ -66,14 +63,10 @@ namespace ECM.JobRunner.Web.Data
Action = UpdateJobUpdateJobRequest.UpdateJobAction.Update
});
if (resp != null && resp.OK)
{
return true;
}
else
{
return false;
}
if (resp == null) return false;
if (resp.OK == false) return false;
return true;
}
public async Task<bool> CreateJob(JobDefinition job)