3

我们正在开发一个 Web 应用程序,它将提供一些 WebDAV 功能,为了实现这些功能,我们正在评估用于 .NET 的 IT-Hit 服务器引擎组件。

目的是根据一些内部逻辑,以读写或只读模式给用户某个MS Office文档;我们曾尝试通过 Visual Studio 中的 WebDAV 模板应用程序和在线文档进行调查,但我们还没有找到具体的方法来完成此操作。我们在哪里可以找到更具体的参考资料?

此外,是否可以知道用户何时关闭了 MS Office 应用程序(即 MS Word)并完成了他/她与文档的交互?

4

1 回答 1

0

To make a file read-only you can implement IMsItem interface on file items. Your IMsItem.GetFileAttributes method implementation must return read-only attribute for a file:

public FileAttributes GetFileAttributes()
{
    ...
    if(/*this file is read-only*/)
    {
         return fileSystemInfo.Attributes | FileAttributes.ReadOnly;
    }
    ...
}

Note that this code does not actually protects file from modification, it only marks the file as read-only. If application ignores read-only flag it may be able to overwrite the file. To make sure this does not happen, in your IFile.Write method implementation you must verify if user has rights to modify the file and the file is not read-only. If the file is read-only - throw the exception.

Microsoft Office locks file when opening and unlocks when closing. So when the file is closed the ILock.Unlock() method is called on the server side. Note that in case the connection is lost and the file is not unlocked by MS Office your server implementation usually you will unlock the file automatically after lock expires.

Please also read about how WebDAV locking works here.

于 2013-03-01T07:08:23.323 回答