我是MVC 4的新手,这是我在这项技术中的第一个项目,我看了来自ASP.NET的电影和ContosoUniversity示例。
该网站声称销售预付产品。数据库包含用户表、经销商表、Supplier...etc表。
我在努力安排我的系统。
例如,每天晚上23:59,将从数据库中调用和检索满足特定查询的所有用户名和密码。
我还需要在某一特定日期发送短信,我在表上指定了一个单独的列,以保持在服务结束时发出的警报。
我很想知道一些想法,以及如何开始干扰系统调度或实现特定的想法。
谢谢,请原谅我的英语。
发布于 2012-11-06 10:52:51
最后,我在全球asax中做了这件事。我不知道这是不是最好的方法,但它有效..。
这是密码。
protected void Application_Start()
{
try
{
.
.
.
SetTimer();
}
catch (Exception ex)
{
...
}
}
private static void SetTimer()
{
DateTime tomorow = DateTime.Now.AddDays(1);
DateTime midnight = new DateTime(tomorow.Year, tomorow.Month, tomorow.Day, 0, 0, 0);
TimeSpan d = midnight - DateTime.Now;
sTimer.Enabled = true;
sTimer.Interval = d.TotalMilliseconds;
sTimer.Elapsed += new System.Timers.ElapsedEventHandler(sTimer_Elapsed);
sTimer.Start();
}
static void sTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
sTimer.Interval = TimeSpan.FromHours(24).TotalMilliseconds;
db = new CompanyContext();
//some func
sendInOutUsers();
AlartUsers();
}发布于 2012-08-30 16:17:47
您将需要将调度作为MVC项目之外的一个单独组件来执行。通常,您将创建一个在IIS服务器(或其他服务器)上一直运行的Windows服务项目,该项目将包括一个定时器,以按指定的时间安排启动不同的任务。您可以在数据库中创建包含计划和其他执行信息的配置文件或表,并从服务中查询此文件或表。
发布于 2012-08-30 16:18:42
在服务器上使用将在预定时间运行的单独的windows服务如何?我个人已经实施了这一点,而且效果很好。
https://stackoverflow.com/questions/12201177
复制相似问题