2

VS 2010 で簡単なワークフローを作成しました。人のタスクを作成し、その人がタスクのステータスを「完了」に変更すると、メッセージがワークフロー履歴に記録されます。

ステータスを完了に変更すると、「xxxx (ワークフロー名) でエラーが発生しました」と表示されます。

コード:

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;

namespace WorkflowProject2.Workflow1
 {
 public sealed partial class Workflow1 : SequentialWorkflowActivity
 {
     public Workflow1()
     {
         InitializeComponent();
     }

    public Guid workflowId = default(System.Guid);
     public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();

    private void onWorkflowActived(object sender, ExternalDataEventArgs e)
     {

    }

    public Guid taskID = default(System.Guid);
     public SPWorkflowTaskProperties taskProperties = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
     private bool taskHasCompleted = false;

    public SPWorkflowTaskProperties taskAfterProperties = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
     public SPWorkflowTaskProperties taskBeforeProperties = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
     public String taskOutcome = default(System.String);
     public Guid TaskStatusFieldID = new Guid("c15b34c3-ce7d-490a-b133-3f4de8801b76");  

    private void createTask1_MethodInvoking(object sender, EventArgs e)
     {

        taskID = Guid.NewGuid();
         taskProperties.AssignedTo = "spdev\\lzhang";
         taskProperties.Description = "Please review";
         taskProperties.Title = "Leave application";

    }

     private void completeTask1_MethodInvoking(object sender, EventArgs e)
     {
         // Finalize the task:
         taskAfterProperties.PercentComplete = 100;
         taskOutcome = "Completed";
     }

    private void notComplete(object sender, ConditionalEventArgs e)
     {
         e.Result = !taskHasCompleted;    // **(A)**
     }
     private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)
     { 
        string taskStatus = taskAfterProperties.ExtendedProperties[TaskStatusFieldID].ToString();

        if (taskStatus == "Completed")
         {
             taskHasCompleted = true;     // **(B)**

        }

    }

}
 }

(A)または(B)に何か問題があるに違いないと感じていますが、それを修正する方法がわかりません。14/LOGS フォルダー内のログ ファイルにエラーは見つかりませんでした...

どんな助けにも感謝します!ありがとう!

4

4 に答える 4

1

I have found the problem! It was because in "Workflow1.cs[design]" (the design view) I didn't specify the TaskID for "completeTask1" in the "Properties box". By default it is "00000000-0000-0000-000000000000", I should have changed it to "taskID".

于 2012-11-21T23:56:59.807 に答える
0

ワークフローで現在のタスク ID を取得するには、投稿 http://blog.technovert.com/2013/12/solved-taskid-without-using-ontaskcreated/を読むことをお勧めします。

于 2013-12-17T06:59:45.540 に答える