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

  • 相关阅读:
    ASP.NET MVC WebAPI 上传图片实例
    PowerDesigner设计权限控制数据模型
    ASP.NET中使用WebService异步加载数据显示到页面
    C#+Dotnetbar海益ERP数据管理系统
    centos 6.X minimal 系列最小化安装完成后,安装mono和jexus过程小记录
    MVC3/4伪静态 jexus mvc伪静态
    petapoco 使用 MiniProfiler Glimpse监控
    尝试整理出自己的开发框架1
    初尝Brnshop移植到Linux Mono Jexus环境运行
    (转)Android开发出来的APP在手机的安装路径是?
  • 原文地址:https://www.cnblogs.com/zchblog/p/5508963.html
Copyright © 2020-2023  润新知