2012-02-29 5 views
-1

Microsoft wf 샘플 프로젝트로 작업하고 있습니다. WF_WCF_Samples \ WF \ Application \ VisualWorkflowTracking \ CS 이 샘플 프로젝트는 wf4 시뮬레이션을 실행합니다.워크 플로가 제대로 실행되지 않지만 예외가 throw되지 않습니다.

워크 플로에 입력 bool 인수가 있습니다.

현재 두 가지 문제점이 있습니다.

첫 번째 문제는 : 코드 실행되지만 시뮬레이션이 실행되지 않을 때

내가 인수 (워크 플로우 디자이너)에 값을 입력하면, 나는 예외를하지 않습니다.

코드를 수정하고 인수 컬렉션을 가져 오려고했습니다. 그런 다음 Dictionary에 추가 한 다음 Invoke Method로 전달합니다. 이 방법을 사용하면 오류가 발생하지 않지만 프로세스가 시작되지 않습니다. 논쟁의 가치가 사전에 제대로 전달되지 않았다고 생각합니다. 다음은 코드입니다.

ThreadPool.QueueUserWorkItem(new WaitCallback((context) => 
{ 

    bool noArguments = false; 

    var serviceManager = this.WorkflowDesigner.Context.Services; 

    Dictionary<string, object> retval = new Dictionary<string, object>(); 
    var modelService = serviceManager.GetService<ModelService>(); 
    var rootModelItem = modelService.Root; 

    var properties = rootModelItem.Properties["Properties"]; 
    if (properties == null) noArguments = true; 

    var propertiesCollection = properties.Collection; 
    if (propertiesCollection == null) noArguments = true; 
    if (propertiesCollection.Count == 0) noArguments = true; 

    foreach (var p in propertiesCollection) 
    { 
     var d = p.GetCurrentValue() as DynamicActivityProperty; 
     if (d != null) 
     { 
      var name = d.Name; 
      dynamic inArgument = d.Value; 

      try 
      { 
       var val = inArgument.Expression.Value; 
       retval.Add(name, val); 
      } 
      catch (Exception er) 
      { 
       MessageBox.Show("Variable: " + d.Name + " Value is Empty", "Variable Error",MessageBoxButton.OK,MessageBoxImage.Error); 
      } 
     } 

    } 

    //Invoking the Workflow Instance with Input Arguments 
    if (noArguments) 
    { 
     instance.Invoke(); 
    } 
    else 
    { 
     //this line below does raise any error but it does not run the process. 
     //instance.Invoke(retval, new TimeSpan(1, 0, 0)); 

//this line below works as long as in the workflow designer the argument value is left blank 
     instance.Invoke(new Dictionary<string, object> { { "decisionVar", "hello" } }, new TimeSpan(1, 0, 0)); 
    } 


    //This is to remove the final debug adornment 
    this.Dispatcher.Invoke(DispatcherPriority.Render 
     , (Action)(() => 
    { 
     this.WorkflowDesigner.DebugManagerView.CurrentLocation = new SourceLocation(this.WorkFlowFile,1,1,1,10); 
     //this.WorkflowDesigner.DebugManagerView.CurrentLocation = new SourceLocation("Workflow.xaml",1,1,1,10); 
    })); 

})); 

답변

1

예외가 발생하고 작업중인 스레드가 종료되었을 수 있습니다. try/catch 블록으로 모든 것을 둘러싸고 예외를 기록 할 수 있습니다.

+0

안녕하세요, 제 질문에 대한 의견을 보내 주셔서 감사합니다. – user1239078

+0

안녕하세요, 론, 내 질문에 대해 논평 할 시간을내어 주셔서 감사합니다. WCF 및 WF에 MS 샘플을 다운로드했습니다. WF_WCF_Samples \ WF \ Application \ VisualWorkflowTracking \ CS VisualWorkflowTracking.sln 프로젝트를 엽니 다. F5를 누르고 디버그하는 동안 응용 프로그램에서 "파일"을 클릭 한 다음 "워크 플로 실행"을 클릭합니다. 시뮬라톤이 실행되는 것을 볼 수 있습니다. 이제 다음을 시도해보십시오. 디버그를 중지하고 디자인 모드에서 워크 플로우를 열고 "desicionVar"라는 인수가 있습니다. "기본값"에 값을 입력하십시오. 참 또는 거짓. 다시 실행하면 시뮬레이션이 실행되지 않음을 알 수 있습니다. – user1239078

+0

샘플 코드에서 "WorkflowDesignerHost.xaml.cs"파일에 하드 코딩 된 값을 기본값으로 전달하는 줄이 있습니다. 줄은 다음과 같습니다. instance.Invoke (새 사전 {{"decisionVar ", true}}, 새 TimeSpan (1, 0, 0)); 워크 플로 디자이너에서 decisionVar 인수에 "기본값"을 입력 한 후 시뮬레이션이 실행되지 않는 이유를 모르겠습니까? 컴파일 중 또는 실행 중 오류가 표시되지 않습니다. 내 질문에 대한 답변을 얻으십시오. 여기에 설명 된 내용을 복제 할 수 있는지 알려주십시오. – user1239078

관련 문제