我们正在使用" IT Hit WebDAV AJAX Library Redistribution License"库。
我们一直在成功使用此库来完成此工作流程: 1)客户点击网页上的按钮 2)网页在webdav服务器上找到文档 3)插件将webdav文档与客户端的Ms Office Word连接起来。 4)客户端更新文档的内容 5)客户保存他的更改。此更改将反映并存储在webdav存储中。
我们的问题是: 我们需要在此工作流程中添加以下任务:
6)客户端关闭Ms Office Word应用程序 7)通知wepage客户端已关闭webdav文档 8)网页对该信息做了些什么......
我们不知道如何从您的图书馆获得回调,以便触发我们逻辑所需的许多任务。
我们正在使用此代码打开文档:
function editWordVersion(document_url){
oNs= ITHit.WebDAV.Client.DocManager;
oNs.EditDocument(document_url);
}
我们感谢您使用图书馆的任何方式或替代方案。
答案 0 :(得分:1)
无法直接从MS Office应用程序到IT Hit WebDAV Ajax库获取有关文档的信息。打开文档后,WebDAV Ajax Library对文档没有任何控制权,它只是启动打开文档的过程。
要获取有关正在关闭的文档的通知,您需要使用websockets并通过ILock。Unlock方法实施向网页发送通知。以下是如何使用WebDAV将SigmalR添加到MVC 5项目,发送和使用通知:
在VS 2013中创建MVC 5 ASP.NET Web应用程序。
使用' Add WebDAV Server Implementation' wizard将WebDAV添加到您的项目中。
将Web套接字添加到服务器站点上的项目中:
在项目中添加对Microsoft.AspNet.SignalR.Core和Microsoft.AspNet.SignalR.SystemWeb的引用。
在Startup.cs中调用app.MapSignalR():
public void Configuration(IAppBuilder app) {
app.MapSignalR();
ConfigureAuth(app);
}
创建一个派生自Hub的类。你可以把它留空:
public class MyHub1 : Hub
{
}
在ILock.Unlock方法实现中,向网页发送通知。默认情况下,添加WebDAV服务器实现向导将Unlock方法添加到实现ILock的DavHierarchyItem类中,使用以下代码扩展此方法:
public void Unlock(string lockToken)
{
// your unlock implementation goes here
...
// get the document url (optional)
string documentUrl = System.Web.HttpContext.Current.Response.ApplyAppPathModifier(
context.Request.ApplicationPath.TrimEnd('/') + '/' + this.Path);
// send SignalR message to all web browsers
var signalCntx = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext<MyHub1>();
signalCntx.Clients.All.documentModified(context.Request.HttpMethod, documentUrl);
}
在客户端使用该事件。将以下JavaScript添加到您的网页,例如WebDAV向导生成的MyCustomHandlerPage.aspx页面:
<script src="/Scripts/jquery-1.10.2.js"></script>
<script src="/Scripts/jquery.signalR-2.1.2.min.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="/signalr/hubs"></script>
<!--SignalR script to update the chat page and send messages.-->
<script>
$(function () {
// Reference the auto-generated proxy for the hub.
var chat = $.connection.myHub1;
// This function is called when the document is unlocked.
chat.client.documentModified = function (httpMethod, docPath) {
window.location.reload();
};
// Start the connection.
$.connection.hub.start().done(function () {
});
});
</script>