always use \\windream\objects for moving files

This commit is contained in:
Jonathan Jenne 2020-05-15 14:17:48 +02:00
parent 4d37be19b2
commit 3aa882b490
3 changed files with 139 additions and 131 deletions

View File

@ -94,13 +94,13 @@ Public Class ClassInit
Public Function Load_BasicConfig() Public Function Load_BasicConfig()
Try Try
ClassDatabase.Init() ClassDatabase.Init()
Dim oSql As String = "select * from tbdd_Modules where NAME = 'Global-Indexer'" Dim oSql As String = "SELECT * FROM TBDD_MODULES WHERE NAME = 'Global-Indexer'"
Dim DT As DataTable = ClassDatabase.Return_Datatable(oSql) Dim DT As DataTable = ClassDatabase.Return_Datatable(oSql)
If DT.Rows.Count = 1 Then If DT.Rows.Count = 1 Then
GI_withWindream = DT.Rows(0).Item("BIT1") GI_withWindream = DT.Rows(0).Item("BIT1")
'vWLaufwerk = DT.Rows(0).Item("STRING1") 'vWLaufwerk = DT.Rows(0).Item("STRING1")
End If End If
oSql = "select * from TBDD_BASECONFIG" oSql = "SELECT * FROM TBDD_BASECONFIG"
DT = ClassDatabase.Return_Datatable(oSql) DT = ClassDatabase.Return_Datatable(oSql)
If DT.Rows.Count = 1 Then If DT.Rows.Count = 1 Then
WMDrive = DT.Rows(0).Item("WM_DRIVE") WMDrive = DT.Rows(0).Item("WM_DRIVE")

View File

@ -168,7 +168,8 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\DDMonorepo\Modules.Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath> <HintPath>..\..\DDMonorepo\Modules.Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Windream"> <Reference Include="DigitalData.Modules.Windream, Version=1.0.0.5, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\DDMonorepo\Modules.Windream\bin\Debug\DigitalData.Modules.Windream.dll</HintPath> <HintPath>..\..\DDMonorepo\Modules.Windream\bin\Debug\DigitalData.Modules.Windream.dll</HintPath>
</Reference> </Reference>
<Reference Include="DLLLicenseManager, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="DLLLicenseManager, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">

View File

@ -453,7 +453,9 @@ Public Class frmIndex
CURR_DOKART_WD_DIRECT = DT.Rows(0).Item("WINDREAM_DIRECT") CURR_DOKART_WD_DIRECT = DT.Rows(0).Item("WINDREAM_DIRECT")
CURR_DOKART_OBJECTTYPE = DT.Rows(0).Item("OBJEKTTYP") CURR_DOKART_OBJECTTYPE = DT.Rows(0).Item("OBJEKTTYP")
CURR_WORKFILE_EXTENSION = extension CURR_WORKFILE_EXTENSION = extension
oRAWZielordner = DT.Rows(0).Item("ZIEL_PFAD")
oRAWZielordner = WINDREAM.GetNormalizedPath(DT.Rows(0).Item("ZIEL_PFAD"))
oRAWZielordner = Path.Combine("\\windream\objects", oRAWZielordner)
'#### '####
' Regulären Ausdruck zum Auslesen der Indexe definieren ' Regulären Ausdruck zum Auslesen der Indexe definieren
@ -609,41 +611,41 @@ Public Class frmIndex
CURRENT_NEWFILENAME = oFilesystem.GetCleanFilename(NewFileString) CURRENT_NEWFILENAME = oFilesystem.GetCleanFilename(NewFileString)
'CURRENT_NEWFILENAME = ClassFilehandle.CleanFilename(NewFileString, "") 'CURRENT_NEWFILENAME = ClassFilehandle.CleanFilename(NewFileString, "")
CURRENT_NEWFILENAME = oRAWZielordner & "\" & CURRENT_NEWFILENAME CURRENT_NEWFILENAME = Path.Combine(oRAWZielordner, CURRENT_NEWFILENAME)
If CURRENT_NEWFILENAME.EndsWith("_") Then 'If CURRENT_NEWFILENAME.EndsWith("_") Then
CURRENT_NEWFILENAME = CURRENT_NEWFILENAME.Substring(0, CURRENT_NEWFILENAME.Length - 1) ' CURRENT_NEWFILENAME = CURRENT_NEWFILENAME.Substring(0, CURRENT_NEWFILENAME.Length - 1)
End If 'End If
If CURRENT_NEWFILENAME.StartsWith("_") Then 'If CURRENT_NEWFILENAME.StartsWith("_") Then
CURRENT_NEWFILENAME = CURRENT_NEWFILENAME.Substring(1) ' CURRENT_NEWFILENAME = CURRENT_NEWFILENAME.Substring(1)
End If 'End If
If CURRENT_NEWFILENAME.Contains("__") Then 'If CURRENT_NEWFILENAME.Contains("__") Then
CURRENT_NEWFILENAME = CURRENT_NEWFILENAME.Replace("__", "_") ' CURRENT_NEWFILENAME = CURRENT_NEWFILENAME.Replace("__", "_")
End If 'End If
'CURRENT_NEWFILENAME &= extension ''CURRENT_NEWFILENAME &= extension
Dim sollfilename = System.IO.Path.GetFileName(CURRENT_NEWFILENAME) 'Dim sollfilename = System.IO.Path.GetFileName(CURRENT_NEWFILENAME)
If sollfilename.StartsWith("_") Then 'If sollfilename.StartsWith("_") Then
sollfilename = sollfilename.Substring(1) ' sollfilename = sollfilename.Substring(1)
Dim _path = System.IO.Path.GetDirectoryName(CURRENT_NEWFILENAME) ' Dim _path = System.IO.Path.GetDirectoryName(CURRENT_NEWFILENAME)
CURRENT_NEWFILENAME = _path & "\" & sollfilename ' CURRENT_NEWFILENAME = _path & "\" & sollfilename
End If 'End If
Dim path = System.IO.Path.GetDirectoryName(CURRENT_NEWFILENAME) 'Dim path = System.IO.Path.GetDirectoryName(CURRENT_NEWFILENAME)
If folder_Created = False Then 'If folder_Created = False Then
' Den Zielordner erstellen ' ' Den Zielordner erstellen
If Directory.Exists(path) = False Then ' If Directory.Exists(path) = False Then
Try ' Try
'Try to create the directory. ' 'Try to create the directory.
Directory.CreateDirectory(path) ' Directory.CreateDirectory(path)
Catch ex As Exception ' Catch ex As Exception
LOGGER.Info("Unexpected Error in 'Name_Generieren' - Error: " & vbNewLine & ex.Message & vbNewLine & "Directory.CreateDirectory(" & path & ")") ' LOGGER.Info("Unexpected Error in 'Name_Generieren' - Error: " & vbNewLine & ex.Message & vbNewLine & "Directory.CreateDirectory(" & path & ")")
LOGGER.Error(ex.Message) ' LOGGER.Error(ex.Message)
err = True ' err = True
MsgBox("Unexpected Error in 'Name_Generieren' - Error: " & vbNewLine & ex.Message & vbNewLine & "Directory.CreateDirectory(" & path & ")", MsgBoxStyle.Critical) ' MsgBox("Unexpected Error in 'Name_Generieren' - Error: " & vbNewLine & ex.Message & vbNewLine & "Directory.CreateDirectory(" & path & ")", MsgBoxStyle.Critical)
End Try ' End Try
End If ' End If
folder_Created = True ' folder_Created = True
End If 'End If
'False oder True zurückgeben 'False oder True zurückgeben
LOGGER.Debug("#### ENDE Name_Generieren ####") LOGGER.Debug("#### ENDE Name_Generieren ####")
LOGGER.Debug("") LOGGER.Debug("")
@ -2241,32 +2243,30 @@ Public Class frmIndex
Dim sql As String = "SELECT FOLDER_FOR_INDEX FROM TBDD_DOKUMENTART WHERE GUID = " & CURRENT_DOKART_ID Dim sql As String = "SELECT FOLDER_FOR_INDEX FROM TBDD_DOKUMENTART WHERE GUID = " & CURRENT_DOKART_ID
Dim Folder_for_index = ClassDatabase.Execute_Scalar(sql, MyConnectionString, True) Dim Folder_for_index = ClassDatabase.Execute_Scalar(sql, MyConnectionString, True)
If Not IsDBNull(Folder_for_index) Then If Not IsDBNull(Folder_for_index) Then
If Folder_for_index <> String.Empty Then CreateFolderForIndex(Folder_for_index)
CreateFolderForIndex(Folder_for_index)
End If
End If End If
If CURR_DOKART_WD_DIRECT = False Then If CURR_DOKART_WD_DIRECT = False Then
'Datei verschieben 'Datei verschieben
err = Move_Rename_Only(CURRENT_WORKFILE, CURRENT_NEWFILENAME, CURR_WORKFILE_EXTENSION, VERSION_DELIMITER) err = Move_Rename_Only(CURRENT_WORKFILE, CURRENT_NEWFILENAME, CURR_WORKFILE_EXTENSION, VERSION_DELIMITER)
Else Else
If CURRENT_NEWFILENAME.Contains("//") Then 'If CURRENT_NEWFILENAME.Contains("//") Then
CURRENT_NEWFILENAME = CURRENT_NEWFILENAME.Replace("//", "/") ' CURRENT_NEWFILENAME = CURRENT_NEWFILENAME.Replace("//", "/")
End If 'End If
If CURRENT_NEWFILENAME.Contains("\\") Then 'If CURRENT_NEWFILENAME.Contains("\\") Then
CURRENT_NEWFILENAME = CURRENT_NEWFILENAME.Replace("\\", "\") ' CURRENT_NEWFILENAME = CURRENT_NEWFILENAME.Replace("\\", "\")
End If 'End If
Dim exp2WD As Boolean = False Dim oExportSuccessful As Boolean = False
'Variable Folder 'Variable Folder
If DropType = "|DROPFROMFSYSTEM|" Or DropType = "|OUTLOOK_ATTACHMENT|" Or DropType = "|ATTMNTEXTRACTED|" Or DropType = "|FW_SIMPLEINDEXER|" Then If DropType = "|DROPFROMFSYSTEM|" Or DropType = "|OUTLOOK_ATTACHMENT|" Or DropType = "|ATTMNTEXTRACTED|" Or DropType = "|FW_SIMPLEINDEXER|" Then
exp2WD = SINGLEFILE_2_WINDREAM(CURR_DOKART_OBJECTTYPE) oExportSuccessful = SINGLEFILE_2_WINDREAM(CURR_DOKART_OBJECTTYPE)
ElseIf DropType = "|OUTLOOK_MESSAGE|" Or DropType = "|FW_MSGONLY|" Or DropType = "|MSGONLY|" Then ElseIf DropType = "|OUTLOOK_MESSAGE|" Or DropType = "|FW_MSGONLY|" Or DropType = "|MSGONLY|" Then
exp2WD = SINGLEFILE_2_WINDREAM(CURR_DOKART_OBJECTTYPE) oExportSuccessful = SINGLEFILE_2_WINDREAM(CURR_DOKART_OBJECTTYPE)
End If End If
If exp2WD = True Then If oExportSuccessful = True Then
'Kein Fehler in Export2windream 'Kein Fehler in Export2windream
err = False err = False
If Write_Indizes() = True Then If Write_Indizes() = True Then
@ -2339,99 +2339,105 @@ Public Class frmIndex
Dim oRootFolder As String = Path.GetDirectoryName(CURRENT_NEWFILENAME) Dim oRootFolder As String = Path.GetDirectoryName(CURRENT_NEWFILENAME)
Dim oFilesystem As New DigitalData.Modules.Filesystem.File(LOGCONFIG) Dim oFilesystem As New DigitalData.Modules.Filesystem.File(LOGCONFIG)
'######
Dim oRegexString As String = "\[%{1}[a-zA-Z0-9\!\$\&\/\(\)\=\?\,\.\-\;\:_öÖüÜäÄ\#\'\+\*\~\{\}\@\€\<\>\ ]+]{1}" If DynamicFolderConfig <> String.Empty Then
' einen Regulären Ausdruck laden '######
Dim oRegex As Regex = New Regex(oRegexString) Dim oRegexString As String = "\[%{1}[a-zA-Z0-9\!\$\&\/\(\)\=\?\,\.\-\;\:_öÖüÜäÄ\#\'\+\*\~\{\}\@\€\<\>\ ]+]{1}"
' die Vorkommen im Folder-String auslesen ' einen Regulären Ausdruck laden
Dim oMatches As MatchCollection = oRegex.Matches(DynamicFolderConfig) Dim oRegex As Regex = New Regex(oRegexString)
'#### ' die Vorkommen im Folder-String auslesen
' alle Vorkommen innerhalb des Ordnerstrings durchlaufen Dim oMatches As MatchCollection = oRegex.Matches(DynamicFolderConfig)
For Each oMatch As Match In oMatches '####
LOGGER.Info("Elementname in FolderString: '" & oMatch.ToString & "'")
Select Case oMatch.Value.Substring(2, 1).ToUpper ' alle Vorkommen innerhalb des Ordnerstrings durchlaufen
For Each oMatch As Match In oMatches
LOGGER.Info("Elementname in FolderString: '" & oMatch.ToString & "'")
Select Case oMatch.Value.Substring(2, 1).ToUpper
'Manueller Indexwert 'Manueller Indexwert
Case "M" Case "M"
Dim oManIndexName = oMatch.Value.Substring(3, oMatch.Value.Length - 4) Dim oManIndexName = oMatch.Value.Substring(3, oMatch.Value.Length - 4)
Dim oIsOptional As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & CURRENT_DOKART_ID & " AND UPPER(NAME) = UPPER('" & oManIndexName & "')", MyConnectionString, True) Dim oIsOptional As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & CURRENT_DOKART_ID & " AND UPPER(NAME) = UPPER('" & oManIndexName & "')", MyConnectionString, True)
LOGGER.Info("Versuch den Indexwert aus '" & oManIndexName & "' auszulesen.") LOGGER.Info("Versuch den Indexwert aus '" & oManIndexName & "' auszulesen.")
Dim oManIndexValue As String = GetManIndex_Value(oManIndexName, "FILE", oIsOptional) Dim oManIndexValue As String = GetManIndex_Value(oManIndexName, "FILE", oIsOptional)
LOGGER.Info("Ergebnis/Wert für neuen Ordner: '" & oManIndexName & "'") LOGGER.Info("Ergebnis/Wert für neuen Ordner: '" & oManIndexName & "'")
If Not oManIndexValue = String.Empty Then If Not oManIndexValue = String.Empty Then
If IsDate(oManIndexValue) Then If IsDate(oManIndexValue) Then
oManIndexValue = CDate(oManIndexValue).ToString("yyyyMMdd") oManIndexValue = CDate(oManIndexValue).ToString("yyyyMMdd")
End If
oManIndexValue = oFilesystem.GetCleanPath(oManIndexValue)
'oManIndexValue = ClassFilehandle.CleanFilename(oManIndexValue, "")
DynamicFolderConfig = DynamicFolderConfig.Replace(oMatch.ToString, oManIndexValue)
LOGGER.Info("FolderPattern: '" & DynamicFolderConfig & "'")
Else
If oIsOptional = True Then
LOGGER.Info("Optionaler Indexwert ist NICHT gefüllt")
Else
LOGGER.Info(" - Achtung Ausnahme in 'CrFolderForIndex': der Index ist leer!")
Return True
End If
End If End If
Case "A"
Dim oAutoIndexName = oMatch.Value.Substring(3, oMatch.Value.Length - 4)
LOGGER.Info("Versuch den Auto-Indexwert aus '" & oAutoIndexName & "' auszulesen.")
Dim oAutoIndexValue As String = GetAutoIndex_Value(oAutoIndexName)
LOGGER.Info("Ergebnis/Wert für neuen Ordner: '" & oAutoIndexName & "'")
If Not oAutoIndexValue = String.Empty Then
oManIndexValue = oFilesystem.GetCleanPath(oManIndexValue) oAutoIndexValue = oFilesystem.GetCleanPath(oAutoIndexValue)
'oManIndexValue = ClassFilehandle.CleanFilename(oManIndexValue, "") 'oAutoIndexValue = ClassFilehandle.CleanFilename(oAutoIndexValue, "")
DynamicFolderConfig = DynamicFolderConfig.Replace(oMatch.ToString, oManIndexValue) If oAutoIndexValue = "EMPTY_OI" Then
DynamicFolderConfig = DynamicFolderConfig.Replace(oMatch.ToString, "")
Else
DynamicFolderConfig = DynamicFolderConfig.Replace(oMatch.ToString, oAutoIndexValue)
LOGGER.Info("FolderPattern: '" & DynamicFolderConfig & "'")
End If
LOGGER.Info("FolderPattern: '" & DynamicFolderConfig & "'")
Else
If oIsOptional = True Then
LOGGER.Info("Optionaler Indexwert ist NICHT gefüllt")
Else Else
LOGGER.Info(" - Achtung Ausnahme in 'CrFolderForIndex': der Index ist leer!") LOGGER.Info(" - Achtung Ausnahme in 'CrFolderForIndex': der Index ist leer!")
Return True
End If End If
End If Case "V"
Case "A" Dim oElementTemp As String
Dim oAutoIndexName = oMatch.Value.Substring(3, oMatch.Value.Length - 4) Dim _Month As String = My.Computer.Clock.LocalTime.Month
LOGGER.Info("Versuch den Auto-Indexwert aus '" & oAutoIndexName & "' auszulesen.") If _Month.Length = 1 Then
Dim oAutoIndexValue As String = GetAutoIndex_Value(oAutoIndexName) _Month = "0" & _Month
LOGGER.Info("Ergebnis/Wert für neuen Ordner: '" & oAutoIndexName & "'") End If
If Not oAutoIndexValue = String.Empty Then Dim _day As String = My.Computer.Clock.LocalTime.Day
If _day.Length = 1 Then
_day = "0" & _day
End If
Dim type = oMatch.Value.Substring(3, oMatch.Value.Length - 4)
If type.StartsWith("_") Then
type = type.Replace("_", "")
End If
Select Case type
Case "YYYY/MM/DD"
oElementTemp = My.Computer.Clock.LocalTime.Year & "\" & _Month & "\" & _day
Case "YYYY/MM"
oElementTemp = My.Computer.Clock.LocalTime.Year & "\" & _Month
Case "YYYY"
oElementTemp = My.Computer.Clock.LocalTime.Year
Case "YYYY-MM"
oElementTemp = My.Computer.Clock.LocalTime.Year & "-" & _Month
End Select
DynamicFolderConfig = DynamicFolderConfig.Replace(oMatch.ToString, oElementTemp)
LOGGER.Info("FolderPatter nach V-Element: '" & DynamicFolderConfig & "'")
Case Else
LOGGER.Info(" - Achtung - in der Namenkonvention wurde ein Element gefunden welches nicht zugeordnet werden kann!" & vbNewLine & "Elementname: " & oMatch.Value.ToUpper)
oAutoIndexValue = oFilesystem.GetCleanPath(oAutoIndexValue) If USER_LANGUAGE = "de-DE" Then
'oAutoIndexValue = ClassFilehandle.CleanFilename(oAutoIndexValue, "") MsgBox("Achtung - in der Namenkonvention wurde ein Element gefunden welches nicht zugeordnet werden kann!" & vbNewLine & "Elementname: " & oMatch.Value.ToUpper, MsgBoxStyle.Exclamation, "Unexpected error in Name generieren:")
If oAutoIndexValue = "EMPTY_OI" Then
DynamicFolderConfig = DynamicFolderConfig.Replace(oMatch.ToString, "")
Else Else
DynamicFolderConfig = DynamicFolderConfig.Replace(oMatch.ToString, oAutoIndexValue) MsgBox("Attention - One element in Namingconvention could not be matched!" & vbNewLine & "Elementname: " & oMatch.Value.ToUpper, MsgBoxStyle.Exclamation, "Unexpected error in Name generieren:")
LOGGER.Info("FolderPattern: '" & DynamicFolderConfig & "'")
End If End If
End Select
Next
End If
Else
LOGGER.Info(" - Achtung Ausnahme in 'CrFolderForIndex': der Index ist leer!")
End If
Case "V"
Dim oElementTemp As String
Dim _Month As String = My.Computer.Clock.LocalTime.Month
If _Month.Length = 1 Then
_Month = "0" & _Month
End If
Dim _day As String = My.Computer.Clock.LocalTime.Day
If _day.Length = 1 Then
_day = "0" & _day
End If
Dim type = oMatch.Value.Substring(3, oMatch.Value.Length - 4)
If type.StartsWith("_") Then
type = type.Replace("_", "")
End If
Select Case type
Case "YYYY/MM/DD"
oElementTemp = My.Computer.Clock.LocalTime.Year & "\" & _Month & "\" & _day
Case "YYYY/MM"
oElementTemp = My.Computer.Clock.LocalTime.Year & "\" & _Month
Case "YYYY"
oElementTemp = My.Computer.Clock.LocalTime.Year
Case "YYYY-MM"
oElementTemp = My.Computer.Clock.LocalTime.Year & "-" & _Month
End Select
DynamicFolderConfig = DynamicFolderConfig.Replace(oMatch.ToString, oElementTemp)
LOGGER.Info("FolderPatter nach V-Element: '" & DynamicFolderConfig & "'")
Case Else
LOGGER.Info(" - Achtung - in der Namenkonvention wurde ein Element gefunden welches nicht zugeordnet werden kann!" & vbNewLine & "Elementname: " & oMatch.Value.ToUpper)
If USER_LANGUAGE = "de-DE" Then
MsgBox("Achtung - in der Namenkonvention wurde ein Element gefunden welches nicht zugeordnet werden kann!" & vbNewLine & "Elementname: " & oMatch.Value.ToUpper, MsgBoxStyle.Exclamation, "Unexpected error in Name generieren:")
Else
MsgBox("Attention - One element in Namingconvention could not be matched!" & vbNewLine & "Elementname: " & oMatch.Value.ToUpper, MsgBoxStyle.Exclamation, "Unexpected error in Name generieren:")
End If
End Select
Next
LOGGER.Info("Den Root-Folder zusammenfügen>> ") LOGGER.Info("Den Root-Folder zusammenfügen>> ")
@ -2451,7 +2457,8 @@ Public Class frmIndex
LOGGER.Info("Fullpath (ohne SZ) '" & oNewFullpath & "'") LOGGER.Info("Fullpath (ohne SZ) '" & oNewFullpath & "'")
If Directory.Exists(oNewFullpath) = False Then If Directory.Exists(oNewFullpath) = False Then
Try Try
Directory.CreateDirectory(oNewFullpath) Dim oCreatedPath = Directory.CreateDirectory(oNewFullPath)
oNewFullPath = oCreatedPath.FullName
LOGGER.Info("Folder '" & oNewFullpath & "' wurde angelegt") LOGGER.Info("Folder '" & oNewFullpath & "' wurde angelegt")
Catch ex As Exception Catch ex As Exception
LOGGER.Info("Error in CreateFolderforIndex-Method - Root Folder '" & oNewFullpath & "' could not be created. " & ex.Message) LOGGER.Info("Error in CreateFolderforIndex-Method - Root Folder '" & oNewFullpath & "' could not be created. " & ex.Message)