问题描述
我正在使用带有 C#/Visual Studio 2008 的 MySQL.我需要知道任何方法,以便在一个用户更新数据库时,通知所有通过网络登录的用户,通知发生了更改.如果我通过我的应用程序登录数据库,当时数据库中最新记录的序列号是 10,然后我有权限的人更新了数据库中的记录,同时我被通知数据库已更新为新记录.常见的例子是 MSN Messenger 在朋友上线时提醒他...虽然我真的不想要那个弹出窗口,但警报功能是这样的......
I am using MySQL with C# / Visual Studio 2008. I need to know any method so that if one user updates the database, all the logged in users over the network, are notified that a change has been occurred. If i logged in the database through my application, at that time the serial no of the latest record in the database was 10, and then i someone with the privileges updates the record in the database and at the same time i am being notified that the database has been updated with a new record. Common example can be of MSN messenger's alert for a friend when he gets online... Though i really don't want that popup, but alert functionality is something like that...
还有一件事要问:我想要一个功能,比如如果记录的状态没有更新(比如说超过 3 个小时),那么我希望所有用户也能得到关于这个问题的警报.所有记录都需要此功能,而不是专门针对新记录.
One more thing to ask: I want a functionality like if a record's status is not updated (for say about more than 3 hours), then i want all users to get alert about that issue also. This functionality is needed for all of the records, not specifically for new records.
推荐答案
您可能需要在客户端中设计某种投票功能.例如,您可以每分钟发送一个请求,询问数据库自 [客户端最新更新日期] 以来您是否更新过任何内容?"如果数据库回答 true
,您让客户端请求完整的更新集.如果没有,你让它再睡一分钟.
You probably need to design some kind of poll functionality in your client. For example, you can send a request each minute asking the database "Have you updated anything since [date the client latest got updates]?" If the database answers true
, you let the client request the full set of updates. If not, you let it sleep another minute.
这篇关于每当更新数据库时更新 C# 客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!