Imports System.Xml.Serialization


<Serializable>
<XmlInclude(GetType(DbSyncServiceTask))>
<XmlInclude(GetType(ListenJsonFileServiceTask))>
Public MustInherit Class ServiceTask
    Implements IServiceTask

    ''' <summary>
    ''' 服务任务类型枚举集合
    ''' </summary>
    Enum ServiceTaskTypeEnum
        ''' <summary>
        ''' 数据库同步
        ''' </summary>
        DbSync

        ''' <summary>
        ''' 监听Json文件
        ''' </summary>
        ListenJsonFile
    End Enum

    ''' <summary>
    ''' 服务任务状态枚举值
    ''' </summary>
    Enum ServiceTaskStatusEnum
        ''' <summary>
        ''' 启动状态
        ''' </summary>
        Start

        ''' <summary>
        ''' 停止状态
        ''' </summary>
        [Stop]
    End Enum



    ''' <summary>
    ''' 服务任务类型
    ''' </summary>
    ''' <returns></returns>
    Public Property TaskType() As ServiceTaskTypeEnum


    ''' <summary>
    ''' 服务任务名，服务任务的唯一索引
    ''' </summary>
    ''' <returns></returns>
    Public Property TaskName() As String

    ''' <summary>
    ''' 服务任务的状态
    ''' </summary>
    ''' <returns></returns>
    Public Property TaskStatus() As ServiceTaskStatusEnum

    ''' <summary>
    ''' 任务开启
    ''' </summary>
    Public MustOverride Sub Start() Implements IServiceTask.Start

    ''' <summary>
    ''' 任务停止
    ''' </summary>
    Public MustOverride Sub [Stop]() Implements IServiceTask.[Stop]

    ''' <summary>
    ''' 任务重启
    ''' </summary>
    Public MustOverride Sub Restart() Implements IServiceTask.Restart

    ''' <summary>
    ''' 任务参数集合设置
    ''' </summary>
    ''' <param name="params">任务参数键值对</param>
    Public MustOverride Sub SetParams(params As Dictionary(Of String, String)) Implements IServiceTask.SetParams

    ''' <summary>
    ''' 任务参数集合获取
    ''' </summary>
    ''' <returns></returns>
    Public MustOverride Function GetParams() As Dictionary(Of String, String) Implements IServiceTask.GetParams

End Class
