正在使用在线Excel文件...如何挂钩到回调通知? [英] Online Excel file in use by ... How to hook to callback notification?

查看:93
本文介绍了正在使用在线Excel文件...如何挂钩到回调通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我有一个Silverlight 4(c#)应用程序,需要执行一些简单的文件管理(列出文件和文件夹,打开文件,在文件夹树上导航等).
现在,我正在收集必要的部分解决方案和可重复使用的代码,以构建完整的内容.

这些文件和文件夹是在线资源,将是MS Word,MS Excel,MS Powerpoint和PDF文档.

到目前为止,我已经能够读取文件夹树,每个文件夹的内容并取消使用.
我还能够使用正确的应用程序打开每个文件,并确定在给定的时间是否有人打开了文件.

现在出现问题了!

假设用户A打开一个文件(例如excel工作簿)进行编辑.
当用户B尝试打开同一文件时,他将获得一个带有用户A标识的正在使用文件"消息框,并带有一个通知选项,当用户A释放该文件时.

当该通知回调到达用户B时,他将获得文件现在可用"消息框,并带有使用读/写权限重新打开文件的选项.

我能够找出该文件是否仍处于打开状态,并且可以创建一个计时器事件以不时检查该文件的可用性(例如,每15秒一次).

但是我真正想做的是挂接到用户B收到的回调事件,并同时通知silverlight应用程序,这样我就可以对该同一个文件进行一些处理.

在用户关闭文件后,是否有人对如何捕获该事件有解决方案,甚至是线索?

谢谢您能提供的所有帮助. t允许.

关于文件操作事件,您无需编写自己的事件处理程序.相反,您可以将System.IO命名空间的FileSystemWatcher类与下面的内置事件处理程序一起使用.

 FileSystemWatcher watcher =  FileSystemWatcher();
watcher.Path = filePath;
watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
   | NotifyFilters.FileName | NotifyFilters.DirectoryName;
// 仅观看文本文件.
watcher.Filter = " ;

// 添加事件处理程序.
watcher.Changed + =  FileSystemEventHandler(OnChanged);
watcher.Created + =  FileSystemEventHandler(OnChanged);
watcher.已删除+ =  FileSystemEventHandler(OnChanged);
watcher.已重命名+ =  RenamedEventHandler(OnRenamed);


Hi guys

I have a Silverlight 4 (c#) app where I need to do some simple file mangement (list files and folders, open files, navigate on folder tree, etc.).
Right now I''m gathering the necessary partial solutions and pieces of reusable code to build the full thing.

These files and folders are online resources and will be MS Word, MS Excel, MS Powerpoint and PDF documents.

So far I''ve been able to read the folder tree, each folder content and dispay it.
I''ve also been able to open each file using the correct application and to find out if, at a given moment, a file is opened by someone.

Now comes the problem!

Let''s supose that a user A opens a file (let''s say, an excel workbook) for editing.
When a user B tries to open that same file he gets a "file in use" message box with the user A identification and an option for notification wher User A releases the file.

When that notificaton callback reaches user B he gets the "File now available" message box and an option to reopen the file with read/write previleges.

I''m able to find out if the file is still opened and can create a timer event to check on the avalability of that file from time to time (for instance, every 15 seconds).

But what I realy wanted to do is to hook on that callback event that user B got and notify also the silverlight app so I can do some processing on that same file.

Does anyone have a solution, or even a clue, on how to catch that event after a user has closed the file?

Thanks for all the help I can get.

解决方案

Hope, you are using Silverlight OOB(Out Of Browser) mode for all file handling operation becaz normal mode won''t allow.

Regarding file manipulation events, you don''t need to write your own event handler. In stead, you can use FileSystemWatcher class of System.IO namespace with the below built-in event handlers.

FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = filePath;
watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
   | NotifyFilters.FileName | NotifyFilters.DirectoryName;
// Only watch text files.
watcher.Filter = "*.txt";

// Add event handlers.
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnChanged);
watcher.Renamed += new RenamedEventHandler(OnRenamed);


这篇关于正在使用在线Excel文件...如何挂钩到回调通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆