Common: Fix Property Dialog, Fix context Menu in DocumentResultList
This commit is contained in:
@@ -6,11 +6,13 @@ Imports DigitalData.Modules.Windows.NativeMethods
|
||||
Imports DigitalData.Modules.Windows.File
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
Imports DigitalData.Modules.EDMI.API.Rights
|
||||
Imports DigitalData.Modules.EDMI.API
|
||||
|
||||
Public Class DocumentPropertyMenu
|
||||
Private ReadOnly _Logger As Logger
|
||||
Private ReadOnly _LogConfig As LogConfig
|
||||
Private ReadOnly _Environment As Environment
|
||||
Private ReadOnly _Client As Client
|
||||
Private ReadOnly _File As Modules.Windows.File
|
||||
|
||||
Private ReadOnly _FilePath As String
|
||||
@@ -21,10 +23,11 @@ Public Class DocumentPropertyMenu
|
||||
Public Const COPY_PATH As String = "Dateipfad kopieren"
|
||||
Public Const OPEN_PROPERTIES As String = "Eigenschaften"
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Environment As Environment, FilePath As String, Optional ObjectId As Long = 0)
|
||||
Public Sub New(LogConfig As LogConfig, Environment As Environment, Client As Client, FilePath As String, Optional ObjectId As Long = 0)
|
||||
_LogConfig = LogConfig
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_Environment = Environment
|
||||
_Client = Client
|
||||
_FilePath = FilePath
|
||||
_ObjectId = ObjectId
|
||||
_File = New Modules.Windows.File(LogConfig)
|
||||
@@ -77,7 +80,7 @@ Public Class DocumentPropertyMenu
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(_LogConfig, _Environment, _ObjectId)
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(_LogConfig, _Environment, _Client, _ObjectId)
|
||||
oPropertyDialog.Show()
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -135,52 +135,66 @@ Public Class frmDocumentResultList
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Async Sub GridView_FocusedRowChanged(sender As GridView, e As FocusedRowChangedEventArgs)
|
||||
Private Sub GridView_FocusedRowChanged(sender As GridView, e As FocusedRowChangedEventArgs)
|
||||
_ActiveRowHandle = e.FocusedRowHandle
|
||||
|
||||
If e.FocusedRowHandle >= 0 Then
|
||||
Dim oRow = sender.GetDataRow(e.FocusedRowHandle)
|
||||
DocumentViewer1.CloseDocument()
|
||||
Try
|
||||
Cursor = Cursors.WaitCursor
|
||||
|
||||
If _IsLegacy Then
|
||||
LoadFile_Legacy(oRow)
|
||||
Else
|
||||
Await LoadFile_IDB(oRow)
|
||||
If e.FocusedRowHandle >= 0 Then
|
||||
Dim oRow = sender.GetDataRow(e.FocusedRowHandle)
|
||||
DocumentViewer1.CloseDocument()
|
||||
|
||||
If _IsLegacy Then
|
||||
LoadFile_Legacy(oRow)
|
||||
Else
|
||||
LoadFile_IDB(oRow)
|
||||
End If
|
||||
|
||||
DocumentViewer1.LoadFile(_DocumentInfo.FullPath)
|
||||
|
||||
If _DocumentInfo.AccessRight = Rights.AccessRight.VIEW_ONLY Then
|
||||
DocumentViewer1.SetViewOnly(True)
|
||||
RibbonPageGroup_Export.Visible = False
|
||||
Else
|
||||
DocumentViewer1.SetViewOnly(False)
|
||||
RibbonPageGroup_Export.Visible = True
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
MsgBox("Error while changing row: " & ex.Message, MsgBoxStyle.Critical, Text)
|
||||
Finally
|
||||
Cursor = Cursors.Default
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub LoadFile_Legacy(GridRow As DataRow)
|
||||
Try
|
||||
Dim oFullPath = GridRow.Item(COLUMN_FILEPATH)
|
||||
|
||||
DocumentViewer1.LoadFile(oFullPath)
|
||||
_DocumentInfo = New DocumentInfo() With {
|
||||
.AccessRight = Rights.AccessRight.FULL,
|
||||
.FullPath = oFullPath
|
||||
}
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
MsgBox("Error while loading file", MsgBoxStyle.Critical, Text)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Async Function LoadFile_IDB(GridRow As DataRow) As Task
|
||||
Private Sub LoadFile_IDB(GridRow As DataRow)
|
||||
Try
|
||||
Dim oObjectId = GridRow.Item(COLUMN_DOCID)
|
||||
_Logger.Debug($"Gettin' Infor for oObjectId: {oObjectId}")
|
||||
_DocumentInfo = Await _IDBClient.GetDocumentInfo(_Environment.User.UserId, oObjectId)
|
||||
|
||||
DocumentViewer1.LoadFile(_DocumentInfo.FullPath)
|
||||
|
||||
If _DocumentInfo.AccessRight = Rights.AccessRight.VIEW_ONLY Then
|
||||
DocumentViewer1.SetViewOnly(True)
|
||||
RibbonPageGroup_Export.Visible = False
|
||||
Else
|
||||
DocumentViewer1.SetViewOnly(False)
|
||||
RibbonPageGroup_Export.Visible = True
|
||||
End If
|
||||
' This needs to be Sync bc otherwise the PopupMenuShowing event will fire before this method loaded the Document Info
|
||||
_DocumentInfo = _IDBClient.GetDocumentInfo(_Environment.User.UserId, oObjectId)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
MsgBox("Error while loading file", MsgBoxStyle.Critical, Text)
|
||||
End Try
|
||||
End Function
|
||||
End Sub
|
||||
|
||||
|
||||
Public Function RefreshResults(pResults As IEnumerable(Of BaseResult)) As Boolean Implements IResultForm.RefreshResults
|
||||
@@ -589,7 +603,7 @@ Public Class frmDocumentResultList
|
||||
|
||||
If oRow IsNot Nothing Then
|
||||
Dim oObjectId = oRow.Item(COLUMN_DOCID)
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(_LogConfig, _Environment, oObjectId)
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(_LogConfig, _Environment, _IDBClient, oObjectId)
|
||||
oPropertyDialog.Show()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
@@ -645,6 +659,7 @@ Public Class frmDocumentResultList
|
||||
Dim oMenu As New DocumentPropertyMenu(
|
||||
_LogConfig,
|
||||
_Environment,
|
||||
_IDBClient,
|
||||
oFilepath,
|
||||
oObjectId)
|
||||
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.1.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.1.0.0")>
|
||||
<Assembly: AssemblyVersion("1.2.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.2.0.0")>
|
||||
|
||||
@@ -141,12 +141,14 @@ Partial Class frmObjectPropertyDialog
|
||||
Me.cmbBusinessEntity.EditWidth = 100
|
||||
Me.cmbBusinessEntity.Id = 6
|
||||
Me.cmbBusinessEntity.Name = "cmbBusinessEntity"
|
||||
Me.cmbBusinessEntity.Visibility = DevExpress.XtraBars.BarItemVisibility.OnlyInCustomizing
|
||||
'
|
||||
'BarStaticItem1
|
||||
'
|
||||
Me.BarStaticItem1.Caption = "Entity:"
|
||||
Me.BarStaticItem1.Id = 0
|
||||
Me.BarStaticItem1.Name = "BarStaticItem1"
|
||||
Me.BarStaticItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.OnlyInCustomizing
|
||||
'
|
||||
'TabPageAttributes
|
||||
'
|
||||
|
||||
@@ -8,16 +8,18 @@ Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DevExpress.XtraGrid
|
||||
Imports DigitalData.Modules.EDMI.API
|
||||
|
||||
Public Class frmObjectPropertyDialog
|
||||
Private _LogConfig As LogConfig
|
||||
Private _Logger As Logger
|
||||
Private _Environment As Environment
|
||||
Private ReadOnly _Client As Client
|
||||
Private _ObjectId As Int64
|
||||
Private _Db As MSSQLServer
|
||||
Private _Controls As PropertyControls
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Environment As Environment, ObjectId As Long)
|
||||
Public Sub New(LogConfig As LogConfig, Environment As Environment, Client As Client, ObjectId As Long)
|
||||
' Dieser Aufruf ist für den Designer erforderlich.
|
||||
InitializeComponent()
|
||||
|
||||
@@ -25,6 +27,7 @@ Public Class frmObjectPropertyDialog
|
||||
_LogConfig = LogConfig
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_Environment = Environment
|
||||
_Client = Client
|
||||
_ObjectId = ObjectId
|
||||
_Db = _Environment.DatabaseIDB
|
||||
_Controls = New PropertyControls(_LogConfig, _Db)
|
||||
@@ -36,6 +39,10 @@ Public Class frmObjectPropertyDialog
|
||||
Try
|
||||
oHandle = SplashScreenManager.ShowOverlayForm(Me)
|
||||
|
||||
If IsNothing(_ObjectId) Then
|
||||
Throw New ApplicationException("No valid Object Id supplied!")
|
||||
End If
|
||||
|
||||
Dim oEntityIds = Await GetBusinessEntitiesForObjectId(_ObjectId)
|
||||
Dim oHistoryDataTable = Await GetValueHistoryForObjectId(_ObjectId)
|
||||
Dim oObjectProperties = Await GetPropertiesForObjectId(_ObjectId)
|
||||
@@ -45,15 +52,16 @@ Public Class frmObjectPropertyDialog
|
||||
ShowAttributeHistory(oHistoryDataTable)
|
||||
ShowObjectProperties(oObjectProperties)
|
||||
|
||||
If oEntityIds.Count = 1 Then
|
||||
cmbBusinessEntity.EditValue = oEntityIds.First()
|
||||
End If
|
||||
'If oEntityIds.Count = 1 Then
|
||||
' cmbBusinessEntity.EditValue = oEntityIds.First()
|
||||
'End If
|
||||
cmbBusinessEntity.EditValue = oEntityIds.First()
|
||||
Catch ex As ApplicationException
|
||||
_Logger.Error(ex)
|
||||
MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
MessageBox.Show("Unhandled exception occurred please check the log", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
MessageBox.Show("Unhandled exception occurred. Please check the log." & vbNewLine & ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
Finally
|
||||
If oHandle IsNot Nothing
|
||||
SplashScreenManager.CloseOverlayForm(oHandle)
|
||||
@@ -62,72 +70,90 @@ Public Class frmObjectPropertyDialog
|
||||
End Sub
|
||||
|
||||
Private Async Function GetAttributesForBusinessEntity(EntityId As Long) As Task(Of List(Of Attribute))
|
||||
Dim oSQL = $"SELECT * FROM VWIDB_BE_ATTRIBUTE WHERE BE_ID = {EntityId}"
|
||||
Dim oDatatable = Await _Db.GetDatatableAsync(oSQL)
|
||||
Try
|
||||
Dim oSQL = $"SELECT * FROM VWIDB_BE_ATTRIBUTE WHERE BE_ID = {EntityId}"
|
||||
Dim oResult = Await _Client.GetDatatableFromIDBAsync(oSQL)
|
||||
|
||||
If oDatatable.Rows.Count = 0 Then
|
||||
Throw New ApplicationException($"BusinessEntity {EntityId} does not have any attributes!")
|
||||
Else
|
||||
Dim oAttributes As New List(Of Attribute)
|
||||
If oResult.OK = False Then
|
||||
Throw New ApplicationException($"Attributes for Business Entity {EntityId} could not be retrieved!")
|
||||
|
||||
For Each oRow As DataRow In oDatatable.Rows
|
||||
oAttributes.Add(New Attribute() With {
|
||||
.ID = oRow.Item("ATTR_ID"),
|
||||
.Title = oRow.Item("ATTR_TITLE"),
|
||||
.TypeID = oRow.Item("TYPE_ID"),
|
||||
.TypeName = oRow.Item("TYPE_NAME")
|
||||
})
|
||||
Next
|
||||
ElseIf oResult.Table.Rows.Count = 0 Then
|
||||
Throw New ApplicationException($"BusinessEntity {EntityId} does not have any attributes!")
|
||||
|
||||
Return oAttributes
|
||||
End If
|
||||
Else
|
||||
Dim oAttributes As New List(Of Attribute)
|
||||
|
||||
For Each oRow As DataRow In oResult.Table.Rows
|
||||
oAttributes.Add(New Attribute() With {
|
||||
.ID = oRow.Item("ATTR_ID"),
|
||||
.Title = oRow.Item("ATTR_TITLE"),
|
||||
.TypeID = oRow.Item("TYPE_ID"),
|
||||
.TypeName = oRow.Item("TYPE_NAME")
|
||||
})
|
||||
Next
|
||||
|
||||
Return oAttributes
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return New List(Of Attribute)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Async Function GetBusinessEntitiesForObjectId(ObjectId As Long) As Task(Of List(Of Long))
|
||||
Dim oSQL = $"SELECT BE_ID FROM TBIDB_OBJECT_BE WHERE IDB_OBJ_ID = {ObjectId}"
|
||||
Dim oDatatable = Await _Db.GetDatatableAsync(oSQL)
|
||||
Try
|
||||
Dim oSQL = $"SELECT BE_ID FROM TBIDB_OBJECT_BE WHERE IDB_OBJ_ID = {ObjectId}"
|
||||
Dim oResult = Await _Client.GetDatatableFromIDBAsync(oSQL)
|
||||
|
||||
If oDatatable.Rows.Count = 0 Then
|
||||
Throw New ApplicationException($"ObjectId {ObjectId} is not assigned to any business entity!")
|
||||
Else
|
||||
Dim oEntities As New List(Of Long)
|
||||
If oResult.OK = False Then
|
||||
Throw New ApplicationException($"Business Entities could not be retrieved!")
|
||||
|
||||
For Each oRow In oDatatable.Rows
|
||||
oEntities.Add(oRow.item("BE_ID"))
|
||||
Next
|
||||
ElseIf oResult.Table.Rows.Count = 0 Then
|
||||
Throw New ApplicationException($"ObjectId {ObjectId} is not assigned to any business entity!")
|
||||
|
||||
Return oEntities
|
||||
End If
|
||||
Else
|
||||
Dim oEntities As New List(Of Long)
|
||||
|
||||
For Each oRow In oResult.Table.Rows
|
||||
oEntities.Add(oRow.item("BE_ID"))
|
||||
Next
|
||||
|
||||
Return oEntities
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return New List(Of Long)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Async Function GetValueHistoryForObjectId(ObjectId As Long) As Task(Of DataTable)
|
||||
Dim oSQL As String = $"SELECT * FROM VWIDB_CHANGE_LOG WHERE IDB_OBJ_ID = {ObjectId} ORDER BY ChangeID DESC"
|
||||
Dim oDatatable = Await _Db.GetDatatableAsync(oSQL)
|
||||
Dim oResult = Await _Client.GetDatatableFromIDBAsync(oSQL)
|
||||
|
||||
Return oDatatable
|
||||
Return oResult.Table
|
||||
End Function
|
||||
|
||||
Private Async Function GetPropertiesForObjectId(ObjectId As Long) As Task(Of DataTable)
|
||||
Dim oSQL As String = $"SELECT * FROM TBIDB_OBJECT WHERE IDB_OBJ_ID = {ObjectId}"
|
||||
Dim oDatatable = Await _Db.GetDatatableAsync(oSQL)
|
||||
Dim oResult = Await _Client.GetDatatableFromIDBAsync(oSQL)
|
||||
|
||||
Return oDatatable
|
||||
Return oResult.Table
|
||||
End Function
|
||||
|
||||
Private Async Function GetAttributeValue(AttributeName As String, ObjectId As Long, Optional LanguageCode As String = "de-DE", Optional IsForeign As Boolean = False) As Task(Of Object)
|
||||
Dim oIsForeign = IIf(IsForeign, 1, 0)
|
||||
Dim oSQL = $"SELECT TERM_VALUE FROM [dbo].[FNIDB_PM_GET_VARIABLE_VALUE] ({ObjectId}, '{AttributeName}', '{LanguageCode}', {oIsForeign})"
|
||||
Dim oTermValue = Await _Db.GetScalarValueAsync(oSQL)
|
||||
Dim oResult = Await _Client.GetScalarValueFromIDBAsync(oSQL)
|
||||
|
||||
Return oTermValue
|
||||
Return oResult.Scalar
|
||||
End Function
|
||||
|
||||
Private Async Function GetAttributeValueAsTable(AttributeName As String, ObjectId As Long, Optional LanguageCode As String = "de-DE", Optional IsForeign As Boolean = False) As Task(Of DataTable)
|
||||
Dim oIsForeign = IIf(IsForeign, 1, 0)
|
||||
Dim oSQL = $"SELECT TERM_VALUE FROM [dbo].[FNIDB_PM_GET_VARIABLE_VALUE] ({ObjectId}, '{AttributeName}', '{LanguageCode}', {oIsForeign})"
|
||||
Dim oDatatable = Await _Db.GetDatatableAsync(oSQL)
|
||||
Dim oResult = Await _Client.GetDatatableFromIDBAsync(oSQL)
|
||||
|
||||
Return oDatatable
|
||||
Return oResult.Table
|
||||
End Function
|
||||
|
||||
Private Async Sub cmbBusinessEntity_EditValueChanged(sender As Object, e As EventArgs) Handles cmbBusinessEntity.EditValueChanged
|
||||
|
||||
Reference in New Issue
Block a user