从c#控制台应用程序为每个循环调用SSIS包 [英] Call SSIS Package from c# Console Application For Each Loop
问题描述
我有一个正在调用SSIS程序包的控制台应用程序.下面是运行正常的代码.
I have a Console Application which is invoking SSIS Package.Below is the code which is working Fine.
public static void ExecuteSSIS_Staging()
{
DataAccessLayer objDAL = new DataAccessLayer();
LogManager_SSIS objlogM = new LogManager_SSIS();
String strDestinationFilePath = System.Configuration.ConfigurationManager.AppSettings.Get("FileDownloaded");
try
{
Package pkg;
Application app;
DTSExecResult pkgResults;
MyEventListener eventListener = new MyEventListener();
string staging_pkgLocation = System.Configuration.ConfigurationManager.AppSettings.Get("SSIS_Staging_Filepath").ToString();
app = new Application();
pkg = app.LoadPackage(staging_pkgLocation, eventListener);
pkgResults = pkg.Execute(null, null, eventListener, null, null);
if (pkgResults == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success)
{
Console.WriteLine("Success");
}
else if (pkgResults == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)
{
string err = "";
foreach (Microsoft.SqlServer.Dts.Runtime.DtsError local_DtsError in pkg.Errors)
{
string error = local_DtsError.Description.ToString();
err = err + error;
}
throw new Exception("Error Occurred while executing the SSIS Staging package:" + err);
}
}
catch (Exception ex)
{
throw new Exception("SSIS Package Execution Failed:" + ex.Message.ToString());
}
}
现在我可以在Foreach循环中调用此程序包了.
Now I am in a position to Invoke this Package inside Foreach Loop.
static void Main(string[] args)
{
try
{
foreach (DateTime FileDate in SortedDates)
{
ExecuteSSIS_Staging(FileDate);
}
}
Catch(Exception ex)
{
}
}
我遇到许多类似
Could not load file or assembly 'Microsoft.SqlServer.ManagedDTS
和其他一些DLL参考错误.
and few other DLL reference error.
谁能建议我,我该如何在Foreach循环中调用SSIS包.最主要的是,在我的本地计算机中,它绝对是文件.但是当我在服务器中部署它时,不是.
Can anyone suggest me, how can i invoke SSIS Package Inside Foreach loop. The main thing is, In my Local machine it is working obsolutely file. But When i deploy it in server, it is not.
推荐答案
实际问题是我添加了
Microsoft.SQLServer.ManagedDTS.dll version 9.0
在一台机器上.当我尝试在其他计算机上打开它时,DLL是如何引用到
in one machine. When i tried to open it in other machine, some how DLL is refernced to
Microsoft.SQLServer.ManagedDTS.dll version 10.0 version.
我再次更改了&被执行.现在工作正常.
I changed it again & executed. Now Working Fine.
这篇关于从c#控制台应用程序为每个循环调用SSIS包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!