我正在尝试从WCF服务执行SSIS包,我正在使用method(RunPackage(input1, input2))
初始化SSIS变量。
当我在IIS上部署WCF并使用Web服务调用方法(RunPackage(input1, input2))
时,我收到包失败的消息。
WCF和SSIS包位于Server1(DB服务器),Excel位于Sever2。 Server2可以访问Server1
以下是我在WCF中的RunPackage方法中的代码
strXLPath = @"\\Server1\Excel1.xlsx";
strPackagePath = @"E:\Package.dtsx";
public static string RunPackage(string strXLPath, string strPackagePath)
{
string strResult = "Fail";
try
{
Package pkg;
Application app;
DTSExecResult pkgResults;
//Microsoft.SqlServer.Dts.Runtime.Configuration cnfg;
strPackagePath = strPackagePath.Replace("E:", "\\\\Server2");
//Check if Excel exists
System.IO.FileInfo fiXlFile = new System.IO.FileInfo(strXLPath);
System.IO.FileInfo fiPkgFile = new System.IO.FileInfo(strPackagePath);
//Impersonate.ImpersonateUser("Domain", "UserID", "PWD");
if (fiXlFile.Exists)
{
strResult = "XL Exists";
if (fiPkgFile.Exists)
{
strResult = "Package Exists";
#region Call package as application
app = new Application();
pkg = app.LoadPackage(strPackagePath, null);
Variables pkgVars = pkg.Variables;
string excelpath = "";
#endregion
#region Package variables Initi
foreach (Variable pkgVar in pkgVars)
{
if (!pkgVar.SystemVariable)
{
if (pkgVar.Name == "ConnStr")
{
pkgVar.Value = "Data Source=Server2;User ID=UserId;Initial Catalog=DBName;password=Password;Provider=SQLNCLI10.1;Persist Security Info=True;Auto Translate=False;";
}
else
if (pkgVar.Name == "Excel_Path")
{
pkgVar.Value = strXLPath;
excelpath = pkgVar.Value.ToString();
}
}
}
#endregion
#region Run Package
pkgResults = pkg.Execute();
Console.WriteLine(pkgResults.ToString());
strResult = "Package" + pkgResults.ToString();
#endregion
}
else
{
strResult = "Package doesnt exists.";
}
}
else
{
strResult = "XL doesnt exists";
}
//Impersonate.UndoImpersonation();
return strResult;
}
catch (Exception)
{
return strResult = "Error In method";
}
}
}
请帮帮我。