zoukankan      html  css  js  c++  java
  • Sharepoint the file is locked for use domainuser edit.文件被锁定,解锁方式

    Sharepoint 文档被短期锁定,锁定状态为Short-term,该方式无法通过文档Checkin(comments)进行嵌入。

    造成该文档锁定的原因是用户打开了文件,Sharepoint默认会锁定一段时间(1小时),在这1小时内是不可以修改的。

    如果要进行修改,必须解锁,网络上大多的做法就是修改服务器时间,或者等1小时。最后在一个英文博客上找到更快的解决方式。

    通过连接数据库,修改被短期锁定的文档的签出/释放时间即可,方法如下:

    private void UnlockedFileFromDB(SPListItem item)
            {
                SqlConnection con = null;
                try
                {
                    con = new SqlConnection(item.Web.Site.ContentDatabase.DatabaseConnectionString);
                    con.Open();
                    string updateCommandText = string.Format("UPDATE dbo.AllDocs SET " +
                                                             "CheckoutExpires = '{0:yyyy-MM-dd HH:mm:ss:fff}' WHERE Id = '{1}'",
                                                              DateTime.Now.ToUniversalTime(), item.UniqueId.ToString());
                    SqlCommand UpdateCommand = new SqlCommand(updateCommandText, con);
                    SqlDataAdapter contentDataAdapter = new SqlDataAdapter();
                    contentDataAdapter.UpdateCommand = UpdateCommand;
                    contentDataAdapter.UpdateCommand.ExecuteNonQuery();
                    con.Close();
                }
                catch (Exception ex)
                {

                }
                finally
                {
                    if (con != null && con.State != ConnectionState.Closed)
                    {
                        con.Close();
                    }
                }
            }

    方式二(2016/5/24更新):

    if (nFile.CheckOutStatus == SPFile.SPCheckOutStatus.ShortTerm)
    {
         nFile.ReleaseLock(nFile.LockId);
    }

  • 相关阅读:
    2.配置范例站点站点
    nginx 安装配置+清缓存模块安装
    1.1nginx安装
    1.linux源码安装nginx
    python实现免密码登录lunx服务器
    实现利用公钥私钥免密码登录Linux服务器
    Codeforces Beta Round #61 (Div. 2)
    Codeforces Beta Round #59 (Div. 2)
    Codeforces Beta Round #57 (Div. 2)
    Codeforces Beta Round #55 (Div. 2)
  • 原文地址:https://www.cnblogs.com/zchblog/p/5508963.html
Copyright © 2011-2022 走看看