From d83b8cb3f3a606a7f0f1333e2fbdb545383c7205 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Fri, 15 Feb 2019 13:39:38 +0100 Subject: [PATCH] Fix DocumentPath --- app/DD_PM_WINDREAM/ClassWindream_allgemein.vb | 22 +++- app/DD_PM_WINDREAM/frmMain.vb | 3 - app/DD_PM_WINDREAM/frmMassValidator.vb | 8 +- app/DD_PM_WINDREAM/frmValidator.vb | 104 ++++++++++-------- 4 files changed, 78 insertions(+), 59 deletions(-) diff --git a/app/DD_PM_WINDREAM/ClassWindream_allgemein.vb b/app/DD_PM_WINDREAM/ClassWindream_allgemein.vb index 19228df..403ad2d 100644 --- a/app/DD_PM_WINDREAM/ClassWindream_allgemein.vb +++ b/app/DD_PM_WINDREAM/ClassWindream_allgemein.vb @@ -226,14 +226,24 @@ Public Class ClassWindream_allgemein End Try End Function - Public Function CheckFileExists(Path As String) - Dim oNormalizedPath = Path - If Not Path.StartsWith("\") Then - oNormalizedPath = Path.Substring(2) - End If - If Path.StartsWith("\\windream") Then + + Public Function NormalizePath(Path As String) + Dim oNormalizedPath As String + + If Path.StartsWith("\") Then + oNormalizedPath = Path.Substring(1) + ElseIf Path.StartsWith("\\windream") Then oNormalizedPath = Path.Replace("\\windream\objects\", "") + Else + Return Path End If + + Return oNormalizedPath + End Function + + Public Function CheckFileExists(Path As String) + Dim oNormalizedPath = NormalizePath(Path) + Try Dim oObjectId = 0 Dim oObjectDbId = 0 diff --git a/app/DD_PM_WINDREAM/frmMain.vb b/app/DD_PM_WINDREAM/frmMain.vb index e39d587..8391376 100644 --- a/app/DD_PM_WINDREAM/frmMain.vb +++ b/app/DD_PM_WINDREAM/frmMain.vb @@ -155,9 +155,6 @@ Public Class frmMain End Try If LogErrorsOnly = False Then ClassLogger.Add(" >> MainForm initialized!", False) - - MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)) - End If End Sub diff --git a/app/DD_PM_WINDREAM/frmMassValidator.vb b/app/DD_PM_WINDREAM/frmMassValidator.vb index adfef9f..8f2e357 100644 --- a/app/DD_PM_WINDREAM/frmMassValidator.vb +++ b/app/DD_PM_WINDREAM/frmMassValidator.vb @@ -586,7 +586,7 @@ Public Class frmMassValidator For Each docrow As DataRow In CURRENT_DT_MASS_CHANGE_DOCS.Rows Dim WMDOC As WMObject Try - WMDOC = WINDREAM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, docrow.Item("FULL_PATH").ToString.Substring(2)) + WMDOC = WINDREAM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, docrow.Item("FULL_PATH")) Catch ex As Exception ClassLogger.Add("error while creating WMObject in (textCheckIndex): " & ex.Message) Exit For @@ -922,7 +922,7 @@ Public Class frmMassValidator CURRENT_DOC_GUID = docrow.Item("DOC_GUID") Dim WMDOC As WMObject Try - WMDOC = WINDREAM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, docrow.Item("FULL_PATH").ToString.Substring(2)) + WMDOC = WINDREAM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, docrow.Item("FULL_PATH")) Catch ex As Exception ClassLogger.Add("error while creating WMObject in (IndexVKTMultipleFiles): " & ex.Message) Exit For @@ -1385,7 +1385,7 @@ Public Class frmMassValidator For Each docrow As DataRow In CURRENT_DT_MASS_CHANGE_DOCS.Rows Dim WMDOC As WMObject Try - WMDOC = WINDREAM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, docrow.Item("FULL_PATH").ToString.Substring(2)) + WMDOC = WINDREAM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, docrow.Item("FULL_PATH")) Catch ex As Exception ClassLogger.Add("error while creating WMObject in (IndexMultipleFiles): " & ex.Message) _allfine = False @@ -1437,7 +1437,7 @@ Public Class frmMassValidator For Each docrow As DataRow In CURRENT_DT_MASS_CHANGE_DOCS.Rows Dim WMDOC As WMObject Try - WMDOC = WINDREAM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, docrow.Item("FULL_PATH").ToString.Substring(2)) + WMDOC = WINDREAM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, docrow.Item("FULL_PATH")) Catch ex As Exception ClassLogger.Add("error while creating WMObject in (IndexVKTMultipleFiles): " & ex.Message) _allfine = False diff --git a/app/DD_PM_WINDREAM/frmValidator.vb b/app/DD_PM_WINDREAM/frmValidator.vb index bce77d4..410a91f 100644 --- a/app/DD_PM_WINDREAM/frmValidator.vb +++ b/app/DD_PM_WINDREAM/frmValidator.vb @@ -32,7 +32,10 @@ Public Class frmValidator Dim aktivesDokument As WMObject 'speichert die DocumentDaten Private navStep As String = Nothing - Public Shared Document_Path As String + + Public Shared Windream_Document_Path As String + Public Shared Filesystem_Document_Path As String + Dim OLD_Document_Path As String = "" Dim ValueDTP As Date Dim AnzDoks As Integer @@ -94,7 +97,7 @@ Public Class frmValidator Catch ex As Exception ClassLogger.Add("Error in Load FormLayout: " & ex.Message) End Try - Select Case Path.GetExtension(Document_Path).ToLower + Select Case Path.GetExtension(Windream_Document_Path).ToLower Case ".pdf" Select Case vpdfviewer Case "internal" @@ -137,7 +140,7 @@ Public Class frmValidator Kill_PDFAcrobat() Else If pdfxchange = True Or sumatra = True Then - Close_PDF_Viewer(Document_Path) + Close_PDF_Viewer(Windream_Document_Path) End If KillU_Viewer() End If @@ -1212,9 +1215,9 @@ Public Class frmValidator End Try End Sub Sub Open_PDF_withStandard() - If Document_Path.ToLower.EndsWith(".pdf") = True Then + If Windream_Document_Path.ToLower.EndsWith(".pdf") = True Then Dim Proc As New System.Diagnostics.Process - Dim psi As New ProcessStartInfo(Document_Path) + Dim psi As New ProcessStartInfo(Filesystem_Document_Path) psi.WindowStyle = ProcessWindowStyle.Minimized Proc.EnableRaisingEvents = True Proc.StartInfo = psi @@ -1258,19 +1261,22 @@ Public Class frmValidator newGUID = Next_GUID(OLD_Document_Path, CURRENT_ProfilGUID, PROFIL_sortbynewest) - Document_Path = "" + Windream_Document_Path = "" CURRENT_DOC_PATH = "" If newGUID > 0 Then If LogErrorsOnly = False Then ClassLogger.Add(" >> newGUID: " & newGUID.ToString, False) - Document_Path = TBPM_PROFILE_FILESTableAdapter.CmdGetFilePath_2_GUID(newGUID) - Document_Path = Document_Path.Replace("W:", "\\windream\objects") - Document_Path = Document_Path.Replace("K:", "\\windream\objects") - CURRENT_DOC_PATH = Document_Path - If LogErrorsOnly = False Then ClassLogger.Add(" >> Document_Path: " & Document_Path, False) + Windream_Document_Path = TBPM_PROFILE_FILESTableAdapter.CmdGetFilePath_2_GUID(newGUID) + Windream_Document_Path = Windream_Document_Path.Replace("W:", "\\windream\objects") + Windream_Document_Path = Windream_Document_Path.Replace("K:", "\\windream\objects") + + Filesystem_Document_Path = GetFilesystemDocumentPath(Windream_Document_Path) + + CURRENT_DOC_PATH = Windream_Document_Path + If LogErrorsOnly = False Then ClassLogger.Add(" >> Document_Path: " & Windream_Document_Path, False) If LogErrorsOnly = False Then ClassLogger.Add(" >> Überprüfen ob File existiert?", False) Dim i As Integer = 0 - Do While allgFunk.file_exists(Document_Path, _windream) = False And newGUID <> 0 + Do While allgFunk.file_exists(Windream_Document_Path, _windream) = False And newGUID <> 0 i = i + 1 If i > 800 Then allgFunk.Insert_LogEntry(CURRENT_ProfilGUID, "Get_Next_GUID - Datei nicht vorhanden!", Environment.UserName) @@ -1278,12 +1284,12 @@ Public Class frmValidator Dim Del = "DELETE FROM TBPM_PROFILE_FILES where GUID = " & newGUID ClassDatabase.Execute_non_Query(Del, True) errmessage = "Die windream-Datei existiert nicht!" - Document_Path = "" + Windream_Document_Path = "" CURRENT_DOC_PATH = "" Return 0 End If Loop - OLD_Document_Path = Document_Path + OLD_Document_Path = Windream_Document_Path 'If PROFIL_sortbynewest Then ' newGUID = TBPM_PROFILE_FILESTableAdapter.cmdgetNextFile_GUID_Newest(PROFIL_ID, Document_Path, Environment.UserName) ' Document_Path = TBPM_PROFILE_FILESTableAdapter.CmdGetFilePath_2_GUID(newGUID) @@ -1320,7 +1326,7 @@ Public Class frmValidator AnzDoks = DT.Rows.Count Else AnzDoks = 1 - Document_Path = CURRENT_DOC_PATH + Windream_Document_Path = CURRENT_DOC_PATH End If tsslblDocID.Text = "Document-ID: " & CURRENT_DOC_ID & " - GUID: " & CURRENT_DOC_GUID @@ -1336,7 +1342,7 @@ Public Class frmValidator End If End If If pdfxchange = True Or sumatra = True Or vpdfviewer = "system" Then - Close_PDF_Viewer(Document_Path) + Close_PDF_Viewer(Windream_Document_Path) End If If aktivesDokument Is Nothing = False Then If aktivesDokument.aLocked Then @@ -1356,13 +1362,20 @@ Public Class frmValidator pnlpdf.Visible = visible End Sub + + Function GetFilesystemDocumentPath(WindreamPath As String) + Return Path.Combine(CURRENT_DT_CONFIG.Rows.Item(0).Item("WM_REL_PATH"), Windream_Document_Path) + End Function + Sub Load_Next_Document(first As Boolean) aktivesDokument = Nothing If LogErrorsOnly = False Then ClassLogger.Add(" >> aktivesDokument nothing gesetzt", False) activate_controls(False) errmessage = "" - Document_Path = "" + Windream_Document_Path = "" + Filesystem_Document_Path = "" + CURRENT_HTML_DOC = "" 'Me.lblerror.Visible = False @@ -1391,25 +1404,25 @@ Public Class frmValidator If CURRENT_JUMP_DOC_GUID = 0 Then CURRENT_DOC_GUID = Get_Next_GUID() Else - Document_Path = CURRENT_DOC_PATH + Windream_Document_Path = CURRENT_DOC_PATH + Filesystem_Document_Path = GetFilesystemDocumentPath(Windream_Document_Path) End If If LogErrorsOnly = False Then ClassLogger.Add(" >> Dokument-GUID: '" & CURRENT_DOC_GUID.ToString & "'", False) If CURRENT_DOC_GUID > 0 Then 'Beschriftung des Navigators 'lblNavigator_anzDok.Text = position & " of " & Anzahl_ValDoks & " files" - If Document_Path <> String.Empty Then + If Windream_Document_Path <> String.Empty Then ' >> >> >> >> >> >>##### Das Dokument in Bearbeitung nehmen ########################### TBPM_PROFILE_FILESTableAdapter.CmdSETWORK(True, Environment.UserName, CURRENT_DOC_GUID) ' ############ Infos eintragen ################# tsslblDocID.Text = "Document-ID: " & CURRENT_DOC_ID & " - DocGUID: " & CURRENT_DOC_GUID ' txtDateipfad.Text = Document_Path tstrlbl_Info.Text = "Datei " & docCounter.ToString & " von " & Anzahl_ValDoks.ToString - ClassLogger.Add(">> Validierung für Dokument '" & Document_Path & "' gestartet", False) + ClassLogger.Add(">> Validierung für Dokument '" & Windream_Document_Path & "' gestartet", False) Try - 'aktivesDokument = _windreamPM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, Document_Path.Substring(2)) - aktivesDokument = WINDREAM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, Document_Path.Replace("\\windream\objects", "")) + aktivesDokument = WINDREAM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, WINDREAM.NormalizePath(Windream_Document_Path)) Catch ex As Exception allgFunk.Insert_LogEntry(CURRENT_ProfilGUID, "Fehler bei Erzeugen windream-Objekt - DocGUID: " & CURRENT_DOC_GUID & " - ERROR: " & ex.Message, Environment.UserName) ClassLogger.Add("Fehler bei Erzeugen windream-Objekt in (LoadNextDokument): " & ex.Message) @@ -1418,8 +1431,7 @@ Public Class frmValidator 'Nochmaliger Versuch windream zu initialiseren If Init_windream() = True Then Try - 'aktivesDokument = _windreamPM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, Document_Path.Substring(2)) - aktivesDokument = WINDREAM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, Document_Path.Substring(2)) + aktivesDokument = WINDREAM.oSession.GetWMObjectByPath(WMEntity.WMEntityDocument, Windream_Document_Path) Catch ex1 As Exception ClassLogger.Add("Fehler bei 2. Versuch windream-Objekt: " & ex1.Message) errmessage = "1-Es besteht ein Problem beim Anmelden an windream - Bitte wenden Sie sich an Digital Data!" @@ -1447,7 +1459,7 @@ Public Class frmValidator load_viewer() - If Document_Path.ToLower.EndsWith(".pdf") Then + If Windream_Document_Path.ToLower.EndsWith(".pdf") Then ToolStripButtonAnnotation.Visible = True Else ToolStripButtonAnnotation.Visible = False @@ -1519,19 +1531,19 @@ Public Class frmValidator If Viewer = "uviewer" Then pdfxchange = False sumatra = False - If Document_Path.ToLower.EndsWith(".msg") Then + If Filesystem_Document_Path.ToLower.EndsWith(".msg") Then Show_Email() Else - ShowFile_UniversalViewer(Document_Path) + ShowFile_UniversalViewer(Filesystem_Document_Path) End If ElseIf Viewer = "docview" Then PdfControls_visible(False) - If Document_Path.ToLower.EndsWith(".pdf") And vpdfviewer <> "none" Then + If Filesystem_Document_Path.ToLower.EndsWith(".pdf") And vpdfviewer <> "none" Then Select Case vpdfviewer Case "internal" SplitContainer1.Panel2Collapsed = False - PdfViewer1.LoadDocument(Document_Path) - If LogErrorsOnly = False Then ClassLogger.Add(" >> Internal Viewer Path: " & Document_Path, False) + PdfViewer1.LoadDocument(Filesystem_Document_Path) + If LogErrorsOnly = False Then ClassLogger.Add(" >> Internal Viewer Path: " & Filesystem_Document_Path, False) PdfControls_visible(True) Me.Size = My.Settings.frmValidation_Size_PDFViewer 'PdfViewer1.ZoomFactor = PDFViewer_ZoomMode @@ -1540,14 +1552,14 @@ Public Class frmValidator sumatra = False Case "pdfxchange" SplitContainer1.Panel2Collapsed = True - Open_PDFXCHANGE(Document_Path) + Open_PDFXCHANGE(Filesystem_Document_Path) pdfxchange = True sumatra = False System.Threading.Thread.Sleep(1000) Me.Size = My.Settings.frmValidatorSize Case "sumatra" SplitContainer1.Panel2Collapsed = True - Open_Sumatra(Document_Path) + Open_Sumatra(Filesystem_Document_Path) sumatra = True pdfxchange = False System.Threading.Thread.Sleep(1000) @@ -1560,7 +1572,7 @@ Public Class frmValidator System.Threading.Thread.Sleep(1000) Me.Size = My.Settings.frmValidatorSize End Select - ElseIf Document_Path.ToLower.EndsWith(".msg") Then + ElseIf Filesystem_Document_Path.ToLower.EndsWith(".msg") Then Show_Email() Else SplitContainer1.Panel2Collapsed = True @@ -1590,7 +1602,7 @@ Public Class frmValidator Try Me.grpBetreff.Dock = DockStyle.Top Me.grpbxMailBody.Dock = DockStyle.Fill - Dim msg_email As New Msg.Message(Document_Path) + Dim msg_email As New Msg.Message(Windream_Document_Path) 'Eine tempfile generieren Dim tempFilename = My.Computer.FileSystem.GetTempFileName() Dim name = Path.GetFileNameWithoutExtension(tempFilename) @@ -2521,7 +2533,7 @@ Public Class frmValidator ClassDatabase.Execute_non_Query(ins) Close_document_viewer() - If Document_Path.ToLower.EndsWith(".pdf") Then + If Windream_Document_Path.ToLower.EndsWith(".pdf") Then If Not IsNothing(WORK_HISTORY_ENTRY) Then If CBool(CURRENT_DT_PROFILE.Rows(0).Item("ANNOTATE_WORK_HISTORY_ENTRY")) = True Then sql = String.Format("SELECT * FROM TBPM_FILES_WORK_HISTORY WHERE GUID = (SELECT MAX(GUID) FROM TBPM_FILES_WORK_HISTORY WHERE PROFIL_ID = {0} AND DOC_ID = {1})", CURRENT_ProfilGUID, CURRENT_DOC_ID) @@ -2552,7 +2564,7 @@ Public Class frmValidator 'wenn Move2Folder aktiviert wurde If Move2Folder <> "" Then - idxerr_message = allgFunk.Move2Folder(Document_Path, Move2Folder, CURRENT_ProfilGUID, _windream) + idxerr_message = allgFunk.Move2Folder(Windream_Document_Path, Move2Folder, CURRENT_ProfilGUID, _windream) If idxerr_message <> "" Then errormessage = "Fehler bei Move2Folder:" & vbNewLine & idxerr_message My.Settings.Save() @@ -2561,7 +2573,7 @@ Public Class frmValidator End If End If 'Validierungsfile löschen wenn vorhanden - allgFunk.Delete_xffres(Document_Path, _windream) + allgFunk.Delete_xffres(Windream_Document_Path, _windream) If LogErrorsOnly = False Then ClassLogger.Add(" >> Delete_xffres ausgeführt", False) If LogErrorsOnly = False Then ClassLogger.Add(" >> All Input clear", False) Anzahl_validierte_Dok += 1 @@ -3243,7 +3255,7 @@ Public Class frmValidator Private Sub DateiÖffnenToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles DateiÖffnenToolStripMenuItem.Click Try Dim Proc As New System.Diagnostics.Process - Dim psi As New ProcessStartInfo(Document_Path) + Dim psi As New ProcessStartInfo(Filesystem_Document_Path) Proc.EnableRaisingEvents = True Proc.StartInfo = psi Proc.Start() @@ -3263,8 +3275,8 @@ Public Class frmValidator 'Das Dokument freigeben TBPM_PROFILE_FILESTableAdapter.CmdSETWORK(False, "", CURRENT_DOC_GUID) - If TBPM_FILES_USER_NOT_INDEXEDTableAdapter.FileExists(Environment.UserName, CURRENT_ProfilGUID, Document_Path) = 0 Then - TBPM_FILES_USER_NOT_INDEXEDTableAdapter.cmdInsert(Environment.UserName, CURRENT_ProfilGUID, Document_Path) + If TBPM_FILES_USER_NOT_INDEXEDTableAdapter.FileExists(Environment.UserName, CURRENT_ProfilGUID, Windream_Document_Path) = 0 Then + TBPM_FILES_USER_NOT_INDEXEDTableAdapter.cmdInsert(Environment.UserName, CURRENT_ProfilGUID, Windream_Document_Path) End If If LogErrorsOnly = False Then ClassLogger.Add(" >> Dokument freigegeben", False) @@ -3283,7 +3295,7 @@ Public Class frmValidator Close_document_viewer() 'Aus der Tabelle löschen TBPM_PROFILE_FILESTableAdapter.CmdDelete(CURRENT_DOC_GUID) - Dim resul = allgFunk.Delete_xffres(Document_Path, _windream) + Dim resul = allgFunk.Delete_xffres(Filesystem_Document_Path, _windream) If resul = Nothing Or resul = True Then If Delete_File() = True Then 'MsgBox("Die Datei wurde erfolgreich aus windream gelöscht!" & vbNewLine & "Es wird nun die nächste Datei angezeigt!", MsgBoxStyle.Information, "Erfolgsmeldung:") @@ -3347,12 +3359,12 @@ Public Class frmValidator End Structure Private Sub DateieigenschaftenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DateieigenschaftenToolStripMenuItem.Click - If Document_Path <> "" Then + If Windream_Document_Path <> "" Then Cursor = Cursors.WaitCursor Dim sei As New SHELLEXECUTEINFO sei.cbSize = Marshal.SizeOf(sei) sei.lpVerb = "properties" - sei.lpFile = Document_Path + sei.lpFile = Filesystem_Document_Path sei.nShow = SW_SHOW sei.fMask = SEE_MASK_INVOKEIDLIST If Not ShellExecuteEx(sei) Then @@ -3364,8 +3376,8 @@ Public Class frmValidator End Sub Private Sub frmValidation_ResizeEnd(sender As Object, e As EventArgs) Handles Me.ResizeEnd - If Document_Path Is Nothing = False Then - Select Case Path.GetExtension(Document_Path).ToLower + If Windream_Document_Path Is Nothing = False Then + Select Case Path.GetExtension(Windream_Document_Path).ToLower Case ".pdf" Select Case vpdfviewer Case "internal" @@ -3440,7 +3452,7 @@ Public Class frmValidator Private Sub ToolStripButtonAnnotation_Click(sender As Object, e As EventArgs) Handles ToolStripButtonAnnotation.Click PdfViewer1.CloseDocument() - Close_PDF_Viewer(Document_Path) + Close_PDF_Viewer(Windream_Document_Path) Application.DoEvents() frmAnnotations.ShowDialog()