Initial commit
This commit is contained in:
49
PartSource.Automation/Factories/JobFactory.cs
Normal file
49
PartSource.Automation/Factories/JobFactory.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PartSource.Automation.Jobs;
|
||||
using PartSource.Automation.Jobs.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PartSource.Automation.Factories
|
||||
{
|
||||
public class JobFactory
|
||||
{
|
||||
public IServiceProvider _serviceProvider;
|
||||
|
||||
public JobFactory(IServiceProvider serviceProvider)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public IAutomationJob Build(string jobName)
|
||||
{
|
||||
switch (jobName)
|
||||
{
|
||||
case nameof(AddProducts):
|
||||
return _serviceProvider.GetService<AddProducts>();
|
||||
|
||||
case nameof(DeleteProducts):
|
||||
return _serviceProvider.GetService<DeleteProducts>();
|
||||
|
||||
case nameof(TestJob):
|
||||
return new TestJob();
|
||||
|
||||
case nameof(UpdateFitment):
|
||||
return _serviceProvider.GetService<UpdateFitment>();
|
||||
|
||||
case nameof(UpdatePricing):
|
||||
return _serviceProvider.GetService<UpdatePricing>();
|
||||
|
||||
case nameof(ExecuteSsisPackages):
|
||||
return _serviceProvider.GetService<ExecuteSsisPackages>();
|
||||
|
||||
default:
|
||||
throw new Exception($"The job {jobName} could not be found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user