MS
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
Imports System.IO
|
||||
Imports System.Globalization
|
||||
Imports WINDREAMLib
|
||||
|
||||
Public Class ClassImport_Windream
|
||||
Public Shared Function Import_File(QuellDatei_Path As String, DOCTYPE_ID As Integer)
|
||||
@@ -123,6 +124,10 @@ Public Class ClassImport_Windream
|
||||
End Function
|
||||
|
||||
Public Shared Function Name_Generieren(DocTypeID As Integer)
|
||||
If ClassWindream.Create_Session = False Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim FILE_DELIMITER, VERSION_DELIMITER, _WDOBJECTTYPE, _NewFileString As String
|
||||
Dim sql As String = "select VERSION_DELIMITER, FILE_DELIMITER FROM TBDD_MODULES where UPPER(NAME) = UPPER('Global-Indexer')"
|
||||
@@ -131,7 +136,6 @@ Public Class ClassImport_Windream
|
||||
VERSION_DELIMITER = DT1.Rows(0).Item("VERSION_DELIMITER")
|
||||
|
||||
Dim err As Boolean = False
|
||||
Dim folder_Created As Boolean = False
|
||||
Dim Zielordner As String
|
||||
Dim extension As String = Path.GetExtension(CURRENT_FILENAME)
|
||||
Dim DT As DataTable = ClassDatabase.Return_Datatable("SELECT * FROM TBDD_DOKUMENTART WHERE GUID = " & DocTypeID)
|
||||
@@ -139,41 +143,60 @@ Public Class ClassImport_Windream
|
||||
'sql_history_Index_Values = ""
|
||||
Dim AnzahlIndexe As Integer = 1
|
||||
_WDOBJECTTYPE = DT.Rows(0).Item("OBJEKTTYP")
|
||||
If folder_Created = False Then
|
||||
' Den Zielordner erstellen
|
||||
Zielordner = DT.Rows(0).Item("ZIEL_PFAD")
|
||||
|
||||
sql = "SELECT FOLDER_FOR_INDEX FROM TBDD_DOKUMENTART WHERE GUID = " & DocTypeID
|
||||
Dim Folder_for_index = ClassDatabase.Execute_Scalar(sql)
|
||||
If Not IsDBNull(Folder_for_index) Then
|
||||
If Folder_for_index <> String.Empty Then
|
||||
If CREATE_FOLDER_INDEX(Folder_for_index, DocTypeID) = True And CURRENT_VARIABLE_FOLDER <> "" Then
|
||||
Zielordner = Zielordner & "\" & CURRENT_VARIABLE_FOLDER
|
||||
Else
|
||||
MsgBox("Unexpected Error in Creating Variable Folder - Check logfile!", MsgBoxStyle.Critical)
|
||||
Return False
|
||||
End If
|
||||
' Den Zielordner erstellen
|
||||
Zielordner = DT.Rows(0).Item("ZIEL_PFAD")
|
||||
|
||||
sql = "SELECT FOLDER_FOR_INDEX FROM TBDD_DOKUMENTART WHERE GUID = " & DocTypeID
|
||||
Dim Folder_for_index = ClassDatabase.Execute_Scalar(sql)
|
||||
If Not IsDBNull(Folder_for_index) Then
|
||||
If Folder_for_index <> String.Empty Then
|
||||
If CREATE_FOLDER_INDEX(Folder_for_index, DocTypeID) = True And CURRENT_VARIABLE_FOLDER <> "" Then
|
||||
Zielordner = Zielordner & "\" & CURRENT_VARIABLE_FOLDER
|
||||
Else
|
||||
MsgBox("Unexpected Error in Creating Variable Folder - Check logfile!", MsgBoxStyle.Critical)
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
|
||||
'Unterordner ja oder nein
|
||||
If CURRENT_CHECK_SUBFOLDER = True And CURRENT_SUBFOLDER <> "" Then
|
||||
Zielordner = Zielordner & "\" & CURRENT_SUBFOLDER
|
||||
End If
|
||||
|
||||
If Directory.Exists(Zielordner) = False Then
|
||||
'Try to create the directory.
|
||||
Try
|
||||
Directory.CreateDirectory(Zielordner)
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add(" - Unexpected Error in Creating Target Folder: " & vbNewLine & ex.Message)
|
||||
MsgBox("Unexpected Error in Creating Target Folder: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
Return False
|
||||
End Try
|
||||
|
||||
End If
|
||||
folder_Created = True
|
||||
End If
|
||||
|
||||
'Unterordner ja oder nein
|
||||
If CURRENT_CHECK_SUBFOLDER = True And CURRENT_SUBFOLDER <> "" Then
|
||||
Zielordner = Zielordner & "\" & CURRENT_SUBFOLDER
|
||||
End If
|
||||
|
||||
Try
|
||||
Select Case ClassWindream.WD_PATH_EXISTS(Zielordner.Substring(2))
|
||||
Case False
|
||||
Dim split() As String = Zielordner.Split("\")
|
||||
Dim Path_Combined As String = ""
|
||||
For Each s As String In split
|
||||
Path_Combined &= s & "\"
|
||||
If Path_Combined <> "W:\" Then
|
||||
Try
|
||||
Select Case ClassWindream.WD_PATH_EXISTS(Path_Combined.Substring(2))
|
||||
Case False
|
||||
ClassWindream.oSession.GetNewWMObjectFS(2, Path_Combined.Substring(2), 0) 'WMEntityFolder,WMObjectEditModeNoEdit)
|
||||
Case -10
|
||||
Return False
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
If Not ex.Message.Contains("Filename exists!") Then
|
||||
ClassLogger.Add(String.Format(">> Could not create folder-part ({0}): " & ex.Message, Path_Combined.Substring(2)), True)
|
||||
Return False
|
||||
End If
|
||||
End Try
|
||||
End If
|
||||
Next
|
||||
Case -10
|
||||
Return False
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
If Not ex.Message.Contains("Filename exists!") Then
|
||||
ClassLogger.Add(String.Format(">> Could not create folder ({0}): " & ex.Message, Zielordner.Substring(2)), False)
|
||||
Return False
|
||||
End If
|
||||
End Try
|
||||
'####
|
||||
' Regulären Ausdruck zum Auslesen der Indexe definieren
|
||||
Dim preg As String = "\[%{1}[a-zA-Z0-9\!\$\&\/\(\)\=\?\,\.\-\;\:_öÖüÜäÄ\#\'\+\*\~\{\}\@\€\<\>\ ]+]{1}"
|
||||
@@ -409,34 +432,68 @@ Public Class ClassImport_Windream
|
||||
Dim _neuername As String = DATEINAME.Replace(VERSION_DELIMITER, "")
|
||||
'Dim MoveFilename As String = DATEINAME.Replace(element.Value, "")
|
||||
_NewFileString = _neuername
|
||||
'Überprüfen ob File existiert
|
||||
If File.Exists(_neuername & extension) = False Then
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> File is not existing", False)
|
||||
Const WMCOMEventWMSessionNeedIndex = 1
|
||||
'windream Objekte erstellen ohne Indexierungs-Event
|
||||
ClassWindream.oSession.SwitchEvents(WMCOMEventWMSessionNeedIndex, False)
|
||||
|
||||
'Überprüfen ob File existiert
|
||||
Dim FILE_EXISTS_IN_WD As Boolean
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Versuch auf die Datei in W: zuzugreifen und zu sperren...", False)
|
||||
FILE_EXISTS_IN_WD = ClassWindream.oSession.WMObjectExists(WINDREAMLib.WMEntity.WMEntityDocument, _NewFileString.Substring(2) & extension, 0, 0)
|
||||
Dim WMObject
|
||||
If FILE_EXISTS_IN_WD = False Then
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Datei ist NICHT vorhanden, kann also einfach neu angelegt werden", False)
|
||||
'==================================================================
|
||||
' create an object
|
||||
'==================================================================
|
||||
Try
|
||||
WMObject = ClassWindream.oSession.GetNewWMObjectFS(WINDREAMLib.WMEntity.WMEntityDocument, _NewFileString.Substring(2) & extension, 31)
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add("Could not create the windremObject(File) '" & _NewFileString.Substring(2) & extension & "': " & ex.Message, True)
|
||||
Return False
|
||||
End Try
|
||||
Else
|
||||
Dim msg As String
|
||||
msg = "Achtung: die Datei existiert bereits!" & vbNewLine & _neuername & extension & vbNewLine & "Wollen Sie die vorhandene Datei ersetzen?"
|
||||
If USER_LANGUAGE <> "de-DE" Then
|
||||
msg = "Attention: there is already a file with this name!" & vbNewLine & _neuername & extension & vbNewLine & "Would You like to replace this file with the actual one?"
|
||||
End If
|
||||
Dim result As MsgBoxResult
|
||||
result = MessageBox.Show(msg, "Confirmation needed:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
||||
If result = MsgBoxResult.Yes Then
|
||||
Try
|
||||
File.Delete(_neuername & extension)
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in Replace file: " & ex.Message, MsgBoxStyle.Critical)
|
||||
err = True
|
||||
End Try
|
||||
Else
|
||||
Do While File.Exists(_neuername & extension)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Attention File '" & _neuername & extension & "' is existing!", False)
|
||||
version = version + 1
|
||||
_neuername = Stammname & VERSION_DELIMITER & version
|
||||
_NewFileString = _neuername
|
||||
Loop
|
||||
End If
|
||||
' wenn auf die Datei zugeriffen werden konnte ist sie bereits vorhanden -> Datum anhängen
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Es konnte zugegriffen werden -> DATEI IST BEREITS VORHANDEN", False)
|
||||
|
||||
Do While FILE_EXISTS_IN_WD = True
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Attention File '" & _neuername & extension & "' is existing!", False)
|
||||
_neuername = Stammname & VERSION_DELIMITER & version
|
||||
_NewFileString = _neuername
|
||||
FILE_EXISTS_IN_WD = ClassWindream.oSession.WMObjectExists(WINDREAMLib.WMEntity.WMEntityDocument, _NewFileString.Substring(2) & extension, 0, 0)
|
||||
version = version + 1
|
||||
Loop
|
||||
Try
|
||||
WMObject = ClassWindream.oSession.GetNewWMObjectFS(WINDREAMLib.WMEntity.WMEntityDocument, _NewFileString.Substring(2) & extension, 31)
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add("Could not create the windremObject(File) COPY '" & _NewFileString.Substring(2) & extension & "': " & ex.Message, True)
|
||||
Return False
|
||||
End Try
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> WMObject created after versioning", False)
|
||||
End If
|
||||
ClassWindream.STREAM_OBJECT = Nothing
|
||||
ClassWindream.STREAM_OBJECT = WMObject
|
||||
'If File.Exists(_neuername & extension) = False Then
|
||||
' If LogErrorsOnly = False Then ClassLogger.Add(" >> File is not existing", False)
|
||||
'Else
|
||||
' Dim msg As String
|
||||
' msg = "Achtung: die Datei existiert bereits!" & vbNewLine & _neuername & extension & vbNewLine & "Wollen Sie die vorhandene Datei ersetzen?"
|
||||
' If USER_LANGUAGE <> "de-DE" Then
|
||||
' msg = "Attention: there is already a file with this name!" & vbNewLine & _neuername & extension & vbNewLine & "Would You like to replace this file with the actual one?"
|
||||
' End If
|
||||
' Dim result As MsgBoxResult
|
||||
' result = MessageBox.Show(msg, "Confirmation needed:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
||||
' If result = MsgBoxResult.Yes Then
|
||||
' Try
|
||||
' File.Delete(_neuername & extension)
|
||||
' Catch ex As Exception
|
||||
' MsgBox("Unexpected Error in Replace file: " & ex.Message, MsgBoxStyle.Critical)
|
||||
' err = True
|
||||
' End Try
|
||||
' Else
|
||||
|
||||
' End If
|
||||
'End If
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add(" - Error in Versioning file - Error: " & vbNewLine & ex.Message)
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in Versioning file:")
|
||||
|
||||
Reference in New Issue
Block a user