如何进行多用户事件驱动的屏幕更新?

时间:2021-12-14 00:09:36

I work on a Delphi program that uses a firebird database to store it’s data. It uses a home grown o.r.m. system. When two users look at the same data, for example in a data grid, and one changes something the other screen gets updated immediately. The way this works is that the objects in the one program store them self’s in the database. The database has a trigger that registers this change in a auxiliary changes log table. Writing to this changes log table triggers an event. The second program is listening to that event and knows from the entry in the changes log table what object was changed. It will reload that object and raise an event internally in that program. This event will cause all screens that are showing this object and all objects that base their behavior on this object to update. We would like to switch to .Net and maybe MS SQL. My question is: 1) How do I do this with MS SQL? 2) Is there a framework that supports this? So I won’t have to port this to .Net

我正在使用一个使用firebird数据库存储数据的Delphi程序。它使用了本土的o.r.m.系统。当两个用户查看相同的数据时,例如在数据网格中,并且一个用户更改某个内容,另一个屏幕立即更新。这种方式的工作方式是一个程序中的对象将它们存储在数据库中。数据库有一个触发器,用于在辅助更改日志表中注册此更改。写入此更改日志表会触发事件。第二个程序正在侦听该事件,并从更改日志表中的条目知道更改了哪个对象。它将重新加载该对象并在该程序内部引发事件。此事件将导致显示此对象的所有屏幕以及基于此对象的行为的所有对象都进行更新。我们想切换到.Net和MS SQL。我的问题是:1)如何使用MS SQL执行此操作? 2)是否有支持此功能的框架?所以我不必将它移植到.Net

2 个解决方案

#1


Since the .Net Framework 2.0 and MSSqlServer 2005 versions there is support for change notifications: using the SqlDependency class. You have an example in the codeproject.

由于.Net Framework 2.0和MSSqlServer 2005版本支持更改通知:使用SqlDependency类。您在codeproject中有一个示例。

Take also a look to some recommendations about using notifications in the msdn.

另请参阅有关在msdn中使用通知的一些建议。

#2


doesn't sound like this would be too difficult to implement in c#. try using the "observer pattern" with whatever custom modefications you'd like.

听起来这听起来不太难以在c#中实现。尝试使用“观察者模式”与您想要的任何自定义模式。

#1


Since the .Net Framework 2.0 and MSSqlServer 2005 versions there is support for change notifications: using the SqlDependency class. You have an example in the codeproject.

由于.Net Framework 2.0和MSSqlServer 2005版本支持更改通知:使用SqlDependency类。您在codeproject中有一个示例。

Take also a look to some recommendations about using notifications in the msdn.

另请参阅有关在msdn中使用通知的一些建议。

#2


doesn't sound like this would be too difficult to implement in c#. try using the "observer pattern" with whatever custom modefications you'd like.

听起来这听起来不太难以在c#中实现。尝试使用“观察者模式”与您想要的任何自定义模式。