Imports System.Text

Namespace UTSModule.DbTableModel.LocalPrivate
    ''' <summary>
    ''' 本地未上传记录缓存表
    ''' </summary>
    Public Class CacheTable
        ''' <summary>数据库操作记录表枚举值</summary>
        Enum ColNamesEnum

            ''' <summary>序列号</summary>
            ID

            ''' <summary>用户名</summary>
            [Operator]

            ''' <summary>日期时间</summary>
            DateTime

            ''' <summary>数据库语句</summary>
            SqlCmd

            ''' <summary>是否已经同步到远程数据库</summary>
            IsUpload

            ''' <summary>同步出错编码</summary>
            ErrorCode

            ''' <summary>同步出错提示</summary>
            ErrorMessage

            ''' <summary>备注</summary>
            Remark
        End Enum

        Public Shared ReadOnly TableName As String = "TBL_Table_CaChe"

        ''' <summary>
        ''' Sqlite数据库建表语句
        ''' </summary>
        ''' <returns>建表语句</returns>
        Public Shared Function CreateTableString() As String
            Dim createStr As New StringBuilder
            createStr.Append($"Create Table If Not Exists `{TableName}`")
            createStr.Append(" (")
            createStr.Append($"`{ColNamesEnum.ID}` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL ,")
            createStr.Append($"`{ColNamesEnum.DateTime}` DateTime NOT NULL ,")
            createStr.Append($"`{ColNamesEnum.Operator }` integer,")
            createStr.Append($"`{ColNamesEnum.SqlCmd}` text NOT NULL ,")
            createStr.Append($"`{ColNamesEnum.IsUpload }` bit NOT NULL ,")
            createStr.Append($"`{ColNamesEnum.ErrorCode }` varchar(64) ,")
            createStr.Append($"`{ColNamesEnum.ErrorMessage }` varchar(255) ,")
            createStr.Append($"`{ColNamesEnum.Remark}` varchar(255)")
            createStr.Append(" );")
            Return createStr.ToString()
        End Function

    End Class
End Namespace