는 당신이 바로 그 일을하고 있습니다. 기본 SSIS 패키지를 만들었습니다. 하나의 변수, FolderPath, 유형 문자열이 있습니다. 정보 이벤트와 그 내용이 내가 다음이
public class InformationListener : DefaultEvents
{
public override void OnInformation(DtsObject source, int informationCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError, ref bool fireAgain)
{
//base.OnInformation(source, informationCode, subComponent, description, helpFile, helpContext, idofInterfaceWithError, ref fireAgain);
Console.WriteLine(string.Format("{0} {1}", subComponent, description));
}
}
class Program
{
static void Main(string[] args)
{
string sourcePackage = string.Empty;
string path = string.Empty;
string variableName = string.Empty;
string designValue = string.Empty;
string newValue = string.Empty;
InformationListener listener = null;
sourcePackage = @"J:\Src\SO\SSIS\Package.dtsx";
path = @"J:\runtime";
variableName = "User::FolderPath";
listener = new InformationListener();
Application app = new Application();
Package pkg = null;
Variable ssisVariable = null;
pkg = app.LoadPackage(sourcePackage, null);
ssisVariable = pkg.Variables[variableName];
designValue = ssisVariable.Value.ToString();
Console.WriteLine(string.Format("Designtime value = {0}", designValue));
ssisVariable.Value = path;
newValue = ssisVariable.Value.ToString();
Console.WriteLine(string.Format("new value = {0}", newValue));
DTSExecResult results = DTSExecResult.Canceled;
results = pkg.Execute(null, null, listener, null, null);
Console.WriteLine("Press any key to continue");
Console.ReadKey();
}
}
으로 같은 기본적인 C의 # 콘솔 응용 프로그램을 만들어
FolderPath 변수의 값을 노출 발사 하나의 스크립트 작업이 있습니다 당신은
과에서 변수 검사에서 말할 수있는 내 인쇄 문
내가 위에서 내 문자열을 탈출하는 것을 잊었다하지만 우리가
J:\runtime
을 보여줍니다 척 할 수 있기 때문에
C:\designTime
의 디자인 타임 값이
J:
로 이동
.
이 모든 내용은 SaveToXml
메서드를 호출하여 패키지를 serialize하지 않으면 개체가 범위를 벗어나면 User :: FolderPath 값이 디자인 시간 값으로 다시 설정됩니다. 영구적으로 대답에
app.SaveToXml(sourcePackage, pkg, null);
OP 편집이 토론과 예제처럼 보일 것이다 저를 주도 업데이트 : http://social.msdn.microsoft.com/Forums/sqlserver/en-US/dad8e218-1fe0-49db-89da-5715fb6d4b21/sql-2008-r2-ssis-c-script-task-not-setting-variable
디버깅하는 동안, 내부'Path.GetDirectoryName (e.FullPath)'와'경로 무엇. GetFileNameWithoutExtension (e.FullPath)'입니다. 그것들은 실제 가치입니까? –
e는 실제로 새로 만든 파일에 대한 정보가있는 FileSystemEventArgs 매개 변수입니다. –