使用VS2012 开发SharePoint 2013 客户化的action (代码)
来源:互联网 发布:nginx挂了怎么办 编辑:程序博客网 时间:2024/06/05 15:06
本文讲述使用VS2012 开发SharePoint 2013 客户化的action (代码)。
使用代码 客户化的action的action好处是所有本地代码可以做的事情都可以做,相对声明式的action 更灵活和强大,但是Office 365和SharePoint online是不支持的,只能部署在on-promise 环境。
下面以一个简单需求为例来讲述如何使用代码开发SharePoint 2013 客户化的action:
需求:开发一个action反转一个字符,输入要反转的字符串,输出反转结果
准备工作同:http://blog.csdn.net/abrahamcheng/article/details/12652495
使用VS 2012完成以下工作:
1. 新建一个Workflow library 的项目,命名为CustomCodeActions
2. 在项目中新建 code activity Item
3. ReverseString.cs 内容为:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Activities;namespace CustomCodeActions{ public sealed class ReverseSretring : CodeActivity { // Define an activity input argument of type string [RequiredArgument] public InArgument<string> Input { get; set; } //输入参数 [RequiredArgument] public OutArgument<string> Output { get; set; } // 输出参数 // If your activity returns a value, derive from CodeActivity<TResult> // and return the value from the Execute method. protected override void Execute(CodeActivityContext context) { string input = Input.Get<string>(context); //取得输入参数 char[] arr = input.ToCharArray(); Array.Reverse(arr); string output = new string(arr); Output.Set(context, output); // 设置输出参数 } }}
<?xml version="1.0" encoding="utf-8" ?><AllowedTypes> <Assembly Name="CustomCodeActions"> <Namespace Name="CustomCodeActions"> <Type>ReverseSretring</Type> </Namespace> </Assembly></AllowedTypes>该文件部署时要复制到
%ProgramFiles%\Workflow Manager\1.0\Workflow\Artifacts
%ProgramFiles%\Workflow Manager\1.0\Workflow\WFWebRoot\bin
5. 给项目添加强名
6.编译项目,使用VS2012 Command Prompt运行如下命令取PublickeyToken,第7步会用到它
sn -T CustomCodeActions.dll
7. 新建 ReverseString.actions4,内容为(注意替换PublickeyToken)
<?xml version="1.0" encoding="utf-8"?><WorkflowInfo Language="en-us"> <Actions> <Action Name="ReverseSretring" ClassName="CustomCodeActions.ReverseSretring" Assembly ="CustomCodeActions, Version=1.0.0.0, Culture=neutral, PublickeyToken=e99e4e028044a473" Category="Custom" AppliesTo="all"> <RuleDesigner Sentence="Reverse string %1 and out put to %2"> <!-- Define the UI widgets SharePoint designer should use for configuring this action --> <FieldBind Field="Input" Text="Input string" Id="1" DesignerType="TextOnly" DisplayName="Input string" /> <FieldBind Field="Output" Text="Output string" Id="2" DesignerType="ParameterNames" DisplayName="Output string" /> </RuleDesigner> <Parameters> <Parameter Name="Input" Type="System.String, mscorlib" Direction="In" DesignerType="TextOnly" Description="Input string" /> <Parameter Name="Output" Type="System.String, mscorlib" Direction="Out" DesignerType="ParameterNames" Description="Output string" /> </Parameters> </Action> </Actions></WorkflowInfo>
部署code action:
1.在Workflow manager box上的部署
a.将CustomCodeActions.dll 和AllowedTypes.xml拷贝到如下目录
%ProgramFiles%\WorkflowManager\1.0\Workflow\Artifacts
%ProgramFiles%\WorkflowManager\1.0\Workflow\WFWebRoot\bin
b.重启"Workflow Manager backend"服务
2. 在SharePoint box服务器上的部署
a. 将 CustomCodeActions.dll注册到GAC (使用 gacutil/iCustomCodeActions.dll)
b. 将ReverseString.actions4拷贝到 ~ProgramFiles\Common Files\microsoft shared\Web ServerExtensions\15\TEMPLATE\1033\Workflow
c. 重启IIS
测试CodeAction
1. 清空SharePoint designer 2013 的缓存 C:\Users\v-abchen\AppData\Local\Microsoft\WebsiteCache
2. 启动SharePoint designer 2013,新建一个基于SharePoint 2013 平台的Site workflow
3. 给worklfow添加两个string变量
4. 将messageNeedReverse设置为123456789,并添加ReverString action
5. 输入变量设置为messageNeedReverse,输出变量设置为reversedMessage,将reversedMessage记录到workflow history 中,并添加go to "End of workflow" 结束工作流的语句
6. 启动测试工作流(不要使用系统帐号启动),等待其完成,查看workflow history:
- 使用VS2012 开发SharePoint 2013 客户化的action (代码)
- 使用VS2012 开发SharePoint 2013 声明式的action(activity) 综合实例
- VS2012 开发SharePoint 2013 声明式workflow action(activity)之 HelloWorld
- 使用CSS 客户化 SharePoint 2013 中的 promoted links 样式
- SharePoint 2013 中使用客户化的 (Custom) Filter web part 过滤OOB list view
- SharePoint 2013 用JavaScript 中客户化Field Type时JSLinkUrl 所指向的客户化JS代码只加载第一遍的问题
- 使用vs2012快速提高开发效率的代码
- SharePoint 2013配置开发环境,需安装VS2012插件
- SharePoint 2013 配置开发环境,需安装VS2012插件
- 在VS2012里创建SharePoint Ribbon Custom Action
- SharePoint 2010/2013 创建一个默认值为当前用户的客户化字段
- 使用VS2012进行QT开发的配置
- 使用C#代码部署SharePoint 2013开发包简单总结(一)
- 使用InfoPath和SharePoint Designer进行无代码工作流开发
- SharePoint开发 - 使用Session(代码修改webconfig)
- SharePoint designer 2013 中新的workflow action(操作)
- 使用VS插件在VS2012/2013上编辑和调试Quick-Cocos2d-x的Lua代码
- 使用VS插件在VS2012/2013上编辑和调试Quick-Cocos2d-x的Lua代码
- jQuery插件开发--(转)
- 云畅快转系统
- SQL Server 2005 函数大全
- 剖析<context:component-scan/>、<mvc:annotation-driven/>
- 【cocos2d-x入门之三】cocos2d-x游戏是怎么跑起来的
- 使用VS2012 开发SharePoint 2013 客户化的action (代码)
- 如何卸载编译安装的mysql
- android.uid.system
- 收集的网络上大型的开源图像处理软件代码(提供下载链接)
- Java模拟HTTP的Get和Post请求
- oracle expdp、impdp导入从原表空间更换到其他表空间 ----导入到另个表空间测试
- 局域网实现文件共享
- 【cocos2d-x入门之四】cocos2d-x怎么实现跨平台
- NC57查询引擎-数据交叉技术