다음을 통해 공유


Sequence.PrecedenceConstraints 속성

정의

컨테이너 수준 컨테이너 및 태스크를 정렬된 제어 흐름으로 연결하는 선행 제약 조건에 대해 설명하는 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 컬렉션입니다.

구현

예제

다음 코드 예제에서는 개체를 Sequence 만들고 세 개의 태스크를 만들어 둘 사이에 우선 순위 제약 조건을 배치합니다. PrecedenceConstraints 컬렉션을 사용하여 각 제약 조건에 대한 정보를 인쇄하는 제약 조건을 반복합니다Sequence.

using System;  
using System.Collections.Generic;  
using System.Text;    
using Microsoft.SqlServer.Dts.Runtime;  
using Microsoft.SqlServer.Dts.Tasks. FileSystemTask;  

namespace Sequence_API  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            Package package = new Package();  
            Sequence seq = (Sequence)package.Executables.Add("STOCK:SEQUENCE");  

            // Add a File System task.  
            Executable eFileTask1 = seq.Executables.Add("STOCK:FileSystemTask");  
            TaskHost thFileTask1 = eFileTask1 as TaskHost;  

            // Add a second File System task.  
            Executable eFileTask2 = seq.Executables.Add("STOCK:FileSystemTask");  
            TaskHost thFileTask2 = eFileTask2 as TaskHost;  

            // Add a Bulk Insert task.  
            Executable eBulkInsert = seq.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 = seq.PrecedenceConstraints.Add(eFileTask1, eFileTask2);  

            // 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 = seq.PrecedenceConstraints.Add(eFileTask2, eBulkInsert);  
            // Obtain the precedence constraint collection, and display properties.  
            // Some properties are read/write and have not been set.  
            PrecedenceConstraints seqPCs = seq.PrecedenceConstraints;  
            int numPCs = seqPCs.Count;  
            Console.WriteLine("Number of precedence constraints in Sequence: {0}", numPCs);  
            Console.WriteLine("----------------------------------------");  

            foreach (PrecedenceConstraint pc in seqPCs)  
            {  
                Console.WriteLine("Constrained container  {0}", pc.ConstrainedExecutable);  
                Console.WriteLine("Description            {0}", pc.Description);  
                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("Name                   {0}", pc.Name);  
                Console.WriteLine("Precedence Executable  {0}", pc.PrecedenceExecutable);  
                Console.WriteLine("Value                  {0}", pc.Value);  
                Console.WriteLine("-----------------------------------");  
            }  
            Executables seqExecs = seq.Executables;  
            int numExecs = seqExecs.Count;  
            Console.WriteLine("Number of Executables in Sequence: {0}", numExecs);  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text    
Imports Microsoft.SqlServer.Dts.Runtime  
Imports Microsoft.SqlServer.Dts.Tasks. FileSystemTask  

Namespace Sequence_API  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            Dim package As Package =  New Package()   
            Dim seq As Sequence = CType(package.Executables.Add("STOCK:SEQUENCE"), Sequence)  

            ' Add a File System task.  
            Dim eFileTask1 As Executable =  seq.Executables.Add("STOCK:FileSystemTask")   
            Dim thFileTask1 As TaskHost =  eFileTask1 as TaskHost   

            ' Add a second File System task.  
            Dim eFileTask2 As Executable =  seq.Executables.Add("STOCK:FileSystemTask")   
            Dim thFileTask2 As TaskHost =  eFileTask2 as TaskHost   

            ' Add a Bulk Insert task.  
            Dim eBulkInsert As Executable =  seq.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 =  seq.PrecedenceConstraints.Add(eFileTask1,eFileTask2)   

            ' 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 =  seq.PrecedenceConstraints.Add(eFileTask2,eBulkInsert)   
            ' Obtain the precedence constraint collection, and display properties.  
            ' Some properties are read/write and have not been set.  
            Dim seqPCs As PrecedenceConstraints =  seq.PrecedenceConstraints   
            Dim numPCs As Integer =  seqPCs.Count   
            Console.WriteLine("Number of precedence constraints in Sequence: {0}", numPCs)  
            Console.WriteLine("----------------------------------------")  

            Dim pc As PrecedenceConstraint  
            For Each pc In seqPCs  
                Console.WriteLine("Constrained container  {0}", pc.ConstrainedExecutable)  
                Console.WriteLine("Description            {0}", pc.Description)  
                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("Name                   {0}", pc.Name)  
                Console.WriteLine("Precedence Executable  {0}", pc.PrecedenceExecutable)  
                Console.WriteLine("Value                  {0}", pc.Value)  
                Console.WriteLine("-----------------------------------")  
            Next  
            Dim seqExecs As Executables =  seq.Executables   
            Dim numExecs As Integer =  seqExecs.Count   
            Console.WriteLine("Number of Executables in Sequence: {0}", numExecs)  
        End Sub  
    End Class  
End Namespace  

샘플 출력:

시퀀스의 선행 제약 조건 수: 2

----------------------------------------

제한된 컨테이너 Microsoft.SqlServer.Dts.Runtime.TaskHost

설명

평가 작업 제약 조건

true True를 평가합니다.

ID {A4F5C0E6-A9A6-470D-9646-7FEAFE3B45AD}

LogicalAnd True

이름 {A4F5C0E6-A9A6-470D-9646-7FEAFE3B45AD}

선행 실행 파일 Microsoft.SqlServer.Dts.Runtime.TaskHost

값 성공

-----------------------------------

제한된 컨테이너 Microsoft.SqlServer.Dts.Runtime.TaskHost

설명

평가 작업 제약 조건

true True를 평가합니다.

ID {665C52DE-232A-4593-ADF1-7C51949712B8}

LogicalAnd True

이름 {665C52DE-232A-4593-ADF1-7C51949712B8}

선행 실행 파일 Microsoft.SqlServer.Dts.Runtime.TaskHost

값 성공

-----------------------------------

시퀀스의 실행 파일 수: 3

설명

선행 제약 조건은 컨테이너와 태스크를 정렬된 워크플로에 연결합니다. 패키지를 제외한 모든 유형의 컨테이너와 태스크 간에 우선 순위 제약 조건을 구현할 수 있습니다. 자세한 내용은 Precedence Constraints을(를) 참조하세요.

적용 대상