DNN调度管理解析(一)-----简单介绍及其API
简单介绍
调度管理是DNN提供给开发者在一定的时间间隔实现调度任务的一种机制。
类似,它也是在提供者模式的基础上实现的,所以可以不更改核心代码就
创建新的或修改原有的调度服务。查看有关资料
你会发现这是DNN核心团队的成员Dan Caron 的巨大贡献:
It was during this time that Dan Caron single-handedly made a significant impact on
the project. Based on his experience with other enterprise portals, he proceeded to
add integrated exception handling and event logging to the application. This added
stability and “auditability”; two major factors in most professional software products.
He also added a complex, multithreaded scheduler to the application. The Scheduler
was not just a simple hard-coded implementation like I had seen in other ASP.NET
projects,but rather it was fully configurable via an administration user interface. This
powerful new feature could be used to run background housekeeping jobs as well as
long-running tasks. With this in place,the extensibility of the application improved yet
again.
呵呵,转入正题,由于调度服务是在Web应用程序的环境下运行的,故不
可避免会出现中断或掉线的情况,这时调度服务显然会被中止,所以调度
服务必然不会24小时的运转着,而只能借助设置一定的时间间隔来执行该
调度服务,而DNN的调度任务就是根据已定义的调度日程来执行且只能在
程序正常运行时有效,当然你也可以通过具体设置任务执行的频率周期来
让调度任务自动执行(该频率属性是以分钟/小时/天来区分的)
The API
SchedulingProvider($DNNRoot/Components/Providers/Scheduling目录下)
于DNN其他提供者类类似,这个调度提供者类为调度程序的实现提供必
须的一些方法:
同时声明调度事件委托:
Scheduler($DNNRoot/Components/Providers/Scheduling目录下)
这个是DNN调度服务的基本类,所有需要实现调度服务的程序必须继承于
它。在这个类里边提供了其继承类必须实现的方法DoWork()
'''''''''''''''''''''''''''''''''''''''''''''''''''
'This is the sub that kicks off the actual
'work within the SchedulerClient's subclass
'''''''''''''''''''''''''''''''''''''''''''''''''''
Public MustOverride Sub DoWork()
同时提供在SchedulingProvider类下声明的委托调度程序运行的事件方法:
Public Event ProcessStarted As WorkStarted
Public Event ProcessProgressing As WorkProgressing
Public Event ProcessCompleted As WorkCompleted
Public Event ProcessErrored As WorkErrored
Public Sub Started()
RaiseEvent ProcessStarted(Me)
End Sub
Public Sub Progressing()
RaiseEvent ProcessProgressing(Me)
End Sub
Public Sub Completed()
RaiseEvent ProcessCompleted(Me)
End Sub
Public Sub Errored(ByRef objException As Exception)
RaiseEvent ProcessErrored(Me, objException)
End Sub
'it will not reliably complete
APPLICATION_START
End Enum
Public Enum ScheduleSource
NOT_SET
STARTED_FROM_SCHEDULE_CHANGE
STARTED_FROM_EVENT
STARTED_FROM_TIMER
STARTED_FROM_BEGIN_REQUEST
End Enum
Public Enum ScheduleStatus
NOT_SET
WAITING_FOR_OPEN_THREAD
RUNNING_EVENT_SCHEDULE
RUNNING_TIMER_SCHEDULE
RUNNING_REQUEST_SCHEDULE
WAITING_FOR_REQUEST
SHUTTING_DOWN
STOPPED
End Enum
Public Enum SchedulerMode
DISABLED = 0
TIMER_METHOD = 1
REQUEST_METHOD = 2
End Enum
调度服务的一些枚举类型(附加)
Public Enum EventName
'do not add APPLICATION_END
待续............下一节将介绍如何自定义符合自己要求的调度服务!!!