MS
This commit is contained in:
@@ -1107,7 +1107,7 @@ Public Class frmIndex
|
||||
|
||||
Dim err As Boolean = False
|
||||
Dim folder_Created As Boolean = False
|
||||
Dim Zielordner As String
|
||||
Dim oRAWZielordner As String
|
||||
Dim extension As String = System.IO.Path.GetExtension(CURRENT_WORKFILE)
|
||||
Dim DT As DataTable = ClassDatabase.Return_Datatable("SELECT * FROM TBDD_DOKUMENTART WHERE GUID = " & CURRENT_DOKART_ID)
|
||||
sql_history_INSERT_INTO = "INSERT INTO TBGI_HISTORY (FILENAME_ORIGINAL,FILENAME_NEW"
|
||||
@@ -1116,36 +1116,36 @@ Public Class frmIndex
|
||||
CURR_DOKART_WD_DIRECT = DT.Rows(0).Item("WINDREAM_DIRECT")
|
||||
CURR_DOKART_OBJECTTYPE = DT.Rows(0).Item("OBJEKTTYP")
|
||||
CURR_WORKFILE_EXTENSION = extension
|
||||
Zielordner = DT.Rows(0).Item("ZIEL_PFAD")
|
||||
oRAWZielordner = DT.Rows(0).Item("ZIEL_PFAD")
|
||||
|
||||
'####
|
||||
' Regulären Ausdruck zum Auslesen der Indexe definieren
|
||||
Dim preg As String = "\[%{1}[a-zA-Z0-9ß\!\$\&\/\(\)\=\?\,\.\-\;\:_öÖüÜäÄ\#\'\+\*\~\{\}\@\€\<\>\ ]+]{1}"
|
||||
'schonmal den gesamten Pfad laden
|
||||
Dim DATEINAME As String = Zielordner & "\" & DT.Rows(0).Item("NAMENKONVENTION")
|
||||
NewFileString = DATEINAME
|
||||
Dim oNamenkonvention As String = DT.Rows(0).Item("NAMENKONVENTION") & CURR_WORKFILE_EXTENSION 'oRAWZielordner & "\" & DT.Rows(0).Item("NAMENKONVENTION")
|
||||
NewFileString = oNamenkonvention
|
||||
' einen Regulären Ausdruck laden
|
||||
Dim regulärerAusdruck As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(preg)
|
||||
' die Vorkommen im SQL-String auslesen
|
||||
Dim elemente As System.Text.RegularExpressions.MatchCollection = regulärerAusdruck.Matches(DATEINAME)
|
||||
Dim oMatchelements As System.Text.RegularExpressions.MatchCollection = regulärerAusdruck.Matches(oNamenkonvention)
|
||||
'####
|
||||
If elemente.Count = 0 Then
|
||||
If oMatchelements.Count = 0 Then
|
||||
ClassLogger.Add(" >> No RegularExpression Fileds on Nameconvention!", False)
|
||||
End If
|
||||
' alle Vorkommen innerhalbd er Namenkonvention durchlaufen
|
||||
For Each element As System.Text.RegularExpressions.Match In elemente
|
||||
Select Case element.Value.Substring(2, 1).ToUpper
|
||||
For Each oElement As System.Text.RegularExpressions.Match In oMatchelements
|
||||
Select Case oElement.Value.Substring(2, 1).ToUpper
|
||||
'Manueller Indexwert
|
||||
Case "M"
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >>Manueller Index wird geprüft...", False)
|
||||
Dim Indexname = element.Value.Substring(3, element.Value.Length - 4)
|
||||
Dim Indexname = oElement.Value.Substring(3, oElement.Value.Length - 4)
|
||||
Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & CURRENT_DOKART_ID & " AND UPPER(NAME) = UPPER('" & Indexname & "')", MyConnectionString, True)
|
||||
Dim value As String = GetManIndex_Value(Indexname, "FILE", optional_index)
|
||||
If value <> String.Empty Then
|
||||
Dim firstVectorValue = value.Split(ClassConstants.VECTORSEPARATOR).First()
|
||||
|
||||
DATEINAME = DATEINAME.Replace(element.Value, firstVectorValue)
|
||||
NewFileString = DATEINAME
|
||||
oNamenkonvention = oNamenkonvention.Replace(oElement.Value, firstVectorValue)
|
||||
NewFileString = oNamenkonvention
|
||||
sql_history_INSERT_INTO = sql_history_INSERT_INTO & ", INDEX" & AnzahlIndexe.ToString
|
||||
AnzahlIndexe += 1
|
||||
sql_history_Index_Values = sql_history_Index_Values & ", '" & value.Replace("'", "''") & "'"
|
||||
@@ -1154,25 +1154,26 @@ Public Class frmIndex
|
||||
If optional_index = True Then
|
||||
Dim result As MsgBoxResult
|
||||
|
||||
If USER_LANGUAGE = "de-DE" Then
|
||||
result = MessageBox.Show("Achtung der optionale Index ist leer, wird aber für die Benennung der Datei benutzt." & vbNewLine & "Wollen Sie stattdessen den Originaldateinamen verwenden?", "Bestätigung erforderlich:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
||||
Else
|
||||
result = MessageBox.Show("Attention: optional index is empty, but is being used in renaming the file." & vbNewLine & "Do you want to use the original filename instead?", "Confirmation needed:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
||||
End If
|
||||
'If USER_LANGUAGE = "de-DE" Then
|
||||
' result = MessageBox.Show("Achtung der optionale Index ist leer, wird aber für die Benennung der Datei benutzt." & vbNewLine & "Wollen Sie stattdessen den Originaldateinamen verwenden?", "Bestätigung erforderlich:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
||||
'Else
|
||||
' result = MessageBox.Show("Attention: optional index is empty, but is being used in renaming the file." & vbNewLine & "Do you want to use the original filename instead?", "Confirmation needed:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
||||
'End If
|
||||
|
||||
If result = MsgBoxResult.Yes Then
|
||||
DATEINAME = DATEINAME.Replace(element.Value, System.IO.Path.GetFileNameWithoutExtension(CURRENT_WORKFILE))
|
||||
NewFileString = DATEINAME
|
||||
sql_history_INSERT_INTO = sql_history_INSERT_INTO & ", INDEX" & AnzahlIndexe.ToString
|
||||
AnzahlIndexe += 1
|
||||
sql_history_Index_Values = sql_history_Index_Values & ", '" & System.IO.Path.GetFileNameWithoutExtension(CURRENT_WORKFILE).Replace("'", "''") & "'"
|
||||
Else
|
||||
DATEINAME = DATEINAME.Replace(element.Value, value)
|
||||
NewFileString = DATEINAME
|
||||
sql_history_INSERT_INTO = sql_history_INSERT_INTO & ", INDEX" & AnzahlIndexe.ToString
|
||||
AnzahlIndexe += 1
|
||||
sql_history_Index_Values = sql_history_Index_Values & ", '" & value.Replace("'", "''") & "'"
|
||||
End If
|
||||
'If result = MsgBoxResult.Yes Then
|
||||
' oNamenkonvention = oNamenkonvention.Replace(oElement.Value, System.IO.Path.GetFileNameWithoutExtension(CURRENT_WORKFILE))
|
||||
' NewFileString = oNamenkonvention
|
||||
' sql_history_INSERT_INTO = sql_history_INSERT_INTO & ", INDEX" & AnzahlIndexe.ToString
|
||||
' AnzahlIndexe += 1
|
||||
' sql_history_Index_Values = sql_history_Index_Values & ", '" & System.IO.Path.GetFileNameWithoutExtension(CURRENT_WORKFILE).Replace("'", "''") & "'"
|
||||
'Else
|
||||
oNamenkonvention = oNamenkonvention.Replace("_" & oElement.Value, value)
|
||||
oNamenkonvention = oNamenkonvention.Replace("-" & oElement.Value, value)
|
||||
NewFileString = oNamenkonvention
|
||||
sql_history_INSERT_INTO = sql_history_INSERT_INTO & ", INDEX" & AnzahlIndexe.ToString
|
||||
AnzahlIndexe += 1
|
||||
sql_history_Index_Values = sql_history_Index_Values & ", '" & value.Replace("'", "''") & "'"
|
||||
' End If
|
||||
|
||||
Else
|
||||
ClassLogger.Add(" >> Der Indexvalue für Index '" & Indexname & "' ist String.Empty", False)
|
||||
@@ -1181,14 +1182,14 @@ Public Class frmIndex
|
||||
|
||||
End If
|
||||
Case "A"
|
||||
Dim value As String = GetAutoIndex_Value(element.Value.Substring(3, element.Value.Length - 4))
|
||||
Dim value As String = GetAutoIndex_Value(oElement.Value.Substring(3, oElement.Value.Length - 4))
|
||||
If value <> String.Empty Then
|
||||
If value = "EMPTY_OI" Then
|
||||
DATEINAME = DATEINAME.Replace(element.Value, "")
|
||||
NewFileString = DATEINAME
|
||||
oNamenkonvention = oNamenkonvention.Replace(oElement.Value, "")
|
||||
NewFileString = oNamenkonvention
|
||||
Else
|
||||
DATEINAME = DATEINAME.Replace(element.Value, value)
|
||||
NewFileString = DATEINAME
|
||||
oNamenkonvention = oNamenkonvention.Replace(oElement.Value, value)
|
||||
NewFileString = oNamenkonvention
|
||||
sql_history_INSERT_INTO = sql_history_INSERT_INTO & ", INDEX" & AnzahlIndexe.ToString
|
||||
AnzahlIndexe += 1
|
||||
sql_history_Index_Values = sql_history_Index_Values & ", '" & value.Replace("'", "''") & "'"
|
||||
@@ -1206,7 +1207,7 @@ Public Class frmIndex
|
||||
If _day.Length = 1 Then
|
||||
_day = "0" & _day
|
||||
End If
|
||||
Dim type = element.Value '.ToUpper.Replace("[v%", "")
|
||||
Dim type = oElement.Value '.ToUpper.Replace("[v%", "")
|
||||
type = type.Replace("[%v_", "")
|
||||
type = type.Replace("[%v", "")
|
||||
type = type.Replace("]", "")
|
||||
@@ -1228,32 +1229,32 @@ Public Class frmIndex
|
||||
Case "DDMMYYYY"
|
||||
datetemp = _day & _Month & My.Computer.Clock.LocalTime.Year
|
||||
Case "OFilename"
|
||||
DATEINAME = DATEINAME.Replace(element.Value, System.IO.Path.GetFileNameWithoutExtension(CURRENT_WORKFILE))
|
||||
oNamenkonvention = oNamenkonvention.Replace(oElement.Value, System.IO.Path.GetFileNameWithoutExtension(CURRENT_WORKFILE))
|
||||
Case "Username".ToUpper
|
||||
DATEINAME = DATEINAME.Replace(element.Value, Environment.UserName)
|
||||
oNamenkonvention = oNamenkonvention.Replace(oElement.Value, Environment.UserName)
|
||||
Case "Usercode".ToUpper
|
||||
DATEINAME = DATEINAME.Replace(element.Value, USER_SHORT_NAME)
|
||||
oNamenkonvention = oNamenkonvention.Replace(oElement.Value, USER_SHORT_NAME)
|
||||
Case ""
|
||||
End Select
|
||||
If datetemp <> "" Then
|
||||
DATEINAME = DATEINAME.Replace(element.Value, datetemp)
|
||||
oNamenkonvention = oNamenkonvention.Replace(oElement.Value, datetemp)
|
||||
End If
|
||||
NewFileString = DATEINAME
|
||||
NewFileString = oNamenkonvention
|
||||
Case "[%Version]".ToUpper
|
||||
Try
|
||||
Dim version As Integer = 1
|
||||
Dim Stammname As String = DATEINAME.Replace(element.Value, "")
|
||||
Dim _neuername As String = DATEINAME.Replace(element.Value, "")
|
||||
Dim Stammname As String = oRAWZielordner & "\" & oNamenkonvention.Replace(oElement.Value, "")
|
||||
Dim _neuername As String = oRAWZielordner & "\" & oNamenkonvention.Replace(oElement.Value, "")
|
||||
Stammname = _neuername.Replace(VERSION_DELIMITER, "")
|
||||
_neuername = _neuername.Replace(VERSION_DELIMITER, "")
|
||||
'Dim MoveFilename As String = DATEINAME.Replace(element.Value, "")
|
||||
'Überprüfen ob File existiert
|
||||
If File.Exists(_neuername & extension) = False Then
|
||||
If File.Exists(_neuername) = False Then
|
||||
NewFileString = _neuername
|
||||
Else
|
||||
Do While File.Exists(_neuername & extension)
|
||||
Do While File.Exists(_neuername)
|
||||
version = version + 1
|
||||
_neuername = Stammname & VERSION_DELIMITER & version
|
||||
_neuername = Stammname.Replace(extension, "") & VERSION_DELIMITER & version & extension
|
||||
NewFileString = _neuername
|
||||
Loop
|
||||
End If
|
||||
@@ -1263,11 +1264,14 @@ Public Class frmIndex
|
||||
err = True
|
||||
End Try
|
||||
Case Else
|
||||
ClassLogger.Add(" - Achtung - in der Namenkonvention wurde ein Element gefunden welches nicht zugeordnet werden kann!" & vbNewLine & "Elementname: " & element.Value.ToUpper)
|
||||
MsgBox("Achtung - in der Namenkonvention wurde ein Element gefunden welches nicht zugeordnet werden kann!" & vbNewLine & "Elementname: " & element.Value.ToUpper, MsgBoxStyle.Exclamation, "Unexpected error in Name generieren:")
|
||||
ClassLogger.Add(" - Achtung - in der Namenkonvention wurde ein Element gefunden welches nicht zugeordnet werden kann!" & vbNewLine & "Elementname: " & oElement.Value.ToUpper)
|
||||
MsgBox("Achtung - in der Namenkonvention wurde ein Element gefunden welches nicht zugeordnet werden kann!" & vbNewLine & "Elementname: " & oElement.Value.ToUpper, MsgBoxStyle.Exclamation, "Unexpected error in Name generieren:")
|
||||
End Select
|
||||
Next
|
||||
|
||||
|
||||
CURRENT_NEWFILENAME = ClassFilehandle.CleanFilename(NewFileString, "")
|
||||
CURRENT_NEWFILENAME = oRAWZielordner & "\" & CURRENT_NEWFILENAME
|
||||
|
||||
If CURRENT_NEWFILENAME.EndsWith("_") Then
|
||||
CURRENT_NEWFILENAME = CURRENT_NEWFILENAME.Substring(0, CURRENT_NEWFILENAME.Length - 1)
|
||||
@@ -1278,7 +1282,7 @@ Public Class frmIndex
|
||||
If CURRENT_NEWFILENAME.Contains("__") Then
|
||||
CURRENT_NEWFILENAME = CURRENT_NEWFILENAME.Replace("__", "_")
|
||||
End If
|
||||
CURRENT_NEWFILENAME &= extension
|
||||
'CURRENT_NEWFILENAME &= extension
|
||||
Dim sollfilename = System.IO.Path.GetFileName(CURRENT_NEWFILENAME)
|
||||
If sollfilename.StartsWith("_") Then
|
||||
sollfilename = sollfilename.Substring(1)
|
||||
@@ -1840,17 +1844,17 @@ Public Class frmIndex
|
||||
End Function
|
||||
Function Move_Rename_Only(Quelle As String, _NewFilename As String, extension As String, _versionTz As String)
|
||||
'Überprüfen ob File existiert
|
||||
If File.Exists(_NewFilename & extension) = False Then
|
||||
CURRENT_NEWFILENAME = _NewFilename & extension
|
||||
If File.Exists(_NewFilename) = False Then
|
||||
CURRENT_NEWFILENAME = _NewFilename
|
||||
Else
|
||||
'Versionieren
|
||||
Dim version As Integer = 1
|
||||
Dim Stammname As String = _NewFilename
|
||||
Dim neuername As String = _NewFilename
|
||||
Do While File.Exists(neuername & extension)
|
||||
Do While File.Exists(neuername)
|
||||
version = version + 1
|
||||
neuername = Stammname & _versionTz & version
|
||||
CURRENT_NEWFILENAME = neuername & extension
|
||||
neuername = Stammname.Replace(extension, "") & _versionTz & version & extension
|
||||
CURRENT_NEWFILENAME = neuername
|
||||
Loop
|
||||
End If
|
||||
'Die Datei wird nun verschoben
|
||||
@@ -1861,7 +1865,7 @@ Public Class frmIndex
|
||||
Dim tempCur_WF = CURRENT_WORKFILE.Replace("'", "''")
|
||||
Dim tempCur_New_FN = CURRENT_NEWFILENAME.Replace("'", "''")
|
||||
Insert_String = sql_history_INSERT_INTO & ",ADDED_WHO,ADDED_WHERE) VALUES ('" & tempCur_WF & "','" & tempCur_New_FN & "'" & sql_history_Index_Values & ",'" & Environment.UserDomainName & "\" & Environment.UserName & "','" & Environment.MachineName & "')"
|
||||
If ClassDatabase.Execute_Scalar(Insert_String, MyConnectionString) = True Then
|
||||
If ClassDatabase.Execute_non_Query(Insert_String) = True Then
|
||||
If CURRENT_MESSAGEID <> "" Then
|
||||
Dim max As String = "SELECT MAX(GUID) FROM TBGI_HISTORY"
|
||||
Dim GUID = ClassDatabase.Execute_Scalar(max, MyConnectionString, True)
|
||||
@@ -1946,6 +1950,7 @@ Public Class frmIndex
|
||||
CURRENT_ISATTACHMENT = False
|
||||
DropType = ClassDatabase.Execute_Scalar("SELECT HANDLE_TYPE FROM TBGI_FILES_USER WHERE GUID = " & CURRENT_WORKFILE_GUID, MyConnectionString, True)
|
||||
chkdelete_origin.Visible = False
|
||||
'DocumentViewer1.Init(LOGCONFIG, "21182889975216572111813147150675976632")
|
||||
CURRENT_DROPTYPE = DropType.Replace("|", "")
|
||||
If DropType = "|DROPFROMFSYSTEM|" Then
|
||||
chkdelete_origin.Visible = True
|
||||
@@ -2054,12 +2059,32 @@ Public Class frmIndex
|
||||
Me.Cursor = Cursors.Default
|
||||
Refresh_Dokart()
|
||||
Me.pnlIndex.Controls.Clear()
|
||||
chkdelete_origin.Checked = CONFIG.Config.DeleteOriginalFile
|
||||
CURR_DELETE_ORIGIN = chkdelete_origin.Checked
|
||||
|
||||
formloaded = True
|
||||
If My.Settings.DA_Vorauswahlaktiv = True Then
|
||||
If CURRENT_LASTDOKART <> "" Then
|
||||
cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(CURRENT_LASTDOKART)
|
||||
End If
|
||||
End If
|
||||
Try
|
||||
If DTTBGI_REGEX_DOCTYPE.Rows.Count > 0 Then
|
||||
For Each oRoW As DataRow In DTTBGI_REGEX_DOCTYPE.Rows
|
||||
Dim oOnlyFilename = Path.GetFileName(CURRENT_WORKFILE)
|
||||
If Regex.IsMatch(oOnlyFilename, oRoW.Item("Regex")) Then
|
||||
ClassLogger.Add($"There is a match on REGEX_DOCTYPE: {oRoW.Item("DOCTYPE")}")
|
||||
cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(oRoW.Item("DOCTYPE"))
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add(" - Unexpected error DTTBGI_REGEX_DOCTYPE - ErrorMessage: " & vbNewLine & ex.Message)
|
||||
End Try
|
||||
Me.TopMost = True
|
||||
Me.BringToFront()
|
||||
|
||||
End Sub
|
||||
Sub Refresh_Dokart()
|
||||
Try
|
||||
@@ -2559,11 +2584,14 @@ Public Class frmIndex
|
||||
Me.pnlPDF.Visible = False
|
||||
CURRENT_HTML_DOC = ""
|
||||
Dim workfile As String = CURRENT_WORKFILE.ToLower
|
||||
'DocumentViewer1.LoadFile(CURRENT_WORKFILE)
|
||||
|
||||
If Not workfile.EndsWith("msg") Then
|
||||
CURRENT_HTML_DOC = ""
|
||||
If workfile.EndsWith("pdf") Then
|
||||
Me.SplitContainer1.Panel2Collapsed = False
|
||||
PdfViewer1.LoadDocument(CURRENT_WORKFILE)
|
||||
PdfViewer1.ZoomMode = DevExpress.XtraPdfViewer.PdfZoomMode.FitToWidth
|
||||
pnlPDF.Dock = DockStyle.Fill
|
||||
SplitContainer1.SplitterDistance = My.Settings.SplitterDistance_Viewer
|
||||
Me.pnlPDF.Visible = True
|
||||
@@ -2771,8 +2799,8 @@ Public Class frmIndex
|
||||
|
||||
CURRENT_LASTDOKART = cmbDokumentart.Text
|
||||
ClassLogger.Add(" >> Datei '" & CURRENT_NEWFILENAME & "' erfolgreich erzeugt.", False)
|
||||
Dim upd As String = "UPDATE TBGI_FILES_USER SET WORKED = 1 WHERE GUID = " & CURRENT_WORKFILE_GUID
|
||||
ClassDatabase.Execute_non_Query(upd, True)
|
||||
Dim oDEL As String = "DELETE FROM TBGI_FILES_USER WHERE GUID = " & CURRENT_WORKFILE_GUID
|
||||
ClassDatabase.Execute_non_Query(oDEL, True)
|
||||
Return True
|
||||
End If
|
||||
|
||||
@@ -2888,9 +2916,17 @@ Public Class frmIndex
|
||||
Private Function Move_File2_Target()
|
||||
Dim err As Boolean = False
|
||||
Try
|
||||
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)
|
||||
If Not IsDBNull(Folder_for_index) Then
|
||||
If Folder_for_index <> String.Empty Then
|
||||
CreateFolderForIndex(Folder_for_index)
|
||||
End If
|
||||
End If
|
||||
|
||||
If CBool(CURR_DOKART_WD_DIRECT) = False Then
|
||||
'Datei verschieben
|
||||
err = Move_Rename_Only(CURRENT_WORKFILE, NewFileString, CURR_WORKFILE_EXTENSION, VERSION_DELIMITER)
|
||||
err = Move_Rename_Only(CURRENT_WORKFILE, CURRENT_NEWFILENAME, CURR_WORKFILE_EXTENSION, VERSION_DELIMITER)
|
||||
Else
|
||||
If CURRENT_NEWFILENAME.Contains("//") Then
|
||||
CURRENT_NEWFILENAME = CURRENT_NEWFILENAME.Replace("//", "/")
|
||||
@@ -2900,13 +2936,8 @@ Public Class frmIndex
|
||||
End If
|
||||
Dim exp2WD As Boolean = False
|
||||
'Variable Folder
|
||||
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)
|
||||
If Not IsDBNull(Folder_for_index) Then
|
||||
If Folder_for_index <> String.Empty Then
|
||||
CreateFolderForIndex(Folder_for_index)
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
|
||||
If DropType = "|DROPFROMFSYSTEM|" Or DropType = "|OUTLOOK_ATTACHMENT|" Or DropType = "|ATTMNTEXTRACTED|" Or DropType = "|FW_SIMPLEINDEXER|" Then
|
||||
exp2WD = SINGLEFILE_2_WINDREAM(CURR_DOKART_OBJECTTYPE)
|
||||
@@ -3010,16 +3041,16 @@ Public Class frmIndex
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
Private Function CreateFolderForIndex(folderindex As String)
|
||||
Private Function CreateFolderForIndex(myDynamicFolder As String)
|
||||
Try
|
||||
Dim RootFolder As String = Path.GetDirectoryName(CURRENT_NEWFILENAME)
|
||||
Dim ORootFolder As String = Path.GetDirectoryName(CURRENT_NEWFILENAME)
|
||||
|
||||
'######
|
||||
Dim p_reg As String = "\[%{1}[a-zA-Z0-9\!\$\&\/\(\)\=\?\,\.\-\;\:_öÖüÜäÄ\#\'\+\*\~\{\}\@\€\<\>\ ]+]{1}"
|
||||
' einen Regulären Ausdruck laden
|
||||
Dim regularExpression As Regex = New Regex(p_reg)
|
||||
' die Vorkommen im Folder-String auslesen
|
||||
Dim elemente As MatchCollection = regularExpression.Matches(folderindex)
|
||||
Dim elemente As MatchCollection = regularExpression.Matches(myDynamicFolder)
|
||||
'####
|
||||
' alle Vorkommen innerhalb des Ordnerstrings durchlaufen
|
||||
For Each element As Match In elemente
|
||||
@@ -3037,8 +3068,10 @@ Public Class frmIndex
|
||||
If IsDate(ManIndex_Value) Then
|
||||
ManIndex_Value = CDate(ManIndex_Value).ToString("yyyyMMdd")
|
||||
End If
|
||||
folderindex = folderindex.Replace(element.ToString, ManIndex_Value)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> FolderPattern: '" & folderindex & "'", False)
|
||||
ManIndex_Value = ClassFilehandle.CleanFilename(ManIndex_Value, "")
|
||||
myDynamicFolder = myDynamicFolder.Replace(element.ToString, ManIndex_Value)
|
||||
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> FolderPattern: '" & myDynamicFolder & "'", False)
|
||||
Else
|
||||
|
||||
If optional_index = True Then
|
||||
@@ -3054,18 +3087,19 @@ Public Class frmIndex
|
||||
Dim AutoIndex_Value As String = GetAutoIndex_Value(AutoIndexname)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Ergebnis/Wert für neuen Ordner: '" & AutoIndexname & "'", False)
|
||||
If Not AutoIndex_Value = String.Empty Then
|
||||
AutoIndex_Value = ClassFilehandle.CleanFilename(AutoIndex_Value, "")
|
||||
If AutoIndex_Value = "EMPTY_OI" Then
|
||||
folderindex = folderindex.Replace(element.ToString, "")
|
||||
myDynamicFolder = myDynamicFolder.Replace(element.ToString, "")
|
||||
Else
|
||||
folderindex = folderindex.Replace(element.ToString, AutoIndex_Value)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> FolderPattern: '" & folderindex & "'", False)
|
||||
myDynamicFolder = myDynamicFolder.Replace(element.ToString, AutoIndex_Value)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> FolderPattern: '" & myDynamicFolder & "'", False)
|
||||
End If
|
||||
|
||||
Else
|
||||
ClassLogger.Add(" - Achtung Ausnahme in 'CrFolderForIndex': der Index ist leer!", True)
|
||||
End If
|
||||
Case "V"
|
||||
Dim folder_temp As String
|
||||
Dim oElementTemp As String
|
||||
Dim _Month As String = My.Computer.Clock.LocalTime.Month
|
||||
If _Month.Length = 1 Then
|
||||
_Month = "0" & _Month
|
||||
@@ -3080,16 +3114,16 @@ Public Class frmIndex
|
||||
End If
|
||||
Select Case type
|
||||
Case "YYYY/MM/DD"
|
||||
folder_temp = My.Computer.Clock.LocalTime.Year & "\" & _Month & "\" & _day
|
||||
oElementTemp = My.Computer.Clock.LocalTime.Year & "\" & _Month & "\" & _day
|
||||
Case "YYYY/MM"
|
||||
folder_temp = My.Computer.Clock.LocalTime.Year & "\" & _Month
|
||||
oElementTemp = My.Computer.Clock.LocalTime.Year & "\" & _Month
|
||||
Case "YYYY"
|
||||
folder_temp = My.Computer.Clock.LocalTime.Year
|
||||
oElementTemp = My.Computer.Clock.LocalTime.Year
|
||||
Case "YYYY-MM"
|
||||
folder_temp = My.Computer.Clock.LocalTime.Year & "-" & _Month
|
||||
oElementTemp = My.Computer.Clock.LocalTime.Year & "-" & _Month
|
||||
End Select
|
||||
folderindex = folderindex.Replace(element.ToString, folder_temp)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> FolderPatter nach V-Element: '" & folderindex & "'", False)
|
||||
myDynamicFolder = myDynamicFolder.Replace(element.ToString, oElementTemp)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> FolderPatter nach V-Element: '" & myDynamicFolder & "'", False)
|
||||
Case Else
|
||||
ClassLogger.Add(" - Achtung - in der Namenkonvention wurde ein Element gefunden welches nicht zugeordnet werden kann!" & vbNewLine & "Elementname: " & element.Value.ToUpper)
|
||||
|
||||
@@ -3104,35 +3138,35 @@ Public Class frmIndex
|
||||
|
||||
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Den Root-Folder zusammenfügen>> ", False)
|
||||
Dim fullpath As String = RootFolder & "\" & folderindex & "\"
|
||||
fullpath = fullpath.Replace("\\", "\")
|
||||
Dim oNewFullpath As String = ORootFolder & "\" & myDynamicFolder & "\"
|
||||
oNewFullpath = oNewFullpath.Replace("\\", "\")
|
||||
|
||||
fullpath = Path.Combine(RootFolder, folderindex)
|
||||
oNewFullpath = Path.Combine(ORootFolder, myDynamicFolder)
|
||||
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Fullpath (mit evtl. Sonderzeichen (SZ)) '" & fullpath & "'", False)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Fullpath (mit evtl. Sonderzeichen (SZ)) '" & oNewFullpath & "'", False)
|
||||
Dim invalidPathChars() As Char = Path.GetInvalidPathChars()
|
||||
For Each sonderChar As Char In invalidPathChars
|
||||
'Sonderzeichen ausser Whitespace entfernen
|
||||
If Char.IsWhiteSpace(sonderChar) = False Then
|
||||
If fullpath.Contains(sonderChar) Then
|
||||
fullpath = fullpath.Replace(sonderChar, "")
|
||||
If oNewFullpath.Contains(sonderChar) Then
|
||||
oNewFullpath = oNewFullpath.Replace(sonderChar, "")
|
||||
End If
|
||||
End If
|
||||
Next sonderChar
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Fullpath (ohne SZ) '" & fullpath & "'", False)
|
||||
If Directory.Exists(fullpath) = False Then
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Fullpath (ohne SZ) '" & oNewFullpath & "'", False)
|
||||
If Directory.Exists(oNewFullpath) = False Then
|
||||
Try
|
||||
Directory.CreateDirectory(fullpath)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Folder '" & fullpath & "' wurde angelegt", False)
|
||||
Directory.CreateDirectory(oNewFullpath)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Folder '" & oNewFullpath & "' wurde angelegt", False)
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add(" >> Error in CreateFolderforIndex-Method - Root Folder '" & fullpath & "' could not be created. " & ex.Message, True)
|
||||
MsgBox("Attention: Root Folder '" & fullpath & "' could not be created." & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
ClassLogger.Add(" >> Error in CreateFolderforIndex-Method - Root Folder '" & oNewFullpath & "' could not be created. " & ex.Message, True)
|
||||
MsgBox("Attention: Root Folder '" & oNewFullpath & "' could not be created." & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
Return False
|
||||
End Try
|
||||
|
||||
End If
|
||||
|
||||
CURRENT_NEWFILENAME = Path.Combine(fullpath, Path.GetFileName(CURRENT_NEWFILENAME))
|
||||
CURRENT_NEWFILENAME = Path.Combine(oNewFullpath, Path.GetFileName(CURRENT_NEWFILENAME))
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
@@ -3155,9 +3189,11 @@ Public Class frmIndex
|
||||
End Sub
|
||||
|
||||
Private Sub chkdelete_origin_CheckedChanged(sender As Object, e As EventArgs) Handles chkdelete_origin.CheckedChanged
|
||||
CURR_DELETE_ORIGIN = chkdelete_origin.Checked
|
||||
CONFIG.Config.DeleteOriginalFile = chkdelete_origin.Checked
|
||||
CONFIG.Save()
|
||||
If formloaded = True Then
|
||||
CURR_DELETE_ORIGIN = chkdelete_origin.Checked
|
||||
CONFIG.Config.DeleteOriginalFile = chkdelete_origin.Checked
|
||||
CONFIG.Save()
|
||||
End If
|
||||
'SaveConfigValue("Delete_OriginFile", CURR_DELETE_ORIGIN)
|
||||
End Sub
|
||||
|
||||
|
||||
Reference in New Issue
Block a user