简体   繁体   中英

Schedule task in ASP.NET MVC 5

I am developing an ASP.NET MVC 5 application. I am using EF6 (Code First approach) to handle the data access and C#.

I have the next scenarios:

I have an Entity named Event with the following structure

public class Entity{
    public int Id{get; set;}
    public DateTime InitialDateTime{get; set;}
    public DateTime FinalDateTime{get; set;}
    public int Status {get; set;}
    // Another properties....
}

This entity has a corresponding Controller and Views in my Web application.

Users in role Manager can schedule events through the Create action of my Event Controller. Once an event is created, the status property (described as an integer value) is set to 0.

The event status must change to 1 once the InitialDateTime property equals to the current date and time. The same operation must be done with the FinalDateTime property but changing the event status to 2. This two operations must be automatic, without any interaction of the system administrator.

I have been checking FluentScheduler, it is amazing, but seems that this library works only with predefined tasks. I need schedule tasks dynamically , maybe I am wrong.

So, my question is:

How can I change the event status automatically depending on the current date and time and the given date and time intervals?

查看FluentScheduler.Model.Schedule的代码,看起来您应该能够执行以下操作:

Schedule(SomeTask).ToRunOnceAt(entity.InitialDateTime);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM