Versionierung windream, DocRecordLink, Overlay in NodeNavigation

This commit is contained in:
Developer01
2026-03-27 14:08:05 +01:00
parent e9cb352674
commit 0125d9b047
12 changed files with 421 additions and 336 deletions

View File

@@ -1,182 +1,127 @@
Imports System.IO
Imports DevExpress.XtraGrid.Columns
Public Class frmDocRecordLink
Public Property myDocuments As New List(Of ClassDocGrid.clsWMDoc)
Private CURRENT_LINK_ENTITY_ID As Integer = 0
Private ENTITY_LOAD_ACTIVE As Boolean = False
Private DT_ENTITYDATA As DataTable
Private Class ClassEntity
Public title As String
Public id As Integer
Public Overrides Function ToString() As String
Return Me.title
End Function
End Class
Private Function GET_CURRENT_ENTITY_DATA()
If IsNothing(CURRENT_DT_ENTITY_RECORDS) Then
Return Nothing
End If
Dim oDatatable As DataTable = CURRENT_DT_ENTITY_RECORDS.Copy
Return oDatatable
End Function
Sub Refresh_Grid_Data(current As Boolean, ENTITY_DATATABLE As DataTable)
Dim DT_RECORDS As DataTable
If current = True Then
DT_RECORDS = GET_CURRENT_ENTITY_DATA()
Else
DT_RECORDS = ENTITY_DATATABLE
End If
Private Function GET_CURRENT_ENTITY_DATA() As DataTable
If IsNothing(CURRENT_DT_ENTITY_RECORDS) Then Return Nothing
Return CURRENT_DT_ENTITY_RECORDS.Copy()
End Function
''' <summary>
''' Lädt das Grid neu.
''' Wenn current=True wird versucht, die zuletzt gewählte Entity korrekt zu laden.
''' </summary>
Sub Refresh_Grid_Data(current As Boolean, ENTITY_DATATABLE As DataTable)
If CURRENT_LINK_ENTITY_ID = 0 Then
CURRENT_LINK_ENTITY_ID = CURRENT_ENTITY_ID
End If
Dim DT_RECORDS As DataTable
If current = True Then
If CURRENT_LINK_ENTITY_ID = CURRENT_ENTITY_ID Then
DT_RECORDS = GET_CURRENT_ENTITY_DATA()
Else
DT_RECORDS = ReturnDataforEntity(CURRENT_LINK_ENTITY_ID)
DT_ENTITYDATA = DT_RECORDS
End If
Else
DT_RECORDS = ENTITY_DATATABLE
End If
Try
grvwGrid.Columns.Clear()
dgEntityRecords.DataSource = DT_RECORDS
Catch ex As Exception
ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error in format grid", ex.Message, ex.StackTrace)
End Try
End Sub
Private Sub frmDocRecordLink_Load(sender As Object, e As EventArgs) Handles Me.Load
' OLD WAY
If myDocuments.Count = 0 Then
ENTITY_LOAD_ACTIVE = True
If ClassDocGrid.DT_RESULTFILES.Rows.Count = 1 Then
txtFileInfo.Text = ClassDocGrid.DT_RESULTFILES.Rows(0).Item("DOC_PATH")
Else
txtFileInfo.Text = String.Format("{0} files selected for linking to record", ClassDocGrid.DT_RESULTFILES.Rows.Count)
End If
Try
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)
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
ENTITY_LOAD_ACTIVE = True
' Dateiinfo-Text setzen
If myDocuments.Count > 0 Then
ENTITY_LOAD_ACTIVE = True
If myDocuments.Count = 1 Then
txtFileInfo.Text = myDocuments.First.DocPath
Else
txtFileInfo.Text = String.Format("{0} files selected for linking to record", myDocuments.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)
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....."
txtFileInfo.Text = If(myDocuments.Count = 1,
myDocuments.First.DocPath,
String.Format("{0} files selected for linking to record", myDocuments.Count))
Else
txtFileInfo.Text = If(ClassDocGrid.DT_RESULTFILES.Rows.Count = 1,
ClassDocGrid.DT_RESULTFILES.Rows(0).Item("DOC_PATH").ToString(),
String.Format("{0} files selected for linking to record", ClassDocGrid.DT_RESULTFILES.Rows.Count))
End If
Try
If myDocuments.Count > 0 AndAlso IsNothing(CURRENT_DT_ENTITY_RECORDS) Then
Me.Close()
Return
End If
If CURRENT_LINK_ENTITY_ID = 0 Then
Refresh_Grid_Data(True, Nothing)
CURRENT_LINK_ENTITY_ID = CURRENT_ENTITY_ID
DT_ENTITYDATA = GET_CURRENT_ENTITY_DATA()
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
DT_ENTITYDATA = DT_RESULT
Refresh_Grid_Data(False, DT_RESULT)
End If
End If
Dim DT_ENTITIES As DataTable = GetENTITIES()
If IsNothing(DT_ENTITIES) OrElse DT_ENTITIES.Rows.Count = 0 Then Exit Sub
Dim oSelectedIndex As Integer = 0
Dim oCount As Integer = 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
Me.Text = If(USER_LANGUAGE = "de-DE",
CURRENT_DT_SELECTED_FILES.Rows.Count.ToString & " Datei(en) mit Datensatz verknüpfen:",
"Link " & CURRENT_DT_SELECTED_FILES.Rows.Count.ToString & " files with record:")
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 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)
Return dt
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)
Return MYDB_ECM.GetDatatable(SQL)
Catch ex As Exception
MsgBox("Entities could not be loaded in LinkToRecord: " & vbNewLine & ex.Message)
Return Nothing
@@ -187,25 +132,23 @@ Public Class frmDocRecordLink
Try
If Not IsNothing(dgEntityRecords.DataSource) Then
Dim RecordId As Integer = grvwGrid.GetFocusedRowCellValue(grvwGrid.Columns("Record-ID"))
bsiInfo.Caption = "Record (" & RecordId.ToString & ") selected!"
End If
Catch ex As Exception
MsgBox("Could not get the RecordID: " & ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
Sub Save_DocGrid_Layout()
Try
Dim XMLPath = Get_DocGrid_Layout_Filename()
grvwGrid.SaveLayoutToXml(XMLPath)
bsiInfo.Caption = "Grid-Layout saved - " + Now.ToLongTimeString
Catch ex As Exception
ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error in Save_DocGrid_Layout", ex.Message, ex.StackTrace)
End Try
End Sub
Sub Load_DocGrid_Layout()
Try
Dim XMLPath = Get_DocGrid_Layout_Filename()
@@ -213,16 +156,17 @@ Public Class frmDocRecordLink
grvwGrid.RestoreLayoutFromXml(XMLPath)
grvwGrid.GuessAutoFilterRowValuesFromFilter()
bsiInfo.Caption = "Grid-Layout loaded - " + Now.ToLongTimeString
End If
Catch ex As Exception
ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error in Load_DocGrid_Layout", ex.Message, ex.StackTrace)
End Try
End Sub
Private Function Get_DocGrid_Layout_Filename()
Private Function Get_DocGrid_Layout_Filename() As String
Dim Filename As String = String.Format("GridViewDocRecordLink-{0}-UserLayout.xml", CURRENT_LINK_ENTITY_ID)
Return System.IO.Path.Combine(Application.UserAppDataPath(), Filename)
End Function
Private Sub frmDocRecordLink_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
If ENTITY_LOAD_ACTIVE = False Then Save_DocGrid_Layout()
End Sub
@@ -231,6 +175,7 @@ Public Class frmDocRecordLink
Me.Cursor = Cursors.WaitCursor
If cmbConstructorForms.SelectedIndex <> -1 Then
Dim entity As ClassEntity = DirectCast(cmbConstructorForms.SelectedItem, ClassEntity)
LOGGER.Debug("Selected Entity: {0} (ID: {1})", entity.title, entity.id)
ENTITY_LOAD_ACTIVE = True
dgEntityRecords.DataSource = Nothing
grvwGrid.Columns.Clear()
@@ -240,23 +185,26 @@ Public Class frmDocRecordLink
CURRENT_LINK_ENTITY_ID = entity.id
txtcurrSichtData.Text = entity.title
DT_ENTITYDATA = DT_RESULT
LOGGER.Debug("Data for Entity {0} loaded with {1} records", entity.title, DT_RESULT.Rows.Count)
Refresh_Grid_Data(False, DT_RESULT)
End If
Load_DocGrid_Layout()
Else
bsiInfo.Caption = "Bitte wöhlen Sie eine Sicht aus! " + Now.ToShortTimeString
bsiInfo.Caption = "Bitte wählen Sie eine Sicht aus! " + Now.ToShortTimeString
End If
' FIX Problem A: ENTITY_LOAD_ACTIVE nach abgeschlossenem Ladevorgang zurücksetzen
ENTITY_LOAD_ACTIVE = False
Me.Cursor = Cursors.Default
End Sub
Private Function ReturnDataforEntity(oEntityID As Integer) As DataTable
Dim ResultSQL, ResultViewName As String
LOGGER.Debug("GridType = Grid")
ResultViewName = $"VWPMO_ENTITY_TABLE{oEntityID}"
bsitmSource.Caption = $"Source: " + ResultViewName
ResultSQL = $"SELECT T.* FROM {ResultViewName} T"
LOGGER.Debug("ResultSQL: " & ResultSQL)
LOGGER.Debug("Executing SQL to load entity data: " & ResultSQL)
Return MYDB_ECM.GetDatatable(ResultSQL)
End Function
@@ -269,15 +217,13 @@ Public Class frmDocRecordLink
Dim selectedRows As Integer() = grvwGrid.GetSelectedRows()
Dim oLinkCount As Integer = 0
LOGGER.Info("Start der Verknüpfung - Es wurden [{0}] Datensätze ausgewählt!", selectedRows.Count)
For Each rowhandle As Integer In selectedRows
Dim oSelectedRecordID = grvwGrid.GetRowCellValue(rowhandle, "Record-ID")
If IsNothing(oSelectedRecordID) Then
Continue For
End If
If IsNothing(oSelectedRecordID) Then Continue For
Try
For Each oRow As DataRow In CURRENT_DT_SELECTED_FILES.Rows
Dim oDocID As Integer
oDocID = oRow.Item("DOC_ID")
Dim oDocID As Integer = oRow.Item("DOC_ID")
LOGGER.Info("DocID {0} will be linked with Record {1} ", oDocID.ToString, oSelectedRecordID.ToString)
Dim DOC_PATH = oRow.Item("FILEPATH")
Dim _objecttype = oRow.Item("OBJECTTYPE")
@@ -307,12 +253,13 @@ Public Class frmDocRecordLink
ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error in Linking Record to file", ex.Message, ex.StackTrace)
End Try
Next
Dim omsg = $"[{oLinkCount}] Datensätze erfolgreich verknüpft! - {Now.ToShortTimeString}"
If USER_LANGUAGE <> "de-DE" Then
omsg = $"[{oLinkCount}] records successfully linked - {Now.ToShortTimeString}"
End If
Dim omsg = If(USER_LANGUAGE = "de-DE",
$"[{oLinkCount}] Datensätze erfolgreich verknüpft! - {Now.ToShortTimeString}",
$"[{oLinkCount}] records successfully linked - {Now.ToShortTimeString}")
MsgBox(omsg, MsgBoxStyle.Information, "orgFLOW")
DT_ENTITYDATA = ReturnDataforEntity(CURRENT_LINK_ENTITY_ID)
Refresh_Grid_Data(False, DT_ENTITYDATA)
Load_DocGrid_Layout()
grvwGrid.ClearSelection()
@@ -325,14 +272,14 @@ Public Class frmDocRecordLink
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtnitmresetlayout.ItemClick
Reset_View_layout()
End Sub
Sub Reset_View_layout()
Me.Cursor = Cursors.WaitCursor
Try
Dim XMLPath = Get_DocGrid_Layout_Filename()
If File.Exists(XMLPath) Then
File.Delete(XMLPath)
Refresh_Grid_Data(True, Nothing)
Refresh_Grid_Data(False, DT_ENTITYDATA)
Else
MsgBox("Resetting the layout was not successful - File not existing!", MsgBoxStyle.Information)
End If