在.net c#中显示Web应用程序的最新更新所需的实施帮助 [英] Implementation help needed for displaying recent updates om webapp in .net c#

查看:49
本文介绍了在.net c#中显示Web应用程序的最新更新所需的实施帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现一个仪表板页面,上面有4个小部件.所有4个小部件将属于不同的类别,并将显示该类别的最新更新和更改.如果应该在表上定义触发器,如果​​我在表上发生任何插入/更新,将它们复制到表中并在小部件中显示,该如何在表上定义触发器?谢谢.

I need to implement a dashboard page which has like 4 widgets on it. All  4 widgets will belong to a different category and will display recent updates and changes on that category. How should i proceed keeping in mind the database end..should i define triggers on my table for the purpose if any insert / update happens on the table i copy them to my tables and display them inside a widget? Thanks.

推荐答案

如果是我,我将使用计时器对象或在小部件中创建的线程创建,然后在小部件中查询数据库大约每分钟.如果数据发生更改,请让窗口小部件自行更新.
If it were me, I''d use either a timer object or a thread that started in widget was created, and in the widget, query the database every minute or so. If the data changed, have the widget update itself.


Web应用程序的重要点在于,所有更新都是由客户端驱动的. HTTP是无状态的,并且在模型上运行,客户端要求信息,而服务器则提供信息.

因此,在客户代码中,您将需要有一个AJAX请求,要求对小部件进行更新.为了节省流量,您可以要求对所有四个进行更新.该请求的回调应解析服务器响应,并对窗口小部件显示进行适当的调整.

在服务器上,您需要一种简单的方法来确定自特定时间以来表是否已更改.具体执行方式取决于小部件和数据存储的类型,但应快速(即没有复杂的查询).当我执行类似的操作(当您收到消息时,一个PM框会更新其显示)时,我使用的表具有一个auto_increment键,并且客户端代码使用了它视为请求令牌的最大ID.像从pm选择id的查询,其中id> @clientrequestid 从pm订单选择id的ID dec限制1 这样的查询将完成告诉您是否有更新的工作重击数据库;如果有更新,则可以执行更复杂的查询以检索客户端将需要呈现更新的数据.
The important point with web applications is that all updates are driven by the client. HTTP is stateless and operates on a model with clients asking for information and servers providing it.

So in your client code, you will need to have an AJAX request that asks for updates to the widgets. To save on traffic you could ask for updates to all four. The callback for that request should parse the server response and make appropriate adjustments to the widget display.

On the server, you need an easy way of determining whether a table has changed since a particular time. How exactly you do this depends on what the widgets and the data storage is, but it should be fast (i.e. no complex queries). When I did something similar (a PM box which updated its display when you received a message) the table I was using had an auto_increment key and the client code used the largest ID it had seen as the request token. A query like select id from pm where id>@clientrequestid or select id from pm order by id desc limit 1 will do the job of telling you whether there are updates and not hit the database hard; if there are updates, you can then do a more complex query to retrieve the data the client will need to render the update.


只有一种方法可以检查更新.浏览器和Web服务器(正在轮询).您可以使用window.setTimeout(从客户端发起AJAX请求)执行此操作,也可以在页面上设置计时器.

为了获得更好的性能,在轮询数据时应在页面上实现AJAX.

当呼叫转到后端时,请检查数据库以进行更新,并使用新内容更新小部件.

HTML-5中的Websocket API提供了更好的体系结构来处理这种情况.服务器将任何更改通知客户端(浏览器).但是,如果您的实际需求与我的需求相去甚远,我会认为.

但是目前,轮询是实现这种要求的最佳方法.
There is only one way to check for update when it comes to browser and web server, which is polling. You can do this using window.setTimeout (initiate AJAX request from client) or you can have timer on your page.

For better performance you should implement AJAX on your page when you are polling for data.

When call goes to backend check database for update and update the widgets with new content.

The Websocket API in HTML-5 provides better architecture to handle this kind of situation. Where server notify client (browser) for any changes. But I thing it if far from your actual requirement.

But for now polling is the best way to implement this kind of requirement.


这篇关于在.net c#中显示Web应用程序的最新更新所需的实施帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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