0
static void Main(string[] args)
{
WorkflowDbContext db = new WorkflowDbContext();
var workflowFromDb = db.Workflows.Find("1");
string workFlowDefinition = workflowFromDb.WorkflowDefinition;
ActivityXamlServicesSettings settings = new ActivityXamlServicesSettings
{
CompileExpressions = true
};
}
나는이 때 :이 워크 플로를 호출하려면 어떻게해야합니까?
DynamicActivity<int> wf = ActivityXamlServices.Load(new StringReader(workFlowDefinition), settings) as DynamicActivity<int>;
내가 얻을이 오류 :
CacheMetadata for activity 'PeakTriggerActivities.SalesToService' threw 'System.Xaml.XamlObjectWriterException: Cannot create unknown type '{clr-namespace:PeakTriggerActivities}GetTouchPoint'.
나는 또한이 시도했지만, WF 다만이 경우에는 null 값이된다 :
//Encoding this way since xml file shows utf-16
MemoryStream mStream = new MemoryStream(Encoding.Unicode.GetBytes(workFlowDefinition));
//Also tried LocalAssembly = System.Reflection.Assembly.GetExecutingAssembly() instead of LocalAssembly = typeof(GetTouchPoint).Assembly
DynamicActivity<int> wf = ActivityXamlServices.Load(new XamlXmlReader(mStream, new XamlXmlReaderSettings { LocalAssembly = typeof(GetTouchPoint).Assembly }), settings) as DynamicActivity<int>;
을
이것은 workFlowDefinition 문자열에 포함되어 있으며 GetTouchPoint라는 클래스는 다음과 같은 프로젝트에 있습니다. program.cs에서이 주요 방법 :
<?xml version="1.0" encoding="utf-16"?>
<Activity mc:Ignorable="sap sap2010 sads" x:Class="PeakTriggerActivities.SalesToService" sap2010:ExpressionActivityEditor.ExpressionActivityEditor="C#" sap2010:WorkflowViewState.IdRef="PeakTriggerActivities.SalesToService_1"
xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
xmlns:local="clr-namespace:PeakTriggerActivities"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mca="clr-namespace:Microsoft.CSharp.Activities;assembly=System.Activities"
xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
xmlns:t="clr-namespace:TouchPointModels;assembly=TouchPointModels"
xmlns:t1="clr-namespace:TouchPointServices;assembly=TouchPointService"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextExpression.NamespacesForImplementation>
<sco:Collection x:TypeArguments="x:String">
<x:String>System</x:String>
<x:String>System.Collections.Generic</x:String>
<x:String>System.Data</x:String>
<x:String>System.Linq</x:String>
<x:String>System.Text</x:String>
<x:String>TouchPointModels</x:String>
</sco:Collection>
</TextExpression.NamespacesForImplementation>
<TextExpression.ReferencesForImplementation>
<sco:Collection x:TypeArguments="AssemblyReference">
<AssemblyReference>Microsoft.CSharp</AssemblyReference>
<AssemblyReference>PresentationCore</AssemblyReference>
<AssemblyReference>PresentationFramework</AssemblyReference>
<AssemblyReference>System</AssemblyReference>
<AssemblyReference>System.Activities</AssemblyReference>
<AssemblyReference>System.Activities.Presentation</AssemblyReference>
<AssemblyReference>System.Core</AssemblyReference>
<AssemblyReference>System.Data</AssemblyReference>
<AssemblyReference>System.Runtime.Serialization</AssemblyReference>
<AssemblyReference>System.ServiceModel</AssemblyReference>
<AssemblyReference>System.ServiceModel.Activities</AssemblyReference>
<AssemblyReference>System.ServiceModel.Channels</AssemblyReference>
<AssemblyReference>System.Xaml</AssemblyReference>
<AssemblyReference>System.Xml</AssemblyReference>
<AssemblyReference>System.Xml.Linq</AssemblyReference>
<AssemblyReference>WindowsBase</AssemblyReference>
<AssemblyReference>TouchPointModels</AssemblyReference>
<AssemblyReference>TouchPointService</AssemblyReference>
<AssemblyReference>mscorlib</AssemblyReference>
<AssemblyReference>PeakTriggerActivities</AssemblyReference>
</sco:Collection>
</TextExpression.ReferencesForImplementation>
<Sequence sap2010:WorkflowViewState.IdRef="Sequence_1">
<Sequence.Variables>
<Variable x:TypeArguments="x:String" Name="varTouchPointCode" />
<Variable x:TypeArguments="t:TouchPoint" Name="varTouchPoint" />
<Variable x:TypeArguments="x:Int32" Name="varProgramNumber" />
</Sequence.Variables>
<local:GetTouchPoint Text="{x:Null}" sap2010:WorkflowViewState.IdRef="GetTouchPoint_1" InProgramNumber="1" InTouchPointCode="SATM">
<local:GetTouchPoint.OutProgramNumber>
<OutArgument x:TypeArguments="x:Int32">
<mca:CSharpReference x:TypeArguments="x:Int32">varProgramNumber</mca:CSharpReference>
</OutArgument>
</local:GetTouchPoint.OutProgramNumber>
<local:GetTouchPoint.OutTouchPoint>
<OutArgument x:TypeArguments="t:TouchPoint">
<mca:CSharpReference x:TypeArguments="t:TouchPoint">varTouchPoint</mca:CSharpReference>
</OutArgument>
</local:GetTouchPoint.OutTouchPoint>
<local:GetTouchPoint.OutTouchPointCode>
<OutArgument x:TypeArguments="x:String">
<mca:CSharpReference x:TypeArguments="x:String">varTouchPointCode</mca:CSharpReference>
</OutArgument>
</local:GetTouchPoint.OutTouchPointCode>
</local:GetTouchPoint>
<If sap2010:WorkflowViewState.IdRef="If_1">
<If.Condition>
<InArgument x:TypeArguments="x:Boolean">
<mca:CSharpValue x:TypeArguments="x:Boolean">varTouchPoint == null</mca:CSharpValue>
</InArgument>
</If.Condition>
<If.Then>
<WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_1">
<InArgument x:TypeArguments="x:String">
<mca:CSharpValue x:TypeArguments="x:String">"Cannot find Touchpoint Code :" + varTouchPointCode</mca:CSharpValue>
</InArgument>
</WriteLine>
</If.Then>
<If.Else>
<Sequence sap2010:WorkflowViewState.IdRef="Sequence_2">
<WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_3">
<InArgument x:TypeArguments="x:String">
<mca:CSharpValue x:TypeArguments="x:String">"Processing Touchpoint: " + varTouchPoint.Code + " - " + varTouchPoint.Name</mca:CSharpValue>
</InArgument>
</WriteLine>
<t1:ProcessTouchPoint InTouchPoint="{x:Null}" Success="{x:Null}" Text="{x:Null}" sap2010:WorkflowViewState.IdRef="ProcessTouchPoint_1">
<t1:ProcessTouchPoint.InProgramNumber>
<InArgument x:TypeArguments="x:Int32">
<mca:CSharpValue x:TypeArguments="x:Int32">varProgramNumber</mca:CSharpValue>
</InArgument>
</t1:ProcessTouchPoint.InProgramNumber>
<t1:ProcessTouchPoint.InTouchPointCode>
<InArgument x:TypeArguments="x:String">
<mca:CSharpValue x:TypeArguments="x:String">varTouchPointCode</mca:CSharpValue>
</InArgument>
</t1:ProcessTouchPoint.InTouchPointCode>
</t1:ProcessTouchPoint>
</Sequence>
</If.Else>
</If>
<sads:DebugSymbol.Symbol>d0tDOlxwcm9qZWN0c1xQZWFrVHJpZ2dlckFjdGl2aXRpZXNcUGVha1RyaWdnZXJBY3Rpdml0aWVzXFNhbGVzVG9TZXJ2aWNlLnhhbWwRMANrDgIBATYFRhsCARtHBWkKAgECNoEBNocBAgEpOQs5YAIBJUMLQ2ICASE+Cz5iAgEdNmw2bwIBHEoLSl8CAQNOCVIVAgEWVQlnFAIBB1ANUH4CARdWC1oXAgERWwtmIgIBCFgPWJgBAgESYxFjYAIBDV4RXl4CAQk= </sads:DebugSymbol.Symbol>
</Sequence>
<sap2010:WorkflowViewState.ViewStateManager>
<sap2010:ViewStateManager>
<sap2010:ViewStateData Id="GetTouchPoint_1" sap:VirtualizedContainerService.HintSize="469,22" />
<sap2010:ViewStateData Id="WriteLine_1" sap:VirtualizedContainerService.HintSize="211,62" />
<sap2010:ViewStateData Id="WriteLine_3" sap:VirtualizedContainerService.HintSize="211,62" />
<sap2010:ViewStateData Id="ProcessTouchPoint_1" sap:VirtualizedContainerService.HintSize="211,22" />
<sap2010:ViewStateData Id="Sequence_2" sap:VirtualizedContainerService.HintSize="233,248">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</sap2010:ViewStateData>
<sap2010:ViewStateData Id="If_1" sap:VirtualizedContainerService.HintSize="469,398" />
<sap2010:ViewStateData Id="Sequence_1" sap:VirtualizedContainerService.HintSize="491,584">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg:Dictionary></sap:WorkflowViewStateService.ViewState>
</sap2010:ViewStateData>
<sap2010:ViewStateData Id="PeakTriggerActivities.SalesToService_1" sap:VirtualizedContainerService.HintSize="531,664" />
</sap2010:ViewStateManager>
</sap2010:WorkflowViewState.ViewStateManager>
</Activity>
아마도 이것은 실제 문제와 우연히 만나는 해결책은 아닙니다 ... 일어나지 않았습니까? 어쨌든, 어셈블리 바인딩 로그를 사용하여 향후 이와 같은 문제를 디버깅해야합니다 (자세한 내용은 fuslogvw 검색). – Will