SSIS OnVariableValueChanged not fired



我正在使用BIML生成SSIS dtsx。我希望记录任何变量值的每次更改。我有几个变量,都在 TRUE 的 RaiseChangeEvent 中。我为包和变量更改(通过计数行(的数据流设置了一个 OnVariableValueChanged 事件处理程序。

当我执行 dtsx 时,我看到处理程序甚至没有被调用。我尝试了其他事件,它们被称为。那么是什么阻止了OnVariableValueChanged被处理呢?

所有变量都将设置为 0 或正值,我确保它们以 -1 的值开头,以确保值实际上会发生变化。

似乎对我有用。我创建了一个RaiseChangedEvent设置为 true 的变量。然后,我有一个 For 循环递增该值。我在 for 循环中有一个脚本任务,记录值,并附加到 OnVariableValueChanged 事件的包的事件处理程序。在那里,我有一个序列容器和一个脚本任务(已禁用(。如果我在容器上放置一个断点,我可以看到它正在被调用。尽管脚本任务与控制流中的代码相同,但在此处启用脚本任务仍会导致锁定变量的超时错误。/耸肩

<!-- http://stackoverflow.com/q/42945383/181965 -->
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
    <Packages>
        <Package Name="so_42945383" >
            <Variables>
                <Variable DataType="Int32" Name="IndexCurrent" RaiseChangedEvent="true">-1</Variable>
                <Variable DataType="Int32" Name="IndexStart">0</Variable>
                <Variable DataType="Int32" Name="IndexStop">1</Variable>
            </Variables>
            <Tasks>
                <ForLoop Name="FLT Modify values" ConstraintMode="Linear">
                    <InitializerExpression><![CDATA[@[User::IndexCurrent] = @[User::IndexStart]]]></InitializerExpression>
                    <LoopTestExpression><![CDATA[@[User::IndexCurrent] <= @[User::IndexStop]]]></LoopTestExpression>
                    <CountingExpression><![CDATA[@[User::IndexCurrent] = @[User::IndexCurrent] + 1]]></CountingExpression>
                    <Tasks>
                        <Container Name="SEQC Do nothing" />
                        <Script ProjectCoreName="FLT_ST_EchoBack" Name="SCR Echo Back FLT">
                            <ScriptTaskProjectReference ScriptTaskProjectName="ST_EchoBack" />
                        </Script>  
                    </Tasks>
                </ForLoop>
            </Tasks>
            <Events>
                <Event Name="OVVC" EventType="OnVariableValueChanged">
                    <Tasks>
                        <Container Name="SEQC Do nothing" />
                        <Script ProjectCoreName="OVCC_ST_EchoBack" Name="SCR Echo Back OVVC" Disabled="true">
                            <ScriptTaskProjectReference ScriptTaskProjectName="ST_EchoBack" />
                        </Script>  
                    </Tasks>
                </Event>
            </Events>
        </Package>
    </Packages>
<ScriptProjects>
        <ScriptTaskProject ProjectCoreName="ST_EchoBack" Name="ST_EchoBack" VstaMajorVersion="0">
            <ReadOnlyVariables>
                <!-- List all the variables you are interested in tracking -->
                <Variable Namespace="User" VariableName="IndexCurrent" DataType="Int32" />
                <Variable Namespace="User" VariableName="IndexStart" DataType="Int32" />
                <Variable Namespace="User" VariableName="IndexStop" DataType="Int32" />
            </ReadOnlyVariables>
            <Files>
                <File Path="ScriptMain.cs" BuildAction="Compile">using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
namespace ST_EchoBack
{
    [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {
        public void Main()
        {
            bool fireAgain = false;
            string message = "{0}::{1} : {2}";
            foreach (var item in Dts.Variables)
            {
                Dts.Events.FireInformation(0, "SCR Echo Back", string.Format(message, item.Namespace, item.Name, item.Value), string.Empty, 0, ref fireAgain);
            }
            Dts.TaskResult = (int)ScriptResults.Success;
        }
        enum ScriptResults
        {
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        };
    }
}                </File>
                <File Path="PropertiesAssemblyInfo.cs" BuildAction="Compile">
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyVersion("1.0.*")]
                </File>
            </Files>
            <AssemblyReferences>
                <AssemblyReference AssemblyPath="System" />
                <AssemblyReference AssemblyPath="System.Data" />
                <AssemblyReference AssemblyPath="System.Windows.Forms" />
                <AssemblyReference AssemblyPath="System.Xml" />
                <AssemblyReference AssemblyPath="Microsoft.SqlServer.ManagedDTS.dll" />
                <AssemblyReference AssemblyPath="Microsoft.SqlServer.ScriptTask.dll" />
            </AssemblyReferences>
        </ScriptTaskProject>
    </ScriptProjects>
</Biml>

相关内容

  • 没有找到相关文章

最新更新