.NET version updates, add database complete email
This commit is contained in:
@@ -8,46 +8,48 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace PartSource.Automation.Jobs
|
||||
{
|
||||
public class ExecuteSsisPackages : IAutomationJob
|
||||
{
|
||||
private readonly FtpService _ftpService;
|
||||
private readonly SsisService _ssisService;
|
||||
private readonly ILogger<ExecuteSsisPackages> _logger;
|
||||
public class ExecuteSsisPackages : IAutomationJob
|
||||
{
|
||||
private readonly EmailService _emailService;
|
||||
private readonly FtpService _ftpService;
|
||||
private readonly SsisService _ssisService;
|
||||
private readonly ILogger<ExecuteSsisPackages> _logger;
|
||||
|
||||
// TODO: set from config
|
||||
private readonly string[] _ssisPackages = { "Parts Availability" };
|
||||
// TODO: set from config
|
||||
private readonly string[] _ssisPackages = { "Parts Price", "Parts Availability" };
|
||||
|
||||
public ExecuteSsisPackages(IConfiguration configuration, SsisService ssisService, ILogger<ExecuteSsisPackages> logger)
|
||||
{
|
||||
FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AzureConfiguration").Get<FtpConfiguration>();
|
||||
public ExecuteSsisPackages(EmailService emailService, FtpService ftpService, SsisService ssisService, ILogger<ExecuteSsisPackages> logger)
|
||||
{
|
||||
_ftpService = ftpService;
|
||||
_emailService = emailService;
|
||||
_ssisService = ssisService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
_ftpService = new FtpService(ftpConfiguration);
|
||||
_ssisService = ssisService;
|
||||
_logger = logger;
|
||||
}
|
||||
public async Task Run()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
foreach (string package in _ssisPackages)
|
||||
{
|
||||
try
|
||||
{
|
||||
_ftpService.Download($"{package}.txt");
|
||||
_ssisService.Execute($"{package}.dtsx");
|
||||
|
||||
public async Task Run()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
foreach (string package in _ssisPackages)
|
||||
{
|
||||
try
|
||||
{
|
||||
_ftpService.Download($"{package}.txt");
|
||||
_ssisService.Execute($"{package}.dtsx");
|
||||
_logger.LogInformation("Execution of SSIS package {package} completed successfully.", package);
|
||||
}
|
||||
|
||||
_logger.LogInformation($"Execution of SSIS package {package} completed successfully.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Execution of SSIS package {package} failed", package);
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"Execution of SSIS package {package} failed.", ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
_emailService.Send("Database Updates Complete", "Database updates to support pricing and availability have completed successfully.");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user