59 lines
2.1 KiB
VB.net
59 lines
2.1 KiB
VB.net
Imports System.Data.SqlClient
|
|
Imports DigitalData.Modules.Base
|
|
|
|
Public Class HistoryModel
|
|
Inherits BaseModel
|
|
|
|
Public Sub New(pState As State)
|
|
MyBase.New(pState)
|
|
End Sub
|
|
|
|
Private Function ToEnvelopeHistoryEntry(pRow As DataRow) As EnvelopeHistoryEntry
|
|
Return New EnvelopeHistoryEntry() With {
|
|
.ActionDate = pRow.Item("ACTION_DATE"),
|
|
.EnvelopeId = pRow.Item("ENVELOPE_ID"),
|
|
.Status = pRow.Item("STATUS"),
|
|
.UserReference = pRow.ItemEx("USER_REFERENCE", "")
|
|
}
|
|
End Function
|
|
|
|
Public Function List(pEnvelopeId As Integer) As List(Of EnvelopeHistoryEntry)
|
|
Dim oSql = $"SELECT * FROM TBSIG_ENVELOPE_HISTORY WHERE ENVELOPE_ID = {pEnvelopeId} AND STATUS < 3000 ORDER BY ADDED_WHEN DESC"
|
|
Dim oTable = Database.GetDatatable(oSql)
|
|
Return oTable?.Rows.
|
|
Cast(Of DataRow).
|
|
Select(AddressOf ToEnvelopeHistoryEntry).
|
|
ToList()
|
|
End Function
|
|
|
|
Public Function Insert(pHistory As EnvelopeHistoryEntry) As Boolean
|
|
Try
|
|
Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE_HISTORY] "
|
|
oSql += " ([ENVELOPE_ID] "
|
|
oSql += " ,[USER_REFERENCE] "
|
|
oSql += " ,[STATUS] "
|
|
oSql += " ,[ACTION_DATE]) "
|
|
oSql += " VALUES "
|
|
oSql += " (@ENVELOPE_ID "
|
|
oSql += " ,@USER_REFERENCE "
|
|
oSql += " ,@STATUS "
|
|
oSql += " ,@ACTION_DATE) "
|
|
|
|
Dim oCommand As New SqlCommand(oSql)
|
|
oCommand.Parameters.Add("ENVELOPE_ID", SqlDbType.Int).Value = pHistory.EnvelopeId
|
|
oCommand.Parameters.Add("USER_REFERENCE", SqlDbType.NVarChar).Value = pHistory.UserReference
|
|
oCommand.Parameters.Add("STATUS", SqlDbType.Int).Value = pHistory.Status
|
|
oCommand.Parameters.Add("ACTION_DATE", SqlDbType.DateTime).Value = pHistory.ActionDate
|
|
|
|
If Database.ExecuteNonQuery(oCommand) Then
|
|
Return True
|
|
Else
|
|
Return False
|
|
End If
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
End Class
|