惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News | PayPal Newsroom
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
H
Hacker News: Front Page
Apple Machine Learning Research
Apple Machine Learning Research
TaoSecurity Blog
TaoSecurity Blog
Help Net Security
Help Net Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
人人都是产品经理
人人都是产品经理
博客园 - 三生石上(FineUI控件)
Security Latest
Security Latest
Cloudbric
Cloudbric
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Know Your Adversary
Know Your Adversary
A
Arctic Wolf
L
LangChain Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
W
WeLiveSecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
小众软件
小众软件
NISL@THU
NISL@THU
云风的 BLOG
云风的 BLOG
P
Privacy & Cybersecurity Law Blog
S
Security @ Cisco Blogs
博客园 - 【当耐特】
I
InfoQ
Vercel News
Vercel News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Proofpoint News Feed
O
OpenAI News
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
K
Kaspersky official blog
T
Threat Research - Cisco Blogs
量子位
宝玉的分享
宝玉的分享

博客园 - sumh

用Openxml获取本地文件的扩展信息 用PowerShell批量删除未部署的wsp包 用PowerShell批量收回wsp包 用PowerShell批量部署wsp包 WSS3.0升级到Foundation 2010 PowerShell 操作bcs PowerShell搜索元数据 开发,部署,监视SharePoint 2010的沙盒解决方案 修改MOSS的RTF字段的上传图片功能 高权限的工作流 可重用声明性工作流 站点工作流 工作流事件 可插接式的工作流服务 WF4的新功能 介绍WF4 用Aspx页面做流程表单的一些感想 创建网站集的内容类型 创建Infopath表单数据源的详细步骤图解
sharepoint 2010 beta Workflow
sumh · 2009-12-13 · via 博客园 - sumh
 

一、准备条件

系统:Windows  Server2008Windows Server 2008 R2;

软件:

1、SharePoint Server 2010 Betahttp://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=77c30c6c-47fc-416d-88e7-8122534b3f37

2、Microsoft Visual Studio 2010 Ultimate Beta http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=dc333ac8-596d-41e3-ba6c-84264e761b81

3、Microsoft® SQL Server® 2008 Enterprise Evaluation: Trial Experience for Developershttp://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=6b10c7c1-4f97-42c4-9362-58d4d088cd38

4Office 2010 beta

二、主体

阅读该Demo需要有moss 2007 开发WF 的基础。下载代码

2010 相对于2007创建workflow简单了许多,2010已经将关联任务的内容类型内置到WorkflowElements.xml文件中,初始化表单和关联表单都可以直接创建。

1、表单

初始化表单:

2010中初始化表单已经将创建流程实例的代码自动生成,只需在 GetInitiationData()方法中将初始化表单的数据返回即可。

任务表单:

在工程中添加新项选择应用程序模板,创建任务表单.将表单与关联任务的内容类型连续起来。在任务的内容类型的节点中ContentType〉XmlDocuments>XmlDocument〉FormUrls〉Edit添加任务表单页面。通过Workflow节点的属性TaskListContentTypeId与流程关联。

下列以创建任务表单为例,如下图:

新建项目:

选择模板,SharePoint下面的2010,在选择2010模板下的Application Page。

2、流程设计器

打开vs2010,创建顺序工作流:

如下图:

3、代码

初始化表单GetInitiationData()的代码:

      //Build the AssociationData XML

            StringBuilder associtionDataXML = new StringBuilder();

            associtionDataXML.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");

            associtionDataXML.AppendLine("<workflow>");

            associtionDataXML.AppendLine("<" + this.txtApprover.ID + ">");

            associtionDataXML.AppendLine(this.txtApprover.Text);

            associtionDataXML.AppendLine("</" + this.txtApprover.ID + ">");

            associtionDataXML.AppendLine("</workflow>");

            //End of Build the AssociationData XML

            return associtionDataXML.ToString();

任务表单的代码:

        protected void btnReject_Click(object sender, EventArgs e)

        {

            Hashtable htData = new Hashtable();

            htData["TaskStatus"] = "Completed";

            htData["TaskData"] = "Reject";

            SPListItem _taskItem = this.Web.Lists[new Guid(this.Request.QueryString["List"])].GetItemById(Convert.ToInt32(this.Request.QueryString["ID"]));

            SPWorkflowTask.AlterTask(_taskItem, htData, true);

            Guid workflowInstanceId = new Guid(_taskItem["WorkflowInstanceID"].ToString());

            _workflowInstance = new SPWorkflow(this.Web, workflowInstanceId);

            this.RedirectToListDefaultView();

        }

        protected void btnApproved_Click(object sender, EventArgs e)

        {

            Hashtable htData = new Hashtable();

            htData["TaskStatus"] = "Completed";

            htData["TaskData"] = "Approved";

            SPListItem _taskItem = this.Web.Lists[new Guid(this.Request.QueryString["List"])].GetItemById(Convert.ToInt32(this.Request.QueryString["ID"]));

            SPWorkflowTask.AlterTask(_taskItem, htData, true);

            Guid workflowInstanceId = new Guid(_taskItem["WorkflowInstanceID"].ToString());

            _workflowInstance = new SPWorkflow(this.Web, workflowInstanceId);

            this.RedirectToListDefaultView();

        }

        /// <summary>

        /// 跳转到列表默认视图页面

        /// </summary>

        protected void RedirectToListDefaultView()

        {          

            SPUtility.Redirect(this.WorkflowInstance.TaskList.DefaultViewUrl, SPRedirectFlags.UseSource, this.Context);

        }

流程设计器活动的代码

活动的属性:

        #region Properties
        public Guid workflowId = default(System.Guid);
        public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
        public Guid TaskId = default(System.Guid);
        public SPWorkflowTaskProperties TaskProperties = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
        public String TaskOutcome = default(System.String);

        private string _approver;
        private string _approvalResult;
        #endregion

启动流程:

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

            if (!string.IsNullOrEmpty(workflowProperties.InitiationData))
            {
                XmlDocument AssociationDataXML = new XmlDocument();
                AssociationDataXML.LoadXml(workflowProperties.InitiationData);
                _approver = AssociationDataXML.FirstChild.NextSibling.InnerText.ToString().Trim();
            }
        }

创建任务:

        private void createTask1_MethodInvoking(object sender, EventArgs e)
        {
            TaskId = Guid.NewGuid();
            TaskProperties.AssignedTo = _approver;
            TaskProperties.Title = "Test Title";
        }

审批任务:

       private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)
        {
            _approvalResult = TaskProperties.ExtendedProperties["TaskData"].ToString();

            if (_approvalResult == "Approved")
            {
                this.TaskOutcome = "同意!";
            }
            else if (_approvalResult == "Reject")
            {
                this.TaskOutcome = "拒绝!";
            }
        }
    }

4、 xml文件

Workflow的Elements.xml的任务内容类型节点ContentType

Workflow的Elements.xml的流程Workflow节点

5、效果图

打开SharePoint站点,给Test文档库添加工作流;

Test 文档库

工作流设置

添加工作流

选择该Demo的工作流模板

 创建wf工作流

启动流程

 选择创建好的流程模板

链接到初始化表单,填写一级审批者;

流程已启动并给管理员分配任务,点击进行中,进入流程管理页面;

流程管理页面,任务列表中有未启动的任务。

编辑任务

弹出任务审批表单,审批流程。

审批完成