From 080a711067d9e356a8bccbb3722b7b24da499457 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Wed, 2 Aug 2023 08:11:40 +0200 Subject: [PATCH] Multiselect --- .../Classes/ClassTreeListViewState.vb | 103 +++ .../Classes/ClassWindreamDocGrid.vb | 44 +- .../ModuleRuntimeVariables.vb | 3 +- app/DD-Record-Organizer/OrgFlow.vbproj | 1 + app/DD-Record-Organizer/frmDocRecordLink.vb | 172 +++-- app/DD-Record-Organizer/frmDoc_Links.vb | 94 ++- app/DD-Record-Organizer/frmEntities.vb | 22 +- .../frmNodeNavigation.Designer.vb | 30 +- .../frmNodeNavigation.resx | 3 - app/DD-Record-Organizer/frmNodeNavigation.vb | 587 ++++++++---------- 10 files changed, 636 insertions(+), 423 deletions(-) create mode 100644 app/DD-Record-Organizer/Classes/ClassTreeListViewState.vb diff --git a/app/DD-Record-Organizer/Classes/ClassTreeListViewState.vb b/app/DD-Record-Organizer/Classes/ClassTreeListViewState.vb new file mode 100644 index 0000000..3542ced --- /dev/null +++ b/app/DD-Record-Organizer/Classes/ClassTreeListViewState.vb @@ -0,0 +1,103 @@ +Imports DevExpress.XtraTreeList +Imports DevExpress.XtraTreeList.Nodes +Imports DevExpress.XtraTreeList.Nodes.Operations + +Public Class ClassTreeListViewState + Private expanded As ArrayList + Private selected As ArrayList + Private focused As Object + Private topNode As Object + + Public Sub New() + Me.New(Nothing) + End Sub + Public Sub New(ByVal treeList As TreeList) + Me.treeList_Renamed = treeList + expanded = New ArrayList() + selected = New ArrayList() + End Sub + + Public Sub Clear() + expanded.Clear() + selected.Clear() + focused = Nothing + topNode = Nothing + End Sub + Private Function GetExpanded() As ArrayList + Dim op As New OperationSaveExpanded() + TreeList.NodesIterator.DoOperation(op) + Return op.Nodes + End Function + Private Function GetSelected() As ArrayList + Dim al As New ArrayList() + For Each node As TreeListNode In TreeList.Selection + al.Add(node.GetValue(TreeList.KeyFieldName)) + Next node + Return al + End Function + + Public Sub LoadState() + TreeList.BeginUpdate() + Try + TreeList.CollapseAll() + Dim node As TreeListNode + For Each key As Object In expanded + node = TreeList.FindNodeByKeyID(key) + If node IsNot Nothing Then + node.Expanded = True + End If + Next key + TreeList.FocusedNode = TreeList.FindNodeByKeyID(focused) + For Each key As Object In selected + node = TreeList.FindNodeByKeyID(key) + If node IsNot Nothing Then + TreeList.Selection.Add(node) + End If + Next key + + Finally + TreeList.EndUpdate() + Dim topVisibleNode As TreeListNode = TreeList.FindNodeByKeyID(topNode) + If topVisibleNode Is Nothing Then + topVisibleNode = TreeList.FocusedNode + End If + TreeList.TopVisibleNodeIndex = TreeList.GetVisibleIndexByNode(topVisibleNode) + End Try + End Sub + Public Sub SaveState() + If TreeList.FocusedNode IsNot Nothing Then + expanded = GetExpanded() + selected = GetSelected() + focused = TreeList.FocusedNode(TreeList.KeyFieldName) + topNode = TreeList.GetNodeByVisibleIndex(TreeList.TopVisibleNodeIndex)(TreeList.KeyFieldName) + Else + Clear() + End If + End Sub + + Private treeList_Renamed As TreeList + Public Property TreeList() As TreeList + Get + Return treeList_Renamed + End Get + Set(ByVal value As TreeList) + treeList_Renamed = value + Clear() + End Set + End Property + + Private Class OperationSaveExpanded + Inherits TreeListOperation + Private al As New ArrayList() + Public Overrides Sub Execute(ByVal node As TreeListNode) + If node.HasChildren AndAlso node.Expanded Then + al.Add(node.GetValue(node.TreeList.KeyFieldName)) + End If + End Sub + Public ReadOnly Property Nodes() As ArrayList + Get + Return al + End Get + End Property + End Class +End Class \ No newline at end of file diff --git a/app/DD-Record-Organizer/Classes/ClassWindreamDocGrid.vb b/app/DD-Record-Organizer/Classes/ClassWindreamDocGrid.vb index cca39fa..1d4883f 100644 --- a/app/DD-Record-Organizer/Classes/ClassWindreamDocGrid.vb +++ b/app/DD-Record-Organizer/Classes/ClassWindreamDocGrid.vb @@ -8,6 +8,35 @@ Imports DevExpress.XtraGrid.Views.Base Imports DevExpress.XtraEditors.Controls Public Class ClassWindreamDocGrid + ' === BEGIN CLASS PART === + + Public Class WindreamDoc + Public Property DocId As Integer + Public Property DocPath As String + Public Property DisplayName As String + Public Property DocType As String + End Class + + Private ReadOnly GridView As GridView + + Public ReadOnly Property SelectedDocuments As List(Of WindreamDoc) + Get + Return GetSelectedDocuments(GridView) + End Get + End Property + + Public ReadOnly Property HasSelectedDocuments As Boolean + Get + Return HasNoSelectedDocuments(GridView) + End Get + End Property + + Public Sub New(pGridView As GridView) + GridView = pGridView + End Sub + + ' === END CLASS PART === + Private Shared _Helper As ClassHelper Public Shared SELECTED_DOC_PATH As String 'Public Shared RESULT_OBJECTTYPE As String @@ -31,12 +60,6 @@ Public Class ClassWindreamDocGrid Private Shared _textValueChangedHandler As EventHandler Private Shared _checkValueChangedHandler As EventHandler - Public Class WindreamDoc - Public Property DocId As Integer - Public Property DocPath As String - Public Property DisplayName As String - End Class - Private Shared Function Init_Table() Try Dim table As New DataTable With { @@ -60,7 +83,12 @@ Public Class ClassWindreamDocGrid End Function - Public Shared Function GetSelectedDocuments(pGridView As GridView) + Public Shared Function HasNoSelectedDocuments(pGridView As GridView) As Boolean + Dim oSelectedRows As List(Of Integer) = pGridView.GetSelectedRows().ToList() + Return oSelectedRows.Count = 0 + End Function + + Public Shared Function GetSelectedDocuments(pGridView As GridView) As List(Of WindreamDoc) Dim oSelectedRows As List(Of Integer) = pGridView.GetSelectedRows().ToList() Dim oDocuments As New List(Of WindreamDoc) @@ -68,10 +96,12 @@ Public Class ClassWindreamDocGrid Dim oDocId = pGridView.GetRowCellValue(oRowHandle, "DocID") Dim oDisplayName = pGridView.GetRowCellValue(oRowHandle, "Displayname") Dim oDocPath = pGridView.GetRowCellValue(oRowHandle, "FULLPATH") + Dim oDocType = pGridView.GetRowCellValue(oRowHandle, "OBJECTTYPE") oDocuments.Add(New WindreamDoc With { .DocId = oDocId, .DocPath = oDocPath, + .DocType = oDocType, .DisplayName = oDisplayName }) Next diff --git a/app/DD-Record-Organizer/ModuleRuntimeVariables.vb b/app/DD-Record-Organizer/ModuleRuntimeVariables.vb index eb43373..1ed4fd0 100644 --- a/app/DD-Record-Organizer/ModuleRuntimeVariables.vb +++ b/app/DD-Record-Organizer/ModuleRuntimeVariables.vb @@ -66,7 +66,6 @@ Module ModuleRuntimeVariables Public CURRENT_NOTIFICATION_MSG As String Public CURRENT_ENTITY_ID As Integer - Public CURRENT_LINK_ENTITY_ID As Integer = 0 Public CURRENT_FORMVIEW_ID As Integer Public CURRENT_REDUNDANT_FORM_ID As Integer Public CURRENT_REDUNDANT_FORMVIEW_ID As Integer @@ -140,7 +139,7 @@ Module ModuleRuntimeVariables Public CURRENT_SEARCH_TYPE As String = "RECORD" Public CURRENT_FULLTEXT_PATTERN As String - Public CURRENT_DT_SELECTED_FILES As DataTable + Public Property CURRENT_DT_SELECTED_FILES As DataTable Public MASS_RECORD_IDs2CHANGE As ArrayList Public MASS_COLUMN_LIST As ArrayList diff --git a/app/DD-Record-Organizer/OrgFlow.vbproj b/app/DD-Record-Organizer/OrgFlow.vbproj index dcbaf2c..5bcf5e6 100644 --- a/app/DD-Record-Organizer/OrgFlow.vbproj +++ b/app/DD-Record-Organizer/OrgFlow.vbproj @@ -268,6 +268,7 @@ + diff --git a/app/DD-Record-Organizer/frmDocRecordLink.vb b/app/DD-Record-Organizer/frmDocRecordLink.vb index eb18bb7..99ab4c9 100644 --- a/app/DD-Record-Organizer/frmDocRecordLink.vb +++ b/app/DD-Record-Organizer/frmDocRecordLink.vb @@ -2,7 +2,12 @@ Imports System.Text Imports DD_LIB_Standards Public Class frmDocRecordLink - Dim ENTITY_LOAD_ACTIVE As Boolean = False + + Public Property Documents As New List(Of ClassWindreamDocGrid.WindreamDoc) + + Private CURRENT_LINK_ENTITY_ID As Integer = 0 + Private ENTITY_LOAD_ACTIVE As Boolean = False + Private Class ClassEntity Public title As String Public id As Integer @@ -58,71 +63,140 @@ Public Class frmDocRecordLink grvwGrid.BestFitColumns() End Sub Private Sub frmDocRecordLink_Load(sender As Object, e As EventArgs) Handles Me.Load - ENTITY_LOAD_ACTIVE = True - If ClassWindreamDocGrid.DT_RESULTFILES.Rows.Count = 1 Then - txtFileInfo.Text = ClassWindreamDocGrid.DT_RESULTFILES.Rows(0).Item("DOC_PATH") - Else - txtFileInfo.Text = String.Format("{0} files selected for linking to record", ClassWindreamDocGrid.DT_RESULTFILES.Rows.Count) - End If - Try - If IsNothing(CURRENT_DT_ENTITY_RECORDS) Then - Me.Close() - End If - If CURRENT_LINK_ENTITY_ID = 0 Then - Refresh_Grid_Data(True, Nothing) - CURRENT_LINK_ENTITY_ID = CURRENT_ENTITY_ID + ' OLD WAY + If Documents.Count = 0 Then + ENTITY_LOAD_ACTIVE = True + If ClassWindreamDocGrid.DT_RESULTFILES.Rows.Count = 1 Then + txtFileInfo.Text = ClassWindreamDocGrid.DT_RESULTFILES.Rows(0).Item("DOC_PATH") Else - Dim DT_RESULT As DataTable - If CURRENT_LINK_ENTITY_ID = CURRENT_ENTITY_ID Then - DT_RESULT = CURRENT_DT_ENTITY_RECORDS - Else - DT_RESULT = ReturnDataforEntity(CURRENT_LINK_ENTITY_ID) + txtFileInfo.Text = String.Format("{0} files selected for linking to record", ClassWindreamDocGrid.DT_RESULTFILES.Rows.Count) + End If + Try + If IsNothing(CURRENT_DT_ENTITY_RECORDS) Then + Me.Close() End If + If CURRENT_LINK_ENTITY_ID = 0 Then + Refresh_Grid_Data(True, Nothing) + CURRENT_LINK_ENTITY_ID = CURRENT_ENTITY_ID + Else + Dim DT_RESULT As DataTable + If CURRENT_LINK_ENTITY_ID = CURRENT_ENTITY_ID Then + DT_RESULT = CURRENT_DT_ENTITY_RECORDS + Else + DT_RESULT = ReturnDataforEntity(CURRENT_LINK_ENTITY_ID) + End If - If Not IsNothing(DT_RESULT) Then - Refresh_Grid_Data(False, DT_RESULT) + If Not IsNothing(DT_RESULT) Then + Refresh_Grid_Data(False, DT_RESULT) + End If End If - End If - Dim DT_ENTITIES As DataTable = GetENTITIES() - Dim oSelectedIndex As Integer = 0 + Dim DT_ENTITIES As DataTable = GetENTITIES() + Dim oSelectedIndex As Integer = 0 - If DT_ENTITIES.Rows.Count = 0 Then - Exit Sub - End If - Dim oCount = 0 - For Each row As DataRow In DT_ENTITIES.Rows - Dim entity As New ClassEntity - entity.title = row.Item("FORM_TITLE") - entity.id = row.Item("FORM_ID") - cmbConstructorForms.Items.Add(entity) - If CURRENT_LINK_ENTITY_ID = entity.id Then - txtcurrSichtData.Text = entity.title - oSelectedIndex = oCount + If DT_ENTITIES.Rows.Count = 0 Then + Exit Sub End If - oCount += 1 - Next - If USER_LANGUAGE = "de-DE" Then - Me.Text = CURRENT_DT_SELECTED_FILES.Rows.Count.ToString & " Datei(en) mit Datensatz verknüpfen:" + Dim oCount = 0 + For Each row As DataRow In DT_ENTITIES.Rows + Dim entity As New ClassEntity + entity.title = row.Item("FORM_TITLE") + entity.id = row.Item("FORM_ID") + cmbConstructorForms.Items.Add(entity) + If CURRENT_LINK_ENTITY_ID = entity.id Then + txtcurrSichtData.Text = entity.title + oSelectedIndex = oCount + End If + oCount += 1 + Next + If USER_LANGUAGE = "de-DE" Then + Me.Text = CURRENT_DT_SELECTED_FILES.Rows.Count.ToString & " Datei(en) mit Datensatz verknüpfen:" + Else + Me.Text = "Link " & CURRENT_DT_SELECTED_FILES.Rows.Count.ToString & " files with record:" + End If + ' Den index der aktuell geöffneten ConstructorForm setzen + cmbConstructorForms.SelectedIndex = oSelectedIndex + + Catch ex As Exception + ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error in frmDocRecordLink_Load", ex.Message, ex.StackTrace) + End Try + + Load_DocGrid_Layout() + bsiInfo.Caption = "Waiting for record-Selection....." + + + End If + + If Documents.Count > 0 Then + ENTITY_LOAD_ACTIVE = True + If Documents.Count = 1 Then + txtFileInfo.Text = Documents.First.DocPath Else - Me.Text = "Link " & CURRENT_DT_SELECTED_FILES.Rows.Count.ToString & " files with record:" + txtFileInfo.Text = String.Format("{0} files selected for linking to record", Documents.Count) End If - ' Den index der aktuell geöffneten ConstructorForm setzen - cmbConstructorForms.SelectedIndex = oSelectedIndex + Try + If IsNothing(CURRENT_DT_ENTITY_RECORDS) Then + Me.Close() + End If + If CURRENT_LINK_ENTITY_ID = 0 Then + Refresh_Grid_Data(True, Nothing) + CURRENT_LINK_ENTITY_ID = CURRENT_ENTITY_ID + Else + Dim DT_RESULT As DataTable + If CURRENT_LINK_ENTITY_ID = CURRENT_ENTITY_ID Then + DT_RESULT = CURRENT_DT_ENTITY_RECORDS + Else + DT_RESULT = ReturnDataforEntity(CURRENT_LINK_ENTITY_ID) + End If - Catch ex As Exception - ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error in frmDocRecordLink_Load", ex.Message, ex.StackTrace) - End Try + If Not IsNothing(DT_RESULT) Then + Refresh_Grid_Data(False, DT_RESULT) + End If + End If + + + Dim DT_ENTITIES As DataTable = GetENTITIES() + Dim oSelectedIndex As Integer = 0 + + If DT_ENTITIES.Rows.Count = 0 Then + Exit Sub + End If + Dim oCount = 0 + For Each row As DataRow In DT_ENTITIES.Rows + Dim entity As New ClassEntity + entity.title = row.Item("FORM_TITLE") + entity.id = row.Item("FORM_ID") + cmbConstructorForms.Items.Add(entity) + If CURRENT_LINK_ENTITY_ID = entity.id Then + txtcurrSichtData.Text = entity.title + oSelectedIndex = oCount + End If + oCount += 1 + Next + If USER_LANGUAGE = "de-DE" Then + Me.Text = CURRENT_DT_SELECTED_FILES.Rows.Count.ToString & " Datei(en) mit Datensatz verknüpfen:" + Else + Me.Text = "Link " & CURRENT_DT_SELECTED_FILES.Rows.Count.ToString & " files with record:" + End If + ' Den index der aktuell geöffneten ConstructorForm setzen + cmbConstructorForms.SelectedIndex = oSelectedIndex + + Catch ex As Exception + ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error in frmDocRecordLink_Load", ex.Message, ex.StackTrace) + End Try + + Load_DocGrid_Layout() + bsiInfo.Caption = "Waiting for record-Selection....." + + End If - Load_DocGrid_Layout() - bsiInfo.Caption = "Waiting for record-Selection....." End Sub Private Function GetENTITIES() As DataTable Try Dim SQL As String = String.Format("SELECT DISTINCT FORM_ID,FORM_TITLE,SEQUENCE FROM VWPMO_CONSTRUCTOR_FORMS where CONSTRUCT_ID in " & "(SELECT CONSTRUCT_ID FROM TBPMO_CONSTRUCTOR_USER WHERE USER_ID = {0}) ORDER BY SEQUENCE", USER_GUID) - Dim dt As DataTable = MYDB_ECM.GetDatatable(sql) + Dim dt As DataTable = MYDB_ECM.GetDatatable(SQL) Return dt Catch ex As Exception MsgBox("Entities could not be loaded in LinkToRecord: " & vbNewLine & ex.Message) diff --git a/app/DD-Record-Organizer/frmDoc_Links.vb b/app/DD-Record-Organizer/frmDoc_Links.vb index 0a01a88..3547d02 100644 --- a/app/DD-Record-Organizer/frmDoc_Links.vb +++ b/app/DD-Record-Organizer/frmDoc_Links.vb @@ -3,16 +3,29 @@ Imports DD_LIB_Standards Imports DevExpress.XtraPrinting Public Class frmDoc_Links + Public Property Documents As New List(Of ClassWindreamDocGrid.WindreamDoc) + Private Sub frmDoc_DocLinks_Load(sender As Object, e As EventArgs) Handles Me.Load Try + Refresh_Grid_Data(Documents) - Refresh_Grid_Data() - If ClassWindreamDocGrid.DT_RESULTFILES.Rows.Count = 1 Then - Me.Text = $"Document-Links for file: {ClassWindreamDocGrid.DT_RESULTFILES.Rows(0).Item("DOC_PATH")}" + ' TODO: this does not work for the old form + If Documents.Count = 0 Then + Text = $"Document-Links for: NODOC-ID" + ElseIf Documents.Count = 1 Then + Text = $"Document-Links for: {Documents.First.DocPath}" Else - Me.Text = $"Document-Links for file: NODOC-ID" + Text = $"Document-Links for {Documents.Count} files" End If + + 'If ClassWindreamDocGrid.DT_RESULTFILES.Rows.Count = 1 Then + ' Me.Text = $"Document-Links for file: {ClassWindreamDocGrid.DT_RESULTFILES.Rows(0).Item("DOC_PATH")}" + 'Else + ' Me.Text = $"Document-Links for file: NODOC-ID" + 'End If + bbtnitmdeletelink.Enabled = False + Select Case CURRENT_FILE_RIGHT Case "RW" bbtnitmdeletelink.Enabled = True @@ -23,22 +36,44 @@ Public Class frmDoc_Links ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error in frmDoc_DocLinks_Load", ex.Message, ex.StackTrace) End Try End Sub - Sub Refresh_Grid_Data() + + Private Function Get_Grid_Data(pDocuments As List(Of ClassWindreamDocGrid.WindreamDoc)) As DataTable + Dim oTable As DataTable + Dim oSql As String = "" + + If pDocuments.Count > 0 Then + Dim oIds = String.Join(",", pDocuments.Select(Function(d) d.DocId).ToArray()) + oSql = $"SELECT * FROM VWPMO_CUST_DOC_OBJECT_LINKS WHERE DocID IN ({oIds})" + oTable = MYDB_ECM.GetDatatable(oSql) + Else + oSql = $"select * FROM VWPMO_CUST_DOC_OBJECT_LINKS WHERE DocID = {CURRENT_DOC_ID}" + oTable = MYDB_ECM.GetDatatable(oSql) + End If + + If oTable Is Nothing Then + LOGGER.Error("Please check your link-object-relation: {0}", oSql) + End If + + Return oTable + End Function + + Sub Refresh_Grid_Data(pDocuments As List(Of ClassWindreamDocGrid.WindreamDoc)) Try - Dim DT_RECORDS As DataTable - Dim oSql = $"select * FROM VWPMO_CUST_DOC_OBJECT_LINKS WHERE DocID = {CURRENT_DOC_ID}" - DT_RECORDS = MYDB_ECM.GetDatatable(oSql) - If Not IsNothing(DT_RECORDS) Then - BarStaticItemStatus.Caption = $"{DT_RECORDS.Rows.Count} links for Document found!" + Dim oTable = Get_Grid_Data(pDocuments) + + If Not IsNothing(oTable) Then + BarStaticItemStatus.Caption = $"{oTable.Rows.Count} links for Document found!" grvwGrid.Columns.Clear() - GridControlRecords.DataSource = DT_RECORDS + GridControlRecords.DataSource = oTable 'grvwGrid.Columns.Item("already linked").Fixed = True Try grvwGrid.Columns.Item("DocID").Visible = False grvwGrid.Columns.Item("RecordID").Visible = False 'grvwGrid.Columns.Item("FULL_FILENAME").Visible = False Try - grvwGrid.Columns.Item("VALUE").Visible = False + If grvwGrid.Columns.Item("VALUE") IsNot Nothing Then + grvwGrid.Columns.Item("VALUE").Visible = False + End If Catch ex1 As Exception LOGGER.Warn("Column VALUE not part of VWPMO_CUST_DOC_OBJECT_LINKS" & ex1.Message) End Try @@ -49,16 +84,17 @@ Public Class frmDoc_Links End Try GridControlRecords.RefreshDataSource() - 'If DT_RECORDS.Rows.Count > 10000 Then + 'If oTable.Rows.Count > 10000 Then ' BarButtonItem2.Enabled = False 'Else ' BarButtonItem2.Enabled = True 'End If Else - MsgBox($"Please check Your link-object-relation: {oSql}", MsgBoxStyle.Exclamation) + MsgBox($"Please check Your link-object-relation", MsgBoxStyle.Exclamation) End If Catch ex As Exception + LOGGER.Error(ex) ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error in Sub Refresh_Grid_Data", ex.Message, ex.StackTrace) End Try @@ -86,22 +122,25 @@ Public Class frmDoc_Links End Try Next - Refresh_Grid_Data() + Refresh_Grid_Data(Documents) End Sub Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick Try - Dim saveFileDialogDocSearchResult As New SaveFileDialog - saveFileDialogDocSearchResult.Filter = "Excel File|*.xlsx" - saveFileDialogDocSearchResult.Title = "Export to Excel:" + Dim saveFileDialogDocSearchResult As New SaveFileDialog With { + .Filter = "Excel File|*.xlsx", + .Title = "Export to Excel:" + } saveFileDialogDocSearchResult.ShowDialog() + If saveFileDialogDocSearchResult.FileName <> "" Then - Dim oOptions As XlsxExportOptionsEx = New XlsxExportOptionsEx - oOptions.ShowGridLines = True - oOptions.AllowSortingAndFiltering = DevExpress.Utils.DefaultBoolean.True - oOptions.ExportType = DevExpress.Export.ExportType.DataAware - oOptions.ExportMode = XlsxExportMode.SingleFile - oOptions.AllowFixedColumnHeaderPanel = DevExpress.Utils.DefaultBoolean.True + Dim oOptions As New XlsxExportOptionsEx With { + .ShowGridLines = True, + .AllowSortingAndFiltering = DevExpress.Utils.DefaultBoolean.True, + .ExportType = DevExpress.Export.ExportType.DataAware, + .ExportMode = XlsxExportMode.SingleFile, + .AllowFixedColumnHeaderPanel = DevExpress.Utils.DefaultBoolean.True + } Cursor = Cursors.WaitCursor GridControlRecords.MainView.ExportToXlsx(saveFileDialogDocSearchResult.FileName, oOptions) @@ -118,21 +157,18 @@ Public Class frmDoc_Links End If Catch ex As Exception + LOGGER.Error(ex) MsgBox("Unexpected Error in ExportExcel: " & ex.Message, MsgBoxStyle.Critical) End Try Cursor = Cursors.Default End Sub - Private Sub frmDoc_Links_MaximizedBoundsChanged(sender As Object, e As EventArgs) Handles MyBase.MaximizedBoundsChanged - - End Sub - Private Sub frmDoc_Links_SizeChanged(sender As Object, e As EventArgs) Handles Me.SizeChanged Try grvwGrid.OptionsView.ColumnAutoWidth = False grvwGrid.BestFitColumns() Catch ex As Exception - + LOGGER.Error(ex) End Try End Sub diff --git a/app/DD-Record-Organizer/frmEntities.vb b/app/DD-Record-Organizer/frmEntities.vb index 448a1fc..88702ab 100644 --- a/app/DD-Record-Organizer/frmEntities.vb +++ b/app/DD-Record-Organizer/frmEntities.vb @@ -422,16 +422,22 @@ Public Class frmEntities End Sub Private Sub BW_Entity_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BW_Entity.RunWorkerCompleted - ProgressPanel1.Visible = False - btncancel.Visible = False - If Not IsNothing(DT_RESULT) Then - Dim result = DT_RESULT.Rows(0).Item(0) - If result <> 0 Then - MsgBox("Unexpected Error in Executing Procedure - Check the log!", MsgBoxStyle.Critical) - Else - MsgBox("Procedure was executed successfully!", MsgBoxStyle.Information) + If e.Error IsNot Nothing Then + MsgBox("Unexpected Error in Executing Procedure - Check the log!", MsgBoxStyle.Critical, Text) + LOGGER.Error(e.Error) + Else + If Not IsNothing(DT_RESULT) Then + Dim result = DT_RESULT.Rows(0).Item(0) + If result <> 0 Then + MsgBox("Unexpected Error in Executing Procedure - Check the log!", MsgBoxStyle.Critical, Text) + Else + MsgBox("Procedure was executed successfully!", MsgBoxStyle.Information, Text) + End If End If End If + + ProgressPanel1.Visible = False + btncancel.Visible = False End Sub Private Sub btncancel_Click(sender As Object, e As EventArgs) Handles btncancel.Click diff --git a/app/DD-Record-Organizer/frmNodeNavigation.Designer.vb b/app/DD-Record-Organizer/frmNodeNavigation.Designer.vb index 2544c1f..fb7cd2e 100644 --- a/app/DD-Record-Organizer/frmNodeNavigation.Designer.vb +++ b/app/DD-Record-Organizer/frmNodeNavigation.Designer.vb @@ -24,7 +24,7 @@ Partial Class frmNodeNavigation Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmNodeNavigation)) - Dim GridLevelNode2 As DevExpress.XtraGrid.GridLevelNode = New DevExpress.XtraGrid.GridLevelNode() + Dim GridLevelNode1 As DevExpress.XtraGrid.GridLevelNode = New DevExpress.XtraGrid.GridLevelNode() Me.ribbonNodeNavigation = New DevExpress.XtraBars.Ribbon.RibbonControl() Me.bbtnitmRecEdit = New DevExpress.XtraBars.BarButtonItem() Me.bsiInfo = New DevExpress.XtraBars.BarStaticItem() @@ -113,7 +113,7 @@ Partial Class frmNodeNavigation Me.ribbonNodeNavigation.ShowExpandCollapseButton = DevExpress.Utils.DefaultBoolean.[True] Me.ribbonNodeNavigation.ShowMoreCommandsButton = DevExpress.Utils.DefaultBoolean.[False] Me.ribbonNodeNavigation.ShowToolbarCustomizeItem = False - Me.ribbonNodeNavigation.Size = New System.Drawing.Size(1307, 147) + Me.ribbonNodeNavigation.Size = New System.Drawing.Size(1307, 158) Me.ribbonNodeNavigation.StatusBar = Me.RibbonStatusBar1 Me.ribbonNodeNavigation.Toolbar.ShowCustomizeItem = False ' @@ -271,10 +271,10 @@ Partial Class frmNodeNavigation Me.RibbonStatusBar1.ItemLinks.Add(Me.bsitmRecordID) Me.RibbonStatusBar1.ItemLinks.Add(Me.BarStaticItemLocked) Me.RibbonStatusBar1.ItemLinks.Add(Me.bsitmtInfoDoc) - Me.RibbonStatusBar1.Location = New System.Drawing.Point(0, 821) + Me.RibbonStatusBar1.Location = New System.Drawing.Point(0, 822) Me.RibbonStatusBar1.Name = "RibbonStatusBar1" Me.RibbonStatusBar1.Ribbon = Me.ribbonNodeNavigation - Me.RibbonStatusBar1.Size = New System.Drawing.Size(1307, 23) + Me.RibbonStatusBar1.Size = New System.Drawing.Size(1307, 22) ' 'RibbonPage2 ' @@ -284,7 +284,7 @@ Partial Class frmNodeNavigation 'SplitContainerMain ' Me.SplitContainerMain.Dock = System.Windows.Forms.DockStyle.Fill - Me.SplitContainerMain.Location = New System.Drawing.Point(0, 147) + Me.SplitContainerMain.Location = New System.Drawing.Point(0, 158) Me.SplitContainerMain.Name = "SplitContainerMain" ' 'SplitContainerMain.Panel1 @@ -296,7 +296,7 @@ Partial Class frmNodeNavigation ' Me.SplitContainerMain.Panel2.Controls.Add(Me.SplitContainer1) Me.SplitContainerMain.Panel2.Text = "Panel2" - Me.SplitContainerMain.Size = New System.Drawing.Size(1307, 674) + Me.SplitContainerMain.Size = New System.Drawing.Size(1307, 664) Me.SplitContainerMain.SplitterPosition = 451 Me.SplitContainerMain.TabIndex = 2 ' @@ -332,7 +332,7 @@ Partial Class frmNodeNavigation Me.TreeListDevexpress.OptionsView.ShowTreeLines = DevExpress.Utils.DefaultBoolean.[False] Me.TreeListDevexpress.OptionsView.ShowVertLines = False Me.TreeListDevexpress.OptionsView.TreeLineStyle = DevExpress.XtraTreeList.LineStyle.Dark - Me.TreeListDevexpress.Size = New System.Drawing.Size(451, 674) + Me.TreeListDevexpress.Size = New System.Drawing.Size(451, 664) Me.TreeListDevexpress.StateImageList = Me.ImageCollection1 Me.TreeListDevexpress.TabIndex = 1 ' @@ -355,8 +355,8 @@ Partial Class frmNodeNavigation 'SplitContainer1.Panel2 ' Me.SplitContainer1.Panel2.Controls.Add(Me.GridControlDocSearch) - Me.SplitContainer1.Size = New System.Drawing.Size(844, 674) - Me.SplitContainer1.SplitterDistance = 219 + Me.SplitContainer1.Size = New System.Drawing.Size(846, 664) + Me.SplitContainer1.SplitterDistance = 215 Me.SplitContainer1.TabIndex = 0 ' 'pnlControls @@ -366,7 +366,7 @@ Partial Class frmNodeNavigation Me.pnlControls.Dock = System.Windows.Forms.DockStyle.Fill Me.pnlControls.Location = New System.Drawing.Point(0, 0) Me.pnlControls.Name = "pnlControls" - Me.pnlControls.Size = New System.Drawing.Size(844, 219) + Me.pnlControls.Size = New System.Drawing.Size(846, 215) Me.pnlControls.TabIndex = 0 ' 'GridControlDocSearch @@ -374,12 +374,12 @@ Partial Class frmNodeNavigation Me.GridControlDocSearch.AllowDrop = True Me.GridControlDocSearch.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center Me.GridControlDocSearch.Dock = System.Windows.Forms.DockStyle.Fill - GridLevelNode2.RelationName = "Level1" - Me.GridControlDocSearch.LevelTree.Nodes.AddRange(New DevExpress.XtraGrid.GridLevelNode() {GridLevelNode2}) + GridLevelNode1.RelationName = "Level1" + Me.GridControlDocSearch.LevelTree.Nodes.AddRange(New DevExpress.XtraGrid.GridLevelNode() {GridLevelNode1}) Me.GridControlDocSearch.Location = New System.Drawing.Point(0, 0) Me.GridControlDocSearch.MainView = Me.GridViewDoc_Search Me.GridControlDocSearch.Name = "GridControlDocSearch" - Me.GridControlDocSearch.Size = New System.Drawing.Size(844, 451) + Me.GridControlDocSearch.Size = New System.Drawing.Size(846, 445) Me.GridControlDocSearch.TabIndex = 8 Me.GridControlDocSearch.TabStop = False Me.GridControlDocSearch.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.GridViewDoc_Search}) @@ -393,13 +393,15 @@ Partial Class frmNodeNavigation Me.GridViewDoc_Search.GridControl = Me.GridControlDocSearch Me.GridViewDoc_Search.LevelIndent = 10 Me.GridViewDoc_Search.Name = "GridViewDoc_Search" + Me.GridViewDoc_Search.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown Me.GridViewDoc_Search.OptionsClipboard.CopyColumnHeaders = DevExpress.Utils.DefaultBoolean.[False] Me.GridViewDoc_Search.OptionsDetail.ShowDetailTabs = False Me.GridViewDoc_Search.OptionsSelection.EnableAppearanceFocusedCell = False Me.GridViewDoc_Search.OptionsSelection.EnableAppearanceFocusedRow = False Me.GridViewDoc_Search.OptionsSelection.EnableAppearanceHideSelection = False Me.GridViewDoc_Search.OptionsSelection.MultiSelect = True - Me.GridViewDoc_Search.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CellSelect + Me.GridViewDoc_Search.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect + Me.GridViewDoc_Search.OptionsSelection.ResetSelectionClickOutsideCheckboxSelector = True Me.GridViewDoc_Search.OptionsView.ColumnAutoWidth = False Me.GridViewDoc_Search.OptionsView.EnableAppearanceEvenRow = True Me.GridViewDoc_Search.OptionsView.ShowAutoFilterRow = True diff --git a/app/DD-Record-Organizer/frmNodeNavigation.resx b/app/DD-Record-Organizer/frmNodeNavigation.resx index 557aaa5..cc85f24 100644 --- a/app/DD-Record-Organizer/frmNodeNavigation.resx +++ b/app/DD-Record-Organizer/frmNodeNavigation.resx @@ -429,9 +429,6 @@ 17, 17 - - 17, 17 - diff --git a/app/DD-Record-Organizer/frmNodeNavigation.vb b/app/DD-Record-Organizer/frmNodeNavigation.vb index 2f7b7f6..2484929 100644 --- a/app/DD-Record-Organizer/frmNodeNavigation.vb +++ b/app/DD-Record-Organizer/frmNodeNavigation.vb @@ -14,28 +14,9 @@ Imports System.IO Imports System.Runtime.InteropServices Imports DD_LIB_Standards Imports DigitalData.Modules.Base +Imports DigitalData.Modules.Logging Public Class frmNodeNavigation - - Public Shared Function ShellExecuteEx(ByRef lpExecInfo As SHELLEXECUTEINFO) As Boolean - End Function - Public Structure SHELLEXECUTEINFO - Public cbSize As Integer - Public fMask As Integer - Public hwnd As IntPtr - Public lpVerb As String - Public lpFile As String - Public lpParameters As String - Public lpDirectory As String - Dim nShow As Integer - Dim hInstApp As IntPtr - Dim lpIDList As IntPtr - Public lpClass As String - Public hkeyClass As IntPtr - Public dwHotKey As Integer - Public hIcon As IntPtr - Public hProcess As IntPtr - End Structure #Region "Laufzeitvariablen & Konstanten" Dim DT_STRUCTURE_NODES As DataTable Dim DT_ADDING_USERS As DataTable @@ -60,6 +41,8 @@ Public Class frmNodeNavigation Delete End Enum + Private WindowsEx As WindowsEx + Private DT_CONTROLS_ENTITY As DataTable Private DT_COLUMNS_GRID_ENTITY As DataTable Private DT_DOCRESULT_DROPDOWN_ITEMS As DataTable @@ -94,121 +77,26 @@ Public Class frmNodeNavigation Public Const SW_SHOW As Short = 5 Private CONTROL_DOCTYPE_MATCH As Integer = 0 Private FocusedNode As TreeListNode - Private MyTreeListViewState As TreeListViewState + Private MyTreeListViewState As ClassTreeListViewState #End Region - Public Class TreeListViewState - Private expanded As ArrayList - Private selected As ArrayList - Private focused As Object - Private topNode As Object - - Public Sub New() - Me.New(Nothing) - End Sub - Public Sub New(ByVal treeList As TreeList) - Me.treeList_Renamed = treeList - expanded = New ArrayList() - selected = New ArrayList() - End Sub - Public Sub Clear() - expanded.Clear() - selected.Clear() - focused = Nothing - topNode = Nothing - End Sub - Private Function GetExpanded() As ArrayList - Dim op As New OperationSaveExpanded() - TreeList.NodesIterator.DoOperation(op) - Return op.Nodes - End Function - Private Function GetSelected() As ArrayList - Dim al As New ArrayList() - For Each node As TreeListNode In TreeList.Selection - al.Add(node.GetValue(TreeList.KeyFieldName)) - Next node - Return al - End Function - Public Sub LoadState() - TreeList.BeginUpdate() - Try - TreeList.CollapseAll() - Dim node As TreeListNode - For Each key As Object In expanded - node = TreeList.FindNodeByKeyID(key) - If node IsNot Nothing Then - node.Expanded = True - End If - Next key - TreeList.FocusedNode = TreeList.FindNodeByKeyID(focused) - For Each key As Object In selected - node = TreeList.FindNodeByKeyID(key) - If node IsNot Nothing Then - TreeList.Selection.Add(node) - End If - Next key + Private DocList As ClassWindreamDocGrid - Finally - TreeList.EndUpdate() - Dim topVisibleNode As TreeListNode = TreeList.FindNodeByKeyID(topNode) - If topVisibleNode Is Nothing Then - topVisibleNode = TreeList.FocusedNode - End If - TreeList.TopVisibleNodeIndex = TreeList.GetVisibleIndexByNode(topVisibleNode) - End Try - End Sub - Public Sub SaveState() - If TreeList.FocusedNode IsNot Nothing Then - expanded = GetExpanded() - selected = GetSelected() - focused = TreeList.FocusedNode(TreeList.KeyFieldName) - topNode = TreeList.GetNodeByVisibleIndex(TreeList.TopVisibleNodeIndex)(TreeList.KeyFieldName) - Else - Clear() - End If - End Sub - - Private treeList_Renamed As TreeList - Public Property TreeList() As TreeList - Get - Return treeList_Renamed - End Get - Set(ByVal value As TreeList) - treeList_Renamed = value - Clear() - End Set - End Property - - Private Class OperationSaveExpanded - Inherits TreeListOperation - Private al As New ArrayList() - Public Overrides Sub Execute(ByVal node As TreeListNode) - If node.HasChildren AndAlso node.Expanded Then - al.Add(node.GetValue(node.TreeList.KeyFieldName)) - End If - End Sub - Public ReadOnly Property Nodes() As ArrayList - Get - Return al - End Get - End Property - End Class - End Class Public Sub New(pEntityID As Int16, pConstructID As Int16) - ' Dieser Aufruf ist für den Designer erforderlich. InitializeComponent() ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. oEntityID = pEntityID oConstructID = pConstructID - + DocList = New ClassWindreamDocGrid(GridViewDoc_Search) + WindowsEx = New WindowsEx(LOGCONFIG) End Sub Private Function Get_Splitter_Layout_Filename() Dim Filename As String = String.Format("{0}-{1}-SplitterLayout.xml", CONSTRUCTOR_DETAIL_ID, CONSTRUCTOR_DETAIL_ID.ToString) - Return System.IO.Path.Combine(Application.UserAppDataPath(), Filename) + Return Path.Combine(Application.UserAppDataPath(), Filename) End Function Sub Save_Splitter_Layout() Try @@ -294,9 +182,10 @@ Public Class frmNodeNavigation Catch ex As System.Exception ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error", ex.Message, "Error in Loading Form part 4") End Try + Load_nodes() End Sub - Async Function Load_nodes() As Threading.Tasks.Task + Private Sub Load_nodes() Dim oHandle = SplashScreenManager.ShowOverlayForm(Me) Try @@ -345,12 +234,13 @@ Public Class frmNodeNavigation Catch ex As Exception + LOGGER.Error(ex) Finally SplashScreenManager.CloseOverlayForm(oHandle) End Try - End Function + End Sub Private Sub TreeListDevexpress_ColumnFilterChanged(sender As Object, e As EventArgs) Dim tree As TreeList = TryCast(sender, TreeList) Dim filteredColumns As List(Of TreeListColumn) = tree.Columns.Cast(Of TreeListColumn)().Where(Function(c) c.FilterInfo.AutoFilterRowValue IsNot Nothing).ToList() @@ -1847,15 +1737,12 @@ Public Class frmNodeNavigation Save_DocGrid_Layout() End Sub - - Private Sub GridViewDoc_Search_FocusedColumnChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedColumnChangedEventArgs) Handles GridViewDoc_Search.FocusedColumnChanged - - ClassWindreamDocGrid.GetDocItems(GridViewDoc_Search) + 'ClassWindreamDocGrid.GetDocItems(GridViewDoc_Search) Refresh_DocID() End Sub Private Sub GridViewDoc_Search_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles GridViewDoc_Search.FocusedRowChanged - ClassWindreamDocGrid.GetDocItems(GridViewDoc_Search) + 'ClassWindreamDocGrid.GetDocItems(GridViewDoc_Search) Refresh_DocID() End Sub @@ -2266,52 +2153,58 @@ Public Class frmNodeNavigation End If Me.Cursor = Cursors.WaitCursor - ClassWindreamDocGrid.GetDocItems(GridViewDoc_Search) - If IsNothing(ClassWindreamDocGrid.DT_RESULTFILES) Then + Dim oSelectedDocs = ClassWindreamDocGrid.GetSelectedDocuments(GridViewDoc_Search) + + 'Refresh_DocID() + + If ClassWindreamDocGrid.HasNoSelectedDocuments(GridViewDoc_Search) Then e.Cancel = True End If - Refresh_DocID() - If ClassWindreamDocGrid.DT_RESULTFILES.Rows.Count = 1 Then - If ClassWindreamDocGrid.DT_RESULTFILES.Rows(0).Item("DOC_ID") = 0 Then + + If oSelectedDocs.First.DocId = 0 Then + e.Cancel = True + End If + + If oSelectedDocs.Count > 1 Then + ContextMenu_Multiplefiles() + ElseIf oSelectedDocs.Count = 1 Then + File_in_Work() + Dim oSelectedDocument = oSelectedDocs.First + Dim Result = ClassDOC_SEARCH.Get_File_Rights(oSelectedDocument.DocId) + If Not IsNothing(Result) Then + ROW_READ_ONLY = False + Select Case Result.ToString + Case "R" + ContextMenu_Read() + Case "RW" + ContextMenu_Write() + Case "RWA" + ContextMenu_Write() + Case "" + If USER_IS_ADMIN = False Then + ContextMenu_Read() + Else + LOGGER.Warn("FileRight is '' but User is Admin!! - Check the configuration!") + End If + ROW_READ_ONLY = True + End Select + CURRENT_FILE_RIGHT = Result.ToString + Else + ContextMenu_Read() + ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error", "Error in Getting rights - check the log") e.Cancel = True End If - End If - File_in_Work() - Dim Result = ClassDOC_SEARCH.Get_File_Rights(ClassWindreamDocGrid.SELECTED_DOC_ID) - If Not IsNothing(Result) Then - ROW_READ_ONLY = False - Select Case Result.ToString - Case "R" - ContextMenu_Read() - Case "RW" - ContextMenu_Write() - Case "RWA" - ContextMenu_Write() - Case "" + If ROW_READ_ONLY = False Then + If RIGHT_READ_ONLY_DOC = True Then If USER_IS_ADMIN = False Then ContextMenu_Read() Else - LOGGER.Warn("FileRight is '' but User is Admin!! - Check the configuration!") + LOGGER.Warn("RIGHT_READ_ONLY_DOC = True but User is Admin!! - Check the configuration!") End If - ROW_READ_ONLY = True - End Select - CURRENT_FILE_RIGHT = Result.ToString - Else - ContextMenu_Read() - ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error", "Error in Getting rights - check the log") - e.Cancel = True - End If - If ROW_READ_ONLY = False Then - If RIGHT_READ_ONLY_DOC = True Then - If USER_IS_ADMIN = False Then - ContextMenu_Read() - Else - LOGGER.Warn("RIGHT_READ_ONLY_DOC = True but User is Admin!! - Check the configuration!") End If End If - End If - If ClassWindreamDocGrid.DT_RESULTFILES.Rows.Count = 1 Then - If ClassWindreamDocGrid.DT_RESULTFILES.Rows(0).Item("DISPLAYNAME") <> "" Then + + If oSelectedDocs.First.DisplayName <> "" Then tsmiFileRenameDisplayname.Visible = True Else tsmiFileRenameDisplayname.Visible = False @@ -2328,36 +2221,70 @@ Public Class frmNodeNavigation End Try End Sub + Sub ContextMenu_Multiplefiles() + tsmiFileProperties.Enabled = False + + tsmiFileOpen.Enabled = False + tsmiFileFolderOpen.Enabled = False + + tsmiFileInWork.Enabled = False + + tsmiFileLink_Add.Enabled = True + tsmiFileLink_ShowAll.Enabled = True + tsmiFileLinkRemove.Enabled = True + + tsmiFileRename.Enabled = False + tsmiFileVersion.Enabled = False + tsmiFileRightsShow.Enabled = False + + tsmiFileDelete.Enabled = False + End Sub Sub ContextMenu_Read() + tsmiFileProperties.Enabled = True + tsmiFileOpen.Enabled = True + tsmiFileFolderOpen.Enabled = True - tsmiFileRename.Enabled = False tsmiFileInWork.Enabled = False + tsmiFileLink_Add.Enabled = False tsmiFileLink_ShowAll.Enabled = True + tsmiFileLinkRemove.Enabled = False + + tsmiFileRename.Enabled = False + tsmiFileVersion.Enabled = True + tsmiFileRightsShow.Enabled = True tsmiFileDelete.Enabled = False - tsmiFileLinkRemove.Enabled = False End Sub Sub ContextMenu_Write() + tsmiFileProperties.Enabled = True + tsmiFileOpen.Enabled = True + tsmiFileFolderOpen.Enabled = True - tsmiFileRename.Enabled = True tsmiFileInWork.Enabled = True + tsmiFileLink_Add.Enabled = True tsmiFileLink_ShowAll.Enabled = True - - tsmiFileDelete.Enabled = True tsmiFileLinkRemove.Enabled = True + tsmiFileRename.Enabled = True + tsmiFileVersion.Enabled = True + tsmiFileRightsShow.Enabled = True + + tsmiFileDelete.Enabled = True End Sub Sub Open_File() Me.Cursor = Cursors.WaitCursor Dim allow_Open As Boolean = False - ClassWindreamDocGrid.GetDocItems(GridViewDoc_Search) + 'ClassWindreamDocGrid.GetDocItems(GridViewDoc_Search) + Dim Result = ClassDOC_SEARCH.Get_File_Rights(ClassWindreamDocGrid.SELECTED_DOC_ID) + + If Not IsNothing(Result) Then Select Case Result.ToString Case "R" @@ -2369,16 +2296,23 @@ Public Class frmNodeNavigation End Select End If If allow_Open = True Then - If IsNothing(ClassWindreamDocGrid.DT_RESULTFILES) Then + 'If IsNothing(ClassWindreamDocGrid.DT_RESULTFILES) Then + ' MsgBox("Could not read File Parameters(5)!", MsgBoxStyle.Exclamation) + ' Exit Sub + 'End If + If ClassWindreamDocGrid.HasNoSelectedDocuments(GridViewDoc_Search) Then MsgBox("Could not read File Parameters(5)!", MsgBoxStyle.Exclamation) Exit Sub End If - For Each row As DataRow In ClassWindreamDocGrid.DT_RESULTFILES.Rows - If ClassHelper.File_open(row.Item("DOC_PATH"), row.Item("DOC_ID")) = True Then + 'For Each row As DataRow In ClassWindreamDocGrid.DT_RESULTFILES.Rows + ' If ClassHelper.File_open(row.Item("DOC_PATH"), row.Item("DOC_ID")) = True Then + ' TimerFileHandle.Enabled = True + ' End If + 'Next + For Each oDoc As ClassWindreamDocGrid.WindreamDoc In ClassWindreamDocGrid.GetSelectedDocuments(GridViewDoc_Search) + If ClassHelper.File_open(oDoc.DocPath, oDoc.DocId) = True Then TimerFileHandle.Enabled = True End If - - Next Else If clsWD_GET.WDFile_exists(ClassWindreamDocGrid.SELECTED_DOC_PATH, DD_LIB_Standards.clsDatabase.DB_PROXY_INITIALIZED, ClassProxy.MyLinkedServer, True) = True Then @@ -2445,7 +2379,7 @@ Public Class frmNodeNavigation End Sub Private Sub tsmiFileInWork_Click(sender As Object, e As EventArgs) Handles tsmiFileInWork.Click - If IsNothing(ClassWindreamDocGrid.DT_RESULTFILES) Then + If ClassWindreamDocGrid.HasNoSelectedDocuments(GridViewDoc_Search) Then MsgBox("Could not read File Parameters (3)!", MsgBoxStyle.Exclamation) Exit Sub End If @@ -2482,15 +2416,30 @@ Public Class frmNodeNavigation Private Sub tsmiFileRenameDisplayname_Click(sender As Object, e As EventArgs) Handles tsmiFileRenameDisplayname.Click Try - If ClassWindreamDocGrid.DT_RESULTFILES.Rows.Count = 1 Then - If ClassWindreamDocGrid.DT_RESULTFILES.Rows(0).Item("DISPLAYNAME") <> "" Then - Dim oRowHandle As Integer = GridViewDoc_Search.FocusedRowHandle - Dim frm As New frmFileRename(1, ClassWindreamDocGrid.DT_RESULTFILES.Rows(0).Item("DISPLAYNAME"), "Displayname") - frm.ShowDialog() - RUN_WDSEARCH_GRID(True) - If Not IsNothing(oRowHandle) Then - GridViewDoc_Search.FocusedRowHandle = oRowHandle - End If + If ClassWindreamDocGrid.HasNoSelectedDocuments(GridViewDoc_Search) Then + Exit Sub + End If + + 'If ClassWindreamDocGrid.DT_RESULTFILES.Rows.Count = 1 Then + ' If ClassWindreamDocGrid.DT_RESULTFILES.Rows(0).Item("DISPLAYNAME") <> "" Then + ' Dim oRowHandle As Integer = GridViewDoc_Search.FocusedRowHandle + ' Dim frm As New frmFileRename(1, ClassWindreamDocGrid.DT_RESULTFILES.Rows(0).Item("DISPLAYNAME"), "Displayname") + ' frm.ShowDialog() + ' RUN_WDSEARCH_GRID(True) + ' If Not IsNothing(oRowHandle) Then + ' GridViewDoc_Search.FocusedRowHandle = oRowHandle + ' End If + ' End If + 'End If + Dim oDocuments = ClassWindreamDocGrid.GetSelectedDocuments(GridViewDoc_Search) + + If oDocuments.First.DisplayName <> "" Then + Dim oRowHandle As Integer = GridViewDoc_Search.FocusedRowHandle + Dim frm As New frmFileRename(1, oDocuments.First.DisplayName, "Displayname") + frm.ShowDialog() + RUN_WDSEARCH_GRID(True) + If Not IsNothing(oRowHandle) Then + GridViewDoc_Search.FocusedRowHandle = oRowHandle End If End If Catch ex As Exception @@ -2507,7 +2456,11 @@ Public Class frmNodeNavigation LOGGER.Warn("Attention: Could not set DocVariable RENAME_DOC_PATH: " & ex.Message) RENAME_DOC_PATH = Nothing End Try - If IsNothing(ClassWindreamDocGrid.DT_RESULTFILES) Then + 'If IsNothing(ClassWindreamDocGrid.DT_RESULTFILES) Then + ' MsgBox("Could not read File Parameters!", MsgBoxStyle.Exclamation) + ' Exit Sub + 'End If + If ClassWindreamDocGrid.HasNoSelectedDocuments(GridViewDoc_Search) Then MsgBox("Could not read File Parameters!", MsgBoxStyle.Exclamation) Exit Sub End If @@ -2539,32 +2492,49 @@ Public Class frmNodeNavigation End Sub Private Sub tsmiFileFolderOpen_Click(sender As Object, e As EventArgs) Handles tsmiFileFolderOpen.Click - If IsNothing(ClassWindreamDocGrid.DT_RESULTFILES) Then + 'If IsNothing(ClassWindreamDocGrid.DT_RESULTFILES) Then + ' MsgBox("Could not read File Parameters(5)!", MsgBoxStyle.Exclamation) + ' Exit Sub + 'End If + If ClassWindreamDocGrid.HasNoSelectedDocuments(GridViewDoc_Search) Then MsgBox("Could not read File Parameters(5)!", MsgBoxStyle.Exclamation) Exit Sub End If - For Each row As DataRow In ClassWindreamDocGrid.DT_RESULTFILES.Rows - ClassHelper.Open_Folder(row.Item("DOC_PATH"), row.Item("DOC_ID")) + 'For Each row As DataRow In ClassWindreamDocGrid.DT_RESULTFILES.Rows + ' ClassHelper.Open_Folder(row.Item("DOC_PATH"), row.Item("DOC_ID")) + 'Next + For Each oDoc As ClassWindreamDocGrid.WindreamDoc In ClassWindreamDocGrid.GetSelectedDocuments(GridViewDoc_Search) + ClassHelper.Open_Folder(oDoc.DocPath, oDoc.DocId) Next End Sub Private Sub tsmiFileLink_Add_Click(sender As Object, e As EventArgs) Handles tsmiFileLink_Add.Click Try - ClassWindreamDocGrid.GetDocItems(GridViewDoc_Search) - If IsNothing(ClassWindreamDocGrid.DT_RESULTFILES) Then + 'ClassWindreamDocGrid.GetDocItems(GridViewDoc_Search) + 'If IsNothing(ClassWindreamDocGrid.DT_RESULTFILES) Then + ' MsgBox("Could not read File Parameters (LinkRecord)!", MsgBoxStyle.Exclamation) + ' Exit Sub + 'End If + 'ClassWindreamDocGrid.GetDocItems(GridViewDoc_Search) + If ClassWindreamDocGrid.HasNoSelectedDocuments(GridViewDoc_Search) Then MsgBox("Could not read File Parameters (LinkRecord)!", MsgBoxStyle.Exclamation) Exit Sub End If Refresh_Selected_Table() - Dim frm As New frmDocRecordLink - frm.Show() + + Dim oDocuments = DocList.SelectedDocuments + Dim oForm As New frmDocRecordLink With {.Documents = oDocuments} + oForm.Show() + Catch ex As Exception + LOGGER.Error(ex) MsgBox("Unexpected Error in Linking Record: " & ex.Message, MsgBoxStyle.Critical) End Try End Sub Sub Refresh_Selected_Table() - Dim table As New DataTable - table.TableName = "SelectedFiles" + Dim table As New DataTable With { + .TableName = "SelectedFiles" + } ' Create two columns, ID and Name. Dim idColumn As DataColumn = table.Columns.Add("ID", GetType(System.Int32)) @@ -2575,13 +2545,13 @@ Public Class frmNodeNavigation table.Columns.Add("FILEPATH", GetType(System.String)) table.Columns.Add("DOC_ID", GetType(System.Int32)) table.Columns.Add("OBJECTTYPE", GetType(System.String)) - For Each row As DataRow In ClassWindreamDocGrid.DT_RESULTFILES.Rows - If row.Item("DOC_PATH") <> String.Empty Then + For Each oDoc As ClassWindreamDocGrid.WindreamDoc In ClassWindreamDocGrid.GetSelectedDocuments(GridViewDoc_Search) + If oDoc.DocPath <> String.Empty Then 'Set the ID column as the primary key column. Dim newRow As DataRow = table.NewRow() - newRow("FILEPATH") = row.Item("DOC_PATH") - newRow("DOC_ID") = row.Item("DOC_ID") - newRow("OBJECTTYPE") = row.Item("OBJECTTYPE") + newRow("FILEPATH") = oDoc.DocPath + newRow("DOC_ID") = oDoc.DocId + newRow("OBJECTTYPE") = oDoc.DocType table.Rows.Add(newRow) End If Next @@ -2598,9 +2568,10 @@ Public Class frmNodeNavigation End If CURRENT_DOC_ID = GridViewDoc_Search.GetRowCellValue(GridViewDoc_Search.FocusedRowHandle, "DocID") - Dim frm As New frmDoc_Links - frm.Show() - frm.BringToFront() + Dim oDocuments = DocList.SelectedDocuments + Dim oForm As New frmDoc_Links With {.Documents = oDocuments} + oForm.Show() + oForm.BringToFront() Catch ex As Exception MsgBox("Unexpected Error in Showing DocLinks: " & ex.Message, MsgBoxStyle.Critical) End Try @@ -2611,32 +2582,31 @@ Public Class frmNodeNavigation ClassHelper.MSGBOX_Handler("INFO", "Attention", "Missing Selection:", "Please select a record!") Exit Sub End If - If IsNothing(ClassWindreamDocGrid.DT_RESULTFILES) Then + If ClassWindreamDocGrid.HasNoSelectedDocuments(GridViewDoc_Search) Then Exit Sub End If - If ClassWindreamDocGrid.DT_RESULTFILES.Rows.Count > 0 Then - Dim msg = "Wollen Sie die Verknüpfung der gewählten Datei/en wirklich entfernen?" & vbNewLine & "Datei/en bleibt/bleiben im DMS/Archiv/Explorer erhalten!" - If USER_LANGUAGE <> "de-DE" Then - msg = "Would You like to delete only the references?" & vbNewLine & "File(s) will stay in ECM/Archive/Explorer!" - End If - Dim result As MsgBoxResult - result = MessageBox.Show(msg, CAPTION_CONFIRMATION, MessageBoxButtons.YesNo, MessageBoxIcon.Question) - If result = MsgBoxResult.Yes Then - Try - For Each row As DataRow In ClassWindreamDocGrid.DT_RESULTFILES.Rows - If ClassFileResult.Delete_ResultFile(row.Item("DOC_ID"), CURRENT_RECORD_ID, 0) = True Then - ClassHelper.InsertEssential_Log(row.Item("DOC_ID"), "DOC-ID", "RECORD LINK REMOVED FROM DOC-SEARCH") - Cursor = Cursors.WaitCursor - RUN_WDSEARCH_GRID(True) - End If + Dim msg = "Wollen Sie die Verknüpfung der gewählten Datei/en wirklich entfernen?" & vbNewLine & "Datei/en bleibt/bleiben im DMS/Archiv/Explorer erhalten!" + If USER_LANGUAGE <> "de-DE" Then + msg = "Would You like to delete only the references?" & vbNewLine & "File(s) will stay in ECM/Archive/Explorer!" + End If + Dim result As MsgBoxResult + result = MessageBox.Show(msg, CAPTION_CONFIRMATION, MessageBoxButtons.YesNo, MessageBoxIcon.Question) + If result = MsgBoxResult.Yes Then + Try + For Each oDoc As ClassWindreamDocGrid.WindreamDoc In ClassWindreamDocGrid.GetSelectedDocuments(GridViewDoc_Search) + If ClassFileResult.Delete_ResultFile(oDoc.DocId, CURRENT_RECORD_ID, 0) = True Then + ClassHelper.InsertEssential_Log(oDoc.DocId, "DOC-ID", "RECORD LINK REMOVED FROM DOC-SEARCH") + Cursor = Cursors.WaitCursor + RUN_WDSEARCH_GRID(True) + End If - Next - Catch ex As Exception - ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error", "Error in Removing links from file:", ex.Message) - End Try - End If + Next + + Catch ex As Exception + ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error", "Error in Removing links from file:", ex.Message) + End Try End If End Sub @@ -2665,27 +2635,25 @@ Public Class frmNodeNavigation Show_File_Properties() End Sub Sub Show_File_Properties() - If IsNothing(ClassWindreamDocGrid.DT_RESULTFILES) Then + If ClassWindreamDocGrid.HasNoSelectedDocuments(GridViewDoc_Search) Then MsgBox("Could not read File Parameters(4)!", MsgBoxStyle.Exclamation) Exit Sub End If - For Each row As DataRow In ClassWindreamDocGrid.DT_RESULTFILES.Rows - If row.Item("DOC_PATH") <> "" Then - Dim oFileFullPath = ClassHelper.FORMAT_WM_PATH(row.Item("DOC_PATH")) - Cursor = Cursors.WaitCursor - Dim sei As New SHELLEXECUTEINFO - sei.cbSize = Marshal.SizeOf(sei) - sei.lpVerb = "properties" - sei.lpFile = oFileFullPath - sei.nShow = SW_SHOW - sei.fMask = SEE_MASK_INVOKEIDLIST - If Not ShellExecuteEx(sei) Then - Dim ex As New System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error()) - ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error", "Error in Open file propertys:", ex.Message) - End If + Cursor = Cursors.WaitCursor + For Each oDoc As ClassWindreamDocGrid.WindreamDoc In ClassWindreamDocGrid.GetSelectedDocuments(GridViewDoc_Search) + If oDoc.DocPath <> "" Then + Dim oFileFullPath = ClassHelper.FORMAT_WM_PATH(oDoc.DocPath) + Try + If Not WindowsEx.OpenFileProperties(oFileFullPath) Then + Dim ex As New System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error()) + ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error", "Error in Open file propertys:", ex.Message) + End If + Catch ex As Exception + LOGGER.Error(ex) + End Try End If - Cursor = Cursors.Default Next + Cursor = Cursors.Default End Sub Private Sub EigenschaftenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles EigenschaftenToolStripMenuItem.Click @@ -2710,7 +2678,7 @@ Public Class frmNodeNavigation End Sub Private Sub UnterknotenNeuOrdnenToolStripMenuItem_Click(sender As Object, e As EventArgs) - MyTreeListViewState = New TreeListViewState(TreeListDevexpress) + MyTreeListViewState = New ClassTreeListViewState(TreeListDevexpress) Dim oQuestion = "Wollen Sie die gesamte Struktur unterhalb dieses Knotens neu ordnen lassen?" & vbNewLine & "Nein, wenn nur die direkten Unterknoten neu geordnet werden sollen!" If USER_LANGUAGE <> "de-DE" Then oQuestion = "Do you want to reorder the entire structure below this node?" & vbNewLine & "No, if only the direct subnodes are to be reordered!" @@ -2761,77 +2729,78 @@ Public Class frmNodeNavigation 'End Sub Private Sub GridViewDoc_Search_RowStyle(sender As Object, e As RowStyleEventArgs) Handles GridViewDoc_Search.RowStyle - If e.RowHandle = DevExpress.XtraGrid.GridControl.AutoFilterRowHandle Then - e.Appearance.BackColor = Color.Yellow - Else - If e.RowHandle = -1 Then - Exit Sub - End If - Try - Dim rowCellValue = GridViewDoc_Search.GetRowCellValue(e.RowHandle, "in work?") - If Not IsNothing(rowCellValue) Then - Dim inwork = rowCellValue - If inwork = True Then - e.Appearance.BackColor = Color.Orchid - e.HighPriority = True - End If - End If - Catch ex As Exception - LOGGER.Warn("Unexpected Error in Checking Value In Work: " & ex.Message) - End Try - - Try - Dim DROPDOWN_VALUE - If Not IsNothing(DT_DOCRESULT_DROPDOWN_ITEMS) Then - 'Den ColumnTitle aus ConfigTableholen - If DT_DOCRESULT_DROPDOWN_ITEMS.Rows.Count > 0 Then - For Each confrow As DataRow In DT_DOCRESULT_DROPDOWN_ITEMS.Rows - Dim CAPTION = confrow.Item("HEADER_CAPTION") - DROPDOWN_VALUE = GridViewDoc_Search.GetRowCellValue(e.RowHandle, CAPTION) - If Not IsNothing(DROPDOWN_VALUE) Then - Exit For - End If - Next - - If Not IsNothing(DROPDOWN_VALUE) Then - Dim ColorRow As Color - Dim expression As String = String.Format("VALUE = '{0}'", DROPDOWN_VALUE) - Dim matchingRows() As DataRow = DT_DOCRESULT_DROPDOWN_ITEMS.Select(expression, "SEQUENCE") - Dim rowcolorname As String = "" - 'Die Color für den value auswählen - For Each matchingRow As DataRow In matchingRows - rowcolorname = "" - If Not IsDBNull(matchingRow.Item("COLOR")) Then - rowcolorname = matchingRow.Item("COLOR") - End If - - If rowcolorname <> "" Then - Exit For - End If - Next - If rowcolorname <> "" Then - ColorRow = Color.FromName(rowcolorname) - e.Appearance.BackColor = ColorRow - e.HighPriority = True - End If - - - 'Dim c As Color = DirectCast(rowCellValue, Color) - - End If - End If - - - End If - Catch ex As Exception - LOGGER.Warn("Unexpected Error in RowStyle-Color Dropdown: " & ex.Message) - End Try + 'TODO: Refactor RowStyle maybe + 'If e.RowHandle = DevExpress.XtraGrid.GridControl.AutoFilterRowHandle Then + ' e.Appearance.BackColor = Color.Yellow + 'Else + ' If e.RowHandle = -1 Then + ' Exit Sub + ' End If + ' Try + ' Dim rowCellValue = GridViewDoc_Search.GetRowCellValue(e.RowHandle, "in work?") + ' If Not IsNothing(rowCellValue) Then + ' Dim inwork = rowCellValue + ' If inwork = True Then + ' e.Appearance.BackColor = Color.Orchid + ' e.HighPriority = True + ' End If + ' End If + ' Catch ex As Exception + ' LOGGER.Warn("Unexpected Error in Checking Value In Work: " & ex.Message) + ' End Try + + ' Try + ' Dim DROPDOWN_VALUE + ' If Not IsNothing(DT_DOCRESULT_DROPDOWN_ITEMS) Then + ' 'Den ColumnTitle aus ConfigTableholen + ' If DT_DOCRESULT_DROPDOWN_ITEMS.Rows.Count > 0 Then + ' For Each confrow As DataRow In DT_DOCRESULT_DROPDOWN_ITEMS.Rows + ' Dim CAPTION = confrow.Item("HEADER_CAPTION") + ' DROPDOWN_VALUE = GridViewDoc_Search.GetRowCellValue(e.RowHandle, CAPTION) + ' If Not IsNothing(DROPDOWN_VALUE) Then + ' Exit For + ' End If + ' Next + + ' If Not IsNothing(DROPDOWN_VALUE) Then + ' Dim ColorRow As Color + ' Dim expression As String = String.Format("VALUE = '{0}'", DROPDOWN_VALUE) + ' Dim matchingRows() As DataRow = DT_DOCRESULT_DROPDOWN_ITEMS.Select(expression, "SEQUENCE") + ' Dim rowcolorname As String = "" + ' 'Die Color für den value auswählen + ' For Each matchingRow As DataRow In matchingRows + ' rowcolorname = "" + ' If Not IsDBNull(matchingRow.Item("COLOR")) Then + ' rowcolorname = matchingRow.Item("COLOR") + ' End If + + ' If rowcolorname <> "" Then + ' Exit For + ' End If + ' Next + ' If rowcolorname <> "" Then + ' ColorRow = Color.FromName(rowcolorname) + ' e.Appearance.BackColor = ColorRow + ' e.HighPriority = True + ' End If + + + ' 'Dim c As Color = DirectCast(rowCellValue, Color) + + ' End If + ' End If + + + ' End If + ' Catch ex As Exception + ' LOGGER.Warn("Unexpected Error in RowStyle-Color Dropdown: " & ex.Message) + ' End Try - End If + 'End If End Sub Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BbtnitmNodeReorder.ItemClick - MyTreeListViewState = New TreeListViewState(TreeListDevexpress) + MyTreeListViewState = New ClassTreeListViewState(TreeListDevexpress) Dim oQuestion = "Wollen Sie die gesamte Struktur unterhalb dieses Knotens neu ordnen lassen?" & vbNewLine & "Nein, wenn nur die direkten Unterknoten neu geordnet werden sollen!" If USER_LANGUAGE <> "de-DE" Then oQuestion = "Do you want to reorder the entire structure below this node?" & vbNewLine & "No, if only the direct subnodes are to be reordered!" @@ -2879,8 +2848,4 @@ Public Class frmNodeNavigation Private Sub bbtnitmRecSave_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtnitmRecSave.ItemClick Save_Record() End Sub - - Private Sub GridViewDoc_Search_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles GridViewDoc_Search.SelectionChanged - Dim oDocuments = ClassWindreamDocGrid.GetSelectedDocuments(GridViewDoc_Search) - End Sub End Class \ No newline at end of file