DTSPrecedenceEvalOp 枚举
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指示优先约束使用的求值运算。
public enum class DTSPrecedenceEvalOp
public enum DTSPrecedenceEvalOp
type DTSPrecedenceEvalOp =
Public Enum DTSPrecedenceEvalOp
- 继承
-
DTSPrecedenceEvalOp
字段
Constraint | 2 | 指定执行结果确定受约束的容器或任务是否运行。 请将 Value 的 PrecedenceConstraint 属性设置为 DTSExecResult 枚举中的所需值。 |
Expression | 1 | 指定表达式的值确定受约束的容器或任务是否运行。 请设置 Expression 的 PrecedenceConstraint 属性。 |
ExpressionAndConstraint | 3 | 指定约束结果必须发生且表达式必须计算,受约束的容器或任务才能运行。 设置属性 Value 和 Expression 属性 PrecedenceConstraint,并将其 LogicalAnd 属性设置为 true。 |
ExpressionOrConstraint | 4 | 指定约束结果必须发生,或者表达式必须计算,受约束的容器或任务才能运行。 设置属性 Value 和 Expression 属性 PrecedenceConstraint,并将其 LogicalAnd 属性设置为 false。 |
示例
下面的代码示例创建三个任务,并在它们之间放置优先约束。 PrecedenceConstraints使用集合,循环访问包中的约束,显示有关每个约束的信息,包括属性,其中包含EvalOp此枚举中的值之一。 然后,代码示例更改使用此枚举的值 EvalOp 。
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.BulkInsertTask;
using Microsoft.SqlServer.Dts.Tasks.FileSystemTask;
namespace PrecedenceConst
{
class Program
{
static void Main(string[] args)
{
Package pkg = new Package();
// Add a File System task.
Executable eFileTask1 = pkg.Executables.Add("STOCK:FileSystemTask");
TaskHost thFileTask1 = eFileTask1 as TaskHost;
// Add a second File System task.
Executable eFileTask2 = pkg.Executables.Add("STOCK:FileSystemTask");
TaskHost thFileTask2 = eFileTask2 as TaskHost;
// Add a Bulk Insert task.
Executable eBulkInsert = pkg.Executables.Add("STOCK:BulkInsertTask");
TaskHost thBulkInsert = eBulkInsert as TaskHost;
// Add a precedence contraint between eFileTask1 and eFileTask2.
// Set the constraint to be that eFileTask2 cannot run
// until eFileTask1 completes.
PrecedenceConstraint pcFileTasks = pkg.PrecedenceConstraints.Add(eFileTask1, eFileTask2);
pcFileTasks.Name = "constraint between File System Tasks";
// Add another precedence contraint. Add it between eFileTask2 and BulkInsert.
// Again, set the constraint to be that BulkInsert cannot run
// until eFileTask2 completes.
PrecedenceConstraint pcFiletoBulk = pkg.PrecedenceConstraints.Add(eFileTask2, eBulkInsert);
pcFileTasks.Name = "constraint between File System and Bulk Insert Tasks";
// Obtain the precedence constraint collection.
PrecedenceConstraints pConsts = pkg.PrecedenceConstraints;
Boolean containsConstraint = pkg.PrecedenceConstraints.Contains("constraint between File System and Bulk Insert Tasks");
Console.WriteLine("Contains the constraint between File System and Bulk Insert Tasks? {0}", containsConstraint);
foreach (PrecedenceConstraint pc in pConsts)
{
Console.WriteLine("Constrained container {0}", pc.ConstrainedExecutable);
Console.WriteLine("Evaluation operation {0}", pc.EvalOp);
Console.WriteLine("Evaluates true {0}", pc.EvaluatesTrue);
Console.WriteLine("ID {0}", pc.ID);
Console.WriteLine("LogicalAnd {0}", pc.LogicalAnd);
Console.WriteLine("Precedence Executable {0}", pc.PrecedenceExecutable);
Console.WriteLine("-----------------------------------");
}
// Set the EvalOp of the first constraint using the DtsPrecedenceEvalOp enumerator.
PrecedenceConstraint firstPC = pConsts[0];
firstPC.EvalOp = DTSPrecedenceEvalOp.Expression;
Console.WriteLine("Evaluation operation after {0}", firstPC.EvalOp);
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask
Imports Microsoft.SqlServer.Dts.Tasks.FileSystemTask
Namespace PrecedenceConst
Class Program
Shared Sub Main(ByVal args() As String)
Dim pkg As Package = New Package()
' Add a File System task.
Dim eFileTask1 As Executable = pkg.Executables.Add("STOCK:FileSystemTask")
Dim thFileTask1 As TaskHost = eFileTask1 as TaskHost
' Add a second File System task.
Dim eFileTask2 As Executable = pkg.Executables.Add("STOCK:FileSystemTask")
Dim thFileTask2 As TaskHost = eFileTask2 as TaskHost
' Add a Bulk Insert task.
Dim eBulkInsert As Executable = pkg.Executables.Add("STOCK:BulkInsertTask")
Dim thBulkInsert As TaskHost = eBulkInsert as TaskHost
' Add a precedence contraint between eFileTask1 and eFileTask2.
' Set the constraint to be that eFileTask2 cannot run
' until eFileTask1 completes.
Dim pcFileTasks As PrecedenceConstraint = pkg.PrecedenceConstraints.Add(eFileTask1,eFileTask2)
pcFileTasks.Name = "constraint between File System Tasks"
' Add another precedence contraint. Add it between eFileTask2 and BulkInsert.
' Again, set the constraint to be that BulkInsert cannot run
' until eFileTask2 completes.
Dim pcFiletoBulk As PrecedenceConstraint = pkg.PrecedenceConstraints.Add(eFileTask2,eBulkInsert)
pcFileTasks.Name = "constraint between File System and Bulk Insert Tasks"
' Obtain the precedence constraint collection.
Dim pConsts As PrecedenceConstraints = pkg.PrecedenceConstraints
Dim containsConstraint As Boolean = pkg.PrecedenceConstraints.Contains("constraint between File System and Bulk Insert Tasks")
Console.WriteLine("Contains the constraint between File System and Bulk Insert Tasks? {0}", containsConstraint)
Dim pc As PrecedenceConstraint
For Each pc In pConsts
Console.WriteLine("Constrained container {0}", pc.ConstrainedExecutable)
Console.WriteLine("Evaluation operation {0}", pc.EvalOp)
Console.WriteLine("Evaluates true {0}", pc.EvaluatesTrue)
Console.WriteLine("ID {0}", pc.ID)
Console.WriteLine("LogicalAnd {0}", pc.LogicalAnd)
Console.WriteLine("Precedence Executable {0}", pc.PrecedenceExecutable)
Console.WriteLine("-----------------------------------")
Next
' Set the EvalOp of the first constraint using the DtsPrecedenceEvalOp enumerator.
Dim firstPC As PrecedenceConstraint = pConsts(0)
firstPC.EvalOp = DTSPrecedenceEvalOp.Expression
Console.WriteLine("Evaluation operation after {0}", firstPC.EvalOp)
End Sub
End Class
End Namespace
示例输出:
Contains the constraint between File System and Bulk Insert Tasks? True
Constrained container Microsoft.SqlServer.Dts.Runtime.TaskHost
Evaluation operation Constraint
Evaluates true True
ID {0EDDD5B8-7135-4A73-B240-EDF54C0E66AC}
LogicalAnd True
Precedence Executable Microsoft.SqlServer.Dts.Runtime.TaskHost
-----------------------------------
Constrained container Microsoft.SqlServer.Dts.Runtime.TaskHost
Evaluation operation Constraint
Evaluates true True
ID {80584B94-A3D0-4E08-B9C1-8CCC7BD7D086}
LogicalAnd True
Precedence Executable Microsoft.SqlServer.Dts.Runtime.TaskHost
-----------------------------------
Evaluation operation after Expression
注解
优先项是任务或容器,其表达式或执行结果 (完成、成功或失败) 确定下一个任务或容器(约束项)是否运行。 默认值为 Constraint。 有关详细信息,请参阅 优先约束。