Compare commits
5 Commits
a9c817f2ef
...
9c63c3e7cc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c63c3e7cc | ||
|
|
47d02aefee | ||
|
|
3f4f4681b5 | ||
|
|
946d9c2119 | ||
|
|
c924a5ec70 |
@@ -8,12 +8,14 @@ Public Class EnvelopeModel
|
|||||||
|
|
||||||
Private ReadOnly UserModel As UserModel
|
Private ReadOnly UserModel As UserModel
|
||||||
Private ReadOnly ReceiverModel As ReceiverModel
|
Private ReadOnly ReceiverModel As ReceiverModel
|
||||||
|
Private ReadOnly DocumentModel As DocumentModel
|
||||||
|
|
||||||
Public Sub New(pState As State)
|
Public Sub New(pState As State)
|
||||||
MyBase.New(pState)
|
MyBase.New(pState)
|
||||||
|
|
||||||
UserModel = New UserModel(pState)
|
UserModel = New UserModel(pState)
|
||||||
ReceiverModel = New ReceiverModel(pState)
|
ReceiverModel = New ReceiverModel(pState)
|
||||||
|
DocumentModel = New DocumentModel(pState)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Function ToEnvelope(pRow As DataRow) As Envelope
|
Private Function ToEnvelope(pRow As DataRow) As Envelope
|
||||||
@@ -32,6 +34,7 @@ Public Class EnvelopeModel
|
|||||||
|
|
||||||
oEnvelope.User = UserModel.SelectUser(oEnvelope.UserId)
|
oEnvelope.User = UserModel.SelectUser(oEnvelope.UserId)
|
||||||
oEnvelope.Receivers = ReceiverModel.ListEnvelopeReceivers(oEnvelope.Id)
|
oEnvelope.Receivers = ReceiverModel.ListEnvelopeReceivers(oEnvelope.Id)
|
||||||
|
oEnvelope.Documents = DocumentModel.List(oEnvelope.Id)
|
||||||
|
|
||||||
Return oEnvelope
|
Return oEnvelope
|
||||||
End Function
|
End Function
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
Imports DigitalData.Modules.Config.ConfigAttributes
|
|
||||||
|
|
||||||
Public Class Config
|
|
||||||
<ConnectionString>
|
|
||||||
Property ConnectionString As String = ""
|
|
||||||
End Class
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
Public Class Constants
|
|
||||||
|
|
||||||
Public Enum EnvelopeStatus
|
|
||||||
Created = 0
|
|
||||||
Saved = 1
|
|
||||||
Sent = 2
|
|
||||||
End Enum
|
|
||||||
|
|
||||||
Public Enum ElementType
|
|
||||||
Signature = 0
|
|
||||||
End Enum
|
|
||||||
|
|
||||||
Public Enum ElementStatus
|
|
||||||
Created = 0
|
|
||||||
End Enum
|
|
||||||
|
|
||||||
End Class
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
Public Class DbConfig
|
|
||||||
Public Property DocumentPath As String = ""
|
|
||||||
End Class
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
Public Class ElementMetadata
|
|
||||||
Public Property Index As Integer
|
|
||||||
Public Property Page As Integer
|
|
||||||
End Class
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
Public Class Envelope
|
|
||||||
Public Property Id As Integer = 0
|
|
||||||
Public Property Subject As String
|
|
||||||
Public Property Message As String
|
|
||||||
Public Property UserId As Integer
|
|
||||||
Public Property Uuid As String = Guid.NewGuid.ToString()
|
|
||||||
Public Property Status As Constants.EnvelopeStatus
|
|
||||||
|
|
||||||
Public Property Documents As New List(Of EnvelopeDocument)
|
|
||||||
Public Property Receivers As New List(Of EnvelopeReceiver)
|
|
||||||
|
|
||||||
Public Function Validate() As List(Of String)
|
|
||||||
Dim oErrors As New List(Of String)
|
|
||||||
|
|
||||||
If String.IsNullOrWhiteSpace(Subject) Then
|
|
||||||
oErrors.Add(My.Resources.Envelope.Missing_Subject)
|
|
||||||
End If
|
|
||||||
|
|
||||||
If String.IsNullOrWhiteSpace(Message) Then
|
|
||||||
oErrors.Add(My.Resources.Envelope.Missing_Message)
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Documents.Count = 0 Then
|
|
||||||
oErrors.Add(My.Resources.Envelope.Missing_Documents)
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Receivers.Count = 0 Then
|
|
||||||
oErrors.Add(My.Resources.Envelope.Missing_Receivers)
|
|
||||||
End If
|
|
||||||
|
|
||||||
For Each Receiver In Receivers
|
|
||||||
If IsValidEmailAddress(Receiver.Email) = False Then
|
|
||||||
oErrors.Add(String.Format(My.Resources.Envelope.Invalid_Email_Address, Receiver.Name))
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
|
|
||||||
Return oErrors
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Private Function IsValidEmailAddress(pEmailAddress As String) As Boolean
|
|
||||||
Try
|
|
||||||
Dim oAddress = New System.Net.Mail.MailAddress(pEmailAddress)
|
|
||||||
Return oAddress.Address = pEmailAddress
|
|
||||||
Catch ex As Exception
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
End Class
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
Imports System.IO
|
|
||||||
|
|
||||||
Public Class EnvelopeDocument
|
|
||||||
Public Property Id As Integer
|
|
||||||
|
|
||||||
Public Property FileInfo As FileInfo
|
|
||||||
|
|
||||||
Public Property IsTempFile As Boolean = True
|
|
||||||
|
|
||||||
Public Property EnvelopeId As Integer = 0
|
|
||||||
|
|
||||||
Public ReadOnly Property Filename As String
|
|
||||||
Get
|
|
||||||
Return FileInfo.Name
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
|
|
||||||
Public ReadOnly Property Filepath As String
|
|
||||||
Get
|
|
||||||
Return FileInfo.FullName
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
End Class
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
Public Class EnvelopeDocumentElement
|
|
||||||
Public Property Id As Integer = 0
|
|
||||||
Public Property X As Double
|
|
||||||
Public Property Y As Double
|
|
||||||
Public Property Width As Double
|
|
||||||
Public Property Height As Double
|
|
||||||
Public Property ElementType As String
|
|
||||||
Public Property DocumentId As Integer
|
|
||||||
Public Property ReceiverId As Integer
|
|
||||||
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 AnnotationIndex As Integer
|
|
||||||
End Class
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
Imports EnvelopeGenerator.Common.Constants
|
|
||||||
|
|
||||||
Public Class EnvelopeHistoryEntry
|
|
||||||
Public EnvelopeId As Integer
|
|
||||||
Public Status As EnvelopeStatus
|
|
||||||
Public UserEmailAddress As String
|
|
||||||
Public ActionTitle As String
|
|
||||||
Public ActionDescription As String
|
|
||||||
Public AddedWhen As Date
|
|
||||||
|
|
||||||
|
|
||||||
End Class
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
Imports DigitalData.Modules.Base
|
|
||||||
|
|
||||||
Public Class EnvelopeReceiver
|
|
||||||
Public Property Id As Integer
|
|
||||||
Public Property UserId As Integer
|
|
||||||
|
|
||||||
Public Property Name As String
|
|
||||||
Public Property Company As String = ""
|
|
||||||
Public Property JobTitle As String = ""
|
|
||||||
|
|
||||||
Public Property Email As String
|
|
||||||
Public ReadOnly Property Signature As String
|
|
||||||
Get
|
|
||||||
Return StringEx.GetChecksum(Email.ToUpper)
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
Public ReadOnly Property HasId As Boolean
|
|
||||||
Get
|
|
||||||
Return Id > 0
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
|
|
||||||
Public Property Sequence As Integer = 0
|
|
||||||
Public Property PrivateMessage As String = ""
|
|
||||||
Public Property AccessCode As String = ""
|
|
||||||
End Class
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
Imports DigitalData.Modules.Database
|
|
||||||
Imports DigitalData.Modules.Logging
|
|
||||||
|
|
||||||
Public Class State
|
|
||||||
Public Property UserId As Integer
|
|
||||||
Public Property Config As Config
|
|
||||||
Public Property DbConfig As DbConfig
|
|
||||||
Public Property LogConfig As LogConfig
|
|
||||||
Public Property Database As MSSQLServer
|
|
||||||
End Class
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<RootNamespace>EnvelopeGenerator.Common</RootNamespace>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="NLog" Version="5.0.5" />
|
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="DigitalData.Modules.Base">
|
|
||||||
<HintPath>..\..\DDModules\Base\bin\Debug\DigitalData.Modules.Base.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="DigitalData.Modules.Config">
|
|
||||||
<HintPath>..\..\DDModules\Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="DigitalData.Modules.Database">
|
|
||||||
<HintPath>..\..\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="DigitalData.Modules.Logging">
|
|
||||||
<HintPath>..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="Strings\Envelope.Designer.vb">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Envelope.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Update="Strings\Envelope.resx">
|
|
||||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
|
||||||
<LastGenOutput>Envelope.Designer.vb</LastGenOutput>
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
Imports DigitalData.Modules.Database
|
|
||||||
Imports DigitalData.Modules.Logging
|
|
||||||
Imports System.Data
|
|
||||||
|
|
||||||
Public MustInherit Class BaseModel
|
|
||||||
Protected Database As MSSQLServer
|
|
||||||
Protected Logger As Logger
|
|
||||||
Protected State As State
|
|
||||||
|
|
||||||
Public Sub New(pState As State)
|
|
||||||
Logger = pState.LogConfig.GetLogger()
|
|
||||||
Database = pState.Database
|
|
||||||
State = pState
|
|
||||||
End Sub
|
|
||||||
End Class
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
Imports System.Data
|
|
||||||
Imports DigitalData.Modules.Base
|
|
||||||
Public Class DocumentModel
|
|
||||||
Inherits BaseModel
|
|
||||||
|
|
||||||
Public Sub New(pState As State)
|
|
||||||
MyBase.New(pState)
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Function ToDocument(pRow As DataRow) As EnvelopeDocument
|
|
||||||
Return New EnvelopeDocument() With {
|
|
||||||
.Id = pRow.ItemEx("GUID", 0),
|
|
||||||
.EnvelopeId = pRow.ItemEx("ENVELOPE_ID", 0),
|
|
||||||
.FileInfo = New IO.FileInfo(pRow.ItemEx("FILEPATH", "")),
|
|
||||||
.IsTempFile = False
|
|
||||||
}
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function List(pEnvelopeId As Integer) As IEnumerable(Of EnvelopeDocument)
|
|
||||||
Try
|
|
||||||
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_ENVELOPE_DOCUMENT] WHERE ENVELOPE_ID = {pEnvelopeId}"
|
|
||||||
Dim oTable = Database.GetDatatable(oSql)
|
|
||||||
|
|
||||||
Return oTable?.Rows.Cast(Of DataRow).
|
|
||||||
Select(AddressOf ToDocument).
|
|
||||||
ToList()
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return Nothing
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
End Class
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
Imports System.Data
|
|
||||||
Imports DigitalData.Modules.Base
|
|
||||||
|
|
||||||
Public Class ElementModel
|
|
||||||
Inherits BaseModel
|
|
||||||
|
|
||||||
Public Sub New(pState As State)
|
|
||||||
MyBase.New(pState)
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Function ToElement(pRow As DataRow) As EnvelopeDocumentElement
|
|
||||||
Return New EnvelopeDocumentElement() With {
|
|
||||||
.Id = pRow.ItemEx("GUID", 0),
|
|
||||||
.DocumentId = pRow.ItemEx("DOCUMENT_ID", 0),
|
|
||||||
.ReceiverId = pRow.ItemEx("RECEIVER_ID", 0),
|
|
||||||
.ElementType = [Enum].Parse(GetType(Constants.ElementType), pRow.ItemEx("ELEMENT_TYPE", Constants.ElementType.Signature.ToString)),
|
|
||||||
.X = pRow.ItemEx("POSITION_X", 0.0),
|
|
||||||
.Y = pRow.ItemEx("POSITION_Y", 0.0),
|
|
||||||
.Width = pRow.ItemEx("WIDTH", 0.0),
|
|
||||||
.Height = pRow.ItemEx("HEIGHT", 0.0),
|
|
||||||
.Page = pRow.ItemEx("PAGE", 0),
|
|
||||||
.AnnotationIndex = pRow.ItemEx("ANNOTATION_INDEX", 0)
|
|
||||||
}
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function ElementsExist(pEnvelopeId As Integer, pReceiverId As Integer) As Boolean
|
|
||||||
Try
|
|
||||||
Dim oSql = $"SELECT COUNT(*) FROM [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] T
|
|
||||||
JOIN TBSIG_ENVELOPE_DOCUMENT T2 ON T.DOCUMENT_ID = T2.GUID
|
|
||||||
WHERE T.RECEIVER_ID = {pReceiverId} AND T2.ENVELOPE_ID = {pEnvelopeId}"
|
|
||||||
Dim oElementCount As Integer = Database.GetScalarValue(oSql)
|
|
||||||
|
|
||||||
Return oElementCount > 0
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function List(pDocumentId As Integer) As List(Of EnvelopeDocumentElement)
|
|
||||||
Try
|
|
||||||
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] WHERE DOCUMENT_ID = {pDocumentId} ORDER BY PAGE ASC, ANNOTATION_INDEX ASC"
|
|
||||||
Dim oTable = Database.GetDatatable(oSql)
|
|
||||||
|
|
||||||
Return oTable?.Rows.Cast(Of DataRow).
|
|
||||||
Select(AddressOf ToElement).
|
|
||||||
ToList()
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return Nothing
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
End Class
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
Imports System.Data.SqlClient
|
|
||||||
Imports DigitalData.Modules.Logging
|
|
||||||
Imports DigitalData.Modules.Base
|
|
||||||
Imports System.Data
|
|
||||||
|
|
||||||
Public Class EnvelopeModel
|
|
||||||
Inherits BaseModel
|
|
||||||
|
|
||||||
Public Sub New(pState As State)
|
|
||||||
MyBase.New(pState)
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Function ToEnvelope(pRow As DataRow) As Envelope
|
|
||||||
Dim oEnvelope = New Envelope() With {
|
|
||||||
.Id = pRow.ItemEx("GUID", 0),
|
|
||||||
.Uuid = pRow.ItemEx("ENVELOPE_UUID", ""),
|
|
||||||
.Subject = pRow.ItemEx("SUBJECT", ""),
|
|
||||||
.Message = pRow.ItemEx("MESSAGE", ""),
|
|
||||||
.UserId = State.UserId,
|
|
||||||
.Status = ObjectEx.ToEnum(Of Constants.EnvelopeStatus)(pRow.ItemEx("STATUS", "Created"))
|
|
||||||
}
|
|
||||||
|
|
||||||
Return oEnvelope
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function List() As IEnumerable(Of Envelope)
|
|
||||||
Try
|
|
||||||
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_ENVELOPE] WHERE USER_ID = {State.UserId}"
|
|
||||||
Dim oTable = Database.GetDatatable(oSql)
|
|
||||||
|
|
||||||
Return oTable?.Rows.Cast(Of DataRow).
|
|
||||||
Select(AddressOf ToEnvelope).
|
|
||||||
ToList()
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return Nothing
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function Insert(pEnvelope As Envelope) As Boolean
|
|
||||||
Try
|
|
||||||
Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE] (SUBJECT, MESSAGE, ENVELOPE_UUID, STATUS, USER_ID) VALUES (@SUBJECT, @MESSAGE, @UUID, @STATUS, @USER_ID)"
|
|
||||||
Dim oCommand As New SqlCommand(oSql)
|
|
||||||
oCommand.Parameters.Add("SUBJECT", SqlDbType.NVarChar).Value = String.Empty
|
|
||||||
oCommand.Parameters.Add("MESSAGE", SqlDbType.NVarChar).Value = String.Empty
|
|
||||||
oCommand.Parameters.Add("UUID", SqlDbType.NVarChar).Value = pEnvelope.Uuid
|
|
||||||
oCommand.Parameters.Add("STATUS", SqlDbType.NVarChar).Value = Constants.EnvelopeStatus.Created
|
|
||||||
oCommand.Parameters.Add("USER_ID", SqlDbType.Int).Value = pEnvelope.UserId
|
|
||||||
|
|
||||||
If Database.ExecuteNonQuery(oCommand) Then
|
|
||||||
pEnvelope.Id = GetEnvelopeId(pEnvelope)
|
|
||||||
Return True
|
|
||||||
Else
|
|
||||||
Return False
|
|
||||||
End If
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function Update(pEnvelope As Envelope, pTransaction As SqlTransaction) As Boolean
|
|
||||||
Try
|
|
||||||
Dim oSql = "UPDATE [dbo].[TBSIG_ENVELOPE] SET [SUBJECT] = @SUBJECT, [MESSAGE] = @MESSAGE, [STATUS] = @STATUS WHERE GUID = @ID AND USER_ID = @USER_ID"
|
|
||||||
Dim oCommand As New SqlCommand(oSql)
|
|
||||||
oCommand.Parameters.Add("SUBJECT", SqlDbType.NVarChar).Value = pEnvelope.Subject
|
|
||||||
oCommand.Parameters.Add("MESSAGE", SqlDbType.NVarChar).Value = pEnvelope.Message
|
|
||||||
oCommand.Parameters.Add("STATUS", SqlDbType.NVarChar).Value = pEnvelope.Status
|
|
||||||
|
|
||||||
oCommand.Parameters.Add("ID", SqlDbType.Int).Value = pEnvelope.Id
|
|
||||||
oCommand.Parameters.Add("USER_ID", SqlDbType.Int).Value = pEnvelope.UserId
|
|
||||||
|
|
||||||
Return Database.ExecuteNonQuery(oCommand, pTransaction)
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function Delete(pEnvelope As Envelope) As Boolean
|
|
||||||
Try
|
|
||||||
Dim oSql = $"DELETE FROM [dbo].[TBSIG_ENVELOPE] WHERE GUID = {pEnvelope.Id}"
|
|
||||||
Return Database.ExecuteNonQuery(oSql)
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Return False
|
|
||||||
Logger.Error(ex)
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Private Function GetEnvelopeId(pEnvelope As Envelope) As Integer
|
|
||||||
Try
|
|
||||||
Return Database.GetScalarValue($"SELECT MAX(GUID) FROM TBSIG_ENVELOPE WHERE USER_ID = {pEnvelope.UserId}")
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return Nothing
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
End Class
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
Imports System.Data
|
|
||||||
Imports System.Data.SqlClient
|
|
||||||
|
|
||||||
Public Class HistoryModel
|
|
||||||
Inherits BaseModel
|
|
||||||
|
|
||||||
Public Sub New(pState As State)
|
|
||||||
MyBase.New(pState)
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Public Function Insert(pHistory As EnvelopeHistoryEntry) As Boolean
|
|
||||||
Try
|
|
||||||
Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE_HISTORY]
|
|
||||||
([ENVELOPE_ID]
|
|
||||||
,[STATUS]
|
|
||||||
,[USER_EMAIL_ADDRESS]
|
|
||||||
,[ACTION_TITLE]
|
|
||||||
,[ACTION_DESCRIPTION])
|
|
||||||
VALUES
|
|
||||||
(@ENVELOPE_ID
|
|
||||||
,@STATUS
|
|
||||||
,@EMAIL
|
|
||||||
,@TITLE
|
|
||||||
,@DESCRIPTION"
|
|
||||||
|
|
||||||
Dim oCommand As New SqlCommand(oSql)
|
|
||||||
oCommand.Parameters.Add("ENVELOPE_ID", SqlDbType.Int).Value = pHistory.EnvelopeId
|
|
||||||
oCommand.Parameters.Add("STATUS", SqlDbType.NVarChar).Value = pHistory.Status
|
|
||||||
oCommand.Parameters.Add("EMAIL", SqlDbType.NVarChar).Value = pHistory.UserEmailAddress
|
|
||||||
oCommand.Parameters.Add("TITLE", SqlDbType.NVarChar).Value = pHistory.ActionTitle
|
|
||||||
oCommand.Parameters.Add("DESCRIPTION", SqlDbType.NVarChar).Value = pHistory.ActionDescription
|
|
||||||
|
|
||||||
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
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
Imports System.Data
|
|
||||||
Imports System.Data.Common
|
|
||||||
Imports System.Data.SqlClient
|
|
||||||
Imports DigitalData.Modules.Base
|
|
||||||
Public Class ReceiverModel
|
|
||||||
Inherits BaseModel
|
|
||||||
|
|
||||||
Public Sub New(pState As State)
|
|
||||||
MyBase.New(pState)
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Function ToReceiver(pRow As DataRow) As EnvelopeReceiver
|
|
||||||
Return New EnvelopeReceiver() With {
|
|
||||||
.Id = pRow.ItemEx("GUID", 0),
|
|
||||||
.Email = pRow.ItemEx("EMAIL_ADDRESS", ""),
|
|
||||||
.Name = pRow.ItemEx("NAME", ""),
|
|
||||||
.Sequence = pRow.ItemEx("SEQUENCE", 0)
|
|
||||||
}
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function TestReceiverExists(pReceiver As EnvelopeReceiver) As Boolean
|
|
||||||
Try
|
|
||||||
Dim oGuid = Database.GetScalarValue($"SELECT COALESCE(GUID, 0) FROM TBSIG_RECEIVER WHERE EMAIL_ADDRESS = '{pReceiver.Email}'")
|
|
||||||
pReceiver.Id = oGuid
|
|
||||||
Return oGuid > 0
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function Insert(pReceiver As EnvelopeReceiver, pTransaction As SqlTransaction) As Boolean
|
|
||||||
Try
|
|
||||||
Dim oSql As String = "INSERT INTO [dbo].[TBSIG_RECEIVER]
|
|
||||||
([EMAIL_ADDRESS]
|
|
||||||
,[SIGNATURE])
|
|
||||||
VALUES
|
|
||||||
(@EMAIL
|
|
||||||
,@SIGNATURE)"
|
|
||||||
|
|
||||||
Dim oCommand = New SqlCommand(oSql)
|
|
||||||
oCommand.Parameters.Add("EMAIL", SqlDbType.NVarChar).Value = pReceiver.Email
|
|
||||||
oCommand.Parameters.Add("SIGNATURE", SqlDbType.NVarChar).Value = pReceiver.Signature
|
|
||||||
|
|
||||||
Dim oResult = Database.ExecuteNonQuery(oCommand, pTransaction)
|
|
||||||
If oResult = True Then
|
|
||||||
pReceiver.Id = GetReceiverId(pReceiver.Email, pTransaction)
|
|
||||||
Else
|
|
||||||
Return False
|
|
||||||
End If
|
|
||||||
|
|
||||||
Return True
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function Update(pReceiver As EnvelopeReceiver, pTransaction As SqlTransaction) As Boolean
|
|
||||||
Try
|
|
||||||
Dim oSql As String = "UPDATE [dbo].[TBSIG_USER_RECEIVER]
|
|
||||||
SET [NAME] = @NAME
|
|
||||||
,[COMPANY_NAME] = @COMPANY
|
|
||||||
,[JOB_TITLE] = @JOB
|
|
||||||
WHERE RECEIVER_ID = @RECEIVER_ID"
|
|
||||||
|
|
||||||
Dim oCommand = New SqlCommand(oSql)
|
|
||||||
oCommand.Parameters.Add("NAME", SqlDbType.NVarChar).Value = pReceiver.Name
|
|
||||||
oCommand.Parameters.Add("COMPANY", SqlDbType.NVarChar).Value = pReceiver.Company
|
|
||||||
oCommand.Parameters.Add("JOB", SqlDbType.NVarChar).Value = pReceiver.JobTitle
|
|
||||||
oCommand.Parameters.Add("RECEIVER_ID", SqlDbType.Int).Value = pReceiver.Id
|
|
||||||
oCommand.Parameters.Add("USER_ID", SqlDbType.Int).Value = pReceiver.Id
|
|
||||||
|
|
||||||
Return Database.ExecuteNonQuery(oCommand, pTransaction)
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function Unassign(pEnvelope As Envelope, pTransaction As SqlTransaction) As Boolean
|
|
||||||
Try
|
|
||||||
Return Database.ExecuteNonQuery($"DELETE FROM [dbo].[TBSIG_ENVELOPE_RECEIVER] WHERE [ENVELOPE_ID] = {pEnvelope.Id}", pTransaction)
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function Assign(pEnvelope As Envelope, pReceiver As EnvelopeReceiver, pTransaction As SqlTransaction) As Boolean
|
|
||||||
Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE_RECEIVER]
|
|
||||||
([ENVELOPE_ID]
|
|
||||||
,[RECEIVER_ID]
|
|
||||||
,[PRIVATE_MESSAGE]
|
|
||||||
,[ACCESS_CODE]
|
|
||||||
,[NAME]
|
|
||||||
,[JOB_TITLE]
|
|
||||||
,[COMPANY_NAME]
|
|
||||||
,[SEQUENCE])
|
|
||||||
VALUES
|
|
||||||
(@ENVELOPE_ID
|
|
||||||
,@RECEIVER_ID
|
|
||||||
,@MESSAGE
|
|
||||||
,@ACCESS_CODE
|
|
||||||
,@NAME
|
|
||||||
,@JOB
|
|
||||||
,@COMPANY
|
|
||||||
,@SEQUENCE)"
|
|
||||||
|
|
||||||
Dim oCommand As New SqlCommand(oSql)
|
|
||||||
oCommand.Parameters.Add("ENVELOPE_ID", SqlDbType.NVarChar).Value = pEnvelope.Id
|
|
||||||
oCommand.Parameters.Add("RECEIVER_ID", SqlDbType.NVarChar).Value = pReceiver.Id
|
|
||||||
oCommand.Parameters.Add("MESSAGE", SqlDbType.NVarChar).Value = pReceiver.PrivateMessage
|
|
||||||
oCommand.Parameters.Add("ACCESS_CODE", SqlDbType.NVarChar).Value = pReceiver.AccessCode
|
|
||||||
oCommand.Parameters.Add("NAME", SqlDbType.NVarChar).Value = pReceiver.Name
|
|
||||||
oCommand.Parameters.Add("JOB", SqlDbType.NVarChar).Value = pReceiver.JobTitle
|
|
||||||
oCommand.Parameters.Add("COMPANY", SqlDbType.NVarChar).Value = pReceiver.Company
|
|
||||||
oCommand.Parameters.Add("SEQUENCE", SqlDbType.NVarChar).Value = pReceiver.Sequence
|
|
||||||
|
|
||||||
Return Database.ExecuteNonQuery(oCommand, pTransaction)
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function List(pEnvelopeId As Integer) As IEnumerable(Of EnvelopeReceiver)
|
|
||||||
Try
|
|
||||||
Dim oSql = $"SELECT * FROM [dbo].[VWSIG_ENVELOPE_RECEIVERS] WHERE ENVELOPE_ID = {pEnvelopeId}"
|
|
||||||
Dim oTable = Database.GetDatatable(oSql)
|
|
||||||
|
|
||||||
Return oTable?.Rows.Cast(Of DataRow).
|
|
||||||
Select(AddressOf ToReceiver).
|
|
||||||
ToList()
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return Nothing
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function Delete(pReceiverId As Integer, pDocumentId As Integer) As Boolean
|
|
||||||
Try
|
|
||||||
Dim oSql = $"DELETE FROM TBSIG_DOCUMENT_RECEIVER WHERE RECEIVER_ID = {pReceiverId} AND DOCUMENT_ID = {pDocumentId}"
|
|
||||||
Return Database.ExecuteNonQuery(oSql)
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return False
|
|
||||||
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Private Function GetReceiverId(pEmailAddress As String, pTransaction As SqlTransaction) As Integer
|
|
||||||
Try
|
|
||||||
Return Database.GetScalarValue($"SELECT GUID FROM TBSIG_RECEIVER WHERE EMAIL_ADDRESS = '{pEmailAddress}'", pTransaction)
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return Nothing
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
End Class
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
'------------------------------------------------------------------------------
|
|
||||||
' <auto-generated>
|
|
||||||
' Dieser Code wurde von einem Tool generiert.
|
|
||||||
' Laufzeitversion:4.0.30319.42000
|
|
||||||
'
|
|
||||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
|
||||||
' der Code erneut generiert wird.
|
|
||||||
' </auto-generated>
|
|
||||||
'------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Option Strict On
|
|
||||||
Option Explicit On
|
|
||||||
|
|
||||||
Imports System
|
|
||||||
|
|
||||||
Namespace My.Resources
|
|
||||||
|
|
||||||
'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
|
|
||||||
'-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
|
||||||
'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
|
||||||
'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
|
||||||
'''<summary>
|
|
||||||
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
|
||||||
'''</summary>
|
|
||||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0"), _
|
|
||||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
|
||||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
|
||||||
Friend Class Envelope
|
|
||||||
|
|
||||||
Private Shared resourceMan As Global.System.Resources.ResourceManager
|
|
||||||
|
|
||||||
Private Shared resourceCulture As Global.System.Globalization.CultureInfo
|
|
||||||
|
|
||||||
<Global.System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _
|
|
||||||
Friend Sub New()
|
|
||||||
MyBase.New
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
'''<summary>
|
|
||||||
''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
|
||||||
'''</summary>
|
|
||||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
|
||||||
Friend Shared ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
|
|
||||||
Get
|
|
||||||
If Object.ReferenceEquals(resourceMan, Nothing) Then
|
|
||||||
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("EnvelopeGenerator.Common.Envelope", GetType(Envelope).Assembly)
|
|
||||||
resourceMan = temp
|
|
||||||
End If
|
|
||||||
Return resourceMan
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
|
|
||||||
'''<summary>
|
|
||||||
''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
|
||||||
''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
|
||||||
'''</summary>
|
|
||||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
|
||||||
Friend Shared Property Culture() As Global.System.Globalization.CultureInfo
|
|
||||||
Get
|
|
||||||
Return resourceCulture
|
|
||||||
End Get
|
|
||||||
Set
|
|
||||||
resourceCulture = value
|
|
||||||
End Set
|
|
||||||
End Property
|
|
||||||
|
|
||||||
'''<summary>
|
|
||||||
''' Sucht eine lokalisierte Zeichenfolge, die Empfänger {0} hat keine gültige Email Addresse. ähnelt.
|
|
||||||
'''</summary>
|
|
||||||
Friend Shared ReadOnly Property Invalid_Email_Address() As String
|
|
||||||
Get
|
|
||||||
Return ResourceManager.GetString("Invalid Email Address", resourceCulture)
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
|
|
||||||
'''<summary>
|
|
||||||
''' Sucht eine lokalisierte Zeichenfolge, die Missing Documents ähnelt.
|
|
||||||
'''</summary>
|
|
||||||
Friend Shared ReadOnly Property Missing_Documents() As String
|
|
||||||
Get
|
|
||||||
Return ResourceManager.GetString("Missing Documents", resourceCulture)
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
|
|
||||||
'''<summary>
|
|
||||||
''' Sucht eine lokalisierte Zeichenfolge, die Missing Message ähnelt.
|
|
||||||
'''</summary>
|
|
||||||
Friend Shared ReadOnly Property Missing_Message() As String
|
|
||||||
Get
|
|
||||||
Return ResourceManager.GetString("Missing Message", resourceCulture)
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
|
|
||||||
'''<summary>
|
|
||||||
''' Sucht eine lokalisierte Zeichenfolge, die Missing Receivers ähnelt.
|
|
||||||
'''</summary>
|
|
||||||
Friend Shared ReadOnly Property Missing_Receivers() As String
|
|
||||||
Get
|
|
||||||
Return ResourceManager.GetString("Missing Receivers", resourceCulture)
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
|
|
||||||
'''<summary>
|
|
||||||
''' Sucht eine lokalisierte Zeichenfolge, die Missing Subject ähnelt.
|
|
||||||
'''</summary>
|
|
||||||
Friend Shared ReadOnly Property Missing_Subject() As String
|
|
||||||
Get
|
|
||||||
Return ResourceManager.GetString("Missing Subject", resourceCulture)
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
End Class
|
|
||||||
End Namespace
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<data name="Invalid Email Address" xml:space="preserve">
|
|
||||||
<value>Empfänger {0} hat keine gültige Email Addresse.</value>
|
|
||||||
</data>
|
|
||||||
<data name="Missing Documents" xml:space="preserve">
|
|
||||||
<value>Missing Documents</value>
|
|
||||||
</data>
|
|
||||||
<data name="Missing Message" xml:space="preserve">
|
|
||||||
<value>Missing Message</value>
|
|
||||||
</data>
|
|
||||||
<data name="Missing Receivers" xml:space="preserve">
|
|
||||||
<value>Missing Receivers</value>
|
|
||||||
</data>
|
|
||||||
<data name="Missing Subject" xml:space="preserve">
|
|
||||||
<value>Missing Subject</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
||||||
90
EnvelopeGenerator.Web/Controllers/DocumentController.cs
Normal file
90
EnvelopeGenerator.Web/Controllers/DocumentController.cs
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
using DigitalData.Modules.Logging;
|
||||||
|
using EnvelopeGenerator.Common;
|
||||||
|
using EnvelopeGenerator.Web.Services;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Reflection.Metadata;
|
||||||
|
using static EnvelopeGenerator.Web.Handler.FileHandler;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Web.Controllers
|
||||||
|
{
|
||||||
|
public class DocumentController : Controller
|
||||||
|
{
|
||||||
|
private readonly DatabaseService database;
|
||||||
|
private readonly LoggingService logging;
|
||||||
|
private readonly Logger logger;
|
||||||
|
private readonly ApiService api;
|
||||||
|
|
||||||
|
public DocumentController(DatabaseService database, LoggingService logging, ApiService api)
|
||||||
|
{
|
||||||
|
this.database = database;
|
||||||
|
this.logging = logging;
|
||||||
|
this.logger = logging.LogConfig.GetLoggerFor(GetType().Name);
|
||||||
|
this.api = api;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("api/document/{envelopeKey}")]
|
||||||
|
[IgnoreAntiforgeryToken]
|
||||||
|
public async Task<IActionResult> Get(string envelopeKey)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
logger.Info("Handling file download.");
|
||||||
|
|
||||||
|
EnvelopeResponse r = api.EnsureValidEnvelopeKey(envelopeKey);
|
||||||
|
|
||||||
|
var Request = ControllerContext.HttpContext.Request;
|
||||||
|
var document = api.GetDocument(Request, envelopeKey);
|
||||||
|
|
||||||
|
// Load the document from disk
|
||||||
|
var bytes = await System.IO.File.ReadAllBytesAsync(document.Filepath);
|
||||||
|
logger.Info("Serving file, size: [{0}]", bytes.Length);
|
||||||
|
|
||||||
|
// Return the document as bytes
|
||||||
|
return File(bytes, "application/octet-stream");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// Better error handling & reporting
|
||||||
|
logger.Error(e);
|
||||||
|
return Problem(
|
||||||
|
statusCode: 500,
|
||||||
|
detail: e.Message,
|
||||||
|
type: ErrorType.ServerError.ToString());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Route("api/document/{envelopeKey}")]
|
||||||
|
[IgnoreAntiforgeryToken]
|
||||||
|
public async Task<IActionResult> Update(string envelopeKey)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
logger.Info("Handling file update.");
|
||||||
|
|
||||||
|
api.EnsureValidEnvelopeKey(envelopeKey);
|
||||||
|
|
||||||
|
var Request = ControllerContext.HttpContext.Request;
|
||||||
|
var document = api.GetDocument(Request, envelopeKey);
|
||||||
|
|
||||||
|
if (!await api.UpdateDocument(Request.Body, document.Filepath))
|
||||||
|
{
|
||||||
|
throw new IOException("Document could not be saved to disk!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// Better error handling & reporting
|
||||||
|
logger.Error(e);
|
||||||
|
return Problem(
|
||||||
|
statusCode: 500,
|
||||||
|
detail: e.Message,
|
||||||
|
type: ErrorType.ServerError.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
98
EnvelopeGenerator.Web/Controllers/EnvelopeController.cs
Normal file
98
EnvelopeGenerator.Web/Controllers/EnvelopeController.cs
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
using EnvelopeGenerator.Common;
|
||||||
|
using EnvelopeGenerator.Web.Services;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NLog;
|
||||||
|
using static EnvelopeGenerator.Web.Handler.FileHandler;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Web.Controllers
|
||||||
|
{
|
||||||
|
public class EnvelopeController : Controller
|
||||||
|
{
|
||||||
|
private readonly DatabaseService database;
|
||||||
|
private readonly LoggingService logging;
|
||||||
|
private readonly Logger logger;
|
||||||
|
private readonly ApiService api;
|
||||||
|
|
||||||
|
public EnvelopeController(DatabaseService database, LoggingService logging, ApiService api)
|
||||||
|
{
|
||||||
|
this.database = database;
|
||||||
|
this.logging = logging;
|
||||||
|
this.logger = logging.LogConfig.GetLoggerFor(GetType().Name);
|
||||||
|
this.api = api;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("api/envelope/{envelopeKey}")]
|
||||||
|
[IgnoreAntiforgeryToken]
|
||||||
|
public IActionResult Get(string envelopeKey)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
logger.Info("Handling envelope loading.");
|
||||||
|
|
||||||
|
EnvelopeResponse r = api.EnsureValidEnvelopeKey(envelopeKey);
|
||||||
|
|
||||||
|
// Return the envelope and additional data as json
|
||||||
|
return Json(r);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// Better error handling & reporting
|
||||||
|
logger.Error(e);
|
||||||
|
return Problem(
|
||||||
|
statusCode: 500,
|
||||||
|
detail: e.Message,
|
||||||
|
type: ErrorType.ServerError.ToString());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Route("api/envelope/{envelopeKey}")]
|
||||||
|
[IgnoreAntiforgeryToken]
|
||||||
|
public async Task<IActionResult> Update(string envelopeKey)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
logger.Info("Handling envelope saving.");
|
||||||
|
|
||||||
|
api.EnsureValidEnvelopeKey(envelopeKey);
|
||||||
|
|
||||||
|
EnvelopeResponse r = database.LoadEnvelope(envelopeKey);
|
||||||
|
|
||||||
|
var Request = ControllerContext.HttpContext.Request;
|
||||||
|
var document = api.GetDocument(Request, envelopeKey);
|
||||||
|
|
||||||
|
string? annotationData = await api.EnsureValidAnnotationData(Request);
|
||||||
|
|
||||||
|
if (annotationData == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("AnnotationData");
|
||||||
|
}
|
||||||
|
|
||||||
|
State state = api.GetState(logging.LogConfig, database.MSSQL);
|
||||||
|
DocumentStatusModel model = new(state);
|
||||||
|
|
||||||
|
model.InsertOrUpdate(new DocumentStatus()
|
||||||
|
{
|
||||||
|
EnvelopeId = r.Envelope.Id,
|
||||||
|
ReceiverId = r.ReceiverId,
|
||||||
|
Value = annotationData,
|
||||||
|
Status = Common.Constants.DocumentStatus.Signed
|
||||||
|
});
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// Better error handling & reporting
|
||||||
|
logger.Error(e);
|
||||||
|
return Problem(
|
||||||
|
statusCode: 500,
|
||||||
|
detail: e.Message,
|
||||||
|
type: ErrorType.ServerError.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
75
EnvelopeGenerator.Web/Controllers/HistoryController.cs
Normal file
75
EnvelopeGenerator.Web/Controllers/HistoryController.cs
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
using DigitalData.Modules.Logging;
|
||||||
|
using EnvelopeGenerator.Common;
|
||||||
|
using EnvelopeGenerator.Web.Services;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Primitives;
|
||||||
|
using static EnvelopeGenerator.Common.Constants;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Web.Controllers
|
||||||
|
{
|
||||||
|
public class HistoryController : Controller
|
||||||
|
{
|
||||||
|
private readonly DatabaseService database;
|
||||||
|
private readonly LoggingService logging;
|
||||||
|
private readonly Logger logger;
|
||||||
|
private readonly ApiService api;
|
||||||
|
|
||||||
|
public HistoryController(DatabaseService database, LoggingService logging, ApiService api)
|
||||||
|
{
|
||||||
|
this.database = database;
|
||||||
|
this.logging = logging;
|
||||||
|
this.logger = logging.LogConfig.GetLoggerFor(GetType().Name);
|
||||||
|
this.api = api;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Route("api/history/{envelopeKey}")]
|
||||||
|
[IgnoreAntiforgeryToken]
|
||||||
|
public IActionResult Create(string envelopeKey, [FromBody] ActionObject action)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var Request = ControllerContext.HttpContext.Request;
|
||||||
|
|
||||||
|
api.EnsureValidEnvelopeKey(envelopeKey);
|
||||||
|
EnvelopeResponse r = database.LoadEnvelope(envelopeKey);
|
||||||
|
var receiver = r.Envelope.Receivers.Where(receiver => receiver.Id == r.ReceiverId).SingleOrDefault();
|
||||||
|
|
||||||
|
if (receiver == null)
|
||||||
|
{
|
||||||
|
return BadRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
string actionTypeString = action.actionType;
|
||||||
|
string actionDescription = action.actionDescription;
|
||||||
|
|
||||||
|
if (!Enum.TryParse<EnvelopeHistoryActionType>(actionTypeString, out var actionType))
|
||||||
|
{
|
||||||
|
return BadRequest();
|
||||||
|
};
|
||||||
|
|
||||||
|
database.InsertHistoryEntry(new EnvelopeHistoryEntry()
|
||||||
|
{
|
||||||
|
ActionDescription = actionDescription,
|
||||||
|
ActionDate = DateTime.Now,
|
||||||
|
ActionType = actionType,
|
||||||
|
EnvelopeId = r.Envelope.Id,
|
||||||
|
UserReference = receiver.Email
|
||||||
|
});
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logger.Error(e);
|
||||||
|
return Problem(statusCode: 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ActionObject
|
||||||
|
{
|
||||||
|
public string actionType { get; set; }
|
||||||
|
public string actionDescription { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ namespace EnvelopeGenerator.Web.Handler
|
|||||||
public enum ErrorType
|
public enum ErrorType
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
ServerError
|
ServerError,
|
||||||
|
FilesystemError
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -3,9 +3,11 @@
|
|||||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<base href="~/" />
|
<base href="~/" />
|
||||||
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
|
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
using EnvelopeGenerator.Web.Handler;
|
|
||||||
using EnvelopeGenerator.Web.Services;
|
using EnvelopeGenerator.Web.Services;
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Components;
|
|
||||||
using Microsoft.AspNetCore.Components.Web;
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@@ -12,8 +8,11 @@ builder.Services.AddServerSideBlazor();
|
|||||||
|
|
||||||
// Add custom services
|
// Add custom services
|
||||||
builder.Services.AddSingleton<LoggingService>();
|
builder.Services.AddSingleton<LoggingService>();
|
||||||
|
builder.Services.AddSingleton<ApiService>();
|
||||||
builder.Services.AddTransient<DatabaseService>();
|
builder.Services.AddTransient<DatabaseService>();
|
||||||
|
|
||||||
|
builder.Services.AddControllers();
|
||||||
|
|
||||||
builder.Services.AddLocalization();
|
builder.Services.AddLocalization();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
@@ -35,13 +34,8 @@ app.UseStaticFiles();
|
|||||||
// Add a router
|
// Add a router
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|
||||||
// Add file download endpoint
|
// Add controller routes
|
||||||
FileHandler handler = new();
|
app.MapControllers();
|
||||||
|
|
||||||
app.MapGet("/api/document/{envelopeKey}", handler.HandleGetDocument);
|
|
||||||
app.MapPost("/api/document/{envelopeKey}", handler.HandlePostDocument);
|
|
||||||
app.MapGet("/api/envelope/{envelopeKey}", handler.HandleGetEnvelope);
|
|
||||||
app.MapPost("/api/envelope/{envelopeKey}", handler.HandlePostEnvelope);
|
|
||||||
|
|
||||||
// Blazor plumbing
|
// Blazor plumbing
|
||||||
app.MapBlazorHub();
|
app.MapBlazorHub();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import PSPDFKitType, { AnnotationsUnion, SignatureFormField as SignatureFormFieldType } from "./index";
|
import PSPDFKitType, { Action, AnnotationsUnion, SignatureFormField as SignatureFormFieldType } from "./index";
|
||||||
import { Instance, WidgetAnnotation, ToolbarItem } from "./index";
|
import { Instance, WidgetAnnotation, ToolbarItem } from "./index";
|
||||||
import { EnvelopeResponse, Envelope, User, Element, Document, IFunction } from "./interfaces";
|
import { EnvelopeResponse, Envelope, User, Element, Document, IFunction } from "./interfaces";
|
||||||
|
|
||||||
@@ -10,6 +10,17 @@ const { SignatureFormField } = PSPDFKit.FormFields;
|
|||||||
const { DRAW, TYPE } = PSPDFKit.ElectronicSignatureCreationMode;
|
const { DRAW, TYPE } = PSPDFKit.ElectronicSignatureCreationMode;
|
||||||
const { DISABLED } = PSPDFKit.AutoSaveMode;
|
const { DISABLED } = PSPDFKit.AutoSaveMode;
|
||||||
|
|
||||||
|
enum ActionType {
|
||||||
|
Created = 0,
|
||||||
|
Saved = 1,
|
||||||
|
Sent = 2,
|
||||||
|
EmailSent = 3,
|
||||||
|
Delivered = 4,
|
||||||
|
Seen = 5,
|
||||||
|
Signed = 6,
|
||||||
|
Rejected = 7,
|
||||||
|
}
|
||||||
|
|
||||||
export class App {
|
export class App {
|
||||||
public static Instance: Instance;
|
public static Instance: Instance;
|
||||||
public static currentDocument: Document;
|
public static currentDocument: Document;
|
||||||
@@ -56,6 +67,9 @@ export class App {
|
|||||||
console.debug("Loading annotations..")
|
console.debug("Loading annotations..")
|
||||||
const annotations = App.Annotation.createAnnotations(App.currentDocument)
|
const annotations = App.Annotation.createAnnotations(App.currentDocument)
|
||||||
const createdAnnotations = await App.Instance.create(annotations)
|
const createdAnnotations = await App.Instance.create(annotations)
|
||||||
|
|
||||||
|
const description = "Umschlag wurde geöffnet"
|
||||||
|
await App.Network.postHistory(App.envelopeKey, ActionType.Seen, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async handleClick(eventType: string) {
|
public static async handleClick(eventType: string) {
|
||||||
@@ -125,6 +139,14 @@ export class App {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const description = "Dokument wurde signiert"
|
||||||
|
await App.Network.postHistory(App.envelopeKey, ActionType.Signed, description);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -242,7 +264,7 @@ class Network {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public postDocument(envelopeKey: string, documentId: number, buffer: ArrayBuffer): Promise<any> {
|
public postDocument(envelopeKey: string, documentId: number, buffer: ArrayBuffer): Promise<any> {
|
||||||
const url = `/api/document/${envelopeKey}/${documentId}`;
|
const url = `/api/document/${envelopeKey}?index=${documentId}`;
|
||||||
const options: RequestInit = {
|
const options: RequestInit = {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -279,6 +301,34 @@ class Network {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public postHistory(envelopeKey: string, actionType: ActionType, actionDescription: string): Promise<boolean> {
|
||||||
|
const url = `/api/history/${envelopeKey}`;
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
actionDescription: actionDescription,
|
||||||
|
actionType: actionType.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
const options: RequestInit = {
|
||||||
|
credentials: "include",
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
'Content-Type': "application/json; charset=utf-8"
|
||||||
|
},
|
||||||
|
body: JSON.stringify(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.debug("PostHistory/Calling url: " + url)
|
||||||
|
return fetch(url, options)
|
||||||
|
.then(this.handleResponse)
|
||||||
|
.then((res: Response) => {
|
||||||
|
if (!res.ok) {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private handleResponse(res: Response) {
|
private handleResponse(res: Response) {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
console.log(`Request failed with status ${res.status}`)
|
console.log(`Request failed with status ${res.status}`)
|
||||||
|
|||||||
134
EnvelopeGenerator.Web/Services/ApiService.cs
Normal file
134
EnvelopeGenerator.Web/Services/ApiService.cs
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
using DigitalData.Modules.Database;
|
||||||
|
using DigitalData.Modules.Logging;
|
||||||
|
using EnvelopeGenerator.Common;
|
||||||
|
using Microsoft.Extensions.Primitives;
|
||||||
|
using System.Reflection.Metadata;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Web.Services
|
||||||
|
{
|
||||||
|
public class ApiService
|
||||||
|
{
|
||||||
|
private readonly DatabaseService database;
|
||||||
|
private readonly LogConfig logConfig;
|
||||||
|
private readonly Logger logger;
|
||||||
|
|
||||||
|
public ApiService(LoggingService Logging, DatabaseService database, IConfiguration Config)
|
||||||
|
{
|
||||||
|
this.database = database;
|
||||||
|
this.logConfig = Logging.LogConfig;
|
||||||
|
this.logger = Logging.LogConfig.GetLogger();
|
||||||
|
|
||||||
|
logger.Debug("Initializing ApiService");
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnvelopeResponse EnsureValidEnvelopeKey(string envelopeKey)
|
||||||
|
{
|
||||||
|
logger.Debug("Parsing EnvelopeKey..");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(envelopeKey))
|
||||||
|
throw new ArgumentNullException("EnvelopeKey");
|
||||||
|
|
||||||
|
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(envelopeKey);
|
||||||
|
logger.Debug("EnvelopeUUID: [{0}]", result.Item1);
|
||||||
|
logger.Debug("ReceiverSignature: [{0}]", result.Item2);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(result.Item1))
|
||||||
|
throw new ArgumentNullException("EnvelopeUUID");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(result.Item2))
|
||||||
|
throw new ArgumentNullException("ReceiverSignature");
|
||||||
|
|
||||||
|
EnvelopeResponse r = database.LoadEnvelope(envelopeKey);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string?> EnsureValidAnnotationData(HttpRequest request)
|
||||||
|
{
|
||||||
|
logger.Debug("Parsing AnnotationData..");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using MemoryStream ms = new();
|
||||||
|
await request.BodyReader.CopyToAsync(ms);
|
||||||
|
var bytes = ms.ToArray();
|
||||||
|
|
||||||
|
return Encoding.UTF8.GetString(bytes);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logger.Error(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int EnsureValidDocumentIndex(HttpRequest request)
|
||||||
|
{
|
||||||
|
if (request.Query.TryGetValue("index", out StringValues documentIndexString))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return int.Parse(documentIndexString.First());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("DocumentIndex", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("DocumentIndex");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public EnvelopeDocument GetDocument(HttpRequest request, string envelopeKey)
|
||||||
|
{
|
||||||
|
EnvelopeResponse r = database.LoadEnvelope(envelopeKey);
|
||||||
|
int documentId = EnsureValidDocumentIndex(request);
|
||||||
|
|
||||||
|
var document = r.Envelope.Documents.
|
||||||
|
Where(d => d.Id == documentId).
|
||||||
|
FirstOrDefault();
|
||||||
|
|
||||||
|
if (document == null)
|
||||||
|
throw new ArgumentException("DocumentId");
|
||||||
|
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateDocument(Stream fileStream, string filePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using FileStream fs = new(filePath, FileMode.Open);
|
||||||
|
await fileStream.CopyToAsync(fs);
|
||||||
|
fs.Flush();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.Error(ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public State GetState(LogConfig LogConfig, MSSQLServer Database)
|
||||||
|
{
|
||||||
|
return new State
|
||||||
|
{
|
||||||
|
LogConfig = LogConfig,
|
||||||
|
Database = Database,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ namespace EnvelopeGenerator.Web.Services
|
|||||||
private DocumentModel documentModel;
|
private DocumentModel documentModel;
|
||||||
private ReceiverModel receiverModel;
|
private ReceiverModel receiverModel;
|
||||||
private ElementModel elementModel;
|
private ElementModel elementModel;
|
||||||
|
private HistoryModel historyModel;
|
||||||
|
|
||||||
private readonly LogConfig _logConfig;
|
private readonly LogConfig _logConfig;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
@@ -54,19 +55,17 @@ namespace EnvelopeGenerator.Web.Services
|
|||||||
documentModel = new(state);
|
documentModel = new(state);
|
||||||
receiverModel = new(state);
|
receiverModel = new(state);
|
||||||
elementModel = new(state);
|
elementModel = new(state);
|
||||||
|
historyModel = new(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnvelopeResponse LoadEnvelope(string pEnvelopeKey)
|
public EnvelopeResponse LoadEnvelope(string pEnvelopeKey)
|
||||||
{
|
{
|
||||||
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(pEnvelopeKey);
|
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(pEnvelopeKey);
|
||||||
var envelopeUuid = result.Item1;
|
var envelopeUuid = result.Item1;
|
||||||
var receiverSignature = result.Item2;
|
var receiverSignature = result.Item2;
|
||||||
var receiverId = receiverModel.GetReceiverIdBySignature(receiverSignature);
|
var receiverId = receiverModel.GetReceiverIdBySignature(receiverSignature);
|
||||||
|
|
||||||
Envelope envelope = envelopeModel.GetByUuid(envelopeUuid);
|
Envelope envelope = envelopeModel.GetByUuid(envelopeUuid);
|
||||||
List<EnvelopeDocument> documents = (List<EnvelopeDocument>)documentModel.List(envelope.Id, receiverId);
|
|
||||||
|
|
||||||
envelope.Documents = documents;
|
|
||||||
|
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
@@ -85,5 +84,10 @@ namespace EnvelopeGenerator.Web.Services
|
|||||||
return documentModel.GetById(pDocumentId);
|
return documentModel.GetById(pDocumentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool InsertHistoryEntry(EnvelopeHistoryEntry historyEntry)
|
||||||
|
{
|
||||||
|
return historyModel.Insert(historyEntry);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,17 @@ var Rect = PSPDFKit.Geometry.Rect;
|
|||||||
var SignatureFormField = PSPDFKit.FormFields.SignatureFormField;
|
var SignatureFormField = PSPDFKit.FormFields.SignatureFormField;
|
||||||
var _a = PSPDFKit.ElectronicSignatureCreationMode, DRAW = _a.DRAW, TYPE = _a.TYPE;
|
var _a = PSPDFKit.ElectronicSignatureCreationMode, DRAW = _a.DRAW, TYPE = _a.TYPE;
|
||||||
var DISABLED = PSPDFKit.AutoSaveMode.DISABLED;
|
var DISABLED = PSPDFKit.AutoSaveMode.DISABLED;
|
||||||
|
var ActionType;
|
||||||
|
(function (ActionType) {
|
||||||
|
ActionType[ActionType["Created"] = 0] = "Created";
|
||||||
|
ActionType[ActionType["Saved"] = 1] = "Saved";
|
||||||
|
ActionType[ActionType["Sent"] = 2] = "Sent";
|
||||||
|
ActionType[ActionType["EmailSent"] = 3] = "EmailSent";
|
||||||
|
ActionType[ActionType["Delivered"] = 4] = "Delivered";
|
||||||
|
ActionType[ActionType["Seen"] = 5] = "Seen";
|
||||||
|
ActionType[ActionType["Signed"] = 6] = "Signed";
|
||||||
|
ActionType[ActionType["Rejected"] = 7] = "Rejected";
|
||||||
|
})(ActionType || (ActionType = {}));
|
||||||
var App = /** @class */ (function () {
|
var App = /** @class */ (function () {
|
||||||
function App() {
|
function App() {
|
||||||
}
|
}
|
||||||
@@ -46,7 +57,7 @@ var App = /** @class */ (function () {
|
|||||||
// and will trigger loading of the Editor Interface
|
// and will trigger loading of the Editor Interface
|
||||||
App.init = function (container, envelopeKey) {
|
App.init = function (container, envelopeKey) {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
var envelopeObject, arrayBuffer, e_1, _a, annotations, createdAnnotations;
|
var envelopeObject, arrayBuffer, e_1, _a, annotations, createdAnnotations, description;
|
||||||
return __generator(this, function (_b) {
|
return __generator(this, function (_b) {
|
||||||
switch (_b.label) {
|
switch (_b.label) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -90,6 +101,10 @@ var App = /** @class */ (function () {
|
|||||||
return [4 /*yield*/, App.Instance.create(annotations)];
|
return [4 /*yield*/, App.Instance.create(annotations)];
|
||||||
case 7:
|
case 7:
|
||||||
createdAnnotations = _b.sent();
|
createdAnnotations = _b.sent();
|
||||||
|
description = "Umschlag wurde geöffnet";
|
||||||
|
return [4 /*yield*/, App.Network.postHistory(App.envelopeKey, ActionType.Seen, description)];
|
||||||
|
case 8:
|
||||||
|
_b.sent();
|
||||||
return [2 /*return*/];
|
return [2 /*return*/];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -136,7 +151,7 @@ var App = /** @class */ (function () {
|
|||||||
};
|
};
|
||||||
App.handleFinish = function (event) {
|
App.handleFinish = function (event) {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
var e_2, json, postEnvelopeResult, e_3, buffer, postDocumentResult, e_4;
|
var e_2, json, postEnvelopeResult, e_3, buffer, postDocumentResult, e_4, description, e_5;
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
switch (_a.label) {
|
switch (_a.label) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -181,7 +196,18 @@ var App = /** @class */ (function () {
|
|||||||
e_4 = _a.sent();
|
e_4 = _a.sent();
|
||||||
console.error(e_4);
|
console.error(e_4);
|
||||||
return [2 /*return*/, false];
|
return [2 /*return*/, false];
|
||||||
case 11: return [2 /*return*/, true];
|
case 11:
|
||||||
|
_a.trys.push([11, 13, , 14]);
|
||||||
|
description = "Dokument wurde signiert";
|
||||||
|
return [4 /*yield*/, App.Network.postHistory(App.envelopeKey, ActionType.Signed, description)];
|
||||||
|
case 12:
|
||||||
|
_a.sent();
|
||||||
|
return [3 /*break*/, 14];
|
||||||
|
case 13:
|
||||||
|
e_5 = _a.sent();
|
||||||
|
console.error(e_5);
|
||||||
|
return [2 /*return*/, false];
|
||||||
|
case 14: return [2 /*return*/, true];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -318,7 +344,7 @@ var Network = /** @class */ (function () {
|
|||||||
.then(function (res) { return res.arrayBuffer(); });
|
.then(function (res) { return res.arrayBuffer(); });
|
||||||
};
|
};
|
||||||
Network.prototype.postDocument = function (envelopeKey, documentId, buffer) {
|
Network.prototype.postDocument = function (envelopeKey, documentId, buffer) {
|
||||||
var url = "/api/document/".concat(envelopeKey, "/").concat(documentId);
|
var url = "/api/document/".concat(envelopeKey, "?index=").concat(documentId);
|
||||||
var options = {
|
var options = {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -353,6 +379,31 @@ var Network = /** @class */ (function () {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Network.prototype.postHistory = function (envelopeKey, actionType, actionDescription) {
|
||||||
|
var url = "/api/history/".concat(envelopeKey);
|
||||||
|
var data = {
|
||||||
|
actionDescription: actionDescription,
|
||||||
|
actionType: actionType.toString()
|
||||||
|
};
|
||||||
|
var options = {
|
||||||
|
credentials: "include",
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
'Content-Type': "application/json; charset=utf-8"
|
||||||
|
},
|
||||||
|
body: JSON.stringify(data)
|
||||||
|
};
|
||||||
|
console.debug("PostHistory/Calling url: " + url);
|
||||||
|
return fetch(url, options)
|
||||||
|
.then(this.handleResponse)
|
||||||
|
.then(function (res) {
|
||||||
|
if (!res.ok) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
};
|
||||||
Network.prototype.handleResponse = function (res) {
|
Network.prototype.handleResponse = function (res) {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
console.log("Request failed with status ".concat(res.status));
|
console.log("Request failed with status ".concat(res.status));
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user