Common/DocumentResultList: Refactor file loading, add zooflow file loading
This commit is contained in:
@@ -52,19 +52,23 @@ Public Class frmDocumentResultList
|
||||
Private ReadOnly _Filesystem As Modules.Filesystem.File
|
||||
Private ReadOnly _GridBuilder As GridBuilder
|
||||
Private ReadOnly _File As Modules.Windows.File
|
||||
Private ReadOnly _OpenDocuments As New DocumentResultCache(50000000)
|
||||
Private ReadOnly _Cache As New DocumentResultCache(50000000)
|
||||
|
||||
|
||||
' Runtime variables
|
||||
Private _IsLoading As Boolean = True
|
||||
Private _ActiveGrid As GridControl = Nothing
|
||||
Private _ActiveGridBand As GridBand = Nothing
|
||||
Private _documentloader As DocumentLoader
|
||||
|
||||
' TODO: Hashes for checking if the opened file was modified externally
|
||||
'Private _HashOriginalFile As String = Nothing
|
||||
'Private _HashOpenedFile As String = Nothing
|
||||
|
||||
Private _CurrentDocument As DocumentResultInfo = Nothing
|
||||
Private _CurrentDocumentId As Long = Nothing
|
||||
Private _DragBoxFromMouseDown As Rectangle
|
||||
Private _ScreenOffset As Point
|
||||
|
||||
Private Property _CurrentDocument As DocumentResultInfo = Nothing
|
||||
Private ReadOnly _Language As String
|
||||
|
||||
Private WithEvents _FileOpenTimer As New Timer
|
||||
@@ -95,6 +99,7 @@ Public Class frmDocumentResultList
|
||||
_Params = Params
|
||||
_File = New Modules.Windows.File(LogConfig)
|
||||
_ResultLists = Params.Results
|
||||
|
||||
_Language = Utils.NotNull(_Environment.User.Language, State.UserState.LANG_EN_US)
|
||||
End Sub
|
||||
|
||||
@@ -119,10 +124,13 @@ Public Class frmDocumentResultList
|
||||
' Operation mode is either guessed from service settings
|
||||
' or explictly set from OperationModeOverride in Params
|
||||
OperationMode = GetOperationMode()
|
||||
If OperationMode = OperationMode.WithAppServer Then
|
||||
If OperationMode = OperationMode.WithAppServer Or OperationMode = OperationMode.ZooFlow Then
|
||||
InitAppServer()
|
||||
End If
|
||||
|
||||
_documentLoader = New DocumentLoader(_LogConfig, OperationMode, _IDBClient, _Environment.User)
|
||||
|
||||
|
||||
If _Params.WindowTitle <> "" Then
|
||||
Text = $"{Text} - {_Params.WindowTitle}"
|
||||
End If
|
||||
@@ -172,6 +180,20 @@ Public Class frmDocumentResultList
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub frmDocumentResultList_Closing(sender As Object, e As CancelEventArgs) Handles Me.FormClosing
|
||||
Try
|
||||
GridViewSave_Layout(_ActiveGrid.MainView)
|
||||
|
||||
_Config.Config.WindowLocation = Location
|
||||
_Config.Config.WindowSize = Size
|
||||
_Config.Save()
|
||||
|
||||
DocumentViewer1.Done()
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub GridView_FocusedRowChanged(sender As GridView, e As FocusedRowChangedEventArgs)
|
||||
_Helpers.SetRowHandle(e)
|
||||
|
||||
@@ -180,58 +202,27 @@ Public Class frmDocumentResultList
|
||||
Cursor = Cursors.WaitCursor
|
||||
|
||||
If e.FocusedRowHandle >= 0 Then
|
||||
Dim oRow = sender.GetDataRow(e.FocusedRowHandle)
|
||||
Dim oRow = sender.GetDataRow(_Helpers.ActiveRowHandle)
|
||||
Dim oObjectId = oRow.ItemEx(Of Long)(COLUMN_DOCID, 0)
|
||||
Dim oFullPath = oRow.ItemEx(Of String)(COLUMN_FILEPATH, "")
|
||||
Dim oDocumentInfo As DocumentResultInfo = Nothing
|
||||
|
||||
DocumentViewer1.CloseDocument()
|
||||
|
||||
Select Case OperationMode
|
||||
Case OperationMode.NoAppServer
|
||||
oDocumentInfo = LoadFile_Legacy(oRow)
|
||||
oDocumentInfo = _documentloader.Load(oObjectId, oFullPath)
|
||||
Dim oFileName = $"{oObjectId}.{oDocumentInfo.Extension}"
|
||||
|
||||
If oDocumentInfo.Contents IsNot Nothing Then
|
||||
Dim oFileInfo As New FileInfo(oDocumentInfo.FullPath)
|
||||
DocumentViewer1.LoadFile(oFileInfo.Name, New MemoryStream(oDocumentInfo.Contents))
|
||||
Else
|
||||
DocumentViewer1.LoadFile(oDocumentInfo.FullPath)
|
||||
End If
|
||||
DocumentViewer1.LoadFile(oFileName, New MemoryStream(oDocumentInfo.Contents))
|
||||
|
||||
Case OperationMode.WithAppServer
|
||||
oDocumentInfo = LoadFile_IDB(oRow)
|
||||
|
||||
If oDocumentInfo.Contents IsNot Nothing Then
|
||||
Dim oFileInfo As New FileInfo(oDocumentInfo.FullPath)
|
||||
DocumentViewer1.LoadFile(oFileInfo.Name, New MemoryStream(oDocumentInfo.Contents))
|
||||
Else
|
||||
DocumentViewer1.LoadFile(oDocumentInfo.FullPath)
|
||||
End If
|
||||
|
||||
|
||||
Case OperationMode.ZooFlow
|
||||
oDocumentInfo = LoadFile_ZooFlow(oRow)
|
||||
|
||||
|
||||
End Select
|
||||
' Save reference to current
|
||||
_CurrentDocument = oDocumentInfo
|
||||
|
||||
' Check DocumentInfo
|
||||
If IsNothing(oDocumentInfo) Then
|
||||
Show_Warning("File could not be loaded!")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If Not IO.File.Exists(oDocumentInfo.FullPath) Then
|
||||
Show_Warning("File does not exist!")
|
||||
' TODO: Create checksum after closing, compare and take action
|
||||
'_HashOriginalFile = Nothing
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If oDocumentInfo.Contents IsNot Nothing Then
|
||||
Dim oFileInfo As New FileInfo(oDocumentInfo.FullPath)
|
||||
DocumentViewer1.LoadFile(oFileInfo.Name, New MemoryStream(oDocumentInfo.Contents))
|
||||
Else
|
||||
DocumentViewer1.LoadFile(oDocumentInfo.FullPath)
|
||||
End If
|
||||
|
||||
If oDocumentInfo.AccessRight = Rights.AccessRight.VIEW_ONLY Then
|
||||
DocumentViewer1.SetViewOnly(True)
|
||||
RibbonPageGroup_Export.Visible = False
|
||||
@@ -263,153 +254,63 @@ Public Class frmDocumentResultList
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function LoadFile_Legacy(GridRow As DataRow) As DocumentResultInfo
|
||||
Try
|
||||
Dim oFullPath = GridRow.Item(COLUMN_FILEPATH)
|
||||
Dim oDocumentInfo = New DocumentResultInfo() With {
|
||||
.AccessRight = Rights.AccessRight.FULL,
|
||||
.FullPath = oFullPath
|
||||
}
|
||||
'Private Function LoadFile_AsByteArray(DocumentInfo As DocumentResultInfo) As DocumentResultInfo
|
||||
' Try
|
||||
' _Logger.Debug("Loading File [{0}]", DocumentInfo.FullPath)
|
||||
' Dim oFullPath As String = DocumentInfo.FullPath
|
||||
' Dim oPathExists = From oFile In _Cache
|
||||
' Where oFile.FullPath = oFullPath And oFile.Contents IsNot Nothing
|
||||
' Select oFile
|
||||
|
||||
If IO.File.Exists(oDocumentInfo.FullPath) Then
|
||||
oDocumentInfo = LoadFile_AsByteArray(oDocumentInfo)
|
||||
_OpenDocuments.Add(oDocumentInfo)
|
||||
_CurrentDocument = oDocumentInfo
|
||||
End If
|
||||
' Dim oExistsInCache = oPathExists.Count() > 0
|
||||
' Dim oSizeChanged = False
|
||||
' Dim oWriteTimeChanged = False
|
||||
|
||||
Return oDocumentInfo
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
' _Logger.Debug("File exists in Cache: [{0}]", oExistsInCache)
|
||||
|
||||
Private Function LoadFile_IDB(GridRow As DataRow) As DocumentResultInfo
|
||||
Try
|
||||
Dim oObjectId = GridRow.Item(COLUMN_DOCID)
|
||||
_Logger.Debug("Loading Information for ObjectId: [{0}]", oObjectId)
|
||||
' ' Get Information about the file on the filesystem
|
||||
' Dim oFileInfo As New FileInfo(oFullPath)
|
||||
|
||||
' This needs to be Sync bc otherwise the PopupMenuShowing event will fire before this method loaded the Document Info
|
||||
Dim oDocumentInfo As DocumentInfo = _IDBClient.GetDocumentInfo(_Environment.User.UserId, oObjectId)
|
||||
Dim oResultDocumentInfo As New DocumentResultInfo() With {
|
||||
.AccessRight = oDocumentInfo.AccessRight,
|
||||
.FullPath = oDocumentInfo.FullPath
|
||||
}
|
||||
_Logger.Debug("Successfully loaded Information for ObjectId: [{0}]", oObjectId)
|
||||
' If oExistsInCache Then
|
||||
' _Logger.Debug("Loading file from cache.")
|
||||
|
||||
_Logger.Debug("Loading file [{0}]", oResultDocumentInfo.FullPath)
|
||||
If IO.File.Exists(oResultDocumentInfo.FullPath) Then
|
||||
oResultDocumentInfo = LoadFile_AsByteArray(oResultDocumentInfo)
|
||||
_OpenDocuments.Add(oResultDocumentInfo)
|
||||
_CurrentDocument = oResultDocumentInfo
|
||||
Else
|
||||
_Logger.Warn("File [{0}] does not exist.", oResultDocumentInfo.FullPath)
|
||||
End If
|
||||
_Logger.Debug("Successfully loaded File [{0}]", oResultDocumentInfo.FullPath)
|
||||
' Dim oCachedItem = oPathExists.First()
|
||||
|
||||
Return oResultDocumentInfo
|
||||
' If oCachedItem.Contents Is Nothing Then
|
||||
' oSizeChanged = False
|
||||
' Else
|
||||
' oSizeChanged = Not (oFileInfo.Length = oCachedItem.Contents.Length)
|
||||
' End If
|
||||
' _Logger.Debug("Filesize changed: [{0}]", oSizeChanged)
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return Nothing
|
||||
' If oCachedItem.LastWriteTime = Nothing Then
|
||||
' oWriteTimeChanged = False
|
||||
' Else
|
||||
' oWriteTimeChanged = Not oFileInfo.LastWriteTime.Equals(oCachedItem.LastWriteTime)
|
||||
' End If
|
||||
' _Logger.Debug("Write-time changed: [{0}]", oWriteTimeChanged)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
' If oSizeChanged Or oWriteTimeChanged Then
|
||||
' _Logger.Debug("Size or Write-time changed, loading from disk.")
|
||||
|
||||
Private Function LoadFile_ZooFlow(GridRow As DataRow)
|
||||
Try
|
||||
Dim oObjectId = GridRow.Item(COLUMN_DOCID)
|
||||
_Logger.Debug("Loading FileObject for ObjectId: [{0}]", oObjectId)
|
||||
' Return LoadFile_FromDisk(DocumentInfo, oFileInfo)
|
||||
' Else
|
||||
' _Logger.Debug("Loading from cache")
|
||||
|
||||
' This needs to be Sync bc otherwise the PopupMenuShowing event will fire before this method loaded the FileObject
|
||||
Dim oFileObject As FileObject = _IDBClient.GetFileObject(oObjectId)
|
||||
Dim oResultDocumentInfo As New DocumentResultInfo() With {
|
||||
.AccessRight = "",
|
||||
.FullPath = "",
|
||||
.Contents = oFileObject._FileContents
|
||||
}
|
||||
_Logger.Debug("Successfully loaded Information for ObjectId: [{0}]", oObjectId)
|
||||
' Return oCachedItem
|
||||
' End If
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return Nothing
|
||||
' Else
|
||||
' _Logger.Debug("File exists in cache, loading from disk.")
|
||||
|
||||
End Try
|
||||
End Function
|
||||
' Return LoadFile_FromDisk(DocumentInfo, oFileInfo)
|
||||
' End If
|
||||
|
||||
Private Function LoadFile_AsByteArray(DocumentInfo As DocumentResultInfo) As DocumentResultInfo
|
||||
Try
|
||||
_Logger.Debug("Loading File [{0}]", DocumentInfo.FullPath)
|
||||
Dim oFullPath As String = DocumentInfo.FullPath
|
||||
Dim oPathExists = From oFile In _OpenDocuments
|
||||
Where oFile.FullPath = oFullPath And oFile.Contents IsNot Nothing
|
||||
Select oFile
|
||||
|
||||
Dim oExistsInCache = oPathExists.Count() > 0
|
||||
Dim oSizeChanged = False
|
||||
Dim oWriteTimeChanged = False
|
||||
|
||||
_Logger.Debug("File exists in Cache: [{0}]", oExistsInCache)
|
||||
|
||||
' Get Information about the file on the filesystem
|
||||
Dim oFileInfo As New FileInfo(oFullPath)
|
||||
|
||||
If oExistsInCache Then
|
||||
_Logger.Debug("Loading file from cache.")
|
||||
|
||||
Dim oCachedItem = oPathExists.First()
|
||||
|
||||
If oCachedItem.Contents Is Nothing Then
|
||||
oSizeChanged = False
|
||||
Else
|
||||
oSizeChanged = Not (oFileInfo.Length = oCachedItem.Contents.Length)
|
||||
End If
|
||||
_Logger.Debug("Filesize changed: [{0}]", oSizeChanged)
|
||||
|
||||
If oCachedItem.LastWriteTime = Nothing Then
|
||||
oWriteTimeChanged = False
|
||||
Else
|
||||
oWriteTimeChanged = Not oFileInfo.LastWriteTime.Equals(oCachedItem.LastWriteTime)
|
||||
End If
|
||||
_Logger.Debug("Write-time changed: [{0}]", oWriteTimeChanged)
|
||||
|
||||
If oSizeChanged Or oWriteTimeChanged Then
|
||||
_Logger.Debug("Size or Write-time changed, loading from disk.")
|
||||
|
||||
Return LoadFile_FromDisk(DocumentInfo, oFileInfo)
|
||||
Else
|
||||
_Logger.Debug("Loading from cache")
|
||||
|
||||
Return oCachedItem
|
||||
End If
|
||||
|
||||
Else
|
||||
_Logger.Debug("File exists in cache, loading from disk.")
|
||||
|
||||
Return LoadFile_FromDisk(DocumentInfo, oFileInfo)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return DocumentInfo
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function LoadFile_FromDisk(pDocumentInfo As DocumentResultInfo, pFileInfo As FileInfo) As DocumentResultInfo
|
||||
Using oStream = IO.File.OpenRead(pDocumentInfo.FullPath)
|
||||
_Logger.Debug("File opened.")
|
||||
|
||||
Using oMemoryStream = New MemoryStream()
|
||||
_Logger.Debug("Copying file contents to memory stream.")
|
||||
oStream.CopyTo(oMemoryStream)
|
||||
pDocumentInfo.Contents = oMemoryStream.ToArray()
|
||||
pDocumentInfo.LastWriteTime = pFileInfo.LastWriteTime
|
||||
_Logger.Debug("Successfully copied file contents to memory stream.")
|
||||
End Using
|
||||
End Using
|
||||
|
||||
Return pDocumentInfo
|
||||
End Function
|
||||
' Catch ex As Exception
|
||||
' _Logger.Error(ex)
|
||||
' Return DocumentInfo
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
Public Function RefreshResults(pResults As IEnumerable(Of BaseResult)) As Boolean Implements IResultForm.RefreshResults
|
||||
_IsLoading = True
|
||||
@@ -427,10 +328,6 @@ Public Class frmDocumentResultList
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub ClearGridData()
|
||||
GridControl1.DataSource = Nothing
|
||||
End Sub
|
||||
|
||||
Private Sub LoadGridData(Result As DocumentResult)
|
||||
If Result.Datatable.Columns.Contains(COLUMN_DOCID) = False Then
|
||||
Throw New ApplicationException($"Datatable is missing DocId Column [{COLUMN_DOCID}] for search {Result.Title}!")
|
||||
@@ -627,30 +524,6 @@ Public Class frmDocumentResultList
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Function TryGetItem(DataRow As DataRow, ColumnName As String, Optional DefaultValue As String = "") As String
|
||||
Try
|
||||
Return DataRow.Item(ColumnName)
|
||||
Catch ex As Exception
|
||||
Return DefaultValue
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub SwitchMainContainerHorizontal_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles SwitchMainContainerHorizontal.CheckedChanged
|
||||
SplitContainerControl1.Horizontal = SwitchMainContainerHorizontal.Checked
|
||||
|
||||
If _Config IsNot Nothing And _IsLoading = False Then
|
||||
_Config.Config.SplitContainer1Horizontal = SwitchMainContainerHorizontal.Checked
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub SwitchDetailContainerHorizontal2_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles SwitchDetailContainerHorizontal.CheckedChanged
|
||||
SplitContainerControl2.Horizontal = SwitchDetailContainerHorizontal.Checked
|
||||
|
||||
If _Config IsNot Nothing And _IsLoading = False Then
|
||||
_Config.Config.SplitContainer2Horizontal = SwitchDetailContainerHorizontal.Checked
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonItemExportGrid1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItemExportGrid1.ItemClick
|
||||
Dim oActiveGrid = GetActiveGridControl()
|
||||
|
||||
@@ -676,18 +549,6 @@ Public Class frmDocumentResultList
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub SplitContainerControl1_SplitterPositionChanged(sender As Object, e As EventArgs) Handles SplitContainerControl1.SplitterPositionChanged
|
||||
If _IsLoading = False Then
|
||||
_Config.Config.SplitContainer1Distance = SplitContainerControl1.SplitterPosition
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub SplitContainerControl2_SplitterPositionChanged(sender As Object, e As EventArgs) Handles SplitContainerControl2.SplitterPositionChanged
|
||||
If _IsLoading = False Then
|
||||
_Config.Config.SplitContainer2Distance = SplitContainerControl2.SplitterPosition
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function GetActiveRow() As DataRow
|
||||
Dim oActiveGrid = GetActiveGridControl()
|
||||
Dim oActiveRowhandle = _Helpers.ActiveRowHandle
|
||||
@@ -700,10 +561,7 @@ Public Class frmDocumentResultList
|
||||
Return Nothing
|
||||
End If
|
||||
End Function
|
||||
Private Function GetDevexpressGrid_LayoutName(pGridView As GridView)
|
||||
Dim Filename As String = $"DevExpressGridViewDocResult_{pGridView.Name}UserLayout.xml"
|
||||
Return Path.Combine(_Config.UserConfigPath.Replace("UserConfig.xml", ""), Filename)
|
||||
End Function
|
||||
|
||||
Private Function GetActiveGridControl() As GridControl
|
||||
If _ActiveGrid Is Nothing Then
|
||||
Return Nothing
|
||||
@@ -711,31 +569,9 @@ Public Class frmDocumentResultList
|
||||
|
||||
Return _ActiveGrid
|
||||
End Function
|
||||
|
||||
Private Sub GridViewSave_Layout(pGridView As GridView)
|
||||
Try
|
||||
Dim oXml As String = GetDevexpressGrid_LayoutName(pGridView)
|
||||
pGridView.SaveLayoutToXml(oXml, OptionsLayoutBase.FullLayout)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Info("Error while saving GridLayout: " & ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
Private Sub RestoreLayout(pGridView As GridView)
|
||||
Try
|
||||
Dim oLayoutFile As String = GetDevexpressGrid_LayoutName(pGridView)
|
||||
If IO.File.Exists(oLayoutFile) Then
|
||||
pGridView.RestoreLayoutFromXml(oLayoutFile, OptionsLayoutBase.FullLayout)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Info("Error while restoring layout: " & ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub GridControl_Enter(sender As GridControl, e As EventArgs) Handles GridControl1.Enter, GridControl2.Enter, GridControl3.Enter
|
||||
_ActiveGrid = sender
|
||||
BarButtonItem5.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
||||
BarButtonResetLayout.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
||||
BarButtonItemExportGrid1.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
||||
SetActiveGridBand()
|
||||
End Sub
|
||||
@@ -757,59 +593,6 @@ Public Class frmDocumentResultList
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub OpenFolderPath()
|
||||
Try
|
||||
Dim oRow = GetActiveRow()
|
||||
|
||||
If oRow IsNot Nothing Then
|
||||
Dim oFilename = _CurrentDocument.FullPath
|
||||
Dim oDirectory = IO.Path.GetDirectoryName(oFilename)
|
||||
Process.Start(oDirectory)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub OpenFile()
|
||||
Try
|
||||
If _CurrentDocument IsNot Nothing Then
|
||||
Process.Start(New ProcessStartInfo With {
|
||||
.FileName = _CurrentDocument.FullPath
|
||||
})
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub CopyFileName()
|
||||
Try
|
||||
Dim oRow = GetActiveRow()
|
||||
|
||||
If oRow IsNot Nothing Then
|
||||
Dim oFilename = _CurrentDocument.FullPath
|
||||
Clipboard.SetText(oFilename)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub OpenProperties()
|
||||
Try
|
||||
Dim oRow = GetActiveRow()
|
||||
|
||||
If oRow IsNot Nothing Then
|
||||
Dim oObjectId = oRow.Item(COLUMN_DOCID)
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(_LogConfig, _Environment, _IDBClient, oObjectId)
|
||||
oPropertyDialog.Show()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub GridView1_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView1.ColumnFilterChanged
|
||||
Dim oRowCount = sender.RowCount
|
||||
UpdateGridHeader(_ResultLists, 0, oRowCount)
|
||||
@@ -830,42 +613,30 @@ Public Class frmDocumentResultList
|
||||
Close()
|
||||
End Sub
|
||||
|
||||
Private Sub frmDocumentResultList_Closing(sender As Object, e As CancelEventArgs) Handles Me.FormClosing
|
||||
Try
|
||||
GridViewSave_Layout(_ActiveGrid.MainView)
|
||||
|
||||
_Config.Config.WindowLocation = Location
|
||||
_Config.Config.WindowSize = Size
|
||||
_Config.Save()
|
||||
|
||||
DocumentViewer1.Done()
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub GridControl_DoubleClick(sender As Object, e As EventArgs) Handles GridControl1.DoubleClick, GridControl2.DoubleClick, GridControl3.DoubleClick
|
||||
If _CurrentDocument IsNot Nothing AndAlso _CurrentDocument.AccessRight > Rights.AccessRight.VIEW_ONLY Then
|
||||
OpenFile()
|
||||
Process.Start(New ProcessStartInfo With {
|
||||
.FileName = _CurrentDocument.FullPath
|
||||
})
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub Show_CriticalError(Message As String)
|
||||
labelCriticalError.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
||||
labelCriticalError.Visibility = BarItemVisibility.Always
|
||||
labelCriticalError.Caption = Message
|
||||
End Sub
|
||||
|
||||
Public Sub Show_Warning(Message As String)
|
||||
labelWarning.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
||||
labelWarning.Visibility = BarItemVisibility.Always
|
||||
labelWarning.Caption = Message
|
||||
End Sub
|
||||
|
||||
Public Sub Reset_Errors()
|
||||
labelCriticalError.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
|
||||
labelWarning.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
|
||||
labelCriticalError.Visibility = BarItemVisibility.Never
|
||||
labelWarning.Visibility = BarItemVisibility.Never
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonItem5_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem5.ItemClick
|
||||
Private Sub BarButtonResetLayout_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonResetLayout.ItemClick
|
||||
If Not IsNothing(_ActiveGrid) Then
|
||||
Try
|
||||
Dim oFile = GetDevexpressGrid_LayoutName(_ActiveGrid.MainView)
|
||||
@@ -879,15 +650,171 @@ Public Class frmDocumentResultList
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private _DragBoxFromMouseDown As Rectangle
|
||||
Private _ScreenOffset As Point
|
||||
Private Function TestPathExists(pTitle As String) As Boolean
|
||||
If IO.File.Exists(_CurrentDocument.FullPath) = False Then
|
||||
MessageBox.Show($"Datei {_CurrentDocument.FullPath} existiert nicht oder wurde verschoben!", pTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
Return False
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function TestObjectIdExists(pObjectId As Long, pTitle As String) As Boolean
|
||||
If pObjectId = 0 Then
|
||||
MessageBox.Show($"Objekt {pObjectId} existiert nicht oder wurde verschoben!", pTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
Return False
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
|
||||
Public Sub FileOpenTimer_Elapsed() Handles _FileOpenTimer.Tick
|
||||
'Try
|
||||
' Dim oProcesses = Process.GetProcesses()
|
||||
' Dim oIds = (From oProc In oProcesses
|
||||
' Select oProc.Id).
|
||||
' ToList()
|
||||
|
||||
' Dim oNewFileOpenList As New Dictionary(Of Integer, String)
|
||||
' For Each oOpenFile In _FileOpenList
|
||||
' If oIds.Contains(oOpenFile.Key) Then
|
||||
' oNewFileOpenList.Add(oOpenFile.Key, oOpenFile.Value)
|
||||
' End If
|
||||
' Next
|
||||
|
||||
' If oNewFileOpenList.Count < _FileOpenList.Count Then
|
||||
' Dim oClosedFiles = _FileOpenList.
|
||||
' Except(oNewFileOpenList).
|
||||
' ToList()
|
||||
|
||||
' If oClosedFiles.Count = 1 Then
|
||||
' Dim oOpenFile = oClosedFiles.First()
|
||||
' DocumentViewer1.LoadFile(oOpenFile.Value)
|
||||
' Else
|
||||
' ClearGridData()
|
||||
' UpdateGridData()
|
||||
' End If
|
||||
|
||||
' _FileOpenList = oNewFileOpenList
|
||||
' End If
|
||||
'Catch ex As Exception
|
||||
' _Logger.Error(ex)
|
||||
'End Try
|
||||
End Sub
|
||||
#Region "Context Menu"
|
||||
|
||||
Private Sub GridView_PopupMenuShowing(sender As Object, e As PopupMenuShowingEventArgs) Handles GridView2.PopupMenuShowing, GridView3.PopupMenuShowing, GridView1.PopupMenuShowing
|
||||
Try
|
||||
Dim oView As GridView = sender
|
||||
|
||||
If e.MenuType = GridMenuType.Row Then
|
||||
Dim oRowHandle = e.HitInfo.RowHandle
|
||||
Dim oRow As DataRow = oView.GetDataRow(oRowHandle)
|
||||
Dim oObjectId As Long = oRow.Item(COLUMN_DOCID)
|
||||
Dim oPoint As Point = oView.GridControl.PointToScreen(e.HitInfo.HitPoint)
|
||||
Dim oRight As Rights.AccessRight = _CurrentDocument.AccessRight
|
||||
|
||||
'_CurrentDocumentId = oObjectId
|
||||
_CurrentDocument.Id = oObjectId
|
||||
|
||||
If OperationMode = OperationMode.WithAppServer Then
|
||||
If oRight = Rights.AccessRight.FULL Or oRight = Rights.AccessRight.VIEW_EXPORT Then
|
||||
MenuFullAccess_IDB.ShowPopup(oPoint)
|
||||
Else
|
||||
MenuViewAccess_IDB.ShowPopup(oPoint)
|
||||
End If
|
||||
ElseIf OperationMode = OperationMode.ZooFlow Then
|
||||
MenuFullAccess_ZOOFLOW.ShowPopup(oPoint)
|
||||
|
||||
Else
|
||||
MenuFullAccess_EDM.ShowPopup(oPoint)
|
||||
End If
|
||||
Else
|
||||
'_CurrentDocumentId = Nothing
|
||||
_CurrentDocument.Id = Nothing
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
MsgBox("Unexpected Error while preparing context menu", MsgBoxStyle.Critical, Text)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemFolderpathCopyECM_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFolderpathCopy.ItemClick
|
||||
Dim oFolderPath = IO.Path.GetDirectoryName(_CurrentDocument.FullPath)
|
||||
Clipboard.SetText(oFolderPath)
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemPropertiesECM_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemPropertiesECM.ItemClick
|
||||
If TestPathExists(OPEN_PROPERTIES) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
_File.OpenFileProperties(_CurrentDocument.FullPath)
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemFilepathCopyIDB_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFilepathCopy.ItemClick
|
||||
Clipboard.SetText(_CurrentDocument.FullPath)
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemFolderOpen_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFolderOpen.ItemClick
|
||||
If TestPathExists(OPEN_DIRECTORY) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oArgs As String = $"/e, /select, ""{_CurrentDocument.FullPath}"""
|
||||
Dim oInfo As New ProcessStartInfo() With {
|
||||
.Arguments = oArgs,
|
||||
.FileName = "explorer"
|
||||
}
|
||||
|
||||
Process.Start(oInfo)
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemPropertiesIDB_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemPropertiesIDB.ItemClick
|
||||
If TestObjectIdExists(_CurrentDocument.Id, OPEN_PROPERTIES) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(_LogConfig, _Environment, _IDBClient, _CurrentDocument.Id)
|
||||
oPropertyDialog.Show()
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemFileOpen_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFileOpen.ItemClick
|
||||
If TestPathExists(OPEN_FILE) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Try
|
||||
Process.Start(New ProcessStartInfo With {
|
||||
.FileName = _CurrentDocument.FullPath
|
||||
})
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemPropertiesZooFlow_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemPropertiesZooFlow.ItemClick
|
||||
If TestObjectIdExists(_CurrentDocument.Id, OPEN_PROPERTIES) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(_LogConfig, _Environment, _IDBClient, _CurrentDocument.Id)
|
||||
oPropertyDialog.Show()
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemsOpenFileZooFlow_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemsOpenFileZooFlow.ItemClick
|
||||
'TODO: Save file to temp dir and then open
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
#Region "Drag to Export"
|
||||
|
||||
Private Sub GridView1_MouseDown(sender As GridView, e As MouseEventArgs) Handles GridView1.MouseDown
|
||||
If sender.FocusedRowHandle >= 0 Then
|
||||
Dim oDragSize As Size = SystemInformation.DragSize
|
||||
|
||||
_DragBoxFromMouseDown = New Rectangle(New Point(e.X - (oDragSize.Width / 2),
|
||||
e.Y - (oDragSize.Height / 2)), oDragSize)
|
||||
_DragBoxFromMouseDown = New Rectangle(New Point(e.X - (oDragSize.Width / 2), e.Y - (oDragSize.Height / 2)), oDragSize)
|
||||
|
||||
Else
|
||||
_DragBoxFromMouseDown = Rectangle.Empty
|
||||
@@ -918,109 +845,67 @@ Public Class frmDocumentResultList
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
#End Region
|
||||
#Region "Layout"
|
||||
Private Sub SplitContainerControl1_SplitterPositionChanged(sender As Object, e As EventArgs) Handles SplitContainerControl1.SplitterPositionChanged
|
||||
If _IsLoading = False Then
|
||||
_Config.Config.SplitContainer1Distance = SplitContainerControl1.SplitterPosition
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub GridView_PopupMenuShowing(sender As Object, e As PopupMenuShowingEventArgs) _
|
||||
Handles GridView2.PopupMenuShowing, GridView3.PopupMenuShowing, GridView1.PopupMenuShowing
|
||||
Private Sub SplitContainerControl2_SplitterPositionChanged(sender As Object, e As EventArgs) Handles SplitContainerControl2.SplitterPositionChanged
|
||||
If _IsLoading = False Then
|
||||
_Config.Config.SplitContainer2Distance = SplitContainerControl2.SplitterPosition
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub SwitchMainContainerHorizontal_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles SwitchMainContainerHorizontal.CheckedChanged
|
||||
SplitContainerControl1.Horizontal = SwitchMainContainerHorizontal.Checked
|
||||
|
||||
If _Config IsNot Nothing And _IsLoading = False Then
|
||||
_Config.Config.SplitContainer1Horizontal = SwitchMainContainerHorizontal.Checked
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub SwitchDetailContainerHorizontal2_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles SwitchDetailContainerHorizontal.CheckedChanged
|
||||
SplitContainerControl2.Horizontal = SwitchDetailContainerHorizontal.Checked
|
||||
|
||||
If _Config IsNot Nothing And _IsLoading = False Then
|
||||
_Config.Config.SplitContainer2Horizontal = SwitchDetailContainerHorizontal.Checked
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function GetDevexpressGrid_LayoutName(pGridView As GridView)
|
||||
Dim Filename As String = $"DevExpressGridViewDocResult_{pGridView.Name}UserLayout.xml"
|
||||
Return Path.Combine(_Config.UserConfigPath.Replace("UserConfig.xml", ""), Filename)
|
||||
End Function
|
||||
|
||||
|
||||
Private Sub GridViewSave_Layout(pGridView As GridView)
|
||||
Try
|
||||
Dim oView As GridView = sender
|
||||
|
||||
If e.MenuType = GridMenuType.Row Then
|
||||
Dim oRowHandle = e.HitInfo.RowHandle
|
||||
Dim oRow As DataRow = oView.GetDataRow(oRowHandle)
|
||||
Dim oObjectId As Long = oRow.Item(COLUMN_DOCID)
|
||||
Dim oPoint As Point = oView.GridControl.PointToScreen(e.HitInfo.HitPoint)
|
||||
Dim oRight As Rights.AccessRight = _CurrentDocument.AccessRight
|
||||
|
||||
_CurrentDocumentId = oObjectId
|
||||
|
||||
If OperationMode = OperationMode.WithAppServer Then
|
||||
If oRight = Rights.AccessRight.FULL Or oRight = Rights.AccessRight.VIEW_EXPORT Then
|
||||
MenuFullAccess_IDB.ShowPopup(oPoint)
|
||||
Else
|
||||
MenuViewAccess_IDB.ShowPopup(oPoint)
|
||||
End If
|
||||
|
||||
Else
|
||||
MenuFullAccess_EDM.ShowPopup(oPoint)
|
||||
End If
|
||||
Else
|
||||
_CurrentDocumentId = Nothing
|
||||
Dim oXml As String = GetDevexpressGrid_LayoutName(pGridView)
|
||||
pGridView.SaveLayoutToXml(oXml, OptionsLayoutBase.FullLayout)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Info("Error while saving GridLayout: " & ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
Private Sub RestoreLayout(pGridView As GridView)
|
||||
Try
|
||||
Dim oLayoutFile As String = GetDevexpressGrid_LayoutName(pGridView)
|
||||
If IO.File.Exists(oLayoutFile) Then
|
||||
pGridView.RestoreLayoutFromXml(oLayoutFile, OptionsLayoutBase.FullLayout)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
MsgBox("Unexpected Error while preparing context menu", MsgBoxStyle.Critical, Text)
|
||||
_Logger.Info("Error while restoring layout: " & ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Function TestPathExists(pTitle As String) As Boolean
|
||||
If IO.File.Exists(_CurrentDocument.FullPath) = False Then
|
||||
MessageBox.Show($"Datei {_CurrentDocument.FullPath} existiert nicht oder wurde verschoben!", pTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
Return False
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function TestObjectIdExists(pObjectId As Long, pTitle As String) As Boolean
|
||||
If pObjectId = 0 Then
|
||||
MessageBox.Show($"Objekt {pObjectId} existiert nicht oder wurde verschoben!", pTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
Return False
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Sub MenuItemPropertiesIDB_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemPropertiesIDB.ItemClick
|
||||
If TestObjectIdExists(_CurrentDocumentId, OPEN_PROPERTIES) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(_LogConfig, _Environment, _IDBClient, _CurrentDocumentId)
|
||||
oPropertyDialog.Show()
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemPropertiesECM_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemPropertiesECM.ItemClick
|
||||
If TestPathExists(OPEN_PROPERTIES) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
#End Region
|
||||
|
||||
_File.OpenFileProperties(_CurrentDocument.FullPath)
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemFileOpen_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFileOpen.ItemClick
|
||||
If TestPathExists(OPEN_FILE) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Try
|
||||
Process.Start(New ProcessStartInfo With {
|
||||
.FileName = _CurrentDocument.FullPath
|
||||
})
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemFolderOpen_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFolderOpen.ItemClick
|
||||
If TestPathExists(OPEN_DIRECTORY) = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oArgs As String = $"/e, /select, ""{_CurrentDocument.FullPath}"""
|
||||
Dim oInfo As New ProcessStartInfo() With {
|
||||
.Arguments = oArgs,
|
||||
.FileName = "explorer"
|
||||
}
|
||||
|
||||
Process.Start(oInfo)
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemFilepathCopyIDB_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFilepathCopy.ItemClick
|
||||
Clipboard.SetText(_CurrentDocument.FullPath)
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemFolderpathCopyECM_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFolderpathCopy.ItemClick
|
||||
Dim oFolderPath = IO.Path.GetDirectoryName(_CurrentDocument.FullPath)
|
||||
Clipboard.SetText(oFolderPath)
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user