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
属性值
包含PrecedenceConstraintsPrecedenceConstraint容器对象的集合。
示例
该 Package 类继承 IDTSSequence 并实现一个 PrecedenceConstraints 集合。以下代码示例演示了向包添加两个任务。 PrecedenceConstraint A被添加到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 该属性被设置为确定执行约束中定义的第二个可执行文件的条件。