IDTSSequence.PrecedenceConstraints 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回与容器关联的 PrecedenceConstraint 对象的集合。 此字段为只读。
public:
property Microsoft::SqlServer::Dts::Runtime::PrecedenceConstraints ^ PrecedenceConstraints { Microsoft::SqlServer::Dts::Runtime::PrecedenceConstraints ^ get(); };
public Microsoft.SqlServer.Dts.Runtime.PrecedenceConstraints PrecedenceConstraints { get; }
member this.PrecedenceConstraints : Microsoft.SqlServer.Dts.Runtime.PrecedenceConstraints
Public ReadOnly Property PrecedenceConstraints As PrecedenceConstraints
属性值
包含 PrecedenceConstraints 容器对象的集合 PrecedenceConstraint 。
示例
该 Package 类继承并 IDTSSequence 实现集合:下面的代码示例演示如何将两个 PrecedenceConstraints 任务添加到包中。 A PrecedenceConstraint 将添加到 PrecedenceConstraints 集合中。 在任务之间创建的约束可防止第二个任务运行,直到第一个任务完成。
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Tasks.FileSystemTask;
namespace DataFlow_Conceptual
{
class Program
{
static void Main(string[] args)
{
Package p = new Package();
// Add a File System task.
Executable eFileTask1 = p.Executables.Add("STOCK:FileSystemTask");
TaskHost thFileHost1 = eFileTask1 as TaskHost;
// Add a second File System task.
Executable eFileTask2 = p.Executables.Add("STOCK:FileSystemTask");
TaskHost thFileHost2 = eFileTask2 as TaskHost;
// Put a precedence constraint between the tasks.
// Set the constraint to be that thFileTask2 cannot run
// until thFileTask1 completes.
PrecedenceConstraint pcFileTasks = p.PrecedenceConstraints.Add((Executable)thFileHost1, (Executable) thFileHost2);
pcFileTasks.Value = DTSExecResult.Completion;
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Tasks.FileSystemTask
Namespace DataFlow_Conceptual
Class Program
Shared Sub Main(ByVal args() As String)
Dim p As Package = New Package()
' Add a File System task.
Dim eFileTask1 As Executable = p.Executables.Add("STOCK:FileSystemTask")
Dim thFileHost1 As TaskHost = eFileTask1 as TaskHost
' Add a second File System task.
Dim eFileTask2 As Executable = p.Executables.Add("STOCK:FileSystemTask")
Dim thFileHost2 As TaskHost = eFileTask2 as TaskHost
' Put a precedence constraint between the tasks.
' Set the constraint to be that thFileTask2 cannot run
' until thFileTask1 completes.
Dim pcFileTasks As PrecedenceConstraint = p.PrecedenceConstraints.Add(CType(thFileHost1,CType(thFileHost2, Executable, Executable)))
pcFileTasks.Value = DTSExecResult.Completion
End Sub
End Class
End Namespace
注解
优先约束建立可执行对象在包中运行的顺序。 优先约束允许控制包中的容器和任务的执行,具体取决于上一个任务或容器的执行结果。 通过在容器对象上调用Add集合的方法PrecedenceConstraints,在两Executable个对象之间建立优先约束。 在两个可执行对象之间创建约束后,该 Value 属性设置为建立用于执行约束中定义的第二个可执行文件的条件。