MS Common Verzeichnisstruktur

This commit is contained in:
SchreiberM 2024-03-19 15:10:51 +01:00
parent a3c66ecd19
commit 5abc1d9779
7 changed files with 68 additions and 34 deletions

View File

@ -1,5 +1,6 @@
Public Class DbConfig
Public Property ExternalProgramName As String = "Sign Flow"
Public Property DocumentPathOrigin As String = ""
Public Property DocumentPath As String = ""
Public Property ExportPath As String = ""
Public Property DocumentPath_DMZ As String = ""

View File

@ -12,6 +12,7 @@ Imports EnvelopeGenerator.Common.Constants
Imports DevExpress.XtraBars.Docking
Imports System.ServiceModel
Imports DevExpress.XtraRichEdit.Export
Imports DevExpress.Pdf.Native.BouncyCastle.Asn1.Cms
Namespace Jobs
Public Class FinalizeDocumentJob
@ -35,7 +36,7 @@ Namespace Jobs
Private PDFMerger As PDFMerger
Private ReportCreator As ReportCreator
Private ReadOnly CompleteWaitTimeInMinutes As Integer = 5
Private ReadOnly CompleteWaitTime As Integer = 5
Private Class EnvelopeData
Public EnvelopeId As Integer
@ -78,7 +79,8 @@ Namespace Jobs
Logger.Debug("Loading ReportCreator..")
ReportCreator = New ReportCreator(LogConfig, oState)
Logger.Debug("My.Settings.RuninDMZ: [{0}]", My.Settings.RuninDMZ.ToString)
Logger.Debug("My.Settings.NetUse_Usr: [{0}]", My.Settings.NetUse_Usr)
If My.Settings.RuninDMZ = True Then
If Config.DocumentPath_DMZ <> String.Empty Then
@ -90,14 +92,16 @@ Namespace Jobs
End If
Else
If Config.DOCUMENT_PATH_MOVE_AFTSEND <> String.Empty Then
Logger.Debug("Using DMZRemotePath: [{0}] - Overwrite Document-Path", Config.DOCUMENT_PATH_MOVE_AFTSEND)
Logger.Debug("Using DMZRemotePath: [{0}] - Overwrite Document-Path...", Config.DOCUMENT_PATH_MOVE_AFTSEND)
Config.DocumentPath = Config.DOCUMENT_PATH_MOVE_AFTSEND
Config.NetUse_necessary = True
Config.NetUse_Finish = True
Else
Config.DocumentPath = Config.DocumentPath
End If
End If
Logger.Debug("DocumentPath: [{0}]", Config.DocumentPath)
If My.Settings.RuninDMZ = True Then
If Config.FINISHED_PATH_EX_DMZ <> String.Empty Then
Logger.Debug("RuninDMZ - FINISHED_PATH_EX_DMZ configured: [{0}]", Config.FINISHED_PATH_EX_DMZ)
@ -109,20 +113,21 @@ Namespace Jobs
Else
Config.ExportPath = Config.ExportPath
End If
ElseIf Config.DOCUMENT_PATH_MOVE_AFTSEND <> String.Empty Then
Logger.Debug("DOCUMENT_PATH_MOVE_AFTSEND configured: [{0}] - Overwrite ExportPath", Config.DOCUMENT_PATH_MOVE_AFTSEND)
Config.ExportPath = Config.DOCUMENT_PATH_MOVE_AFTSEND
Config.NetUse_Finish = True
Else
Config.ExportPath = Config.ExportPath
End If
Logger.Debug("ExportPath: [{0}]", Config.ExportPath)
If Config.NetUse_Finish = True Then
Logger.Debug("NetUse_Finish = true, Now executing NetUse....")
If NetUse_Command(Config.DocumentPath, My.Settings.NetUse_Usr, My.Settings.NetUse_PW) = True Then
Logger.Debug("NetUse_Finish = successful!")
End If
End If
Dim oCompleteStatus As Integer = Constants.EnvelopeStatus.EnvelopeCompletelySigned
Dim oSql = $"SELECT * FROM TBSIG_ENVELOPE WHERE STATUS = {oCompleteStatus} AND DATEDIFF(minute, CHANGED_WHEN, GETDATE()) >= {CompleteWaitTimeInMinutes}"
Dim oSql = $"SELECT * FROM TBSIG_ENVELOPE WHERE STATUS = {oCompleteStatus} AND DATEDIFF(minute, CHANGED_WHEN, GETDATE()) >= {CompleteWaitTime}"
Dim oTable = Database.GetDatatable(oSql)
Dim oEnvelopeIds As List(Of Integer) = oTable.Rows.Cast(Of DataRow).
@ -149,6 +154,11 @@ Namespace Jobs
Logger.Debug("Loading Envelope Data..")
Dim oEnvelopeData = GetEnvelopeData(oId)
If Config.DOCUMENT_PATH_MOVE_AFTSEND <> String.Empty Then
oEnvelopeData.DocumentPath.Replace(Config.DocumentPathOrigin, Config.DOCUMENT_PATH_MOVE_AFTSEND)
Logger.Debug("Replaced Path in oEnvelopeData.DocumentPath!")
End If
If oEnvelopeData Is Nothing Then
Logger.Warn("EnvelopeData could not be loaded for Id [{0}]!", oId)
Throw New ArgumentNullException("EnvelopeData")
@ -187,7 +197,7 @@ Namespace Jobs
Throw New ExportDocumentException("Could not export final document to disk!", ex)
End Try
Logger.Info("Sending final Emails..")
Logger.Info("Sending finalized report-mails..")
If Config.NetUse_Finish = True Then
If Config.FINISHED_PATH_EX_DMZ <> String.Empty Then
@ -196,7 +206,10 @@ Namespace Jobs
If oReturnPath <> String.Empty Then
oOutputFilePath = oReturnPath
If Config.EML_PATH_EX_DMZ <> String.Empty Then
Logger.Debug($"Now replacing [{Config.FINISHED_PATH_EX_DMZ}] with ")
Logger.Debug($"............. [{Config.EML_PATH_EX_DMZ}] ")
oOutputFilePath = oOutputFilePath.Replace(Config.FINISHED_PATH_EX_DMZ, Config.EML_PATH_EX_DMZ)
Logger.Debug($"oOutputFilePath [{oOutputFilePath}] ")
End If
End If
End If
@ -238,11 +251,8 @@ Namespace Jobs
Return Task.FromResult(True)
End Function
Private Function MoveFileWithNetUse(pSourcePath As String, pDestinationPath As String, pUsername As String, pPassword As String) As String
Private Function NetUse_Command(pDestinationPath As String, pUsername As String, pPassword As String)
Dim oDectryptedPW = Helpers.Decrypt(My.Settings.NetUse_PW)
Dim oFilename = System.IO.Path.GetFileName(pSourcePath)
Dim netUseCommand As String = $"net use {pDestinationPath} /user:{pUsername} {oDectryptedPW}"
Dim processInfo As New ProcessStartInfo("cmd.exe", $"/C {netUseCommand}")
@ -255,10 +265,32 @@ Namespace Jobs
' Prüfe den Rückgabewert des net use Befehls
If process.ExitCode = 0 Then
Return True
Else
Return False
End If
End Using
End Function
Private Function MoveFileWithNetUse(pSourcePath As String, pDestinationPath As String, pUsername As String, pPassword As String) As String
Dim oDectryptedPW = Helpers.Decrypt(My.Settings.NetUse_PW)
Dim oFilename = System.IO.Path.GetFileName(pSourcePath)
Dim netUseCommand As String = $"net use {pDestinationPath} /user:{pUsername} {oDectryptedPW}"
Dim processInfo As New ProcessStartInfo("cmd.exe", $"/C {netUseCommand}")
processInfo.RedirectStandardOutput = True
processInfo.UseShellExecute = False
processInfo.CreateNoWindow = True
Using oProcess As Process = Process.Start(processInfo)
oProcess.WaitForExit()
' Prüfe den Rückgabewert des net use Befehls
If oProcess.ExitCode = 0 Then
' Verschiebe die Datei
Try
Dim oFilePath As String = pSourcePath
Dim oDirectory As String = Path.GetDirectoryName(oFilePath)
Dim split As String() = oFilePath.Split("\")
Dim parentFolder As String = split(split.Length - 2)
pDestinationPath &= "\" + parentFolder
@ -271,6 +303,7 @@ Namespace Jobs
End If
Logger.Info($"MoveFileWithNetUse To {pDestinationPath} ...")
System.IO.File.Move(pSourcePath, pDestinationPath)
Directory.Delete(oDirectory)
Return pDestinationPath
Catch ex As Exception
Logger.Error(ex)
@ -352,8 +385,16 @@ Namespace Jobs
Logger.Info("Burning [{0}] signatures", pData.AnnotationData.Count)
Dim oAnnotations = pData.AnnotationData
Dim oInputPath = pData.DocumentPath
Dim oInputPath = ""
If My.Settings.RuninDMZ Then
oInputPath = pData.DocumentPath.Replace(Config.DocumentPathOrigin, Config.DocumentPath)
Logger.Debug("Replaced Path in pData.DocumentPath!")
ElseIf Config.DOCUMENT_PATH_MOVE_AFTSEND <> String.Empty Then
oInputPath = pData.DocumentPath.Replace(Config.DocumentPathOrigin, Config.DOCUMENT_PATH_MOVE_AFTSEND)
Logger.Debug("Replaced Path in pData.DocumentPath!")
End If
Logger.Info("Input path: [{0}]", oInputPath)
Dim oInputDocumentBuffer As Byte()
Try

View File

@ -17,6 +17,7 @@ Public Class ConfigModel
Return New DbConfig() With {
.DocumentPath = oRow.ItemEx("DOCUMENT_PATH", ""),
.DocumentPathOrigin = oRow.ItemEx("DOCUMENT_PATH", ""),
.DocumentPath_DMZ = oRow.ItemEx("DOCUMENT_PATH_DMZ", ""),
.ExportPath = oRow.ItemEx("EXPORT_PATH", ""),
.ExportPath_DMZ = oRow.ItemEx("EXPORT_PATH_DMZ", ""),

View File

@ -72,16 +72,13 @@ Namespace My
End Get
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("sY4vnATDXwosbTJGip6SqA==")> _
Public Property NetUse_PW() As String
Public ReadOnly Property NetUse_PW() As String
Get
Return CType(Me("NetUse_PW"),String)
End Get
Set
Me("NetUse_PW") = value
End Set
End Property
End Class
End Namespace

View File

@ -8,7 +8,7 @@
<Setting Name="NetUse_Usr" Type="System.String" Scope="Application">
<Value Profile="(Default)">dd-gan\Administrator</Value>
</Setting>
<Setting Name="NetUse_PW" Type="System.String" Scope="User">
<Setting Name="NetUse_PW" Type="System.String" Scope="Application">
<Value Profile="(Default)">sY4vnATDXwosbTJGip6SqA==</Value>
</Setting>
</Settings>

View File

@ -5,9 +5,6 @@
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="EnvelopeGenerator.Common.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="EnvelopeGenerator.Common.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<system.diagnostics>
<sources>
@ -40,13 +37,9 @@
<setting name="NetUse_Usr" serializeAs="String">
<value>dd-gan\Administrator</value>
</setting>
</EnvelopeGenerator.Common.My.MySettings>
</applicationSettings>
<userSettings>
<EnvelopeGenerator.Common.My.MySettings>
<setting name="NetUse_PW" serializeAs="String">
<value>sY4vnATDXwosbTJGip6SqA==</value>
</setting>
</EnvelopeGenerator.Common.My.MySettings>
</userSettings>
</applicationSettings>
</configuration>

View File

@ -364,7 +364,7 @@ Partial Public Class frmEnvelopeEditor
' Verschiebe die Datei
Try
Dim oFilePath As String = pSourcePath
Dim oDirectory As String = Path.GetDirectoryName(oFilePath)
Dim split As String() = oFilePath.Split("\")
Dim parentFolder As String = split(split.Length - 2)
pDestinationPath &= "\" + parentFolder
@ -376,6 +376,7 @@ Partial Public Class frmEnvelopeEditor
File.Delete(pDestinationPath)
End If
System.IO.File.Move(pSourcePath, pDestinationPath)
System.IO.Directory.Delete(oDirectory)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in MoveFileWithNetUse")
End Try