Common: Load files on ResultList depending on access rights
This commit is contained in:
@@ -11,6 +11,7 @@ Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DigitalData.Modules.EDMI.API
|
||||
Imports DigitalData.Modules.EDMI.API.Client
|
||||
Imports DevExpress.XtraGrid.Views.Base
|
||||
Imports DevExpress.XtraGrid.Views.BandedGrid
|
||||
Imports System.ComponentModel
|
||||
@@ -18,6 +19,15 @@ Imports System.ComponentModel
|
||||
Public Class frmDocumentResultList
|
||||
Implements IResultForm
|
||||
|
||||
Private Const COLUMN_ICON = "ICON"
|
||||
Private Const COLUMN_FILEPATH = "FULL_FILENAME"
|
||||
Private Const COLUMN_FILENAME = "Filename"
|
||||
Private Const COLUMN_DOCID = "DocID"
|
||||
|
||||
Private _IsLoading As Boolean = True
|
||||
Private _IsLegacy As Boolean = True
|
||||
Private _IDBClient As Client
|
||||
|
||||
Private _LogConfig As LogConfig
|
||||
Private _Logger As Logger
|
||||
Private _Config As ConfigManager(Of DocumentResultConfig)
|
||||
@@ -29,14 +39,7 @@ Public Class frmDocumentResultList
|
||||
Private _ActiveGridBand As GridBand = Nothing
|
||||
Private _ActiveRowHandle As Integer = Constants.NO_ROW_HANDLE
|
||||
|
||||
Private Const COLUMN_ICON = "ICON"
|
||||
Private Const COLUMN_FILEPATH = "FULL_FILENAME"
|
||||
Private Const COLUMN_FILENAME = "Filename"
|
||||
Private Const COLUMN_DOCID = "DocID"
|
||||
|
||||
Private _IsLoading As Boolean = True
|
||||
Private _IsLegacy As Boolean = True
|
||||
Private _IDBClient As Client
|
||||
Private _DocumentInfo As DocumentInfo = Nothing
|
||||
|
||||
Public Property ShouldReturnToPreviousForm As Boolean = False Implements IResultForm.ShouldReturnToPreviousForm
|
||||
|
||||
@@ -60,7 +63,7 @@ Public Class frmDocumentResultList
|
||||
Private Sub MaybeInitIDB()
|
||||
_IsLegacy = Not _Environment.Service.IsActive
|
||||
If _Environment.Service.IsActive Then
|
||||
Dim oSplit As List(Of String) = _Environment.Service.Address.Split(";").ToList()
|
||||
Dim oSplit As List(Of String) = _Environment.Service.Address.Split(":").ToList()
|
||||
Dim oAddress As String = oSplit.Item(0)
|
||||
Dim oPort As Integer = oSplit.Item(1)
|
||||
|
||||
@@ -100,6 +103,7 @@ Public Class frmDocumentResultList
|
||||
' Initialize Viewer with GDPicture.NET License
|
||||
DocumentViewer1.Init(_LogConfig, _Environment.Settings.GdPictureKey)
|
||||
|
||||
|
||||
AddHandler GridView1.FocusedRowChanged, AddressOf GridView_FocusedRowChanged
|
||||
AddHandler GridView2.FocusedRowChanged, AddressOf GridView_FocusedRowChanged
|
||||
AddHandler GridView3.FocusedRowChanged, AddressOf GridView_FocusedRowChanged
|
||||
@@ -114,6 +118,53 @@ Public Class frmDocumentResultList
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Async 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()
|
||||
|
||||
If _IsLegacy Then
|
||||
LoadFile_Legacy(oRow)
|
||||
Else
|
||||
Await LoadFile_IDB(oRow)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub LoadFile_Legacy(GridRow As DataRow)
|
||||
Try
|
||||
Dim oFullPath = GridRow.Item(COLUMN_FILEPATH)
|
||||
|
||||
DocumentViewer1.LoadFile(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
|
||||
Try
|
||||
Dim oObjectId = GridRow.Item(COLUMN_DOCID)
|
||||
_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
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
MsgBox("Error while loading file", MsgBoxStyle.Critical, Text)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
Public Function RefreshResults(pResults As IEnumerable(Of BaseResult)) As Boolean Implements IResultForm.RefreshResults
|
||||
_IsLoading = True
|
||||
Try
|
||||
@@ -210,32 +261,6 @@ Public Class frmDocumentResultList
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Async Sub GridView_FocusedRowChanged(sender As GridView, e As FocusedRowChangedEventArgs)
|
||||
_ActiveRowHandle = e.FocusedRowHandle
|
||||
|
||||
If _IsLegacy Then
|
||||
If e.FocusedRowHandle >= 0 Then
|
||||
DocumentViewer1.CloseDocument()
|
||||
|
||||
Dim oRow = sender.GetDataRow(e.FocusedRowHandle)
|
||||
Dim oFullPath = oRow.Item(COLUMN_FILEPATH)
|
||||
|
||||
DocumentViewer1.LoadFile(oFullPath)
|
||||
End If
|
||||
|
||||
Else
|
||||
If e.FocusedRowHandle >= 0 Then
|
||||
DocumentViewer1.CloseDocument()
|
||||
|
||||
Dim oRow = sender.GetDataRow(e.FocusedRowHandle)
|
||||
Dim oObjectId = oRow.Item(COLUMN_DOCID)
|
||||
|
||||
Dim oInfo = Await _IDBClient.GetDocumentInfo(_Environment.User.UserId, oObjectId)
|
||||
End If
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CreateDocumentGrid(GridView As GridView, Datatable As DataTable)
|
||||
Dim oDocDatatable As New DataTable
|
||||
Try
|
||||
@@ -607,7 +632,7 @@ Public Class frmDocumentResultList
|
||||
|
||||
e.Menu.Items.Clear()
|
||||
|
||||
For Each oItem In oMenu.GetMenuItems(_IsLegacy)
|
||||
For Each oItem In oMenu.GetMenuItems(_IsLegacy, _DocumentInfo.AccessRight)
|
||||
e.Menu.Items.Add(oItem)
|
||||
Next
|
||||
End If
|
||||
|
||||
Reference in New Issue
Block a user