Initial commit
This commit is contained in:
53
PartSource.Automation/Jobs/ExecuteSsisPackages.cs
Normal file
53
PartSource.Automation/Jobs/ExecuteSsisPackages.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using PartSource.Automation.Jobs.Interfaces;
|
||||
using PartSource.Automation.Models;
|
||||
using PartSource.Automation.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PartSource.Automation.Jobs
|
||||
{
|
||||
public class ExecuteSsisPackages : IAutomationJob
|
||||
{
|
||||
private readonly FtpService _ftpService;
|
||||
private readonly SsisService _ssisService;
|
||||
|
||||
// TODO: set from config
|
||||
private readonly string[] _ssisPackages = { "Parts Availability", "Parts Price" };
|
||||
|
||||
public ExecuteSsisPackages(FtpService ftpService, SsisService ssisService)
|
||||
{
|
||||
_ftpService = ftpService;
|
||||
_ssisService = ssisService;
|
||||
}
|
||||
|
||||
public async Task<AutomationJobResult> Run()
|
||||
{
|
||||
IList<string> updatedPackages = new List<string>();
|
||||
IList<string> failedPackages = new List<string>();
|
||||
|
||||
foreach (string package in _ssisPackages)
|
||||
{
|
||||
try
|
||||
{
|
||||
_ftpService.Download($"{package}.txt");
|
||||
_ssisService.Execute($"{package}.dtsx");
|
||||
|
||||
updatedPackages.Add(package);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
failedPackages.Add(package);
|
||||
// TODO: Log
|
||||
}
|
||||
}
|
||||
|
||||
return new AutomationJobResult
|
||||
{
|
||||
Message = $"Updated Packages: {string.Join(',', updatedPackages)} \n Failed Packages: {string.Join(',', failedPackages)}",
|
||||
IsSuccess = failedPackages.Count == 0
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user