日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

SharePoint API测试系列——Records.BypassLocks测试

發布時間:2023/11/27 生活经验 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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[0];Records.BypassLocks(item, delegate (SPListItem spListItem){//Do your stuff here.item["Title"] = itemTitle_textBox.Text;item.Update();if (list.Items[0].Title == itemTitle_textBox.Text){testResult_richTextBox.Text = "Test result is passed! Now the first item's title is: " + list.Items[0].Title;testResult_richTextBox.Select(0, testResult_richTextBox.Text.Length);testResult_richTextBox.SelectionColor = Color.Green;}else{testResult_richTextBox.Text = "Test result is failed!";testResult_richTextBox.Select(0, 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的屬性與內容成為可能。

轉載于:https://www.cnblogs.com/LanTianYou/p/4882050.html

總結

以上是生活随笔為你收集整理的SharePoint API测试系列——Records.BypassLocks测试的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。