add ElementStatus model
This commit is contained in:
10
EnvelopeGenerator.Common/Entities/ElementStatus.vb
Normal file
10
EnvelopeGenerator.Common/Entities/ElementStatus.vb
Normal file
@@ -0,0 +1,10 @@
|
||||
Public Class ElementStatus
|
||||
|
||||
Public Property Id As Integer
|
||||
Public Property EnvelopeId As Integer
|
||||
Public Property ElementId As Integer
|
||||
Public Property ElementValue As String
|
||||
Public Property Status As Constants.ElementStatus = Constants.ElementStatus.Created
|
||||
Public Property StatusChangedWhen As Date
|
||||
|
||||
End Class
|
||||
@@ -10,7 +10,6 @@
|
||||
Public Property Required As Boolean = False
|
||||
Public Property [ReadOnly] As Boolean = False
|
||||
Public Property Page As Integer = 1
|
||||
Public Property Status As Constants.ElementStatus = Constants.ElementStatus.Created
|
||||
Public Property Index As Integer = 0
|
||||
|
||||
Public ReadOnly Property Top As Single
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
<Compile Include="Constants.vb" />
|
||||
<Compile Include="Entities\DbConfig.vb" />
|
||||
<Compile Include="Entities\ElementMetadata.vb" />
|
||||
<Compile Include="Entities\ElementStatus.vb" />
|
||||
<Compile Include="Entities\EmailData.vb" />
|
||||
<Compile Include="Entities\EmailTemplate.vb" />
|
||||
<Compile Include="Entities\Envelope.vb" />
|
||||
@@ -111,6 +112,7 @@
|
||||
<Compile Include="Models\ConfigModel.vb" />
|
||||
<Compile Include="Models\DocumentModel.vb" />
|
||||
<Compile Include="Models\ElementModel.vb" />
|
||||
<Compile Include="Models\ElementStatusModel.vb" />
|
||||
<Compile Include="Models\EmailModel.vb" />
|
||||
<Compile Include="Models\EnvelopeModel.vb" />
|
||||
<Compile Include="Models\HistoryModel.vb" />
|
||||
|
||||
81
EnvelopeGenerator.Common/Models/ElementStatusModel.vb
Normal file
81
EnvelopeGenerator.Common/Models/ElementStatusModel.vb
Normal file
@@ -0,0 +1,81 @@
|
||||
Imports System.Data.SqlClient
|
||||
|
||||
Public Class ElementStatusModel
|
||||
Inherits BaseModel
|
||||
|
||||
Public Sub New(pState As State)
|
||||
MyBase.New(pState)
|
||||
End Sub
|
||||
|
||||
Public Function Insert(pElementStatus As ElementStatus) As Boolean
|
||||
Try
|
||||
Dim oSql = "INSERT INTO [dbo].[TBSIG_ELEMENT_STATUS]
|
||||
([ENVELOPE_ID]
|
||||
,[RECEIVER_ELEMENT_ID]
|
||||
,[STATUS]
|
||||
,[STATUS_CHANGED_WHEN]
|
||||
,[VALUE])
|
||||
VALUES
|
||||
(@ENVELOPE_ID
|
||||
,@ELEMENT_ID
|
||||
,@STATUS
|
||||
,@STATUS_CHANGED_WHEN
|
||||
,@VALUE)"
|
||||
|
||||
Dim oCommand As New SqlCommand(oSql)
|
||||
oCommand.Parameters.Add("ENVELOPE_ID", SqlDbType.Int).Value = pElementStatus.EnvelopeId
|
||||
oCommand.Parameters.Add("ELEMENT_ID", SqlDbType.Int).Value = pElementStatus.ElementId
|
||||
oCommand.Parameters.Add("STATUS", SqlDbType.NVarChar).Value = pElementStatus.Status.ToString()
|
||||
oCommand.Parameters.Add("STATUS_CHANGED_WHEN", SqlDbType.DateTime).Value = Now()
|
||||
oCommand.Parameters.Add("VALUE", SqlDbType.NVarChar).Value = pElementStatus.ElementValue
|
||||
|
||||
If Database.ExecuteNonQuery(oCommand) Then
|
||||
pElementStatus.Id = GetElementId(pElementStatus)
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Update(pElementStatus As ElementStatus) As Boolean
|
||||
Try
|
||||
Dim oSql = "UPDATE [dbo].[TBSIG_ELEMENT_STATUS]
|
||||
SET [STATUS] = @STATUS
|
||||
,[STATUS_CHANGED_WHEN] = @STATUS_CHANGED_WHEN
|
||||
,[CHANGED_WHEN] = @CHANGED_WHEN
|
||||
,[VALUE] = @VALUE
|
||||
WHERE GUID = @GUID"
|
||||
|
||||
Dim oCommand As New SqlCommand(oSql)
|
||||
oCommand.Parameters.Add("GUID", SqlDbType.Int).Value = pElementStatus.Id
|
||||
oCommand.Parameters.Add("STATUS", SqlDbType.NVarChar).Value = pElementStatus.Status.ToString()
|
||||
oCommand.Parameters.Add("STATUS_CHANGED_WHEN", SqlDbType.DateTime).Value = Now()
|
||||
oCommand.Parameters.Add("CHANGED_WHEN", SqlDbType.DateTime).Value = Now()
|
||||
oCommand.Parameters.Add("VALUE", SqlDbType.NVarChar).Value = pElementStatus.ElementValue
|
||||
|
||||
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
|
||||
|
||||
Private Function GetElementId(pElement As ElementStatus) As Integer
|
||||
Try
|
||||
Return Database.GetScalarValue($"SELECT MAX(GUID) FROM TBSIG_ELEMENT_STATUS
|
||||
WHERE ENVELOPE_ID = {pElement.EnvelopeId} AND RECEIVER_ELEMENT_ID = {pElement.ElementId}")
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user