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);
    }

  • 相关阅读:
    围棋术语中英文对照
    修改grub及console的分别率 Linux-Ubuntu
    内核crash (Linux)
    pthread_create build
    内联函数定义的关键字inline及由此产生的编译问题简析
    debian家族重量级成员Ubuntu 20.04下载链接开启了。。。
    stm32 GPIO 输出配置参照
    Linux安装应用程序后,点击图标没法应,怎么解决呢?
    c语言中的引用使用
    QA Issue: PN: startUp is upper case, this can result in unexpected behavior. [uppercase-pn]
  • 原文地址:https://www.cnblogs.com/zchblog/p/5508963.html
Copyright © 2011-2022 走看看