首页 > 解决方案 > SSIS 包中的优先约束未按预期执行

问题描述

在 SSIS 包中,我有一个简单的脚本来检查文件是否存在。如果没有,则流程应该停止。

脚本正确返回文件存在语句为假

信息

并且基于当前的优先约束,它应该只在脚本返回值为 true 时继续

约束

这是文件存在标志以供参考

在此处输入图像描述

但是,包继续,然后失败。我不明白我在这里遗漏了什么或我设置不正确。

编辑:添加实际脚本

 public void Main()
    {
        string targetfile = Dts.Variables["User::FilePathLenovo"].Value.ToString();
        try
        {
            if (File.Exists(targetfile))
            {
                Dts.Variables["User::FileExists"].Value = true;
            }
            else
            {
                Dts.Variables["User::FileExists"].Value = false;
            }

            Dts.TaskResult = (int)ScriptResults.Success;
        }
        catch (Exception Ex)
        {
            Dts.TaskResult = (int)ScriptResults.Failure;
        }
        MessageBox.Show("File.Exists(targetfile): " + File.Exists(targetfile));

    }

标签: c#ssisconstraintsoperator-precedencescript-component

解决方案


推荐阅读