Visual Studio を使ったワークフローの作成

スクリーンキャスト

このデモでは、Visual Studio 2008 (旧称:Visual Studio Codename “Orcas”) の Beta 2 を使用しています。このデモで使用されているクラス、メソッドなどについては今後変更される可能性がありますのでご注意ください。

このデモの内容

ここでは、Visual Studio を使用したワークフローの作成方法についてご紹介します。

デモでご紹介しているソースコード

【ワークフロークラス (C#) 】

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 System.Xml.Serialization;
using System.Xml;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WorkflowActions;
using Microsoft.Office.Workflow.Utility;

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

        public Guid workflowId = default(System.Guid);
        public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties workflowProperties = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties();
        public Guid taskId = default(System.Guid);
        public Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties taskProperties = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();

        private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
        {
            workflowId = workflowProperties.WorkflowId;
            taskId = Guid.NewGuid();
            taskProperties.AssignedTo = System.Threading.Thread.CurrentPrincipal.Identity.Name;
            taskProperties.Title = "確認をお願いします";
        }

        public Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties afterProperties = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();

        private bool isComplete = false;
        private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)
        {
            if (afterProperties.PercentComplete == 1)
                isComplete = true;
        }

        private void isFinished(object sender, ConditionalEventArgs e)
        {
            e.Result = !isComplete;
        }
    }

}

![](images/cc707258.top(ja-jp, MSDN.10).gif)ページのトップへ