5 분마다 SSIS 패키지를 실행하는 Windows 서비스를 만들었습니다. 그것은 꽤 잘 작동하지만, 무언가가 그것을 뛰어 넘고 있습니다.문제 Windows 서비스에서 SSIS 패키지 실행
매주 서버가 다시 시작되고 다시 시작한 후에 서비스가 작동하지 않습니다. SSIS 패키지 시작/종료 실행 이벤트는 여전히 이벤트 뷰어에 나타나지만 패키지가 제대로 작동하지 않습니다. 수동으로 서비스를 시작/중지하면 모두 정상적으로 작동합니다.
Pacakge
으로해야 할 일이 누락 되었습니까?
웹 서비스를 사용하여 SSIS 패키지의 위치를 얻습니다. 아래 코드에서 대부분을 제거했지만 서비스 구조가 유지 될만큼 충분히 남았습니다. 도움을
이namespace MyService
{
partial class MyService : ServiceBase
{
private Timer timer;
private Package pkg;
bool executing;
public MyService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
executing = false;
TimerCallback callback = new TimerCallback(Init);
int period = 1000 * 60; //attempt to initialize every minute.
timer = new Timer(callback, null, 0, period);
}
private void Init(object state)
{
try
{
//Get `timeIntervalMinutes` from Parameters table
string mySQLStatement = "...";
DataSet ds = mySQLQuery(...);
int timeIntervalMinutes = Convert.ToInt32(ds.Tables["timeIntervalMinutes"].Rows[0]["Value"]);
//Get `path` from Parameters table
string mySQLStatement = "...";
DataSet ds = mySQLQuery(...);
string path = Convert.ToString(ds.Tables["path"].Rows[0]["Value"]);
//Get `path` from Parameters table
string mySQLStatement = "...";
DataSet ds = mySQLQuery(...);
string server = Convert.ToString(ds.Tables["server"].Rows[0]["Value"]);
//Load the SSIS Package
Application app = new Application();
pkg = app.LoadFromDtsServer(path, server, null);
//If this line is reached, a connection to MyWS has been made, so switch the timer to run the SSIS package
timer.Dispose();
TimerCallback callback = new TimerCallback(OnTimedEvent);
int period = 1000 * 60 * timeIntervalMinutes;
timer = new Timer(callback, null, 0, period);
}
catch (Exception e)
{
return;
}
}
private void OnTimedEvent(object state)
{
if (!executing)
{
executing = true;
DTSExecResult pkgResults = pkg.Execute();
executing = false;
}
}
protected override void OnStop()
{
}
//<MyWS is here>
}
}
감사 :
여기 내 코드의 JIST입니다!