Bagikan melalui


WorkflowApplication Konstruktor

Definisi

Membuat instans WorkflowApplication baru kelas .

Overload

WorkflowApplication(Activity)

Membuat instans WorkflowApplication baru kelas dengan definisi alur kerja yang ditentukan.

WorkflowApplication(Activity, WorkflowIdentity)

Membuat instans WorkflowApplication baru kelas dengan definisi alur kerja dan identitas definisi yang ditentukan.

WorkflowApplication(Activity, IDictionary<String,Object>)

Membuat instans WorkflowApplication baru kelas yang menggunakan definisi alur kerja dan nilai argumen yang ditentukan.

WorkflowApplication(Activity, IDictionary<String,Object>, WorkflowIdentity)

Membuat instans WorkflowApplication baru kelas yang menggunakan definisi alur kerja dan nilai argumen yang ditentukan, dan identitas definisi.

WorkflowApplication(Activity)

Membuat instans WorkflowApplication baru kelas dengan definisi alur kerja yang ditentukan.

public:
 WorkflowApplication(System::Activities::Activity ^ workflowDefinition);
public WorkflowApplication (System.Activities.Activity workflowDefinition);
new System.Activities.WorkflowApplication : System.Activities.Activity -> System.Activities.WorkflowApplication
Public Sub New (workflowDefinition As Activity)

Parameter

workflowDefinition
Activity

Definisi alur kerja.

Contoh

Contoh berikut meng-hosting alur kerja menggunakan WorkflowApplication. Instans WorkflowApplication dibuat menggunakan definisi alur kerja yang terdiri dari aktivitas DiceRoll tunggal. Aktivitas DiceRoll memiliki dua argumen output yang mewakili hasil operasi pelemparan dadu. Ketika alur kerja selesai, output diambil di Completed handler, dan output berikut ditampilkan ke konsol.

Workflow aae3fb48-7229-4737-b969-d63e131b96b3 Completed.   
The two dice are 1 and 5.  
public sealed class DiceRoll : CodeActivity
{
    public OutArgument<int> D1 { get; set; }
    public OutArgument<int> D2 { get; set; }

    static Random r = new Random();

    protected override void Execute(CodeActivityContext context)
    {
        D1.Set(context, r.Next(1, 7));
        D2.Set(context, r.Next(1, 7));
    }
}
 // Create a WorkflowApplication instance.
 WorkflowApplication wfApp = new WorkflowApplication(new DiceRoll());

 // Subscribe to any desired workflow lifecycle events.
 wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
 {
     if (e.CompletionState == ActivityInstanceState.Faulted)
     {
         Console.WriteLine("Workflow {0} Terminated.", e.InstanceId);
         Console.WriteLine("Exception: {0}\n{1}",
             e.TerminationException.GetType().FullName,
             e.TerminationException.Message);
     }
     else if (e.CompletionState == ActivityInstanceState.Canceled)
     {
         Console.WriteLine("Workflow {0} Canceled.", e.InstanceId);
     }
     else
     {
         Console.WriteLine("Workflow {0} Completed.", e.InstanceId);

         // Outputs can be retrieved from the Outputs dictionary,
         // keyed by argument name.
         Console.WriteLine("The two dice are {0} and {1}.",
             e.Outputs["D1"], e.Outputs["D2"]);
     }
 };

// Run the workflow.
 wfApp.Run();

Berlaku untuk

WorkflowApplication(Activity, WorkflowIdentity)

Membuat instans WorkflowApplication baru kelas dengan definisi alur kerja dan identitas definisi yang ditentukan.

public:
 WorkflowApplication(System::Activities::Activity ^ workflowDefinition, System::Activities::WorkflowIdentity ^ definitionIdentity);
public WorkflowApplication (System.Activities.Activity workflowDefinition, System.Activities.WorkflowIdentity definitionIdentity);
new System.Activities.WorkflowApplication : System.Activities.Activity * System.Activities.WorkflowIdentity -> System.Activities.WorkflowApplication
Public Sub New (workflowDefinition As Activity, definitionIdentity As WorkflowIdentity)

Parameter

workflowDefinition
Activity

Definisi alur kerja.

definitionIdentity
WorkflowIdentity

Identitas definisi.

Berlaku untuk

WorkflowApplication(Activity, IDictionary<String,Object>)

Membuat instans WorkflowApplication baru kelas yang menggunakan definisi alur kerja dan nilai argumen yang ditentukan.

public:
 WorkflowApplication(System::Activities::Activity ^ workflowDefinition, System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ inputs);
public WorkflowApplication (System.Activities.Activity workflowDefinition, System.Collections.Generic.IDictionary<string,object> inputs);
new System.Activities.WorkflowApplication : System.Activities.Activity * System.Collections.Generic.IDictionary<string, obj> -> System.Activities.WorkflowApplication
Public Sub New (workflowDefinition As Activity, inputs As IDictionary(Of String, Object))

Parameter

workflowDefinition
Activity

Definisi alur kerja.

inputs
IDictionary<String,Object>

Nilai untuk argumen yang ditentukan pada aktivitas akar definisi alur kerja, dikuntangani oleh nama argumen.

Contoh

Contoh berikut meng-hosting alur kerja menggunakan WorkflowApplication. WorkflowApplication Instans dibangun menggunakan definisi alur kerja yang terdiri dari satu Divide aktivitas yang mengambil dua argumen input, dan kamus argumen input yang berisi dua nilai yang akan diteruskan, dikuntangani oleh nama argumen. Peristiwa siklus hidup alur kerja yang diinginkan ditangani, dan alur kerja dipanggil dengan panggilan ke Run. Ketika alur kerja selesai, output berikut ditampilkan ke konsol.

Workflow 8dc844c1-bbf8-4b21-a9a2-05f89e416055 Completed  
500 / 36 = 13 Remainder 32  
Workflow 8dc844c1-bbf8-4b21-a9a2-05f89e416055 Unloaded.  
public sealed class Divide : CodeActivity
{
    [RequiredArgument]
    public InArgument<int> Dividend { get; set; }

    [RequiredArgument]
    public InArgument<int> Divisor { get; set; }

    public OutArgument<int> Remainder { get; set; }
    public OutArgument<int> Result { get; set; }

    protected override void Execute(CodeActivityContext context)
    {
        int quotient = Dividend.Get(context) / Divisor.Get(context);
        int remainder = Dividend.Get(context) % Divisor.Get(context);

        Result.Set(context, quotient);
        Remainder.Set(context, remainder);
    }
}
int dividend = 500;
int divisor = 36;

Dictionary<string, object> inputs = new Dictionary<string, object>();
inputs.Add("Dividend", dividend);
inputs.Add("Divisor", divisor);

// Create a WorkflowApplication instance.
WorkflowApplication wfApp = new WorkflowApplication(new Divide(), inputs);

// Subscribe to any desired workflow lifecycle events.
wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
    if (e.CompletionState == ActivityInstanceState.Faulted)
    {
        Console.WriteLine("Workflow {0} Terminated.", e.InstanceId);
        Console.WriteLine("Exception: {0}\n{1}",
            e.TerminationException.GetType().FullName,
            e.TerminationException.Message);
    }
    else if (e.CompletionState == ActivityInstanceState.Canceled)
    {
        Console.WriteLine("Workflow {0} Canceled.", e.InstanceId);
    }
    else
    {
        Console.WriteLine("Workflow {0} Completed.", e.InstanceId);

        // Outputs can be retrieved from the Outputs dictionary,
        // keyed by argument name.
        Console.WriteLine("{0} / {1} = {2} Remainder {3}",
            dividend, divisor, e.Outputs["Result"], e.Outputs["Remainder"]);
    }
};

// Run the workflow.
wfApp.Run();

Berlaku untuk

WorkflowApplication(Activity, IDictionary<String,Object>, WorkflowIdentity)

Membuat instans WorkflowApplication baru kelas yang menggunakan definisi alur kerja dan nilai argumen yang ditentukan, dan identitas definisi.

public:
 WorkflowApplication(System::Activities::Activity ^ workflowDefinition, System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ inputs, System::Activities::WorkflowIdentity ^ definitionIdentity);
public WorkflowApplication (System.Activities.Activity workflowDefinition, System.Collections.Generic.IDictionary<string,object> inputs, System.Activities.WorkflowIdentity definitionIdentity);
new System.Activities.WorkflowApplication : System.Activities.Activity * System.Collections.Generic.IDictionary<string, obj> * System.Activities.WorkflowIdentity -> System.Activities.WorkflowApplication
Public Sub New (workflowDefinition As Activity, inputs As IDictionary(Of String, Object), definitionIdentity As WorkflowIdentity)

Parameter

workflowDefinition
Activity

Definisi alur kerja.

inputs
IDictionary<String,Object>

Identitas definisi.

definitionIdentity
WorkflowIdentity

Nilai untuk argumen yang ditentukan pada aktivitas akar definisi alur kerja, dikuntangani oleh nama argumen.

Berlaku untuk