在MOSS2007中,大家已多次讨论和尝试了,如何在MOSS2007中使用WORKFLOW的功能. 常用的两个开发工具就是Microsoft Visual Studio 2005 Designer for Windowss Workflow Foundation 和 Microsoft Office SharePoint Designer 2007. 用SharePoint Designer2007开发和部署工作流相对比较简单.
接下来,我们就来谈谈如何部署一个用Visual Studio 2005 开发的工作流.此过程需要两个阶段:先部署,再激活.在网上微软介绍的帮助文档,我是看晕了……, 那我还是将我的操作经验一步步的介绍给大家!
一、部署前的准备:
1.将开发好的工作流编译成强名,使用.NET Framework 的强名称工具SN.EXE;
sn.exe -T full path to your filename.dll file. 生成public key token .
2.在sln中增加一个属性定义文件, feature.xml,格式如下
<?xml version="1.0" encoding="utf-8"?>
<!-- _lcid="1033" _version="12.0.3111" _dal="1" -->
<!-- _LocalBinding -->
<Feature Id="[guid]"
Title="[workflow template title]"
Description="[workflow description]"
Version="1.0.0.0"
Scope="Site"
ReceiverAssembly="Microsoft.Office.Workflow.Feature, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
ReceiverClass="Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="workflow.xml" />
</ElementManifests>
<Properties>
<Property Key="GloballyAvailable" Value="true" />
<!-- Value for RegisterForms key indicates the path to the forms relative to feature file location -->
<!-- if you don't have forms, use *.xsn -->
<Property Key="RegisterForms" Value="*.xsn" />
</Properties>
</Feature>
3.在sln中增加一个工作流定义文件, Workflow.xml,格式如下
<?xml version="1.0" encoding="utf-8" ?>
<!-- _lcid="1033" _version="12.0.3015" _dal="1" -->
<!-- _LocalBinding -->
<!-- Insert Workflow.xml Code Snippet here. To do this:
1) Right click on this page and select "Insert Snippet" (or press Ctrl+K, then X)
2) Select SharePoint Workflow->Workflow Template->Workflow.xml Code -->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Workflow
Name="[workflow name]"
Description="[workflow description]"
Id="[guid]"
CodeBesideClass="[workflow class]"
CodeBesideAssembly="[namespace], Version=1.0.0.0, Culture=neutral, PublicKeyToken=[public key token在步骤1中生成的]"
TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160"
AssociationUrl="_layouts/CstWrkflIP.aspx"
InstantiationUrl="_layouts/IniWrkflIP.aspx"
ModificationUrl="_layouts/ModWrkflIP.aspx">
<Categories/>
<!-- Tags to specify InfoPath forms for the workflow; delete tags for forms that you do not have -->
<MetaData>
<Instantiation_FormURN>urn:schemas-microsoft-com:office:infopath:ReviewInitiationForm2:-myXSD-2005-11-22T23-49-53</Instantiation_FormURN>
<Association_FormURN>urn:schemas-microsoft-com:office:infopath:ReviewInitiationForm2:-myXSD-2005-11-22T23-49-53</Association_FormURN>
<Task0_FormURN>urn:schemas-microsoft-com:office:infopath:ReviewTaskForm:-myXSD-2005-11-22T23-52-35</Task0_FormURN>
<StatusPageUrl>_layouts/WrkStat.aspx</StatusPageUrl>
</MetaData>
</Workflow>
</Elements>
4.在sln中编译项目;
5.接下来,我们使用一个install.bat文件来帮助你部署和激活你的工作流(因为以前写的很多工作流流程,发现不能自动的激活,造成在,进行工作流的选择时,无法发现自已的部署到MOSS中的工作流,后来发现需要激活用户自定义的工作流.在MOSS2007管理中心中,选择"站点设置",在"galleries"选项中找到"workflow"选项,你会查询到所有系统级的工作流名称和状态,但在此处你无法激活它,我们必须使用命令STSAMD来激活它,请见install.bat文件的具体内容)
:: Before running this file, sign the assembly in Project properties项目一定使用强名
::
:: To customize this file, find and replace
:: a) "[feature name]" with your own feature name
:: b) "feature.xml" with the name of your feature.xml file
:: c) "workflow.xml" with the name of your workflow.xml file
:: d) "http://localhost" with the name of the site you wish to publish to这是你想部署工作流所在网站或网站集的地址
echo Copying the feature...拷贝属性文件 创建一个名称为workflowdemo的目录名,将feature.xml workflow.xml 及所有xsn的文件拷过去
echo.
rd /s /q "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\workflowdemo"
mkdir "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\workflowdemo"
copy /Y feature.xml "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\workflowdemo\"
copy /Y workflow.xml "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\workflowdemo\"
xcopy /s /Y *.xsn "%programfiles%\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\workflowdemo\"
echo.
echo Adding assemblies to the GAC...增加GAC文件到系统目录
echo.
"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" -uf namespace.classname
"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" -if bin\Debug\namespace.classname.dll
echo.
echo Activating the feature...
echo.
pushd %programfiles%\common files\microsoft shared\web server extensions\12\bin
stsadm -o deactivatefeature -filename workflowdemo\feature.xml -url http://localhost
stsadm -o uninstallfeature -filename workflowdemo\feature.xml
stsadm -o installfeature -filename workflowdemo\feature.xml -force
stsadm -o activatefeature -filename workflowdemo\feature.xml -url http://localhost
echo Doing an iisreset...
echo.
popd
iisreset
至此,你自定义的工作流就可能使用了:)
浙公网安备 33010602011771号