使用VS2012 开发SharePoint 2013 声明式的action(activity) 综合实例

本文讲述使用VS2012 开发SharePoint 2013 声明式的action 综合实例。

需求同: http://blog.csdn.net/abrahamcheng/article/details/12612481

基本操作参考: http://blog.csdn.net/abrahamcheng/article/details/12652495

实现步聚 :

1.新建SharePoint 2013 empty solution(选择farm solution或sandbox solution均可)

2. 新建Custom action(命名为 SendTopNNews)

3. 添加Try catch activity 和 定义输入输出参数


4. 定义内部变量


5. 使用Build Dynamic Value构建requestHeader   


6. 使用 httpsend activity 调用web service 返回jsonResult


7. 使用If分支 activity (如果 responsecode 为 OK, 开始构建MailBody, 否则输出错误)


 8. 否定分支

 

9. 条件成立分支

a. 获取记录条数并初始 MailBody


b.添加循环While activity 拼接Mailbody

 b.1 条件为“loopIndex < itemsCount”


b.2 循环体内容


10.在循环体外结束Mailbody


11. 将是否成功的信号变量设置为ture


12. 收起Try-Catch 的 Try  部分,设置Catch部分的异常 处理



13. 更新 SendTopNNews.actions4

<Action Name="SendTopNNews" ClassName="SendTopNNews.SendTopNNews" Category="Custom" AppliesTo="all"> 
    <RuleDesigner Sentence="Web service adress is %1, out put mail body to %2, out put result code to %3">
      <!-- Define the UI widgets SharePoint designer should use for configuring this action -->
      <FieldBind Field="WebServiceUrl" Text="Web service url" Id="1" DesignerType="TextOnly" DisplayName="Web service url" />
      <FieldBind Field="MailBody" Text="return MailBody" Id="2" DesignerType="ParameterNames" DisplayName="return MailBody" />
      <FieldBind Field="Successed" Text="resultCode" Id="3" DesignerType="ParameterNames" DisplayName="resultCode" />
    </RuleDesigner>
    <Parameters>
      <Parameter Name="WebServiceUrl" Type="System.String, mscorlib" Direction="In" DesignerType="TextOnly" Description="Set the WebServiceUrl" />
      <Parameter Name="MailBody" Type="System.String, mscorlib" Direction="Out" DesignerType="ParameterNames" Description="return MailBody" />
      <Parameter Name="Successed" Type="System.Boolean, mscorlib" Direction="Out" DesignerType="ParameterNames" Description="resultCode" />
    </Parameters> 
</Action>


14. 部署解决方案  (action4会被部署到 ~ProgramFilesCommon Filesmicrosoft sharedWeb ServerExtensions15TEMPLATEFEATURESSendTopNNews_Feature1SendTopNNewsSendTopNNews.actions4 , Xaml将会被部署到 ProgramFilesCommon Filesmicrosoft sharedWeb ServerExtensions15TEMPLATEFEATURESSendTopNNews_Feature1SendTopNNewsSendTopNNews.xaml)

15. 清空 SharePoint designer 2013的缓存  C:UsersaliasAppDataLocalMicrosoftWebsiteCache

16. 启动 SharePoint designer 2013,创建测试工作流 



17.发布工作流 ,启动工作流测试并查看结果:





原文地址:https://www.cnblogs.com/pangblog/p/3370774.html