这可能会有所帮助,我在我的一个项目中定义了许多 Execute Process Tasks。每个容器都有自己的一组输入和输出,我希望记录这些输入和输出,因此我的方法是添加一个 OnPostExecute 事件以及与之关联的脚本任务。在那里,我触发了信息事件以记录该任务中发生的事情的详细信息。这显然假定您已选择要记录的 OnInformation 事件。
try
{
//User::ExecuteArgs,User::ExecuteError,User::ExecuteOutput
string args = Dts.Variables["ExecuteArgs"].Value.ToString();
string output = Dts.Variables["ExecuteOutput"].Value.ToString();
string error = Dts.Variables["ExecuteError"].Value.ToString();
bool fireAgain = false;
if (!string.IsNullOrEmpty(output))
{
Dts.Events.FireInformation(0, "Post execute output", string.Format("Output: {0}", output), string.Empty, 0, ref fireAgain);
}
if (!string.IsNullOrEmpty(error))
{
Dts.Events.FireWarning(0, "Post execute error", string.Format("Error: {0}", error), string.Empty, 0);
}
if (!string.IsNullOrEmpty(args))
{
Dts.Events.FireInformation(0, "Post execute args", string.Format("Args: {0}", args), string.Empty, 0, ref fireAgain);
}
}
catch (Exception ex)
{
this.Dts.Events.FireWarning(0, "Post package execution", string.Format("Trouble accessing variables {0}", ex.ToString()), string.Empty, 0);
}