MS
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
Imports System.IO
|
||||
Imports System.Globalization
|
||||
Imports WINDREAMLib
|
||||
Imports DD_LIB_Standards
|
||||
|
||||
Public Class ClassImport_Windream
|
||||
Public Shared Function Import_File(QuellDatei_Path As String, DOCTYPE_ID As Integer)
|
||||
@@ -11,7 +12,7 @@ Public Class ClassImport_Windream
|
||||
If Not IsNothing(DT_DOCTYPE) Then
|
||||
Dim Targetpath As String = DT_DOCTYPE.Rows(0).Item("ZIEL_PFAD")
|
||||
Dim Dokart As String = DT_DOCTYPE.Rows(0).Item("BEZEICHNUNG")
|
||||
ClassWindream._WDObjekttyp = DT_DOCTYPE.Rows(0).Item("OBJEKTTYP")
|
||||
clsWindream.MY_WDOBJECTTYPE = DT_DOCTYPE.Rows(0).Item("OBJEKTTYP")
|
||||
|
||||
'Den Namen der Dokumentart generieren
|
||||
If ClassImport_Windream.Name_Generieren(DOCTYPE_ID) = False Then
|
||||
@@ -20,7 +21,7 @@ Public Class ClassImport_Windream
|
||||
End If
|
||||
|
||||
'Die Datei nach windream importieren
|
||||
Dim streamresult = ClassWindream.Stream_File(QuellDatei_Path, Targetpath)
|
||||
Dim streamresult = clsWD_SET.Stream_File(QuellDatei_Path, Targetpath)
|
||||
If streamresult = True Then
|
||||
Dim sql As String = String.Format("SELECT DocID FROM VWPMO_DOC_SYNC WHERE UPPER(FULL_FILENAME) = UPPER('{0}') AND CONVERT(DATE,Change_DateTime) = CONVERT(DATE,GETDATE())", CURRENT_FILEIN_WD)
|
||||
CURRENT_DOC_ID = ClassDatabase.Execute_Scalar(sql)
|
||||
@@ -43,9 +44,9 @@ Public Class ClassImport_Windream
|
||||
End If
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Indexvalue: " & idxvalue.ToString, False)
|
||||
Count += 1
|
||||
indexierung_erfolgreich = ClassWindream.IndexFile(CURRENT_FILEIN_WD, indexname, idxvalue)
|
||||
indexierung_erfolgreich = clsWD_SET.IndexFile(CURRENT_FILEIN_WD, indexname, idxvalue, clsWindream.MY_WDOBJECTTYPE)
|
||||
If indexierung_erfolgreich = False Then
|
||||
MsgBox("Unexpected Error in indexing file - See log", MsgBoxStyle.Critical)
|
||||
ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error: ", "Unexpected Error in indexing '" & indexname & "') - Check logfile!")
|
||||
err = True
|
||||
Exit For
|
||||
End If
|
||||
@@ -55,50 +56,29 @@ Public Class ClassImport_Windream
|
||||
Return False
|
||||
End If
|
||||
'den Entity-Key auslesen
|
||||
sql = "Select Top 1 * from TBPMO_WD_OBJECTTYPE where Upper(object_type) = Upper('" & ClassWindream._WDObjekttyp & "')"
|
||||
sql = "Select Top 1 * from TBPMO_WD_OBJECTTYPE where Upper(object_type) = Upper('" & clsWindream.MY_WDOBJECTTYPE & "')"
|
||||
dt = ClassDatabase.Return_Datatable(sql, True)
|
||||
If Not dt Is Nothing Then
|
||||
If dt.Rows.Count = 1 Then
|
||||
Dim indexname = dt.Rows(0).Item("IDXNAME_ENTITYID").ToString
|
||||
Dim idxvalue = CURRENT_ENTITY_ID
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Entity-ID: " & idxvalue.ToString, False)
|
||||
indexierung_erfolgreich = ClassWindream.IndexFile(CURRENT_FILEIN_WD, indexname, idxvalue)
|
||||
indexierung_erfolgreich = clsWD_SET.IndexFile(CURRENT_FILEIN_WD, indexname, idxvalue, clsWindream.MY_WDOBJECTTYPE)
|
||||
If indexierung_erfolgreich = False Then
|
||||
err = True
|
||||
MsgBox("Unexpected Error in indexing file Entity - See log", MsgBoxStyle.Critical)
|
||||
ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error: ", "Unexpected Error in indexing Entity-ID '" & indexname & "') - Check logfile!")
|
||||
Return False
|
||||
End If
|
||||
indexname = dt.Rows(0).Item("IDXNAME_PARENTID").ToString
|
||||
idxvalue = CURRENT_PARENT_ENTITY_ID
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Parent-ID: " & idxvalue.ToString, False)
|
||||
indexierung_erfolgreich = ClassWindream.IndexFile(CURRENT_FILEIN_WD, indexname, idxvalue)
|
||||
indexierung_erfolgreich = clsWD_SET.IndexFile(CURRENT_FILEIN_WD, indexname, idxvalue, clsWindream.MY_WDOBJECTTYPE)
|
||||
If indexierung_erfolgreich = False Then
|
||||
err = True
|
||||
MsgBox("Unexpected Error in indexing file Parent-ID - See log", MsgBoxStyle.Critical)
|
||||
ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error: ", "Unexpected Error in indexing Parent-ID '" & indexname & "') - Check logfile!")
|
||||
Return False
|
||||
End If
|
||||
'####
|
||||
''den Record-Key auslesen
|
||||
'indexname = dt.Rows(0).Item("IDXNAME_RECORDID").ToString
|
||||
'idxvalue = CURRENT_RECORD_ID
|
||||
'If LogErrorsOnly = False Then ClassLogger.Add(" >> Record-ID: " & idxvalue.ToString, False)
|
||||
'indexierung_erfolgreich = ClassWindream.DateiIndexieren(CURRENT_FILEIN_WD, indexname, idxvalue)
|
||||
'If indexierung_erfolgreich = False Then
|
||||
' err = True
|
||||
' MsgBox("Unexpected Error in indexing file Record-ID - See log", MsgBoxStyle.Critical)
|
||||
' Return False
|
||||
'End If
|
||||
''den Doctype-Key auslesen
|
||||
'indexname = dt.Rows(0).Item("IDXNAME_DOCTYPE").ToString
|
||||
'idxvalue = CURRENT_DOKARTSTRING
|
||||
'If LogErrorsOnly = False Then ClassLogger.Add(" >> Doctype: " & idxvalue.ToString, False)
|
||||
'indexierung_erfolgreich = ClassWindream.DateiIndexieren(CURRENT_FILEIN_WD, indexname, idxvalue)
|
||||
'If indexierung_erfolgreich = False Then
|
||||
' err = True
|
||||
' MsgBox("Unexpected Error in indexing file Doctype - See log", MsgBoxStyle.Critical)
|
||||
' Return False
|
||||
'End If
|
||||
'####
|
||||
|
||||
End If
|
||||
End If
|
||||
If indexierung_erfolgreich = True Then
|
||||
@@ -124,9 +104,6 @@ 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
|
||||
@@ -166,7 +143,7 @@ Public Class ClassImport_Windream
|
||||
End If
|
||||
|
||||
Try
|
||||
Select Case ClassWindream.WD_PATH_EXISTS(Zielordner.Substring(2))
|
||||
Select Case clsWD_GET.WD_PATH_EXISTS(Zielordner.Substring(2))
|
||||
Case False
|
||||
Dim split() As String = Zielordner.Split("\")
|
||||
Dim Path_Combined As String = ""
|
||||
@@ -174,9 +151,9 @@ Public Class ClassImport_Windream
|
||||
Path_Combined &= s & "\"
|
||||
If Path_Combined <> "W:\" Then
|
||||
Try
|
||||
Select Case ClassWindream.WD_PATH_EXISTS(Path_Combined.Substring(2))
|
||||
Select Case clsWD_GET.WD_PATH_EXISTS(Path_Combined.Substring(2))
|
||||
Case False
|
||||
ClassWindream.oSession.GetNewWMObjectFS(2, Path_Combined.Substring(2), 0) 'WMEntityFolder,WMObjectEditModeNoEdit)
|
||||
clsWindream.MY_WDSESSION.GetNewWMObjectFS(2, Path_Combined.Substring(2), 0) 'WMEntityFolder,WMObjectEditModeNoEdit)
|
||||
Case -10
|
||||
Return False
|
||||
End Select
|
||||
@@ -189,6 +166,7 @@ Public Class ClassImport_Windream
|
||||
End If
|
||||
Next
|
||||
Case -10
|
||||
MsgBox("Attention: the folder of the doctype does not exist or there was an error while checking....", MsgBoxStyle.Critical)
|
||||
Return False
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
@@ -427,94 +405,12 @@ Public Class ClassImport_Windream
|
||||
Try
|
||||
'ungültige Zeichen entfernen
|
||||
DATEINAME = ClassHelper.CleanFilename(DATEINAME, "")
|
||||
Dim version As Integer = 2
|
||||
Dim Stammname As String = DATEINAME.Replace(VERSION_DELIMITER, "")
|
||||
Dim _neuername As String = DATEINAME.Replace(VERSION_DELIMITER, "")
|
||||
'Dim MoveFilename As String = DATEINAME.Replace(element.Value, "")
|
||||
_NewFileString = _neuername
|
||||
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
|
||||
' 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)
|
||||
Dim msg = "Eine Datei mit identischem Namen existiert bereits! Wollen Sie die bestehende Datei ersetzen?"
|
||||
If USER_LANGUAGE <> "de-DE" Then
|
||||
msg = "There is already a file with the same name! Would You like to replace the file?"
|
||||
End If
|
||||
Dim result As MsgBoxResult
|
||||
result = MessageBox.Show(msg, "File alredy exists:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
||||
If result = MsgBoxResult.Yes Then
|
||||
Try
|
||||
If ClassWindream.Delete_WDFile(_NewFileString.Substring(2) & extension) = True Then
|
||||
WMObject = ClassWindream.oSession.GetNewWMObjectFS(WINDREAMLib.WMEntity.WMEntityDocument, _NewFileString.Substring(2) & extension, 31)
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error in Creating WindreamObject:", ex.Message)
|
||||
Return False
|
||||
End Try
|
||||
|
||||
Else
|
||||
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
|
||||
WMObject = ClassWindream.oSession.GetNewWMObjectFS(WINDREAMLib.WMEntity.WMEntityDocument, _NewFileString.Substring(2) & extension, 31)
|
||||
End If
|
||||
|
||||
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:")
|
||||
err = True
|
||||
End Try
|
||||
CURRENT_NEWFILENAME = _NewFileString & extension
|
||||
CURRENT_NEWFILENAME = DATEINAME & extension
|
||||
|
||||
|
||||
'False oder True zurückgeben
|
||||
|
||||
Reference in New Issue
Block a user