SharePoint API测试系列——Records.BypassLocks测试
转载请注明出自天外归云的博客园: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测试的更多相关文章
- 【转】【iOS测试系列】常用测试小插件的使用
背景介绍 由于iOS系统的限制,在非越狱的自动化测试中无法实现一些常用的功能,比如不同应用之间来回切换.模拟全局的点击事件等等.但是在越狱的环境下,这些限制就不存在了,我们可以利用各种小插件来实现我们 ...
- ASP.NET Web API 2系列(三):查看WebAPI接口的详细说明及测试接口
引言 前边两篇博客介绍了Web API的基本框架以及路由配置,这篇博客主要解决在前后端分离项目中,为前端人员提供详细接口说明的问题,主要是通过修改WebApi HelpPage相关代码和添加WebAp ...
- 「译」JUnit 5 系列:条件测试
原文地址:http://blog.codefx.org/libraries/junit-5-conditions/ 原文日期:08, May, 2016 译文首发:Linesh 的博客:「译」JUni ...
- "Unity测试系列"文章索引
对Unity各种API的细节进行测试 Common 一些Unity基础操作的性能测试 Animation/Animator Animation Play/Stop测试 关于Animation动画事件的 ...
- 前端测试框架Jest系列教程 -- Asynchronous(测试异步代码)
写在前面: 在JavaScript代码中,异步运行是很常见的.当你有异步运行的代码时,Jest需要知道它测试的代码何时完成,然后才能继续进行另一个测试.Jest提供了几种方法来处理这个问题. 测试异步 ...
- Tensorflow object detection API(1)---环境搭建与测试
参考: https://blog.csdn.net/dy_guox/article/details/79081499 https://blog.csdn.net/u010103202/article/ ...
- [转帖]TPC-C解析系列01_TPC-C benchmark测试介绍
TPC-C解析系列01_TPC-C benchmark测试介绍 http://www.itpub.net/2019/10/08/3334/ 学习一下. 自从蚂蚁金服自研数据库OceanBase获得TP ...
- 来自ebay内部的「软件测试」学习资料,覆盖GUI、API自动化、代码级测试及性能测试等,Python等,拿走不谢!...
在软件测试领域从业蛮久了,常有人会问我: 刚入测试一年,很迷茫,觉得没啥好做的-- 测试在公司真的不受重视,我是不是去转型做开发会更好? 资深的测试架构师的发展路径是怎么样的?我平时该怎么学习? 我 ...
- FPGA与simulink联合实时环路系列——实验一 测试
实验一 测试 实验内容 在simulink创建测试模块,通过测试模块产生信号,再传送到FPGA,FPGA读出后再将信号无处理传送回simulink进行显示.由此来测试整个硬件在环的功能是否正常,并且熟 ...
随机推荐
- HTML基础-- 标签、表格
<html> --开始标签 <head> 网页上的控制信息 <title>页面标题</title> </head> <body& ...
- 有时候dfs可以简化各种组合的操作
比如有时某些操作是组合起来的,你不用去模拟每一种,把其拆分为几种单个操作,就可以了,因为反正会枚举所有的,所以也反正会组合出那种...而且不易出错.. 当然以上只是一种思维方式,并不一定可行,还要考虑 ...
- TImageList 和 TlistView 组件(C++Builder)
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { //加载图标到Imagelist Graphics::TBitmap *bm ...
- centos python nginx uwsgi
先更新系统,并安装编译环境等等. yum update yum install python python-devel libxml2 libxml2-devel python-setuptools ...
- Android中操作数据的集中方式---文件,SQLite,ContentProvider
http://blog.csdn.net/he90227/article/details/33734239 转
- PAT乙级 1021. 个位数统计 (15)
1021. 个位数统计 (15) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 给定一个k位整数N = dk-1 ...
- DB2 表空间和缓冲池
简介 对于刚涉足 DB2 领域的 DBA 或未来的 DBA 而言,新数据库的设计和性能选择可能会很令人困惑.在本文中,我们将讨论 DBA 要做出重要选择的两个方面:表空间和缓冲池.表空间和缓冲池的设计 ...
- OpenStack fuel-web不可用解决办法
Contents [hide] 1 为增加一台计算节点 2 磁盘清空 3 启动占用8001端口的进程 4 启动占用5432端口的进程 为增加一台计算节点 打开fuel-web,发现无法打开,弹出ngi ...
- 爱普生 RS330 打印机墨水连供装置墨盒吸墨复位方法
芯片复位方法: 先按充墨键(墨水灯按键),一下一下按,把墨车按停到右侧换墨盒的位置为止(就是右侧框框正中位置), 全程带电操作,停到换墨盒的位置后再按住芯片复位键(墨盒芯片上面白色的小按键)5秒以上再 ...
- Backup: Numbers in Perl6
Perl6 is a new language, not a improved version of Perl5. Perl6 inherits many good features from man ...