zoukankan      html  css  js  c++  java
  • Windows Sharepoint Services v3.0,一个简单的审批工作流

    根据微软的视频作的例子,一个简单的审批流程

    using System;
    using System.ComponentModel;
    using System.ComponentModel.Design;
    using System.Collections;
    using System.Drawing;
    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.Workflow;
    using Microsoft.SharePoint.WorkflowActions;
    using Microsoft.Office.Workflow.Utility;

    namespace DemoReview
    {
        
    public sealed partial class Workflow1 : SharePointSequentialWorkflowActivity
        
    {
            
    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 SPWorkflowTaskProperties taskProps = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
            
    public SPWorkflowTaskProperties afterProps = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
            
    public SPWorkflowTaskProperties beforeProps = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
            
            
    private string assignto = default(System.String);
            
    private string instructions = default(System.String);

            
    private int currentreviewer = 0;

            
    private string itemtitle = default(System.String);

            
    private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
            
    {
                
    this.workflowId = workflowProperties.WorkflowId;

                itemtitle 
    = workflowProperties.Item.DisplayName;

                XmlSerializer myserializer 
    = new XmlSerializer(typeof(myFields));
                XmlTextReader reader 
    = new XmlTextReader(new System.IO.StringReader(workflowProperties.InitiationData));
                myFields myinitf 
    = (myFields)myserializer.Deserialize(reader);

                assignto 
    = (myinitf.assignees).ToString();
                instructions 
    = (myinitf.instructions).ToString();
            }

            
    private void workflownotFinished(object sender, ConditionalEventArgs e)
            
    {
                
    if (this.assignto.Split(Convert.ToChar(";")).Length < currentreviewer + 1)
                
    {
                    e.Result 
    = false;
                }

                
    else
                
    {
                    e.Result 
    = true;
                }

            }


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


            
    private void createTask1_MethodInvoking(object sender, EventArgs e)
            
    {
                taskId 
    = Guid.NewGuid();

                isFinished 
    = false;

                taskProps.Title 
    = "Please Review:" + itemtitle;
                taskProps.AssignedTo 
    = this.assignto.Split(Convert.ToChar(";"))[this.currentreviewer].ToString();
                taskProps.Description 
    = this.instructions;
                taskProps.ExtendedProperties[
    "instructions"= instructions;
            }


            
    private string comment = default(System.String);
            
    private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)
            
    {
                
    this.isFinished = bool.Parse(afterProps.ExtendedProperties["isFinished"].ToString());
                
    this.comment = afterProps.ExtendedProperties["comments"].ToString();
            }


            
    private void completeTask1_MethodInvoking(object sender, EventArgs e)
            
    {
                
    this.currentreviewer++;
            }

        }


    }

  • 相关阅读:
    为什么我们不能坚持到底?
    追从本心,笑斩荆棘
    走出浮躁的泥沼:关于技术与工作
    走出浮躁的泥沼:仅专注就能胜过大部分人
    学不进去?可以试着这么做……
    走出浮躁的泥沼:浮躁的社会原因
    spring-quartz.xml
    1 web.xml配置详解
    多线程学习二
    多线程学习
  • 原文地址:https://www.cnblogs.com/puke/p/901565.html
Copyright © 2011-2022 走看看