在一个队列中,从所有用户运行方法 [英] run methods from all users in a queue

查看:100
本文介绍了在一个队列中,从所有用户运行方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的设置:用户有他在那里执行一些操作和数据转换结果
我存储在一个数据集这些行动(在一个会话)结果
然后,在一个页面。请点击我需要执行一些更多的转换和调用将插入每个DataTable的每一行成一个数据库自定义数据库的功能。我都制定出和它的作品相当不错的。



但是,现在,我需要做的是修改一个按钮单击事件不立即执行,而是把这些行动队列(这是所有人的公共队列用户)。所以,如果USER1单击该按钮,然后点击用户2的按钮,然后我们需要采取user1的数据集和运行方式上,只有经过用户2取数据和运行方法就可以了。一个队列所有。

 私人无效btnclick()
{
的DataSet DS =会话[测试作为数据集;
PerformFinalTransformation(DS);
的foreach(在ds.Tables DataTable的DT)
{
的foreach(在dt.Rows的DataRow DR)
{
CallCustomSqlFunction(DR);
}
}
}



我想想避免存储在数据库中,如果可能的数据集,因为它们不是每个用户(表/列数)是相同的。我正在寻找任何指针如何这可以在asp.net / C#来完成。 (是quartz.net东西,我应该考虑?)。我应该寻找什么概念?并行编程?或asp.net队列?或者是其他东西?甚至不能启动,因为不知道该怎么下手。顺便说一句,我用的是最新的DotNetNuke在我的应用程序是否有帮助弄好了。


解决方案

  1. 要生存重新启动,你有你的队列存储在数据库中。您可以通过序列化每个数据集XML和存储生成的XML在为nvarchar克服数据相异(最大)列。


  2. 要运行队列的最佳方法是使用单独的窗口服务,将在时间和过程中,它选择一个项目。你可以做同样的IIS(刚开始在另一个线程的Application_Start ),但我不建议作为是unscaleable(并受重新启动IIS,池回收等)。



My setup: User has a page where he performs some actions and data transformations.
I store those actions in a dataset (in a session).
Then, on a button click I need to perform some more transformation and call custom database function that will insert each row from each datatable into a database. I have all that worked out and it works pretty good.

However, now, what I need to do is to modify a button click event not to run immediately, but put that action in a queue (it's a common queue for all users). So if user1 click the button, then user2 clicked the button, then we need to take user1 dataset and run method on it, and only after that take user2 dataset and run method on it. one queue for all.

private void btnclick()
{
  DataSet ds = Session["test"] as DataSet;
  PerformFinalTransformation(ds);
  foreach (DataTable dt in ds.Tables)
  {
     foreach (DataRow dr in dt.Rows)
     {
        CallCustomSqlFunction(dr);
     }
  }
}

I'd like to avoid storing datasets in a database if possible, since they are not the same for each user (number of tables/columns). I'm looking for any pointers on how this can be done in asp.net /c#. (Is quartz.net something I should consider?). What concepts should I look for? parallel programming? or asp.net queue? or something else? Cannot even start, since do not know what to start with. Btw, I use the latest DotNetNuke in my app if that helps somehow.

解决方案

  1. To survive restarts, you'll have to store your queue in database. You can overcome data dissimilarity by serializing each dataset to xml and storing resulting xml in nvarchar(max) column.

  2. The best way to run your queue is to use separate windows service that will pick one item at a time and process it. You can do the same with IIS (just starting another thread in Application_Start) but I wouldn't recommend that as being unscaleable (and subject to IIS restarts, pool recycling and so on).

这篇关于在一个队列中,从所有用户运行方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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