.ACTIONS文件路径: |
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\2052\Workflow\ |
1.主要节点概述
节点名称 |
父节点 |
含义 |
<WorkflowInfo> |
无 |
头节点 |
<Actions> |
<WorkflowInfo> |
|
<Action> |
<Actions> |
定义工作流操作 |
<RuleDesigner> |
<Action> |
具体操作中显示的信息,已经参数位置 |
<FieldBind> |
<RuleDesigner> |
控制Designer中操作显示的信息,以及参数默认类型默认文本 |
<Option> |
<FieldBind> |
可自定义FielBind内的值 |
<Parameters> |
<Action> |
定义对应程序集属性的参数集 |
<Parameter> |
<Parameters> |
参数与引用程序集对应的信息,如类型、名称等 |
2.节点属性
2.1 <WorkflowInfo>
属性 |
含义 |
2.2 <Actions>
属性 |
含义 |
Sequential |
|
Parallel |
|
2.3 <Action>
属性 |
含义 |
Name |
操作的名称 |
ClassName |
引用的程序集 |
Assembly |
程序集信息(集名、版本、Culture、公钥) |
AppliesTo |
|
Category |
在Designer中的操作选择项中的类表(自定义) |
2.4 <RuleDesigner>
属性 |
含义 |
Sentence |
选择操作以后显示的信息,如果句子有参数,在需要加参数的地方插入 [%+数字],如:%1 |
2.5 <FieldBind>
属性 |
含义 |
Field |
参数名称 |
DesignerType |
定义Designer输入参数的方式 |
Text |
默认显示的文本 |
Id |
对应父节点Sentence属性中的参数编号,如:对应父节点的%1 则 id=”1” |
2.6 <Parameters>
属性 |
含义 |
2.7 <Parameter>
属性 |
含义 |
Name |
参数名称,必须与引用程序集中声明的属性同名 |
Type |
参数在Designer中的默认值 |
Direction |
定义变量是输出还是输入,值为 ”Out”、 “In”、” Optional” |
3.节点属性参数取值含义详解
3.1 <WorkflowInfo>
3.2 <Actions>
参数名 |
含义 |
|
|
参数名 |
含义 |
|
|
3.4 <Action>
3.5 <RuleDesigner>
3.6 <FieldBind>
参数名 |
含义 |
ParameterNames |
|
ChooseListItem |
|
ListNames |
|
ChooseDoclibItem |
|
TextArea |
|
FieldName |
|
Stringbuilder |
|
Operator |
|
Integer |
|
Dropdown |
|
Date |
|
Email |
|
3.7 <Parameters>
3.8 <Parameter>
参数名 |
含义 |
In |
|
Out |
|
Optional |
|
4. Actions文件实例
<?xml version="1.0" encoding="utf-8" ?>
<WorkflowInfo>
<Actions Sequential="then" Parallel="and">
<Action Name="从用户中获取名称"
ClassName="MyCustomActivity.EventLogger"
Assembly="MyCustomActivity.EventLogger, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0d31bafc5a063039"
AppliesTo="all"
Category="自定义工作流操作">
<RuleDesigner Sentence="将 %1 转化为 %2 ">
<FieldBind Field="UserName" DesignerType="parameterNames" Text="名称" Id="1" />
<FieldBind Field="UserLoginName" DesignerType="parameterNames" Text="工程师帐号" Id="2" />
</RuleDesigner>
<Parameters>
<Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions" Direction="In"/>
<Parameter Name="UserName" Type="System.String, mscorlib" Direction="In" />
<Parameter Name="UserLoginName" Type="System.String, mscorlib" Direction="Out" />
</Parameters>
</Action>
</Actions>
</WorkflowInfo> |
1. 工作流项目模板
2. 开发实例
public static DependencyProperty LoginNameProperty =
System.Workflow.ComponentModel.DependencyProperty.Register("LoginName",typeof(string),typeof(Activty1));
[Category("自定义工作流操作"), Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string LoginName{
get{
return ((string)(base.GetValue(LoginNameProperty)));
}
set{
base.SetValue(LoginNameProperty, value);
}
} |
public static DependencyProperty NameProperty =
System.Workflow.ComponentModel.DependencyProperty.Register("Name", typeof(string), typeof(Activty1));
[Category("自定义工作流操作"), Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string Name{
get{
return ((string)(base.GetValue(NameProperty)));
}
set{
base.SetValue(NameProperty, value);
}
} |
public static DependencyProperty __ContextProperty =
DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(EventLogger));
[ValidationOption(ValidationOption.Required)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public WorkflowContext __Context{
get{
return (WorkflowContext)base.GetValue(__ContextProperty);
}
set{
base.SetValue(__ContextProperty, value);
}
} |
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI |
gacutil /i DLL在本机的路径 |
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext){
try{
// 定义 SPUserCollection 从 __Context 中获取MOSS站点所有用户信息
SPUserCollection spUserCollection = __Context.Web.AllUsers;
// 定义 foreach 循环
foreach (SPUser spUser in spUserCollection){
// 判断对比用户的登录帐号
if (spUser.LoginName == LoginName){
// 将用户的姓名存储到 NameProperty 属性中
base.SetValue(NameProperty, spUser.Name);
break;
}
}
}
catch(){}
return ActivityExecutionStatus.Closed;
} |
3. 部署
sn –T DLL路径 |
gacutil /i DLL路径 |
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\2052\Workflow\ |
<?xml version="1.0" encoding="utf-8" ?>
<WorkflowInfo>
<Actions Sequential="then" Parallel="and">
<Action Name="从用户帐号获取用户名字"
ClassName="ActivityLibrary1.ActivityLibrary1"
Assembly="ActivityLibrary1.ActivityLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=DLL的PublicKeyToken "
AppliesTo="all"
Category="自定义工作流操作">
<RuleDesigner Sentence="从 %1 获取 %2 ">
<FieldBind Field="LoginName" DesignerType=" SinglePerson" Text="帐号" Id="1" />
<FieldBind Field="Name" DesignerType="parameterNames" Text="名字" Id="2" />
</RuleDesigner>
<Parameters>
<Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions" Direction="In"/>
<Parameter Name="LoginName" Type="System.String, mscorlib" Direction="In" />
<Parameter Name="Name" Type="System.String, mscorlib" Direction="Out" />
</Parameters>
</Action>
</Actions>
</WorkflowInfo> |
<authorizedType Assembly=" ActivityLibrary1.ActivityLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken= DLL的PublicKeyToken " Namespace=" ActivityLibrary1" TypeName="*" Authorized="True" /> |
Iisreset /noforce |