2023-09-25

This commit is contained in:
PitzM 2023-09-25 16:37:55 +02:00
parent d7b3cae218
commit 3ee7c180f6
9 changed files with 77 additions and 39 deletions

View File

@ -1,4 +1,5 @@
Public Class DbConfig
Public Property ExternalProgramName As String = "Sign Flow"
Public Property DocumentPath As String = ""
Public Property SendingProfile As Integer = 0
Public Property SignatureHost As String = ""

View File

@ -36,7 +36,7 @@
}
End Sub
Public Sub SetEmailBody(pEmailData As EmailData)
Public Sub FillEmailBody(pEmailData As EmailData)
InitDictionary(pEmailData)

View File

@ -93,7 +93,7 @@
<ItemGroup>
<Compile Include="Config.vb" />
<Compile Include="Constants.vb" />
<Compile Include="DbConfig.vb" />
<Compile Include="Entities\DbConfig.vb" />
<Compile Include="Entities\ElementMetadata.vb" />
<Compile Include="Entities\EmailData.vb" />
<Compile Include="Entities\EmailTemplate.vb" />
@ -107,6 +107,7 @@
<Compile Include="Entities\User.vb" />
<Compile Include="Helpers.vb" />
<Compile Include="Models\BaseModel.vb" />
<Compile Include="Models\ConfigModel.vb" />
<Compile Include="Models\DocumentModel.vb" />
<Compile Include="Models\ElementModel.vb" />
<Compile Include="Models\EmailModel.vb" />

View File

@ -0,0 +1,40 @@
Imports System.Data.SqlClient
Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Logging
Public Class ConfigModel
Inherits BaseModel
Public Sub New(pState As State)
MyBase.New(pState)
End Sub
Public Function LoadConfiguration() As DbConfig
Try
Dim oSql As String = "SELECT TOP 1 * FROM TBSIG_CONFIG"
Dim oTable As DataTable = Database.GetDatatable(oSql)
Dim oRow = oTable.Rows.Item(0)
Return New DbConfig() With {
.DocumentPath = oRow.ItemEx("DOCUMENT_PATH", ""),
.SendingProfile = oRow.ItemEx("SENDING_PROFILE", 0),
.SignatureHost = oRow.ItemEx("SIGNATURE_HOST", ""),
.ExternalProgramName = oRow.ItemEx("EXTERNAL_PROGRAM_NAME", "")
}
Catch ex As Exception
Return New DbConfig()
End Try
End Function
Public Function GetUserId() As Integer
Try
Dim oUserId As Integer = Database.GetScalarValue($"SELECT GUID FROM TBDD_USER WHERE USERNAME = '{Environment.UserName}'")
Return oUserId
Catch ex As Exception
Return 0
End Try
End Function
End Class

View File

@ -48,10 +48,8 @@ Public Class EnvelopeEditorController
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, Envelope.Uuid, receiverItem.Signature)
}
' TODO Email-Template füllen
Dim oTemplate As EmailTemplate = New EmailTemplate(State)
oTemplate.SetEmailBody(oEmailData)
oTemplate.FillEmailBody(oEmailData)
If EmailModel.Insert(oEmailData) = False Then
Logger.Error("EMail data could not be inserted.")
@ -62,7 +60,7 @@ Public Class EnvelopeEditorController
If EnvelopeModel.Send(Envelope) Then
'TODO: Send email
'TODO: Send email to History
Return True
Else
Return False
@ -94,15 +92,16 @@ Public Class EnvelopeEditorController
.UserId = State.UserId,
.User = UserModel.SelectUser()
}
If EnvelopeModel.Insert(oEnvelope) Then
Dim newHistoryEntry As New EnvelopeHistoryEntry With {
.EnvelopeId = oEnvelope.Id,
.Status = HistoryStatus.Created,
.ActionTitle = "Envelope erzeugt",
.ActionDescription = "Envelope wurde erzeugt"
.ActionTitle = "Envelope erstellt",
.ActionDescription = "Envelope wurde neu erstellt",
.UserEmailAddress = oEnvelope.User.Email
}
'TODO .UserEmailAddress = oEnvelope.User.Email ' TODO - fehlt noch
Return oEnvelope
Else

View File

@ -34,12 +34,13 @@ Partial Public Class frmEnvelopeEditor
Private Sub frmEditor_Load(sender As Object, e As EventArgs) Handles Me.Load
Logger = State.LogConfig.GetLogger()
Me.Text = State.DbConfig.ExternalProgramName + " Umschlag-Editor"
If Envelope Is Nothing Then
Controller = New EnvelopeEditorController(State)
' Get additional data
Dim oDataForm As New frmEnvelopeMainData() With {.State = State}
Dim oDataForm As New frmEnvelopeMainData() With {.State = State, .NewEnvelopeMode = True}
Dim oResult As DialogResult = oDataForm.ShowDialog()
If oResult = DialogResult.OK Then
Controller.Envelope.Title = oDataForm.EnvelopeTitle
@ -222,7 +223,8 @@ Partial Public Class frmEnvelopeEditor
{
.State = State,
.EnvelopeTitle = Controller.Envelope.Title,
.EnvelopeContractType = Controller.Envelope.ContractType
.EnvelopeContractType = Controller.Envelope.ContractType,
.NewEnvelopeMode = False
}
If oForm.ShowDialog() = DialogResult.OK Then
Controller.Envelope.Title = oForm.EnvelopeTitle

View File

@ -5,6 +5,7 @@ Public Class frmEnvelopeMainData
Public Property EnvelopeTitle As String
Public Property EnvelopeContractType As ContractType = ContractType.Contract
Public Property NewEnvelopeMode As Boolean = True
Public Property State As State
@ -13,6 +14,13 @@ Public Class frmEnvelopeMainData
End Sub
Private Sub frmEnvelopeMainData_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If NewEnvelopeMode = True Then
Me.Text = "Neuer Umschlag..."
Else
Me.Text = "Umschlag bearbeiten..."
cmbContractType.ReadOnly = True
End If
Dim contractTypeList = [Enum].GetValues(GetType(ContractType)) _
.Cast(Of ContractType)().ToList()
cmbContractType.Properties.Items.AddRange(contractTypeList)

View File

@ -27,6 +27,8 @@ Partial Public Class frmFieldEditor
LogConfig = New LogConfig(LogConfig.PathType.CustomPath, Application.StartupPath, CompanyName:="Digital Data", ProductName:="EnvelopeGenerator")
Logger = LogConfig.GetLogger()
Me.Text = State.DbConfig.ExternalProgramName + " Signatur-Editor"
If Document Is Nothing Then
Throw New ArgumentNullException("Document")
End If

View File

@ -1,5 +1,4 @@
Imports System.IO
Imports DevExpress.XtraSplashScreen
Imports DevExpress.XtraSplashScreen
Imports DigitalData.GUIs.Common
Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Config
@ -13,7 +12,6 @@ Public Class frmMain
Private Logger As Logger
Private Database As MSSQLServer
Private ConfigManager As ConfigManager(Of Config)
Private DbConfig As DbConfig
Private TempFiles As TempFiles
Private GridBuilder As GridBuilder
@ -33,22 +31,25 @@ Public Class frmMain
ConfigManager = New ConfigManager(Of Config)(LogConfig, Application.UserAppDataPath)
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
Database = New MSSQLServer(LogConfig, oConnectionString)
Dim oUserId = 0
If Database.DBInitialized = True Then
DbConfig = GetDatabaseConfig()
oUserId = Database.GetScalarValue($"SELECT GUID FROM TBDD_USER WHERE USERNAME = '{Environment.UserName}'")
End If
State = New State With {
.UserId = CInt(oUserId),
.UserId = 0,
.Config = ConfigManager.Config,
.DbConfig = DbConfig,
.DbConfig = New DbConfig(),
.LogConfig = LogConfig,
.Database = Database
}
If Database.DBInitialized = True Then
Dim ConfigModel = New ConfigModel(State)
State.DbConfig = ConfigModel.LoadConfiguration()
State.UserId = ConfigModel.GetUserId()
End If
If Not String.IsNullOrEmpty(State.DbConfig.ExternalProgramName) Then
Me.Text = State.DbConfig.ExternalProgramName
End If
Controller = New EnvelopeListController(State)
GridBuilder = New GridBuilder(ViewEnvelopes)
@ -64,22 +65,6 @@ Public Class frmMain
End Sub
Private Function GetDatabaseConfig() As DbConfig
Try
Dim oSql As String = "SELECT TOP 1 * FROM TBSIG_CONFIG"
Dim oTable As DataTable = Database.GetDatatable(oSql)
Dim oRow = oTable.Rows.Item(0)
Return New DbConfig() With {
.DocumentPath = oRow.ItemEx("DOCUMENT_PATH", ""),
.SendingProfile = oRow.ItemEx("SENDING_PROFILE", 0),
.SignatureHost = oRow.ItemEx("SIGNATURE_HOST", "")
}
Catch ex As Exception
Return New DbConfig()
End Try
End Function
Private Sub btnCreateEnvelope_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnCreateEnvelope.ItemClick
Dim oHandle = SplashScreenManager.ShowOverlayForm(Me)
Try