0

I'm working on a project for my school assignment, and I may have a problem.

I'm creating web portal which is all about reservations and ads. Reservations for a single ad are stored in a row and whenever one of them expires (duration: 5 days), it is supposed to be marked as expired, and the next one from the row is supposed to get sequence number 1, and be marked as active (was pending). I need a solution to get this done :(

Is there a way to make a project besides my .NET project to run in the background and check these things all the time?

Thank you all so much!

If there is any thing I can explain better please do ask.

Language : C# .Net

Database : mySql

Tools : Visual Studio 2012, Workbench, ...

4

2 回答 2

1

本质上你至少有两个选择,看看使用SQLDependency以便当“它”被标记为过期时,sqlserver 会通知你的应用程序,你可以做你喜欢的事情。

或者使用轮询系统,从您现有的项目中简单地轮询数据库说每 60 分钟一次,看看“它”是否被标记为过期,然后,做你喜欢的事。

不需要单独的项目。

编辑:不确定 sqldependency 是否可以与 mySql 一起使用,也许可以使用类似 SqlCacheDependency 的东西,但老实说,除非你必须绝对拥有“实时”数据,否则轮询解决方案是好的、简单且更易于维护的,像 sqldependency 之类的东西是错误的实施起来可能很痛苦。

于 2013-06-07T09:49:51.703 回答
0

您可以在帮助程序类中以编程方式编写您的更改,该类检查已过去的时间是否 >=5 天,然后执行您需要的任何操作。看一下

http://hangfire.io/

我发现这在创建重复的后台作业时非常有用。

注意:当然,如果您使用的是 EF6,这一切都会奏效

于 2016-08-05T14:33:38.217 回答