自定义一个SharePoint Designer Workflow 所用的Activity

     如果你要做的workflow不是那么的通用的,也不是那么的复杂,那么SharePoint Designer是你的一个非常好的选择。通过它,你能够不用写一行代码就可以做出一些像模像样的workflow。Designer里面内置一些Activaty,但是这些在有的时候并不能完全满足你的要求,这个时候,也许你想自己写一个特殊的Activaty来满足自己的需求。在我的这个Activity中,我实现的功能是从一个list中得到最大的ID,然后返回。

     1.我用的是VS2008.File->New->Project->C#->workflow->Workflow Activity Library

     2.强签名,因为这个dll要放到GAC中。在Solution Explorer中右键点击Project->Properties->Signing->New->输入一个name,不要勾选复选框。

     3.对workflow中需要用到的变量进行定义,这里只是输出一个int类型的变量。

     

ContractedBlock.gif ExpandedBlockStart.gifCode
public static DependencyProperty IDNumberProperty = DependencyProperty.Register("IDNumber",typeof(int),typeof(GetID));


        [Category("Customer"),Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public int IDNumber
        {
            get { return ((int)base.GetValue(GetID.IDNumberProperty)); }
            set { base.SetValue(GetID.IDNumberProperty, value); }
        }

     4. 对于一个Activaty,真正做事情的是下面这个函数,你只需要重写这个函数就可以。对于返回值,ActivityExecutionStatus.Closed是正常情况下的一个返回值,其它的情况,请查看MSDN。

     

ContractedBlock.gif ExpandedBlockStart.gifCode
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
           
            //Do Everything you like.
            return ActivityExecutionStatus.Closed;
        }

 

     5.Build这个Project。可以将dll放置到GAC下。

     6.在你想使用这个Activity的web application下的web.config文件的<authorizedTypes>中加入下面一行。你可以用Reflector得到相应的信息。

     

ContractedBlock.gif ExpandedBlockStart.gifCode
<authorizedType Assembly="**, Version=1.0.0.0, Culture=neutral, PublicKeyToken=<Insert Your PublicKeyToken Here> " Namespace="**" TypeName="*" Authorized="True" /> 

 

     7.到C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\Workflow 打开wss.actions文件,在<actions></actions>中加入以下

     

ContractedBlock.gif ExpandedBlockStart.gif Code
<Action Name="Get the ID number form the Task list"
      ClassName
="**"
      Assembly
="**"
      Category
="Customer"
      AppliesTo
="all">
  
<RuleDesigner Sentence="Set the ID number to %1">//%1 就像printf中的%s类似,只不过%1代表第一个参数,下一行Id=1的参数就是和%1相对应
    <FieldBind Field="IDNumber" Text="The number of ID" DesignerType="ParameterNames" Id="1"/>
  
</RuleDesigner>
  
<Parameters>
    
<Parameter Name="IDNumber" Type="System.Int32,mscorlib" Direction="Out"/>
  
</Parameters>
</Action>

 

     好了,你可以在SharePoint Designer中使用这个Activity了

     

转载于:https://www.cnblogs.com/jdxyw/archive/2008/11/27/1342000.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值