【问题标题】:how to create checkin checkout functionality in file using client object model in sharepint 2010如何在 sharepoint 2010 中使用客户端对象模型在文件中创建签入签出功能
【发布时间】:2012-07-05 05:35:19
【问题描述】:
您能否告诉我如何使用 SharePoint 2010 中的客户端对象模型在文档库下的文件中创建签入签出功能
感谢卡哈尔
【问题讨论】:
标签:
asp.net
sharepoint-2010
sharepoint-clientobject
【解决方案1】:
每次您在 SharePoint 文件中创建、删除或更新元数据时,
建议您在手术前检查,手术后检查。
========================================
//Check Out
clientContext = new Microsoft.SharePoint.Client.ClientContext("Your site here");
clientContext.Credentials = new NetworkCredential("LoginID","LoginPW", "LoginDomain");
clientContext.Load(clientContext.Web);
Microsoft.SharePoint.Client.Web web = clientContext.Web;
Microsoft.SharePoint.Client.File f = web.GetFileByServerRelativeUrl("relative path to the file");
f.CheckOut();
clientContext.ExecuteQuery();
//....... Your operation...............
//Check in
clientContext.Credentials = new NetworkCredential("LoginID","LoginPW","LoginDomain");
clientContext.Load(clientContext.Web);
Microsoft.SharePoint.Client.Web web = clientContext.Web;
Microsoft.SharePoint.Client.File f = web.GetFileByServerRelativeUrl("relative path to the file");
f.CheckIn(String.Concat("File CheckingIn at ", DateTime.Now.ToLongDateString()),
Microsoft.SharePoint.Client.CheckinType.MajorCheckIn);
clientContext.ExecuteQuery();