Compare commits
3 Commits
36e441106a
...
56688d2690
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56688d2690 | ||
|
|
624266a971 | ||
|
|
ea35ed0e29 |
@@ -19,4 +19,20 @@ Public Class EmailData
|
|||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
Public Sub New(pEnvelope As Envelope, pReceiver As EnvelopeReceiver)
|
||||||
|
EmailAdress = pReceiver.Email
|
||||||
|
EmailSubject = pEnvelope.Subject
|
||||||
|
Message = pEnvelope.Message
|
||||||
|
ReferenceID = pEnvelope.Id
|
||||||
|
ReferenceString = pEnvelope.Uuid
|
||||||
|
ReceiverName = pReceiver.Name
|
||||||
|
SenderAdress = pEnvelope.User.Email
|
||||||
|
SenderName = pEnvelope.User.FullName
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub New()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ Public Class EmailTemplate
|
|||||||
_DocumentSignedBodyTemplate = New List(Of String) From {
|
_DocumentSignedBodyTemplate = New List(Of String) From {
|
||||||
"Guten Tag, <NAME_RECEIVER>",
|
"Guten Tag, <NAME_RECEIVER>",
|
||||||
"",
|
"",
|
||||||
"Ihre Unterschrift auf dem Dokument <DOCUMENT_TITLE> wurde verarbeitet.",
|
"Ihre Unterschrift auf dem Dokument <DOCUMENT_TITLE> wurde gespeichert.",
|
||||||
"",
|
"",
|
||||||
"Mit freundlichen Grüßen",
|
"Mit freundlichen Grüßen",
|
||||||
"<NAME_SENDER>"
|
"<NAME_SENDER>"
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
Public Property Status As Constants.EnvelopeStatus
|
Public Property Status As Constants.EnvelopeStatus
|
||||||
Public Property Uuid As String = Guid.NewGuid.ToString()
|
Public Property Uuid As String = Guid.NewGuid.ToString()
|
||||||
|
|
||||||
Public Property Subject As String
|
Public Property Subject As String = My.Resources.Envelope.You_received_a_document_to_sign_
|
||||||
Public Property Message As String
|
Public Property Message As String = My.Resources.Envelope.Please_read_and_sign_this_document
|
||||||
|
|
||||||
Public Property AddedWhen As Date
|
Public Property AddedWhen As Date
|
||||||
Public Property User As New User()
|
Public Property User As New User()
|
||||||
|
|||||||
@@ -2,7 +2,5 @@
|
|||||||
Public EnvelopeId As Integer
|
Public EnvelopeId As Integer
|
||||||
Public UserReference As String
|
Public UserReference As String
|
||||||
Public ActionType As Constants.EnvelopeHistoryActionType
|
Public ActionType As Constants.EnvelopeHistoryActionType
|
||||||
Public ActionDescription As String
|
Public ActionDate As Date
|
||||||
Public ActionDate As DateTime
|
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@@ -7,6 +7,25 @@ Public Class HistoryModel
|
|||||||
MyBase.New(pState)
|
MyBase.New(pState)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Function GetActionDescription(pActionType As Constants.EnvelopeHistoryActionType)
|
||||||
|
Select Case pActionType
|
||||||
|
Case Constants.EnvelopeHistoryActionType.Created
|
||||||
|
Return "Umschlag erfolgreich erstellt"
|
||||||
|
|
||||||
|
Case Constants.EnvelopeHistoryActionType.Sent
|
||||||
|
Return "Umschlag an Empfänger versendet"
|
||||||
|
|
||||||
|
Case Constants.EnvelopeHistoryActionType.Seen
|
||||||
|
Return "Umschlag von Empfänger geöffnet"
|
||||||
|
|
||||||
|
Case Constants.EnvelopeHistoryActionType.Signed
|
||||||
|
Return "Umschlag von Empfänger signiert"
|
||||||
|
|
||||||
|
Case Else
|
||||||
|
Return pActionType.ToString()
|
||||||
|
End Select
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Function Insert(pHistory As EnvelopeHistoryEntry) As Boolean
|
Public Function Insert(pHistory As EnvelopeHistoryEntry) As Boolean
|
||||||
Try
|
Try
|
||||||
Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE_HISTORY] "
|
Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE_HISTORY] "
|
||||||
@@ -26,7 +45,7 @@ Public Class HistoryModel
|
|||||||
oCommand.Parameters.Add("ENVELOPE_ID", SqlDbType.Int).Value = pHistory.EnvelopeId
|
oCommand.Parameters.Add("ENVELOPE_ID", SqlDbType.Int).Value = pHistory.EnvelopeId
|
||||||
oCommand.Parameters.Add("USER_REFERENCE", SqlDbType.NVarChar).Value = pHistory.UserReference
|
oCommand.Parameters.Add("USER_REFERENCE", SqlDbType.NVarChar).Value = pHistory.UserReference
|
||||||
oCommand.Parameters.Add("ACTION_TYPE", SqlDbType.Int).Value = pHistory.ActionType
|
oCommand.Parameters.Add("ACTION_TYPE", SqlDbType.Int).Value = pHistory.ActionType
|
||||||
oCommand.Parameters.Add("ACTION_DESCRIPTION", SqlDbType.NVarChar).Value = pHistory.ActionDescription
|
oCommand.Parameters.Add("ACTION_DESCRIPTION", SqlDbType.NVarChar).Value = GetActionDescription(pHistory.ActionType)
|
||||||
oCommand.Parameters.Add("ACTION_DATE", SqlDbType.DateTime).Value = Now()
|
oCommand.Parameters.Add("ACTION_DATE", SqlDbType.DateTime).Value = Now()
|
||||||
|
|
||||||
If Database.ExecuteNonQuery(oCommand) Then
|
If Database.ExecuteNonQuery(oCommand) Then
|
||||||
|
|||||||
@@ -174,6 +174,9 @@
|
|||||||
<data name="Only one file is allowed" xml:space="preserve">
|
<data name="Only one file is allowed" xml:space="preserve">
|
||||||
<value>Only one file is allowed!</value>
|
<value>Only one file is allowed!</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Please read and sign this document" xml:space="preserve">
|
||||||
|
<value>Please read and sign this document.</value>
|
||||||
|
</data>
|
||||||
<data name="Recipient could not be deleted" xml:space="preserve">
|
<data name="Recipient could not be deleted" xml:space="preserve">
|
||||||
<value>Recipient could not be deleted!</value>
|
<value>Recipient could not be deleted!</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -183,4 +186,7 @@
|
|||||||
<data name="The envelope could not be deleted" xml:space="preserve">
|
<data name="The envelope could not be deleted" xml:space="preserve">
|
||||||
<value>The envelope could not be deleted!</value>
|
<value>The envelope could not be deleted!</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="You received a document to sign:" xml:space="preserve">
|
||||||
|
<value>You received a document to sign:</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -174,6 +174,9 @@
|
|||||||
<data name="Only one file is allowed" xml:space="preserve">
|
<data name="Only one file is allowed" xml:space="preserve">
|
||||||
<value>Es ist nur eine Datei zulässig!</value>
|
<value>Es ist nur eine Datei zulässig!</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Please read and sign this document" xml:space="preserve">
|
||||||
|
<value>Bitte lesen und unterzeichnen Sie dieses Dokument.</value>
|
||||||
|
</data>
|
||||||
<data name="Recipient could not be deleted" xml:space="preserve">
|
<data name="Recipient could not be deleted" xml:space="preserve">
|
||||||
<value>Empfänger konnte nicht gelöscht werden!</value>
|
<value>Empfänger konnte nicht gelöscht werden!</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -183,4 +186,7 @@
|
|||||||
<data name="The envelope could not be deleted" xml:space="preserve">
|
<data name="The envelope could not be deleted" xml:space="preserve">
|
||||||
<value>Der Umschlag konnte nicht gelöscht werden!</value>
|
<value>Der Umschlag konnte nicht gelöscht werden!</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="You received a document to sign:" xml:space="preserve">
|
||||||
|
<value>Sie haben ein Dokument zu signieren erhalten:</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -235,6 +235,15 @@ Namespace My.Resources
|
|||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
'''<summary>
|
||||||
|
''' Sucht eine lokalisierte Zeichenfolge, die Bitte lesen und unterzeichnen Sie dieses Dokument. ähnelt.
|
||||||
|
'''</summary>
|
||||||
|
Public Shared ReadOnly Property Please_read_and_sign_this_document() As String
|
||||||
|
Get
|
||||||
|
Return ResourceManager.GetString("Please read and sign this document", resourceCulture)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
'''<summary>
|
'''<summary>
|
||||||
''' Sucht eine lokalisierte Zeichenfolge, die Empfänger konnte nicht gelöscht werden! ähnelt.
|
''' Sucht eine lokalisierte Zeichenfolge, die Empfänger konnte nicht gelöscht werden! ähnelt.
|
||||||
'''</summary>
|
'''</summary>
|
||||||
@@ -261,5 +270,14 @@ Namespace My.Resources
|
|||||||
Return ResourceManager.GetString("The envelope could not be deleted", resourceCulture)
|
Return ResourceManager.GetString("The envelope could not be deleted", resourceCulture)
|
||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
'''<summary>
|
||||||
|
''' Sucht eine lokalisierte Zeichenfolge, die Sie haben ein Dokument zu signieren erhalten: ähnelt.
|
||||||
|
'''</summary>
|
||||||
|
Public Shared ReadOnly Property You_received_a_document_to_sign_() As String
|
||||||
|
Get
|
||||||
|
Return ResourceManager.GetString("You received a document to sign:", resourceCulture)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
End Class
|
End Class
|
||||||
End Namespace
|
End Namespace
|
||||||
|
|||||||
@@ -33,16 +33,8 @@ Public Class EnvelopeEditorController
|
|||||||
Public Function SendEnvelope() As Boolean
|
Public Function SendEnvelope() As Boolean
|
||||||
For Each receiverItem As EnvelopeReceiver In Envelope.Receivers
|
For Each receiverItem As EnvelopeReceiver In Envelope.Receivers
|
||||||
|
|
||||||
Dim oEmailData As New EmailData With
|
Dim oEmailData As New EmailData(Envelope, receiverItem) With
|
||||||
{
|
{
|
||||||
.EmailAdress = receiverItem.Email,
|
|
||||||
.EmailSubject = Envelope.Subject,
|
|
||||||
.Message = Envelope.Message,
|
|
||||||
.ReferenceID = Envelope.Id,
|
|
||||||
.ReferenceString = Envelope.Uuid,
|
|
||||||
.ReceiverName = receiverItem.Name,
|
|
||||||
.SenderAdress = Envelope.User.Email,
|
|
||||||
.SenderName = Envelope.User.FullName,
|
|
||||||
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, Envelope.Uuid, receiverItem.Signature)
|
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, Envelope.Uuid, receiverItem.Signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,9 +50,22 @@ Public Class EnvelopeEditorController
|
|||||||
|
|
||||||
|
|
||||||
If EnvelopeModel.Send(Envelope) Then
|
If EnvelopeModel.Send(Envelope) Then
|
||||||
'TODO: Send email to History
|
|
||||||
Return True
|
Dim newHistoryEntry As New EnvelopeHistoryEntry With {
|
||||||
|
.EnvelopeId = Envelope.Id,
|
||||||
|
.ActionType = EnvelopeHistoryActionType.Sent,
|
||||||
|
.UserReference = Envelope.User.Email
|
||||||
|
}
|
||||||
|
|
||||||
|
If HistoryModel.Insert(newHistoryEntry) Then
|
||||||
|
'TODO: Send email to History
|
||||||
|
Return True
|
||||||
|
Else
|
||||||
|
Logger.Warn("History Entry could not be created!")
|
||||||
|
Return False
|
||||||
|
End If
|
||||||
Else
|
Else
|
||||||
|
Logger.Warn("Envelope could not be updated!")
|
||||||
Return False
|
Return False
|
||||||
End If
|
End If
|
||||||
End Function
|
End Function
|
||||||
@@ -96,7 +101,6 @@ Public Class EnvelopeEditorController
|
|||||||
Dim newHistoryEntry As New EnvelopeHistoryEntry With {
|
Dim newHistoryEntry As New EnvelopeHistoryEntry With {
|
||||||
.EnvelopeId = oEnvelope.Id,
|
.EnvelopeId = oEnvelope.Id,
|
||||||
.ActionType = EnvelopeHistoryActionType.Created,
|
.ActionType = EnvelopeHistoryActionType.Created,
|
||||||
.ActionDescription = "Envelope wurde neu erstellt",
|
|
||||||
.UserReference = oEnvelope.User.Email
|
.UserReference = oEnvelope.User.Email
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,6 @@ Partial Public Class frmEnvelopeEditor
|
|||||||
Controller = New EnvelopeEditorController(State, Envelope)
|
Controller = New EnvelopeEditorController(State, Envelope)
|
||||||
Documents = New BindingList(Of EnvelopeDocument)(Controller.Envelope.Documents)
|
Documents = New BindingList(Of EnvelopeDocument)(Controller.Envelope.Documents)
|
||||||
Receivers = New BindingList(Of EnvelopeReceiver)(Controller.Envelope.Receivers)
|
Receivers = New BindingList(Of EnvelopeReceiver)(Controller.Envelope.Receivers)
|
||||||
txtMessage.EditValue = Controller.Envelope.Message
|
|
||||||
txtSubject.EditValue = Controller.Envelope.Subject
|
|
||||||
|
|
||||||
For Each docItem As EnvelopeDocument In Documents
|
For Each docItem As EnvelopeDocument In Documents
|
||||||
If docItem.Thumbnail Is Nothing Then
|
If docItem.Thumbnail Is Nothing Then
|
||||||
@@ -78,6 +76,9 @@ Partial Public Class frmEnvelopeEditor
|
|||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
txtMessage.EditValue = Controller.Envelope.Message
|
||||||
|
txtSubject.EditValue = Controller.Envelope.Subject
|
||||||
|
|
||||||
GridDocuments.DataSource = Documents
|
GridDocuments.DataSource = Documents
|
||||||
GridReceivers.DataSource = Receivers
|
GridReceivers.DataSource = Receivers
|
||||||
End Sub
|
End Sub
|
||||||
|
|||||||
120
EnvelopeGenerator.Form/frmHistory.resx
Normal file
120
EnvelopeGenerator.Form/frmHistory.resx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?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>
|
||||||
|
</root>
|
||||||
@@ -40,36 +40,5 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
return ErrorResponse(e);
|
return ErrorResponse(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//[HttpPost]
|
|
||||||
//[Route("api/document/{envelopeKey}")]
|
|
||||||
//public async Task<IActionResult> Update(string envelopeKey)
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// logger.Info("DocumentController/Update");
|
|
||||||
|
|
||||||
// // Validate Envelope Key and load envelope
|
|
||||||
// envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
|
||||||
// EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey);
|
|
||||||
|
|
||||||
// // Load Document info
|
|
||||||
// var Request = ControllerContext.HttpContext.Request;
|
|
||||||
// var document = envelopeService.GetDocument(Request, envelopeKey);
|
|
||||||
|
|
||||||
// // Update the document with new data
|
|
||||||
// await envelopeService.UpdateDocument(Request.Body, document.Filepath);
|
|
||||||
|
|
||||||
// // Add history entry
|
|
||||||
// envelopeService.InsertHistoryEntrySigned(response);
|
|
||||||
|
|
||||||
// return Ok();
|
|
||||||
// }
|
|
||||||
// catch (Exception e)
|
|
||||||
// {
|
|
||||||
// return ErrorResponse(e);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,12 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
public class EnvelopeController : BaseController
|
public class EnvelopeController : BaseController
|
||||||
{
|
{
|
||||||
private readonly EnvelopeService envelopeService;
|
private readonly EnvelopeService envelopeService;
|
||||||
|
private readonly EmailService emailService;
|
||||||
|
|
||||||
public EnvelopeController(DatabaseService database, LoggingService logging, EnvelopeService envelope) : base(database, logging)
|
public EnvelopeController(DatabaseService database, LoggingService logging, EnvelopeService envelope, EmailService email) : base(database, logging)
|
||||||
{
|
{
|
||||||
envelopeService = envelope;
|
envelopeService = envelope;
|
||||||
|
emailService = email;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@@ -58,6 +60,10 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
Status = Common.Constants.DocumentStatus.Signed
|
Status = Common.Constants.DocumentStatus.Signed
|
||||||
});
|
});
|
||||||
|
|
||||||
|
envelopeService.InsertHistoryEntrySigned(response);
|
||||||
|
|
||||||
|
SendSignedEmail(response);
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -65,5 +71,18 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
return ErrorResponse(e);
|
return ErrorResponse(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool SendSignedEmail(EnvelopeResponse response)
|
||||||
|
{
|
||||||
|
EmailTemplate template = new();
|
||||||
|
EmailData emailData = new(response.Envelope, response.Receiver)
|
||||||
|
{
|
||||||
|
SignatureLink = "",
|
||||||
|
};
|
||||||
|
|
||||||
|
template.FillDocumentSignedEmailBody(emailData);
|
||||||
|
|
||||||
|
return emailService.SendEmail(emailData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
{
|
{
|
||||||
public class ActionObject
|
public class ActionObject
|
||||||
{
|
{
|
||||||
public string? ActionType { get; set; }
|
public int ActionType { get; set; }
|
||||||
public string? ActionDescription { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HistoryController : BaseController
|
public class HistoryController : BaseController
|
||||||
@@ -26,23 +25,15 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.Info("EnvelopeController/Get");
|
logger.Info("HistoryController/Post");
|
||||||
|
|
||||||
// Validate Envelope Key and load envelope
|
// Validate Envelope Key and load envelope
|
||||||
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
||||||
EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey);
|
EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey);
|
||||||
|
EnvelopeHistoryActionType actionType = (EnvelopeHistoryActionType)action.ActionType;
|
||||||
string actionTypeString = action.ActionType;
|
|
||||||
string actionDescription = action.ActionDescription;
|
|
||||||
|
|
||||||
if (!Enum.TryParse<EnvelopeHistoryActionType>(actionTypeString, out var actionType))
|
|
||||||
{
|
|
||||||
return BadRequest();
|
|
||||||
};
|
|
||||||
|
|
||||||
envelopeService.InsertHistoryEntry(new EnvelopeHistoryEntry()
|
envelopeService.InsertHistoryEntry(new EnvelopeHistoryEntry()
|
||||||
{
|
{
|
||||||
ActionDescription = actionDescription,
|
|
||||||
ActionDate = DateTime.Now,
|
ActionDate = DateTime.Now,
|
||||||
ActionType = actionType,
|
ActionType = actionType,
|
||||||
EnvelopeId = response.Envelope.Id,
|
EnvelopeId = response.Envelope.Id,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace EnvelopeGenerator.Web
|
|||||||
// Add base services
|
// Add base services
|
||||||
builder.Services.AddSingleton<LoggingService>();
|
builder.Services.AddSingleton<LoggingService>();
|
||||||
builder.Services.AddTransient<DatabaseService>();
|
builder.Services.AddTransient<DatabaseService>();
|
||||||
|
builder.Services.AddTransient<EmailService>();
|
||||||
|
|
||||||
// Add higher order services
|
// Add higher order services
|
||||||
builder.Services.AddSingleton<EnvelopeService>();
|
builder.Services.AddSingleton<EnvelopeService>();
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ namespace EnvelopeGenerator.Web.Services
|
|||||||
public ElementModel elementModel;
|
public ElementModel elementModel;
|
||||||
public HistoryModel historyModel;
|
public HistoryModel historyModel;
|
||||||
public DocumentStatusModel documentStatusModel;
|
public DocumentStatusModel documentStatusModel;
|
||||||
|
public EmailModel emailModel;
|
||||||
|
public ConfigModel configModel;
|
||||||
|
|
||||||
public ModelContainer(State state)
|
public ModelContainer(State state)
|
||||||
{
|
{
|
||||||
@@ -24,6 +26,8 @@ namespace EnvelopeGenerator.Web.Services
|
|||||||
elementModel = new(state);
|
elementModel = new(state);
|
||||||
historyModel = new(state);
|
historyModel = new(state);
|
||||||
documentStatusModel = new(state);
|
documentStatusModel = new(state);
|
||||||
|
emailModel = new(state);
|
||||||
|
configModel = new(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public readonly ModelContainer? Models;
|
public readonly ModelContainer? Models;
|
||||||
@@ -39,7 +43,16 @@ namespace EnvelopeGenerator.Web.Services
|
|||||||
{
|
{
|
||||||
logger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentConnectionString);
|
logger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentConnectionString);
|
||||||
|
|
||||||
|
// There is a circular dependency between state and models
|
||||||
|
// All models need a state object, including the config Model
|
||||||
|
// The state object needs to be filled with the DbConfig property,
|
||||||
|
// which is obtained by the config Model.
|
||||||
|
// So first, the config model is initialized with an incomplete state object,
|
||||||
|
// then all the other models with the DbConfig property filled.
|
||||||
var state = GetState();
|
var state = GetState();
|
||||||
|
var configModel = new ConfigModel(state);
|
||||||
|
state.DbConfig = configModel.LoadConfiguration();
|
||||||
|
|
||||||
Models = new(state);
|
Models = new(state);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
38
EnvelopeGenerator.Web/Services/EmailService.cs
Normal file
38
EnvelopeGenerator.Web/Services/EmailService.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using EnvelopeGenerator.Common;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Web.Services
|
||||||
|
{
|
||||||
|
public class EmailService : BaseService
|
||||||
|
{
|
||||||
|
private ReceiverModel receiverModel;
|
||||||
|
private EnvelopeModel envelopeModel;
|
||||||
|
private HistoryModel historyModel;
|
||||||
|
private DocumentModel documentModel;
|
||||||
|
private DocumentStatusModel documentStatusModel;
|
||||||
|
private EmailModel emailModel;
|
||||||
|
|
||||||
|
public EmailService(IConfiguration Config, LoggingService Logging, DatabaseService database) : base(Config, Logging)
|
||||||
|
{
|
||||||
|
logger = Logging.LogConfig.GetLogger();
|
||||||
|
|
||||||
|
if (database.Models == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Models not loaded.");
|
||||||
|
}
|
||||||
|
|
||||||
|
receiverModel = database.Models.receiverModel;
|
||||||
|
envelopeModel = database.Models.envelopeModel;
|
||||||
|
historyModel = database.Models.historyModel;
|
||||||
|
documentModel = database.Models.documentModel;
|
||||||
|
documentStatusModel = database.Models.documentStatusModel;
|
||||||
|
emailModel = database.Models.emailModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SendEmail(EmailData emailData)
|
||||||
|
{
|
||||||
|
return emailModel.Insert(emailData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -110,7 +110,6 @@ namespace EnvelopeGenerator.Web.Services
|
|||||||
{
|
{
|
||||||
return historyModel.Insert(new EnvelopeHistoryEntry()
|
return historyModel.Insert(new EnvelopeHistoryEntry()
|
||||||
{
|
{
|
||||||
ActionDescription = "Dokument wurde signiert",
|
|
||||||
ActionDate = DateTime.Now,
|
ActionDate = DateTime.Now,
|
||||||
ActionType = EnvelopeHistoryActionType.Signed,
|
ActionType = EnvelopeHistoryActionType.Signed,
|
||||||
EnvelopeId = response.Envelope.Id,
|
EnvelopeId = response.Envelope.Id,
|
||||||
|
|||||||
13
EnvelopeGenerator.Web/package-lock.json
generated
Normal file
13
EnvelopeGenerator.Web/package-lock.json
generated
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "EnvelopeGenerator.Web",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"requires": true,
|
||||||
|
"dependencies": {
|
||||||
|
"prettier": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-TQLvXjq5IAibjh8EpBIkNKxO749UEWABoiIZehEPiY4GNpVdhaFKqSTu+QrlU6D2dPAfubRmtJTi4K4YkQ5eXw=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
EnvelopeGenerator.Web/package.json
Normal file
15
EnvelopeGenerator.Web/package.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "EnvelopeGenerator.Web",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"format": "npx prettier wwwroot/js --write"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"prettier": "^3.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
8
EnvelopeGenerator.Web/prettier.config.mjs
Normal file
8
EnvelopeGenerator.Web/prettier.config.mjs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
const config = {
|
||||||
|
trailingComma: "es5",
|
||||||
|
tabWidth: 4,
|
||||||
|
semi: false,
|
||||||
|
singleQuote: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -1,58 +1,84 @@
|
|||||||
class Annotation {
|
class Annotation {
|
||||||
createAnnotations(document) {
|
createAnnotations(document) {
|
||||||
const annotations = [];
|
const annotations = []
|
||||||
|
|
||||||
document.elements.forEach((element) => {
|
document.elements.forEach((element) => {
|
||||||
console.log("Creating annotation for element", element.id)
|
console.log('Creating annotation for element', element.id)
|
||||||
|
|
||||||
const [annotation, formField] = this.createAnnotationFromElement(element)
|
const [annotation, formField] =
|
||||||
annotations.push(annotation);
|
this.createAnnotationFromElement(element)
|
||||||
annotations.push(formField);
|
annotations.push(annotation)
|
||||||
|
annotations.push(formField)
|
||||||
})
|
})
|
||||||
|
|
||||||
return annotations;
|
return annotations
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteAnnotations(instance) {
|
async deleteAnnotations(instance) {
|
||||||
let pageAnnotations = (
|
let pageAnnotations = (
|
||||||
await Promise.all(Array.from({ length: instance.totalPageCount }).map((_, pageIndex) =>
|
await Promise.all(
|
||||||
instance.getAnnotations(pageIndex)
|
Array.from({ length: instance.totalPageCount }).map(
|
||||||
))
|
(_, pageIndex) => instance.getAnnotations(pageIndex)
|
||||||
).flatMap((annotations) =>
|
)
|
||||||
annotations.reduce((acc, annotation) => acc.concat(annotation), [])
|
)
|
||||||
).filter((annotation) => !!annotation.isSignature || annotation.description == "FRAME");
|
)
|
||||||
|
.flatMap((annotations) =>
|
||||||
|
annotations.reduce(
|
||||||
|
(acc, annotation) => acc.concat(annotation),
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.filter(
|
||||||
|
(annotation) =>
|
||||||
|
!!annotation.isSignature ||
|
||||||
|
annotation.description == 'FRAME'
|
||||||
|
)
|
||||||
//deleting all Annotations
|
//deleting all Annotations
|
||||||
return await instance.delete(pageAnnotations);
|
return await instance.delete(pageAnnotations)
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateAnnotations(instance) {
|
async validateAnnotations(instance) {
|
||||||
let pageAnnotations = (
|
let pageAnnotations = (
|
||||||
await Promise.all(Array.from({ length: instance.totalPageCount }).map((_, pageIndex) =>
|
await Promise.all(
|
||||||
instance.getAnnotations(pageIndex)
|
Array.from({ length: instance.totalPageCount }).map(
|
||||||
))
|
(_, pageIndex) => instance.getAnnotations(pageIndex)
|
||||||
).flatMap((annotations) =>
|
)
|
||||||
annotations.reduce((acc, annotation) => acc.concat(annotation), [])
|
)
|
||||||
).map((annotation) => {
|
)
|
||||||
console.log(annotation.toJS());
|
.flatMap((annotations) =>
|
||||||
return annotation;
|
annotations.reduce(
|
||||||
});
|
(acc, annotation) => acc.concat(annotation),
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.map((annotation) => {
|
||||||
|
console.log(annotation.toJS())
|
||||||
|
return annotation
|
||||||
|
})
|
||||||
|
|
||||||
return true;
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
createAnnotationFromElement(element) {
|
createAnnotationFromElement(element) {
|
||||||
const id = PSPDFKit.generateInstantId()
|
const id = PSPDFKit.generateInstantId()
|
||||||
const width = this.inchToPoint(element.width)
|
const width = this.inchToPoint(element.width)
|
||||||
const height = this.inchToPoint(element.height)
|
const height = this.inchToPoint(element.height)
|
||||||
const top = this.inchToPoint(element.top) - (height / 2)
|
const top = this.inchToPoint(element.top) - height / 2
|
||||||
const left = this.inchToPoint(element.left) - (width / 2)
|
const left = this.inchToPoint(element.left) - width / 2
|
||||||
const page = element.page - 1
|
const page = element.page - 1
|
||||||
const annotation = this.createSignatureAnnotation(id, width, height, top, left, page)
|
const annotation = this.createSignatureAnnotation(
|
||||||
|
id,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
top,
|
||||||
|
left,
|
||||||
|
page
|
||||||
|
)
|
||||||
console.log(annotation)
|
console.log(annotation)
|
||||||
|
|
||||||
const formField = new PSPDFKit.FormFields.SignatureFormField({
|
const formField = new PSPDFKit.FormFields.SignatureFormField({
|
||||||
name: id,
|
name: id,
|
||||||
annotationIds: PSPDFKit.Immutable.List([annotation.id])
|
annotationIds: PSPDFKit.Immutable.List([annotation.id]),
|
||||||
})
|
})
|
||||||
console.log(formField)
|
console.log(formField)
|
||||||
|
|
||||||
@@ -64,56 +90,75 @@
|
|||||||
id: id,
|
id: id,
|
||||||
pageIndex: pageIndex,
|
pageIndex: pageIndex,
|
||||||
formFieldName: id,
|
formFieldName: id,
|
||||||
boundingBox: new PSPDFKit.Geometry.Rect({ width, height, top, left })
|
boundingBox: new PSPDFKit.Geometry.Rect({
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
top,
|
||||||
|
left,
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
return annotation
|
return annotation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createImageAnnotation(boundingBox, pageIndex, imageAttachmentId) {
|
||||||
|
const frameAnnotation = new PSPDFKit.Annotations.ImageAnnotation({
|
||||||
|
pageIndex: pageIndex,
|
||||||
|
isSignature: false,
|
||||||
|
readOnly: true,
|
||||||
|
locked: true,
|
||||||
|
lockedContents: true,
|
||||||
|
contentType: 'image/png',
|
||||||
|
imageAttachmentId,
|
||||||
|
description: 'FRAME',
|
||||||
|
boundingBox: boundingBox,
|
||||||
|
});
|
||||||
|
return frameAnnotation
|
||||||
|
}
|
||||||
|
|
||||||
async createAnnotationFrameBlob(receiverName, width, height) {
|
async createAnnotationFrameBlob(receiverName, width, height) {
|
||||||
const canvas = document.createElement("canvas");
|
const canvas = document.createElement('canvas')
|
||||||
canvas.width = width;
|
canvas.width = width
|
||||||
canvas.height = height;
|
canvas.height = height
|
||||||
|
|
||||||
const ctx = canvas.getContext("2d");
|
const ctx = canvas.getContext('2d')
|
||||||
|
|
||||||
const date = new Date();
|
const date = new Date()
|
||||||
const dateString = date.toLocaleDateString("de-DE");
|
const dateString = date.toLocaleDateString('de-DE')
|
||||||
|
|
||||||
const signatureLength = 100;
|
const signatureLength = 100
|
||||||
|
|
||||||
ctx.beginPath();
|
ctx.beginPath()
|
||||||
|
|
||||||
ctx.moveTo(30, 10);
|
ctx.moveTo(30, 10)
|
||||||
ctx.lineTo(signatureLength, 10);
|
ctx.lineTo(signatureLength, 10)
|
||||||
|
|
||||||
ctx.moveTo(30, 10);
|
ctx.moveTo(30, 10)
|
||||||
ctx.arcTo(10, 10, 10, 30, 20);
|
ctx.arcTo(10, 10, 10, 30, 20)
|
||||||
|
|
||||||
ctx.moveTo(10, 30);
|
ctx.moveTo(10, 30)
|
||||||
ctx.arcTo(10, 50, 30, 50, 20);
|
ctx.arcTo(10, 50, 30, 50, 20)
|
||||||
|
|
||||||
ctx.moveTo(30, 50);
|
ctx.moveTo(30, 50)
|
||||||
ctx.lineTo(signatureLength, 50);
|
ctx.lineTo(signatureLength, 50)
|
||||||
|
|
||||||
ctx.strokeStyle = "darkblue";
|
ctx.strokeStyle = 'darkblue'
|
||||||
ctx.stroke();
|
ctx.stroke()
|
||||||
|
|
||||||
ctx.fillStyle = "black";
|
ctx.fillStyle = 'black'
|
||||||
ctx.font = "10px serif";
|
ctx.font = '10px serif'
|
||||||
ctx.fillText("Signed by", 30, 10)
|
ctx.fillText('Signed by', 30, 10)
|
||||||
ctx.fillText(receiverName + ", " + dateString, 15, 60)
|
ctx.fillText(receiverName + ', ' + dateString, 15, 60)
|
||||||
|
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve) => {
|
||||||
canvas.toBlob((blob) => {
|
canvas.toBlob((blob) => {
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob)
|
||||||
resolve(url)
|
resolve(url)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
inchToPoint(inch) {
|
inchToPoint(inch) {
|
||||||
return inch * 72;
|
return inch * 72
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,84 +6,91 @@ const ActionType = {
|
|||||||
Delivered: 4,
|
Delivered: 4,
|
||||||
Seen: 5,
|
Seen: 5,
|
||||||
Signed: 6,
|
Signed: 6,
|
||||||
Rejected: 7
|
Rejected: 7,
|
||||||
}
|
}
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
constructor(container, envelopeKey) {
|
constructor(container, envelopeKey) {
|
||||||
this.container = container;
|
this.container = container
|
||||||
this.envelopeKey = envelopeKey;
|
this.envelopeKey = envelopeKey
|
||||||
|
|
||||||
// Initialize classes
|
// Initialize classes
|
||||||
console.debug("Initializing classes..")
|
console.debug('Initializing classes..')
|
||||||
this.UI = new UI();
|
this.UI = new UI()
|
||||||
this.Network = new Network();
|
this.Network = new Network()
|
||||||
this.Annotation = new Annotation();
|
this.Annotation = new Annotation()
|
||||||
|
|
||||||
this.Instance = null;
|
this.Instance = null
|
||||||
this.currentDocument = null;
|
this.currentDocument = null
|
||||||
this.currentReceiver = null;
|
this.currentReceiver = null
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function will be called in the ShowEnvelope.razor page
|
// This function will be called in the ShowEnvelope.razor page
|
||||||
// and will trigger loading of the Editor Interface
|
// and will trigger loading of the Editor Interface
|
||||||
async init() {
|
async init() {
|
||||||
|
|
||||||
// Load the envelope from the database
|
// Load the envelope from the database
|
||||||
console.debug("Loading envelope from database..")
|
console.debug('Loading envelope from database..')
|
||||||
const envelopeObject = await this.Network.getEnvelope(this.envelopeKey);
|
const envelopeObject = await this.Network.getEnvelope(this.envelopeKey)
|
||||||
this.currentDocument = envelopeObject.envelope.documents[0];
|
this.currentDocument = envelopeObject.envelope.documents[0]
|
||||||
this.currentReceiver = envelopeObject.receiver;
|
this.currentReceiver = envelopeObject.receiver
|
||||||
|
|
||||||
console.log(envelopeObject)
|
console.log(envelopeObject)
|
||||||
|
|
||||||
// Load the document from the filestore
|
// Load the document from the filestore
|
||||||
console.debug("Loading document from filestore")
|
console.debug('Loading document from filestore')
|
||||||
let arrayBuffer
|
let arrayBuffer
|
||||||
try {
|
try {
|
||||||
arrayBuffer = await this.Network.getDocument(this.envelopeKey, this.currentDocument.id);
|
arrayBuffer = await this.Network.getDocument(
|
||||||
|
this.envelopeKey,
|
||||||
|
this.currentDocument.id
|
||||||
|
)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load PSPDFKit
|
// Load PSPDFKit
|
||||||
console.debug("Loading PSPDFKit..")
|
console.debug('Loading PSPDFKit..')
|
||||||
this.Instance = await this.UI.loadPSPDFKit(arrayBuffer, this.container)
|
this.Instance = await this.UI.loadPSPDFKit(arrayBuffer, this.container)
|
||||||
this.UI.configurePSPDFKit(this.Instance, this.handleClick.bind(this))
|
this.UI.configurePSPDFKit(this.Instance, this.handleClick.bind(this))
|
||||||
|
|
||||||
this.Instance.addEventListener("annotations.load", this.handleAnnotationsLoad)
|
this.Instance.addEventListener(
|
||||||
this.Instance.addEventListener("annotations.change", this.handleAnnotationsChange)
|
'annotations.load',
|
||||||
this.Instance.addEventListener("annotations.create", this.handleAnnotationsCreate.bind(this))
|
this.handleAnnotationsLoad
|
||||||
|
)
|
||||||
|
this.Instance.addEventListener(
|
||||||
|
'annotations.change',
|
||||||
|
this.handleAnnotationsChange
|
||||||
|
)
|
||||||
|
this.Instance.addEventListener(
|
||||||
|
'annotations.create',
|
||||||
|
this.handleAnnotationsCreate.bind(this)
|
||||||
|
)
|
||||||
|
|
||||||
// Load annotations into PSPDFKit
|
// Load annotations into PSPDFKit
|
||||||
console.debug("Loading annotations..")
|
console.debug('Loading annotations..')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const annotations = this.Annotation.createAnnotations(this.currentDocument)
|
const annotations = this.Annotation.createAnnotations(
|
||||||
|
this.currentDocument
|
||||||
|
)
|
||||||
const createdAnnotations = await this.Instance.create(annotations)
|
const createdAnnotations = await this.Instance.create(annotations)
|
||||||
|
|
||||||
const description = "Umschlag wurde geöffnet"
|
await this.Network.postHistory(this.envelopeKey, ActionType.Seen)
|
||||||
await this.Network.postHistory(this.envelopeKey, ActionType.Seen, description);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleAnnotationsLoad(loadedAnnotations) {
|
handleAnnotationsLoad(loadedAnnotations) {
|
||||||
console.log("annotations loaded", loadedAnnotations.toJS());
|
console.log('annotations loaded', loadedAnnotations.toJS())
|
||||||
}
|
}
|
||||||
|
|
||||||
handleAnnotationsChange() {}
|
handleAnnotationsChange() {}
|
||||||
|
|
||||||
async handleAnnotationsCreate(createdAnnotations) {
|
async handleAnnotationsCreate(createdAnnotations) {
|
||||||
console.log("annotations created");
|
const annotation = createdAnnotations.toJS()[0]
|
||||||
|
const isFormField = !!annotation.formFieldName
|
||||||
console.log(createdAnnotations.toJS())
|
const isSignature = !!annotation.isSignature
|
||||||
|
|
||||||
const annotation = createdAnnotations.toJS()[0];
|
|
||||||
const isFormField = !!annotation.formFieldName;
|
|
||||||
const isSignature = !!annotation.isSignature;
|
|
||||||
|
|
||||||
if (isFormField === false && isSignature === true) {
|
if (isFormField === false && isSignature === true) {
|
||||||
|
|
||||||
@@ -92,100 +99,93 @@ class App {
|
|||||||
const width = 150;
|
const width = 150;
|
||||||
const height = 75;
|
const height = 75;
|
||||||
|
|
||||||
console.log(annotation.boundingBox)
|
|
||||||
|
|
||||||
const imageUrl = await this.Annotation.createAnnotationFrameBlob(this.currentReceiver.name, width, height);
|
const imageUrl = await this.Annotation.createAnnotationFrameBlob(this.currentReceiver.name, width, height);
|
||||||
|
|
||||||
const request = await fetch(imageUrl);
|
const request = await fetch(imageUrl);
|
||||||
const blob = await request.blob();
|
const blob = await request.blob();
|
||||||
const imageAttachmentId = await this.Instance.createAttachment(blob);
|
const imageAttachmentId = await this.Instance.createAttachment(blob);
|
||||||
const frameAnnotation = new PSPDFKit.Annotations.ImageAnnotation({
|
|
||||||
pageIndex: annotation.pageIndex,
|
const frameAnnotation = this.Annotation.createImageAnnotation(new PSPDFKit.Geometry.Rect({
|
||||||
isSignature: false,
|
left: left,
|
||||||
readOnly: true,
|
top: top,
|
||||||
locked: true,
|
width: width,
|
||||||
lockedContents: true,
|
height: height,
|
||||||
contentType: 'image/png',
|
}), annotation.pageIndex, imageAttachmentId)
|
||||||
imageAttachmentId,
|
|
||||||
description: 'FRAME',
|
|
||||||
boundingBox: new PSPDFKit.Geometry.Rect({
|
|
||||||
left: left,
|
|
||||||
top: top,
|
|
||||||
width: width,
|
|
||||||
height: height,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
this.Instance.create(frameAnnotation);
|
this.Instance.create(frameAnnotation);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleClick(eventType) {
|
async handleClick(eventType) {
|
||||||
let result = false;
|
let result = false
|
||||||
|
|
||||||
switch (eventType) {
|
switch (eventType) {
|
||||||
case "RESET":
|
case 'RESET':
|
||||||
result = await this.handleReset(null)
|
result = await this.handleReset(null)
|
||||||
|
|
||||||
if (result == true) {
|
if (result == true) {
|
||||||
alert("Dokument zurückgesetzt!");
|
alert('Dokument zurückgesetzt!')
|
||||||
} else {
|
} else {
|
||||||
alert("Fehler beim Zurücksetzen des Dokuments!")
|
alert('Fehler beim Zurücksetzen des Dokuments!')
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break
|
||||||
|
|
||||||
case "FINISH":
|
case 'FINISH':
|
||||||
result = await this.handleFinish(null)
|
result = await this.handleFinish(null)
|
||||||
|
|
||||||
if (result == true) {
|
if (result == true) {
|
||||||
// TODO: Redirect to success page
|
// Redirect to success page after saving to database
|
||||||
alert("Dokument erfolgreich signiert!")
|
window.location.href = `/EnvelopeKey/${this.envelopeKey}/Success`
|
||||||
} else {
|
} else {
|
||||||
alert("Fehler beim Abschließen des Dokuments!")
|
alert('Fehler beim Abschließen des Dokuments!')
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleFinish(event) {
|
async handleFinish(event) {
|
||||||
|
|
||||||
// Save changes before doing anything
|
// Save changes before doing anything
|
||||||
try {
|
try {
|
||||||
await this.Instance.save();
|
await this.Instance.save()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e)
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export annotation data and save to database
|
// Export annotation data and save to database
|
||||||
try {
|
try {
|
||||||
const json = await this.Instance.exportInstantJSON()
|
const json = await this.Instance.exportInstantJSON()
|
||||||
const postEnvelopeResult = await this.Network.postEnvelope(this.envelopeKey, this.currentDocument.id, JSON.stringify(json))
|
const postEnvelopeResult = await this.Network.postEnvelope(
|
||||||
|
this.envelopeKey,
|
||||||
|
this.currentDocument.id,
|
||||||
|
JSON.stringify(json)
|
||||||
|
)
|
||||||
|
|
||||||
|
console.log(postEnvelopeResult)
|
||||||
|
|
||||||
if (postEnvelopeResult === false) {
|
if (postEnvelopeResult === false) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e)
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleReset(event) {
|
async handleReset(event) {
|
||||||
if (confirm("Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?")) {
|
if (
|
||||||
|
confirm(
|
||||||
|
'Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?'
|
||||||
|
)
|
||||||
|
) {
|
||||||
const result = this.Annotation.deleteAnnotations(this.Instance)
|
const result = this.Annotation.deleteAnnotations(this.Instance)
|
||||||
return true;
|
return true
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,86 +1,74 @@
|
|||||||
class Network {
|
class Network {
|
||||||
getEnvelope(envelopeKey) {
|
getEnvelope(envelopeKey) {
|
||||||
return fetch(`/api/envelope/${envelopeKey}`, this.withCSRFToken({ credentials: "include" }))
|
return fetch(
|
||||||
.then(res => res.json());
|
`/api/envelope/${envelopeKey}`,
|
||||||
|
this.withCSRFToken({ credentials: 'include' })
|
||||||
|
).then((res) => res.json())
|
||||||
}
|
}
|
||||||
|
|
||||||
getDocument(envelopeKey, documentId) {
|
getDocument(envelopeKey, documentId) {
|
||||||
return fetch(`/api/document/${envelopeKey}?index=${documentId}`, this.withCSRFToken({ credentials: "include" }))
|
return fetch(
|
||||||
.then(res => res.arrayBuffer());
|
`/api/document/${envelopeKey}?index=${documentId}`,
|
||||||
}
|
this.withCSRFToken({ credentials: 'include' })
|
||||||
|
).then((res) => res.arrayBuffer())
|
||||||
postDocument(envelopeKey, documentId, buffer) {
|
|
||||||
const url = `/api/document/${envelopeKey}?index=${documentId}`;
|
|
||||||
const options = {
|
|
||||||
credentials: "include",
|
|
||||||
method: "POST",
|
|
||||||
body: buffer
|
|
||||||
}
|
|
||||||
|
|
||||||
console.debug("PostDocument/Calling url: " + url)
|
|
||||||
return fetch(url, this.withCSRFToken(options))
|
|
||||||
.then(this.handleResponse)
|
|
||||||
.then((res) => {
|
|
||||||
if (!res.ok) {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
postEnvelope(envelopeKey, documentId, jsonString) {
|
postEnvelope(envelopeKey, documentId, jsonString) {
|
||||||
const url = `/api/envelope/${envelopeKey}?index=${documentId}`;
|
const url = `/api/envelope/${envelopeKey}?index=${documentId}`
|
||||||
const options = {
|
const options = {
|
||||||
credentials: "include",
|
credentials: 'include',
|
||||||
method: "POST",
|
method: 'POST',
|
||||||
body: jsonString
|
body: jsonString,
|
||||||
}
|
}
|
||||||
|
|
||||||
console.debug("PostEnvelope/Calling url: " + url)
|
console.debug('PostEnvelope/Calling url: ' + url)
|
||||||
return fetch(url, this.withCSRFToken(options))
|
return fetch(url, this.withCSRFToken(options))
|
||||||
.then(this.handleResponse)
|
.then(this.handleResponse)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
return false;
|
return false
|
||||||
};
|
}
|
||||||
return true;
|
return true
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
postHistory(envelopeKey, actionType, actionDescription) {
|
postHistory(envelopeKey, actionType) {
|
||||||
const url = `/api/history/${envelopeKey}`;
|
const url = `/api/history/${envelopeKey}`
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
actionDescription: actionDescription,
|
actionType: actionType,
|
||||||
actionType: actionType.toString()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(data)
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
credentials: "include",
|
credentials: 'include',
|
||||||
method: "POST",
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': "application/json; charset=utf-8"
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
},
|
},
|
||||||
body: JSON.stringify(data)
|
body: JSON.stringify(data),
|
||||||
}
|
}
|
||||||
|
|
||||||
console.debug("PostHistory/Calling url: " + url)
|
console.debug('PostHistory/Calling url: ' + url)
|
||||||
return fetch(url, this.withCSRFToken(options))
|
return fetch(url, this.withCSRFToken(options))
|
||||||
.then(this.handleResponse)
|
.then(this.handleResponse)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
return false;
|
return false
|
||||||
};
|
}
|
||||||
return true;
|
return true
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
withCSRFToken(options) {
|
withCSRFToken(options) {
|
||||||
const token = (document.getElementsByName("__RequestVerificationToken")[0]).value;
|
const token = document.getElementsByName(
|
||||||
let headers = options.headers;
|
'__RequestVerificationToken'
|
||||||
options.headers = { ...headers, 'X-XSRF-TOKEN': token };
|
)[0].value
|
||||||
|
let headers = options.headers
|
||||||
|
options.headers = { ...headers, 'X-XSRF-TOKEN': token }
|
||||||
|
|
||||||
return options;
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
handleResponse(res) {
|
handleResponse(res) {
|
||||||
@@ -92,4 +80,3 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
class UI {
|
class UI {
|
||||||
allowedToolbarItems = [
|
allowedToolbarItems = [
|
||||||
"sidebar-thumbnails",
|
'sidebar-thumbnails',
|
||||||
"sidebar-document-ouline",
|
'sidebar-document-ouline',
|
||||||
"sidebar-bookmarks",
|
'sidebar-bookmarks',
|
||||||
"pager",
|
'pager',
|
||||||
"pan",
|
'pan',
|
||||||
"zoom-out",
|
'zoom-out',
|
||||||
"zoom-in",
|
'zoom-in',
|
||||||
"zoom-mode",
|
'zoom-mode',
|
||||||
"spacer",
|
'spacer',
|
||||||
"search"
|
'search',
|
||||||
]
|
]
|
||||||
|
|
||||||
// Load the PSPDFKit UI by setting a target element as the container to render in
|
// Load the PSPDFKit UI by setting a target element as the container to render in
|
||||||
@@ -19,24 +19,27 @@
|
|||||||
styleSheets: ['/css/site.css'],
|
styleSheets: ['/css/site.css'],
|
||||||
container: container,
|
container: container,
|
||||||
document: arrayBuffer,
|
document: arrayBuffer,
|
||||||
autoSaveMode: "DISABLED",
|
autoSaveMode: 'DISABLED',
|
||||||
annotationPresets: this.getPresets(),
|
annotationPresets: this.getPresets(),
|
||||||
electronicSignatures: {
|
electronicSignatures: {
|
||||||
creationModes: ["DRAW", "TYPE"]
|
creationModes: ['DRAW', 'TYPE'],
|
||||||
},
|
},
|
||||||
isEditableAnnotation: function (annotation) {
|
isEditableAnnotation: function (annotation) {
|
||||||
// Check if the annotation is a signature
|
// Check if the annotation is a signature
|
||||||
// This will allow new signatures, but not allow edits.
|
// This will allow new signatures, but not allow edits.
|
||||||
console.log(annotation.isSignature, annotation.description)
|
console.log(annotation.isSignature, annotation.description)
|
||||||
|
|
||||||
if (annotation.isSignature || annotation.description == "FRAME") {
|
if (
|
||||||
return false;
|
annotation.isSignature ||
|
||||||
|
annotation.description == 'FRAME'
|
||||||
|
) {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true
|
||||||
|
|
||||||
//return !annotation.isSignature;
|
//return !annotation.isSignature;
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +47,7 @@
|
|||||||
const toolbarItems = this.getToolbarItems(instance, handler)
|
const toolbarItems = this.getToolbarItems(instance, handler)
|
||||||
instance.setToolbarItems(toolbarItems)
|
instance.setToolbarItems(toolbarItems)
|
||||||
|
|
||||||
console.debug("PSPDFKit configured!");
|
console.debug('PSPDFKit configured!')
|
||||||
}
|
}
|
||||||
|
|
||||||
getToolbarItems(instance, handler) {
|
getToolbarItems(instance, handler) {
|
||||||
@@ -63,46 +66,48 @@
|
|||||||
getCustomItems = function (callback) {
|
getCustomItems = function (callback) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
type: "custom",
|
type: 'custom',
|
||||||
id: "button-reset",
|
id: 'button-reset',
|
||||||
className: "button-reset",
|
className: 'button-reset',
|
||||||
title: "Zurücksetzen",
|
title: 'Zurücksetzen',
|
||||||
onPress() {
|
onPress() {
|
||||||
console.log("RESET")
|
console.log('RESET')
|
||||||
callback("RESET")
|
callback('RESET')
|
||||||
},
|
},
|
||||||
icon: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-arrow-counterclockwise" viewBox="0 0 16 16">
|
icon: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-arrow-counterclockwise" viewBox="0 0 16 16">
|
||||||
<path fill-rule="evenodd" d="M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2v1z"/>
|
<path fill-rule="evenodd" d="M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2v1z"/>
|
||||||
<path d="M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466z"/>
|
<path d="M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466z"/>
|
||||||
</svg>`
|
</svg>`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "custom",
|
type: 'custom',
|
||||||
id: "button-finish",
|
id: 'button-finish',
|
||||||
className: "button-finish",
|
className: 'button-finish',
|
||||||
title: "Abschließen",
|
title: 'Abschließen',
|
||||||
onPress() {
|
onPress() {
|
||||||
console.log("FINISH")
|
console.log('FINISH')
|
||||||
callback("FINISH")
|
callback('FINISH')
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultItems(items) {
|
getDefaultItems(items) {
|
||||||
return items.filter((item) => this.allowedToolbarItems.includes(item.type))
|
return items.filter((item) =>
|
||||||
|
this.allowedToolbarItems.includes(item.type)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getPresets() {
|
getPresets() {
|
||||||
const annotationPresets = PSPDFKit.defaultAnnotationPresets;
|
const annotationPresets = PSPDFKit.defaultAnnotationPresets
|
||||||
annotationPresets.ink = {
|
annotationPresets.ink = {
|
||||||
lineWidth: 10
|
lineWidth: 10,
|
||||||
};
|
|
||||||
|
|
||||||
annotationPresets.widget = {
|
|
||||||
readOnly: true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return annotationPresets;
|
annotationPresets.widget = {
|
||||||
|
readOnly: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
return annotationPresets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user