MS Common Verzeichnisstruktur

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

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