Compare commits

...

2 Commits

Author SHA1 Message Date
Developer01
686b1a3a59 MS Common 2025-05-09 16:51:31 +02:00
Developer01
773b43b1ad Common Rejection update, SendInvitationMailJob 2025-05-08 17:01:12 +02:00
19 changed files with 130 additions and 44 deletions

View File

@@ -19,6 +19,7 @@ Public Class EmailData
Public Property EmailAttachment As String = ""
Public Property ATT1_RELATED_ID As Long
Public Property ATT1_REL_TYPE As String = ""
Public Property ADDED_WHO_PROCESS As String = "DDEnvelopGenerator"
''' <summary>
''' Constructor for sending email to receiver

View File

@@ -33,6 +33,7 @@
Public Property History As New List(Of EnvelopeHistoryEntry)
Public Property EnvelopeType As EnvelopeType
Public Property DOC_RESULT As Byte()
Public Property CURRENT_WORK_APP As String = "signFLOW GUI"
Public ReadOnly Property EnvelopeTypeTitle As String
Get
Return EnvelopeType?.Title

View File

@@ -281,7 +281,7 @@
<Compile Include="Entities\ElementStatus.vb" />
<Compile Include="Entities\EmailData.vb" />
<Compile Include="Entities\EmailTemplate.vb" />
<Compile Include="Jobs\APIBackendJobs\SendInvitationMailJob.vb" />
<Compile Include="Jobs\APIBackendJobs\APIEnvelopeJob.vb" />
<Compile Include="Jobs\FinalizeDocument\PDFBurnerParams.vb" />
<Compile Include="Services\TemplateService.vb" />
<Compile Include="Entities\Envelope.vb" />

View File

@@ -52,6 +52,7 @@ Public Class Helpers
End Function
Public Shared Function GetEnvelopeURL(pHost As String, pEnvelopeUuid As String, pReceiverSignature As String) As String
Dim oEnvelopeUserReference As String = EncodeEnvelopeReceiverId(pEnvelopeUuid, pReceiverSignature)
Dim oURL As String = String.Format("{0}/EnvelopeKey/{1}", pHost.Trim(), oEnvelopeUserReference)
Return oURL

View File

@@ -13,7 +13,7 @@ Imports System.Data.SqlClient
Imports DevExpress.XtraRichEdit.Layout.Engine
Namespace Jobs
Public Class SendInvitationMailJob
Public Class APIEnvelopeJob
Implements IJob
@@ -44,30 +44,29 @@ Namespace Jobs
myTempFiles = New TempFiles(LogConfig)
myTempFiles.Create()
Dim JobId = pContext.JobDetail.Key
Logger.Debug("SendInvMail - Starting job {0}", JobId)
Logger.Debug("API Envelopes - Starting job {0}", JobId)
Try
Logger.Debug("SendInvMail - Loading Database..")
Logger.Debug("API Envelopes - Loading Database..")
Database = GetDatabase(pContext, LogConfig)
Logger.Debug("SendInvMail - Loading Models & Services")
Logger.Debug("API Envelopes - Loading Models & Services")
Dim oState = GetState()
InitializeModels(oState)
Logger.Debug("SendInvMail - Loading Configuration..")
Logger.Debug("API Envelopes - Loading Configuration..")
Config = ConfigModel.LoadConfiguration()
oState.DbConfig = Config
InitializeServices(oState)
Config.DocumentPath = Config.DocumentPath
Logger.Debug("SendInvMail - ExportPath: [{0}]", Config.ExportPath)
Logger.Debug("API Envelopes - ExportPath: [{0}]", Config.ExportPath)
Dim oCompleteStatus As Integer = Constants.EnvelopeStatus.EnvelopeCompletelySigned
Dim oSql = $"SELECT * FROM TBSIG_ENVELOPE where SOURCE = 'API' AND STATUS = 1003 order by guid"
Dim oTable = Database.GetDatatable(oSql)
Dim oDTEnv_invitations = Database.GetDatatable(oSql)
Dim oEnvelopeIds As List(Of Integer) = oTable.Rows.Cast(Of DataRow).
Dim oEnvelopeIds As List(Of Integer) = oDTEnv_invitations.Rows.Cast(Of DataRow).
Select(Function(r) r.Item("GUID")).
Cast(Of Integer).
ToList()
@@ -83,10 +82,12 @@ Namespace Jobs
Logger.Info("SendInvMail - Gathering Info for Envelope [{0}] ({1}/{2})", oId, oCurrent, oTotal)
Try
Dim oEnvelope = EnvelopeModel.GetById(oId)
If oEnvelope Is Nothing Then
Logger.Warn("SendInvMail - Envelope could not be loaded for Id [{0}]!", oId)
Throw New ArgumentNullException("EnvelopeData")
End If
oEnvelope.CURRENT_WORK_APP = "signFLOW_API_EnvJob_InvMail"
Logger.Debug("SendInvMail - Loading Envelope Data..")
Dim oEnvelopeData = GetEnvelopeData(oId)
oEnvelope.Receivers = ReceiverModel.ListEnvelopeReceivers(oEnvelope.Id).ToList()
@@ -108,13 +109,63 @@ Namespace Jobs
Logger.Info("SendInvMail - Envelope finalized!")
Next
'Hier nun der Teil um zurückgezogene Envelopes abzuarbeiten
oSql = $"SELECT ENV.GUID,REJ.COMMENT REJECTION_REASON FROM
(SELECT * FROM TBSIG_ENVELOPE where STATUS = 1009 AND SOURCE = 'API') ENV INNER JOIN
(SELECT MAX(GUID) GUID,ENVELOPE_ID,MAX(ADDED_WHEN) ADDED_WHEN,MAX(ACTION_DATE) ACTION_DATE, COMMENT FROM TBSIG_ENVELOPE_HISTORY where STATUS = 1009 GROUP BY ENVELOPE_ID,COMMENT ) REJ ON ENV.GUID = REJ.ENVELOPE_ID LEFT JOIN
(SELECT * FROM TBSIG_ENVELOPE_HISTORY where STATUS = 3004 ) M_Send ON ENV.GUID = M_Send.ENVELOPE_ID
where M_Send.GUID IS NULL"
Dim oDT_EnvWithdrawn = Database.GetDatatable(oSql)
Logger.Debug("SendInvMail - Completed job {0} successfully!", JobId)
oEnvelopeIds = oDTEnv_invitations.Rows.Cast(Of DataRow).
Select(Function(r) r.Item("GUID")).
Cast(Of Integer).
ToList()
If oEnvelopeIds.Count > 0 Then
Logger.Info("WithdrawnEnv - Found [{0}] envelopes.", oEnvelopeIds.Count)
End If
oTotal = oEnvelopeIds.Count
oCurrent = 1
Dim oEnvID As Integer
For Each oRow As DataRow In oDT_EnvWithdrawn.Rows
oEnvID = oRow.Item("GUID")
Dim oReason = oRow.Item("REJECTION_REASON")
Logger.Info("WithdrawnEnv - Gathering Info for Envelope [{0}] ({1}/{2})", oEnvID, oCurrent, oTotal)
Try
Dim oEnvelope = EnvelopeModel.GetById(oEnvID)
If oEnvelope Is Nothing Then
Logger.Warn("WithdrawnEnv - Envelope could not be loaded for Id [{0}]!", oEnvID)
Throw New ArgumentNullException("EnvelopeData")
End If
oEnvelope.CURRENT_WORK_APP = "signFLOW_API_EnvJob_Withdrawn"
oEnvelope.Receivers = ReceiverModel.ListEnvelopeReceivers(oEnvelope.Id).ToList()
Logger.Debug("WithdrawnEnv - Sending Withdrawn Mails..")
If ActionService.API_SendWithdrawn_Mails(oEnvelope, oReason) = False Then
Logger.Warn("Could not send the Mails for withdrawn Envelope")
Else
Dim oStatInsert = $"INSERT INTO TBSIG_ENVELOPE_HISTORY (ENVELOPE_ID,STATUS,USER_REFERENCE,ADDED_WHEN,ACTION_DATE) VALUES ('{oEnvelope.Id}',3004,'API',GETDATE(),GETDATE())"
Database.ExecuteNonQuery(oStatInsert)
End If
Catch ex As Exception
Logger.Warn(ex, $"WithdrawnEnv - Unhandled exception while working envelope [{oEnvID}]")
End Try
oCurrent += 1
Logger.Info("WithdrawnEnv - Envelope finalized!")
Next
Logger.Debug("API Envelopes - Completed job {0} successfully!", JobId)
Catch ex As Exception
Logger.Warn("SendInvMail job failed!")
Logger.Warn("API Envelopes job failed!")
Logger.Error(ex)
Finally
Logger.Debug("SendInvMail execution for [{0}] ended", JobId)
Logger.Debug("API Envelopes execution for [{0}] ended", JobId)
End Try
Return Task.FromResult(True)
@@ -125,7 +176,7 @@ Namespace Jobs
ReceiverModel = New ReceiverModel(pState)
End Sub
Private Sub InitializeServices(pState As State)
ActionService = New ActionService(pState)
ActionService = New ActionService(pState, Database)
End Sub
Private Function GetDatabase(pContext As IJobExecutionContext, pLogConfig As LogConfig) As MSSQLServer
Dim oConnectionString As String = pContext.MergedJobDataMap.Item(Constants.DATABASE)

View File

@@ -146,7 +146,7 @@ Namespace Jobs
Directory.CreateDirectory(oOutputDirectoryPath)
End If
Dim oOutputFilePath = Path.Combine(oOutputDirectoryPath, $"{oEnvelope.Uuid}.pdf")
Logger.Info("Writing finalized Pdf to disk..")
Logger.Debug("Writing finalized Pdf to disk..")
Logger.Info("Output path is [{0}]", oOutputFilePath)
Try
@@ -156,12 +156,14 @@ Namespace Jobs
Throw New ExportDocumentException("Could not export final document to disk!", ex)
End Try
Logger.Info("Writing EB-bytes to database...")
Logger.Debug("Writing EB-bytes to database...")
Update_File_DB(oOutputFilePath, oEnvelope.Id)
Logger.Info("Sending finalized report-mails..")
If SendFinalEmails(oEnvelope) = False Then ', oOutputFilePath
Throw New ApplicationException("Final emails could not be sent!")
Else
Logger.Info("Report-mails successfully sent!")
End If
Logger.Debug("Setting envelope status..")
If ActionService.FinalizeEnvelope(oEnvelope) = False Then
@@ -174,7 +176,7 @@ Namespace Jobs
oCurrent += 1
Logger.Info("Envelope finalized!")
Logger.Info($"Envelope [{oId}] finalized!")
Next
@@ -191,7 +193,7 @@ Namespace Jobs
Logger.Warn("Certificate Document job failed!")
Logger.Error(ex)
Finally
Logger.Info("Job execution for [{0}] ended", JobId)
Logger.Debug("Job execution for [{0}] ended", JobId)
End Try
Return Task.FromResult(True)
@@ -358,9 +360,9 @@ Namespace Jobs
oInputPath = pEnvelopeData.DocumentPath
Logger.Info($"Input path: [{oInputPath}]")
Else
Logger.Info($"we got bytes..")
Logger.Debug($"we got bytes..")
oInputPath = Config.DocumentPathOrigin
Logger.Info($"oInputPath: {Config.DocumentPathOrigin}")
Logger.Debug($"oInputPath: {Config.DocumentPathOrigin}")
End If
@@ -424,7 +426,7 @@ Namespace Jobs
End Function
Private Sub InitializeServices(pState As State)
ActionService = New ActionService(pState)
ActionService = New ActionService(pState, Database)
End Sub
Private Sub InitializeModels(pState As State)

View File

@@ -18,7 +18,7 @@ Public Class EmailModel
oCommand.Parameters.Add("EMAIL_ADRESS", SqlDbType.NVarChar).Value = pEmail.EmailAdress
oCommand.Parameters.Add("EMAIL_SUBJ", SqlDbType.NVarChar).Value = pEmail.EmailSubject
oCommand.Parameters.Add("EMAIL_BODY", SqlDbType.NVarChar).Value = pEmail.EmailBody
oCommand.Parameters.Add("ADDED_WHO", SqlDbType.NVarChar).Value = "DDEnvelopGenerator"
oCommand.Parameters.Add("ADDED_WHO", SqlDbType.NVarChar).Value = pEmail.ADDED_WHO_PROCESS
oCommand.Parameters.Add("SENDING_PROFILE", SqlDbType.Int).Value = State.DbConfig.SendingProfile
oCommand.Parameters.Add("REFERENCE_ID", SqlDbType.Int).Value = pEmail.ReferenceID
oCommand.Parameters.Add("REFERENCE_STRING", SqlDbType.NVarChar).Value = pEmail.ReferenceString

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' indem Sie "*" wie unten gezeigt eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.6.0.0")>
<Assembly: AssemblyFileVersion("2.6.0.0")>
<Assembly: AssemblyVersion("2.7.0.0")>
<Assembly: AssemblyFileVersion("2.7.0.0")>

View File

@@ -2,19 +2,24 @@
Imports DigitalData.Modules.Base
Imports EnvelopeGenerator.Common.Constants
Imports EnvelopeGenerator.Common.My.Resources
Imports DigitalData.Modules.Database
Imports System.ComponentModel
Public Class ActionService
Inherits BaseService
Private ReadOnly EmailService As EmailService
Private ReadOnly HistoryService As HistoryService
Private ReadOnly ReceiverModel As ReceiverModel
Private myDatabase As MSSQLServer
Public Sub New(pState As State)
Public Sub New(pState As State, pDD_ECM As MSSQLServer)
MyBase.New(pState)
myDatabase = pDD_ECM
EmailService = New EmailService(pState)
HistoryService = New HistoryService(pState)
ReceiverModel = New ReceiverModel(pState)
@@ -63,6 +68,8 @@ Public Class ActionService
Else
oStatus = Constants.EnvelopeStatus.EnvelopeDeleted
End If
Dim oUpd = $"UPDATE TBSIG_ENVELOPE SET REJECTION_REASON = '{pReason}' WHERE GUID = {pEnvelope.Id}"
myDatabase.ExecuteNonQuery(oUpd)
If HistoryService.SetEnvelopeStatus(pEnvelope, oStatus, pEnvelope.User.Email) = False Then
Return False
End If
@@ -77,6 +84,15 @@ Public Class ActionService
Return True
End Function
Public Function API_SendWithdrawn_Mails(pEnvelope As Envelope, pReason As String) As Boolean
Dim oSendResult As Boolean = False
For Each oReceiver As EnvelopeReceiver In pEnvelope.Receivers
If EmailService.SendEnvelopeDeletedEmail(pEnvelope, oReceiver, pReason) = False Then
Return False
End If
Next
Return True
End Function
Public Function OpenEnvelope(pEnvelope As Envelope, pReceiver As EnvelopeReceiver) As Boolean
Dim oUserReference = pReceiver.Email

View File

@@ -1,13 +1,10 @@
Imports DigitalData.Modules.Base
Public Class BaseService
Inherits BaseClass
Friend Property State As State
Public Sub New(pState As State)
MyBase.New(pState.LogConfig)
State = pState
End Sub
End Class

View File

@@ -17,10 +17,11 @@ Public Class EmailService
End Sub
Public Function SendEnvelopeDeletedEmail(pEnvelope As Envelope, pReceiver As EnvelopeReceiver, pReason As String) As Boolean
Logger.Debug("Creating email data object.")
Logger.Debug("SendEnvelopeDeletedEmail - Creating email data object...")
Dim oEmailData As New EmailData(pEnvelope, pReceiver, Constants.EnvelopeStatus.MessageDeletionSent) With
{
.SignatureLink = ""
.SignatureLink = "",
.ADDED_WHO_PROCESS = pEnvelope.CURRENT_WORK_APP
}
EmailTemplate.FillEnvelopeDeletedEmailBody(oEmailData, pReason)
@@ -37,7 +38,8 @@ Public Class EmailService
Logger.Debug("Creating email data object.")
Dim oEmailData As New EmailData(pEnvelope, pReceiver, Constants.EnvelopeStatus.MessageInvitationSent) With
{
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, pEnvelope.Uuid, pReceiver.Signature)
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, pEnvelope.Uuid, pReceiver.Signature),
.ADDED_WHO_PROCESS = pEnvelope.CURRENT_WORK_APP
}
EmailTemplate.FillDocumentReceivedEmailBody(oEmailData)
@@ -51,9 +53,13 @@ Public Class EmailService
End Function
Public Function GetReceiverUrl(pEnvelope As Envelope, pReceiver As EnvelopeReceiver) As String
Logger.Debug($"State.DbConfig.SignatureHost: {State.DbConfig.SignatureHost}")
Logger.Debug($" pEnvelope.Uuid: {pEnvelope.Uuid}")
Logger.Debug($" pReceiver.Signature: {pReceiver.Signature}")
Dim oEmailData As New EmailData(pEnvelope, pReceiver, Constants.EnvelopeStatus.MessageInvitationSent) With
{
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, pEnvelope.Uuid, pReceiver.Signature)
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, pEnvelope.Uuid, pReceiver.Signature),
.ADDED_WHO_PROCESS = pEnvelope.CURRENT_WORK_APP
}
Return oEmailData.SignatureLink
End Function
@@ -61,9 +67,13 @@ Public Class EmailService
Public Function SendDocumentAccessCodeReceivedEmail(pEnvelope As Envelope, pReceiver As EnvelopeReceiver) As Boolean
Logger.Debug("Creating email data object.")
Logger.Debug($"State.DbConfig.SignatureHost: {State.DbConfig.SignatureHost}")
Logger.Debug($" pEnvelope.Uuid: {pEnvelope.Uuid}")
Logger.Debug($" pReceiver.Signature: {pReceiver.Signature}")
Dim oEmailData As New EmailData(pEnvelope, pReceiver, Constants.EnvelopeStatus.MessageAccessCodeSent) With
{
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, pEnvelope.Uuid, pReceiver.Signature)
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, pEnvelope.Uuid, pReceiver.Signature),
.ADDED_WHO_PROCESS = pEnvelope.CURRENT_WORK_APP
}
EmailTemplate.FillDocumentAccessCodeReceivedEmailBody(oEmailData)

View File

@@ -28,7 +28,7 @@ Public MustInherit Class BaseController
State = pState
Database = pState.Database
InitializeModels(pState)
ActionService = New ActionService(pState)
ActionService = New ActionService(pState, Database)
End Sub
Private Sub InitializeModels(pState As State)

View File

@@ -22,7 +22,7 @@ Public Class EnvelopeEditorController
Envelope = CreateEnvelope()
Thumbnail = New Thumbnail(pState.LogConfig)
EmailService = New EmailService(pState)
ActionService = New ActionService(pState)
ActionService = New ActionService(pState, Nothing)
End Sub
Public Sub New(pState As State, pEnvelope As Envelope)
@@ -33,7 +33,7 @@ Public Class EnvelopeEditorController
Envelope.Receivers = ReceiverModel.ListEnvelopeReceivers(pEnvelope.Id).ToList()
Thumbnail = New Thumbnail(pState.LogConfig)
ActionService = New ActionService(pState)
ActionService = New ActionService(pState, Nothing)
End Sub
#Region "Public"

View File

@@ -38,6 +38,6 @@ Public Class frm2Factor_Properties
End If
End If
txtMail.Text = mail
txtValid.Text = Deadline.ToLongDateString
txtValid.Text = Deadline.ToString
End Sub
End Class

View File

@@ -65,6 +65,9 @@ Public Class frmEnvelopeMainData
chked_2Faktor.EditValue = DEF_TF_ENABLED
Else
If IsNothing(Envelope.EnvelopeType) Then
Envelope.EnvelopeType = EnvelopeType
End If
If Envelope.EnvelopeType.ContractType = 0 Then
cmbEnvelopeType.EditValue = EnvelopeType
Else

View File

@@ -57,8 +57,10 @@ Public Class frmMain
End Try
If MYUSER.IsAdmin Then
XtraTabControlMain.TabPages(2).PageVisible = True
XtraTabControlMain.TabPages(3).PageVisible = True
Else
XtraTabControlMain.TabPages(2).PageVisible = False
XtraTabControlMain.TabPages(3).PageVisible = False
End If
LoadEnvelopeData()
End Sub
@@ -224,6 +226,7 @@ Public Class frmMain
bbtnitm_ResendInvitation.Enabled = False
bbtnitmInfoMail.Enabled = False
bbtnitmEB.Enabled = True
bbtnitm2Faktor.Enabled = False
LoadEnvelopeData()
Case 0
btnEditEnvelope.Enabled = True
@@ -232,6 +235,7 @@ Public Class frmMain
btnShowDocument.Enabled = True
bbtnitm_ResendInvitation.Enabled = True
bbtnitmInfoMail.Enabled = True
bbtnitm2Faktor.Enabled = True
bbtnitmEB.Enabled = False
LoadEnvelopeData()

View File

@@ -260,7 +260,7 @@
<ItemGroup>
<Compile Include="Config.vb" />
<Compile Include="LogProvider.vb" />
<Compile Include="Scheduler_API_SendEnvelopeMails.vb" />
<Compile Include="Scheduler_Envelopetask_API.vb" />
<Compile Include="Service.Designer.vb">
<DependentUpon>Service.vb</DependentUpon>
</Compile>

View File

@@ -5,7 +5,7 @@ Imports DigitalData.Modules.Logging
Imports EnvelopeGenerator.Common.Jobs
Imports EnvelopeGenerator.Common.Jobs.FinalizeDocument
Imports Quartz
Public Class Scheduler_API_SendEnvelopeMails
Public Class Scheduler_Envelopetask_API
Inherits BaseClass
Private Scheduler As IScheduler
Private ReadOnly ConnectionString As String
@@ -35,7 +35,7 @@ Public Class Scheduler_API_SendEnvelopeMails
Logger.Debug("Initialized Job [{0}]", JobName)
Dim oJob As IJobDetail = JobBuilder.Create(Of SendInvitationMailJob).
Dim oJob As IJobDetail = JobBuilder.Create(Of APIEnvelopeJob).
UsingJobData(oJobData).
WithIdentity(oJobKey).
Build()

View File

@@ -12,7 +12,7 @@ Public Class Service
Private Database As MSSQLServer
Private TempFiles As TempFiles
Private Scheduler1 As Scheduler_FinishEnvelope
Private Scheduler2 As Scheduler_API_SendEnvelopeMails
Private Scheduler2 As Scheduler_Envelopetask_API
Protected Overrides Async Sub OnStart(ByVal args() As String)
Try
@@ -62,7 +62,7 @@ Public Class Service
Thread.Sleep(2500)
Scheduler2 = New Scheduler_API_SendEnvelopeMails(LogConfig, Config.ConnectionString)
Scheduler2 = New Scheduler_Envelopetask_API(LogConfig, Config.ConnectionString)
Await Scheduler2.Start(Config.IntervalInMin)
Logger.Info("Started [{0}] !", ServiceName)