Metoda PrecedenceConstraints.Add
Dodaje określony Executable jako ograniczenie pierwszeństwa do PrecedenceConstraints kolekcja.
Przestrzeń nazw: Microsoft.SqlServer.Dts.Runtime
Zestaw: Microsoft.SqlServer.ManagedDTS (w Microsoft.SqlServer.ManagedDTS.dll)
Składnia
'Deklaracja
Public Function Add ( _
execFrom As Executable, _
execTo As Executable _
) As PrecedenceConstraint
'Użycie
Dim instance As PrecedenceConstraints
Dim execFrom As Executable
Dim execTo As Executable
Dim returnValue As PrecedenceConstraint
returnValue = instance.Add(execFrom, execTo)
public PrecedenceConstraint Add(
Executable execFrom,
Executable execTo
)
public:
PrecedenceConstraint^ Add(
Executable^ execFrom,
Executable^ execTo
)
member Add :
execFrom:Executable *
execTo:Executable -> PrecedenceConstraint
public function Add(
execFrom : Executable,
execTo : Executable
) : PrecedenceConstraint
Parametry
- execFrom
Typ: Microsoft.SqlServer.Dts.Runtime.Executable
Plik wykonywalny przed ograniczenie pierwszeństwa.
- execTo
Typ: Microsoft.SqlServer.Dts.Runtime.Executable
Plik wykonywalny po ograniczenie pierwszeństwa.
Wartość zwracana
Typ: Microsoft.SqlServer.Dts.Runtime.PrecedenceConstraint
PrecedenceConstraint Obiektu.
Przykłady
Poniższy przykład kodu tworzy trzy zadania i umieszcza więzów kolejności między nimi.Korzystanie z kolekcja PrecedenceConstraints iteracje nad ograniczenia w pakiet, drukowanie informacji na temat każdego z ograniczeń.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
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 constraint between eFileTask1 and eFileTask2.
// Set the constraint to be that eFileTask2 cannot run
// until eFileTask1 completes.
PrecedenceConstraint pcFileTasks = pkg.PrecedenceConstraints.Add(eFileTask1, eFileTask2);
// Add another precedence constraint. 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);
// Obtain the precedence constraint collection, and display properties.
// Some properties are read/write and have not been set.
PrecedenceConstraints pConsts = pkg.PrecedenceConstraints;
foreach (PrecedenceConstraint pc in pConsts)
{
Console.WriteLine("Constrained container {0}", pc.ConstrainedExecutable);
Console.WriteLine("Creation Name {0}", pc.CreationName);
Console.WriteLine("Description {0}", pc.Description);
Console.WriteLine("Evaluation operation {0}", pc.EvalOp);
Console.WriteLine("Evaluates true {0}", pc.EvaluatesTrue);
Console.WriteLine("Expression {0}", pc.Expression);
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("-----------------------------------");
}
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
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 constraint 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)
' Add another precedence constraint. 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)
' Obtain the precedence constraint collection, and display properties.
' Some properties are read/write and have not been set.
Dim pConsts As PrecedenceConstraints = pkg.PrecedenceConstraints
Dim pc As PrecedenceConstraint
For Each pc In pConsts
Console.WriteLine("Constrained container {0}", pc.ConstrainedExecutable)
Console.WriteLine("Creation Name {0}", pc.CreationName)
Console.WriteLine("Description {0}", pc.Description)
Console.WriteLine("Evaluation operation {0}", pc.EvalOp)
Console.WriteLine("Evaluates true {0}", pc.EvaluatesTrue)
Console.WriteLine("Expression {0}", pc.Expression)
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
End Sub
End Class
End Namespace
Przykładowe dane wyjściowe:
Ograniczone kontener Microsoft.SqlServer.Dts.Runtime.TaskHost
Nazwa tworzenia
Opis
Operacja oceny ograniczenia
Wynikiem jest wartość PRAWDA PRAWDA
Wyrażenie
IDENTYFIKATOR {BA20A288-545 D-4E48-864A-E6AF6C3B9AEE}
LogicalAnd True
Nazwa {BA20A288-545 D-4E48-864A-E6AF6C3B9AEE}
Pierwszeństwo wykonywalne Microsoft.SqlServer.Dts.Runtime.TaskHost
Wartość sukces
-----------------------------------
Ograniczone kontener Microsoft.SqlServer.Dts.Runtime.TaskHost
Nazwa tworzenia
Opis
Operacja oceny ograniczenia
Wynikiem jest wartość PRAWDA PRAWDA
Wyrażenie
IDENTYFIKATOR {E8DBC95E-AF27-45 D 7-B961-17E908CC4530}
LogicalAnd True
Nazwa {E8DBC95E-AF27-45 D 7-B961-17E908CC4530}
Pierwszeństwo wykonywalne Microsoft.SqlServer.Dts.Runtime.TaskHost
Wartość sukces
-----------------------------------