2010-11-03 2 views
0

Я хочу написать простое приложение, которое поможет мне понять рабочий процесс 4.0. У меня есть активность последовательности с активностью ReceiveAndSendRepply для связи с моим приложением silverlight.Workflow 4.0 и коллекции

Я хочу создать список студентов типа и в приложении silverlight, отображаемом в datagrid.

На данный момент у меня есть простой класс Студент

public class Student 
{ 
     public int ID { get; set; } 
     public string Name { get; set; } 
} 

Я обнажая свою WF в качестве службы и вызов из моего SilverLight приложения:

StudentService.ServiceClient client = new StudentService.ServiceClient(); 
     public MainPage() 
     { 

      InitializeComponent(); 
      client.GetStudentsCompleted += new EventHandler<StudentService.GetStudentsCompletedEventArgs>(client_GetStudentsCompleted); 
     } 

     private void Button_Click(object sender, RoutedEventArgs e) 
     { 

      client.GetStudentsAsync();  
     } 

я в состоянии использовать назначьте AB и назначьте переменную и дайте ей значение ONE, но я хочу отправить несколько значений и пропустить их.

Как мне получить список учеников, итерацию и отображение в сетке.

Как создать список в рабочем процессе и отправить его обратно в сетку Silverlight?

ответ

2

Просто верните список из службы рабочего процесса, и клиент Silverlight получит это.

Рабочий процесс alt text

Silverlight, клиент

alt text

private void button1_Click(object sender, RoutedEventArgs e) 
{ 
    var proxy = new ServiceClient(); 
    proxy.GetStudentsCompleted += new EventHandler<GetStudentsCompletedEventArgs>(proxy_GetStudentsCompleted); 
    proxy.GetStudentsAsync(); 
} 

void proxy_GetStudentsCompleted(object sender, GetStudentsCompletedEventArgs e) 
{ 
    dgStudents.ItemsSource = e.Result; 
} 

Полный сервис рабочий XAMLX источник выглядит следующим образом:

<WorkflowService mc:Ignorable="sap" ConfigurationName="Service1" sap:VirtualizedContainerService.HintSize="339,620" Name="Service1" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/servicemodel" xmlns:d="clr-namespace:DeclarativeServiceLibrary1;assembly=DeclarativeServiceLibrary1" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:p="http://tempuri.org/" xmlns:p1="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:s4="clr-namespace:System;assembly=System.ServiceModel" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
    <p1:Sequence DisplayName="Sequential Service" sad:XamlDebuggerXmlReader.FileName="c:\temp\DeclarativeServiceLibrary1\DeclarativeServiceLibrary1\Service1.xamlx" sap:VirtualizedContainerService.HintSize="309,590" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces"> 
    <p1:Sequence.Variables> 
     <p1:Variable x:TypeArguments="CorrelationHandle" Name="handle" /> 
     <p1:Variable x:TypeArguments="scg3:List(d:Student)" Default="[New List(Of DeclarativeServiceLibrary1.Student)]" Name="students" /> 
    </p1:Sequence.Variables> 
    <sap:WorkflowViewStateService.ViewState> 
     <scg3:Dictionary x:TypeArguments="x:String, x:Object"> 
     <x:Boolean x:Key="IsExpanded">True</x:Boolean> 
     </scg3:Dictionary> 
    </sap:WorkflowViewStateService.ViewState> 
    <Receive x:Name="__ReferenceID0" CanCreateInstance="True" DisplayName="ReceiveRequest" sap:VirtualizedContainerService.HintSize="287,90" OperationName="GetStudents" ServiceContractName="p:IService"> 
     <Receive.CorrelationInitializers> 
     <RequestReplyCorrelationInitializer CorrelationHandle="[handle]" /> 
     </Receive.CorrelationInitializers> 
    </Receive> 
    <p1:ForEach x:TypeArguments="x:Int32" sap:VirtualizedContainerService.HintSize="287,206" Values="[Enumerable.Range(0, 10)]"> 
     <p1:ActivityAction x:TypeArguments="x:Int32"> 
     <p1:ActivityAction.Argument> 
      <p1:DelegateInArgument x:TypeArguments="x:Int32" Name="item" /> 
     </p1:ActivityAction.Argument> 
     <p1:AddToCollection x:TypeArguments="d:Student" Collection="[students]" DisplayName="AddToCollection&lt;Student&gt;" sap:VirtualizedContainerService.HintSize="257,100" Item="[New Student() With {.ID = item, .Name = &quot;Student &quot; &amp; item}]" /> 
     </p1:ActivityAction> 
    </p1:ForEach> 
    <SendReply Request="{x:Reference __ReferenceID0}" DisplayName="SendResponse" sap:VirtualizedContainerService.HintSize="287,90"> 
     <SendParametersContent> 
     <p1:InArgument x:TypeArguments="scg3:List(d:Student)" x:Key="students">[students]</p1:InArgument> 
     </SendParametersContent> 
    </SendReply> 
    </p1:Sequence> 
</WorkflowService> 
Смежные вопросы