Initial commit
This commit is contained in:
66
PartSource.Automation/Services/SsisService.cs
Normal file
66
PartSource.Automation/Services/SsisService.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using PartSource.Automation.Models.Configuration;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace PartSource.Automation.Services
|
||||
{
|
||||
public class SsisService
|
||||
{
|
||||
private readonly SsisConfiguration _ssisConfiguration;
|
||||
|
||||
public SsisService(SsisConfiguration ssisConfiguration)
|
||||
{
|
||||
_ssisConfiguration = ssisConfiguration;
|
||||
}
|
||||
|
||||
public bool Execute(string packageName)
|
||||
{
|
||||
try
|
||||
{
|
||||
using Process process = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "dtexec",
|
||||
Arguments = $"/file \"{_ssisConfiguration.Directory}\\{packageName}\"",
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
process.Start();
|
||||
|
||||
//process.WaitForExit();
|
||||
|
||||
string stdout = process.StandardOutput.ReadToEnd();
|
||||
string stderr = process.StandardError.ReadToEnd();
|
||||
|
||||
Console.WriteLine(stdout);
|
||||
Console.WriteLine(stderr);
|
||||
|
||||
// Application application = new Application();
|
||||
//Package package = application.LoadPackage($"{_ssisConfiguration.Directory}\\{packageName}", null);
|
||||
|
||||
//DTSExecResult result = package.Execute();
|
||||
|
||||
return true; //result == DTSExecResult.Success;
|
||||
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user