转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/

对于SharePoint中已经是Record的Item,我们想要修改他的属性,这在UI界面是无法完成的:

这时需要通过Records.BypassLocks API来完成。设计一个tool,利用Records.BypassLocks API来修改Recorded Items的属性(这里拿Title举例),界面如下:

代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
//Assembly: Microsoft.Office.Policy (in Microsoft.Office.Policy.dll)
using Microsoft.Office.RecordsManagement.RecordsRepository;
using Microsoft.SharePoint.Publishing; namespace BypassLocksTestTool
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void test_button_Click(object sender, EventArgs e)
{
try
{
SPSecurity.RunWithElevatedPrivileges(delegate ()
{
SPSite site = new SPSite(siteURL_textBox.Text);
SPWeb web = site.RootWeb;
SPList list = web.Lists[listTitle_textBox.Text];
SPListItem item = list.Items[];
Records.BypassLocks(item, delegate (SPListItem spListItem)
{
//Do your stuff here.
item["Title"] = itemTitle_textBox.Text;
item.Update();
if (list.Items[].Title == itemTitle_textBox.Text)
{
testResult_richTextBox.Text = "Test result is passed! Now the first item's title is: " + list.Items[].Title;
testResult_richTextBox.Select(, testResult_richTextBox.Text.Length);
testResult_richTextBox.SelectionColor = Color.Green;
}
else
{
testResult_richTextBox.Text = "Test result is failed!";
testResult_richTextBox.Select(, testResult_richTextBox.Text.Length);
testResult_richTextBox.SelectionColor = Color.Red;
}
});
});
}
catch (Exception ex)
{
testResult_richTextBox.Text = ex.ToString();
}
}
}
}

点击Test按钮进行测试,测试结果会回显到界面,如果Title的value完成了修改,则算测试通过;否则算测试失败。

测试通过后,我们去SharePoint中查看Item的属性,结果和我们预期的一样,对应Item的Title属性值已经变为“SuperTylan”:

这就是对于Records.BypassLocks API的使用与测试,它让我们修改locked recorded item的属性与内容成为可能。

SharePoint API测试系列——Records.BypassLocks测试的更多相关文章

  1. 【转】【iOS测试系列】常用测试小插件的使用

    背景介绍 由于iOS系统的限制,在非越狱的自动化测试中无法实现一些常用的功能,比如不同应用之间来回切换.模拟全局的点击事件等等.但是在越狱的环境下,这些限制就不存在了,我们可以利用各种小插件来实现我们 ...

  2. ASP.NET Web API 2系列(三):查看WebAPI接口的详细说明及测试接口

    引言 前边两篇博客介绍了Web API的基本框架以及路由配置,这篇博客主要解决在前后端分离项目中,为前端人员提供详细接口说明的问题,主要是通过修改WebApi HelpPage相关代码和添加WebAp ...

  3. 「译」JUnit 5 系列:条件测试

    原文地址:http://blog.codefx.org/libraries/junit-5-conditions/ 原文日期:08, May, 2016 译文首发:Linesh 的博客:「译」JUni ...

  4. "Unity测试系列"文章索引

    对Unity各种API的细节进行测试 Common 一些Unity基础操作的性能测试 Animation/Animator Animation Play/Stop测试 关于Animation动画事件的 ...

  5. 前端测试框架Jest系列教程 -- Asynchronous(测试异步代码)

    写在前面: 在JavaScript代码中,异步运行是很常见的.当你有异步运行的代码时,Jest需要知道它测试的代码何时完成,然后才能继续进行另一个测试.Jest提供了几种方法来处理这个问题. 测试异步 ...

  6. Tensorflow object detection API(1)---环境搭建与测试

    参考: https://blog.csdn.net/dy_guox/article/details/79081499 https://blog.csdn.net/u010103202/article/ ...

  7. [转帖]TPC-C解析系列01_TPC-C benchmark测试介绍

    TPC-C解析系列01_TPC-C benchmark测试介绍 http://www.itpub.net/2019/10/08/3334/ 学习一下. 自从蚂蚁金服自研数据库OceanBase获得TP ...

  8. 来自ebay内部的「软件测试」学习资料,覆盖GUI、API自动化、代码级测试及性能测试等,Python等,拿走不谢!...

    在软件测试领域从业蛮久了,常有人会问我: 刚入测试一年,很迷茫,觉得没啥好做的-- 测试在公司真的不受重视,我是不是去转型做开发会更好?  资深的测试架构师的发展路径是怎么样的?我平时该怎么学习? 我 ...

  9. FPGA与simulink联合实时环路系列——实验一 测试

    实验一 测试 实验内容 在simulink创建测试模块,通过测试模块产生信号,再传送到FPGA,FPGA读出后再将信号无处理传送回simulink进行显示.由此来测试整个硬件在环的功能是否正常,并且熟 ...

随机推荐

  1. JavaBean 动作元素事例

    JavaBean.jsp JavaBeanSuccess.jsp Type类 效果

  2. js eventhandler

    1.获取所有eventhandler 使用 getEventHandler(target) 2.target.addEventHandler(type,handler,userCapture?) 3. ...

  3. Ejb: remote调用

    用的是wildfly 9.0.2 一:在myeclipse中新建wildfly 9.0.2的server(如何新建去网上搜) 二:修改wildfly server的argument(在run conf ...

  4. vs2010打包系统必备选择.net framework 3.5sp1编译错误的解决方法

    利用visual studio 2010进行打包程序,默认安装的是Framework 4.0,如果需要将3.5sp1打包到系统中一起安装(选择了"从与我的应用程序相同的位置下载系统必备组件& ...

  5. 使用console进行 性能测试 和 计算代码运行时间(转载)

    本文转载自: 使用console进行 性能测试 和 计算代码运行时间

  6. 安装Debian的正确方法

    一.说明: Debian7.0.0的安装镜像文件有3个DVD,安装基本系统只用到第一个镜像文件,即DVD1 其它镜像文件是附带的软件包. 附Debian 7.0.0系统镜像下载地址: 32位:http ...

  7. 雅虎工程师提供的CSS初始化代码

    body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,b ...

  8. Mysql子查询、关联查询

    mysql中update.delete.install尽量不要使用子查询 一.mysql查询的五种子句         where(条件查询).having(筛选).group by(分组).orde ...

  9. 安装SQLServer2005错误无法在com+目录中安装和配置程序集

    无法在com+目录中安装和配置程序集c:\program files\Microsoft SQL Server\90\DTS\tasks\microsoft.sqlserver.MSMQTASK.DL ...

  10. HAVING用法详解

    HAVING 子句对 GROUP BY 子句设置条件的方式与 WHERE 和 SELECT 的交互方式类似.WHERE 搜索条件在进行分组操作之前应用:而 HAVING 搜索条件在进行分组操作之后应用 ...