簡單介紹

調度管理是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其他提供者類類似,這個調度提供者類為調度程序的實現提供必
須的一些方法:

 

openharmony resource_schedule_service 調度策略_ide

 同時聲明調度事件委託:

openharmony resource_schedule_service 調度策略_Public_02

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

 待續............openharmony resource_schedule_service 調度策略_DNN_03下一節將介紹如何自定義符合自己要求的調度服務!!!