Common/DocumentResultList: Cache opened files and load as stream
This commit is contained in:
parent
d63d90f0d2
commit
1277c393ba
@ -104,6 +104,7 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="DocumentPropertyMenu\DocumentPropertyMenu.vb" />
|
<Compile Include="DocumentPropertyMenu\DocumentPropertyMenu.vb" />
|
||||||
<Compile Include="DocumentResultList\DocumentResultConfig.vb" />
|
<Compile Include="DocumentResultList\DocumentResultConfig.vb" />
|
||||||
|
<Compile Include="DocumentResultList\DocumentResultInfo.vb" />
|
||||||
<Compile Include="DocumentResultList\DocumentResultList.vb" />
|
<Compile Include="DocumentResultList\DocumentResultList.vb" />
|
||||||
<Compile Include="DocumentResultList\DocumentResultParams.vb" />
|
<Compile Include="DocumentResultList\DocumentResultParams.vb" />
|
||||||
<Compile Include="DocumentResultList\frmDocumentResultList.Designer.vb">
|
<Compile Include="DocumentResultList\frmDocumentResultList.Designer.vb">
|
||||||
@ -112,6 +113,7 @@
|
|||||||
<Compile Include="DocumentResultList\frmDocumentResultList.vb">
|
<Compile Include="DocumentResultList\frmDocumentResultList.vb">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="DocumentResultList\DocumentResultCache.vb" />
|
||||||
<Compile Include="IResultForm.vb" />
|
<Compile Include="IResultForm.vb" />
|
||||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||||
<Compile Include="My Project\Application.Designer.vb">
|
<Compile Include="My Project\Application.Designer.vb">
|
||||||
|
|||||||
117
GUIs.Common/DocumentResultList/DocumentResultCache.vb
Normal file
117
GUIs.Common/DocumentResultList/DocumentResultCache.vb
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
Imports DigitalData.Modules.EDMI.API.Client
|
||||||
|
|
||||||
|
Public Class DocumentResultCache
|
||||||
|
Implements ICollection(Of DocumentResultInfo)
|
||||||
|
|
||||||
|
Private Const _DefaultCapacity As Long = 1000
|
||||||
|
|
||||||
|
Public Shared ReadOnly Property DefaultCapacity As Long
|
||||||
|
Get
|
||||||
|
Return _DefaultCapacity
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
Friend ReadOnly List As New LinkedList(Of DocumentResultInfo)
|
||||||
|
Private ReadOnly Index As New Dictionary(Of String, LinkedListNode(Of DocumentResultInfo))
|
||||||
|
Private ReadOnly Lock As New Object
|
||||||
|
|
||||||
|
Public Sub New()
|
||||||
|
Me.New(_DefaultCapacity)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub New(capacity As Long)
|
||||||
|
If capacity < 0 Then
|
||||||
|
Throw New InvalidOperationException("DocumentResultCache capacity must be positive.")
|
||||||
|
End If
|
||||||
|
|
||||||
|
Me.Capacity = capacity
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Event DiscardingOldestItem As EventHandler
|
||||||
|
Public Property Capacity As Long
|
||||||
|
Public Property Count As Integer Implements ICollection(Of DocumentResultInfo).Count
|
||||||
|
|
||||||
|
Public ReadOnly Property Oldest As DocumentResultInfo
|
||||||
|
Get
|
||||||
|
Return List.First.Value
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
Public Sub Add(item As DocumentResultInfo) Implements ICollection(Of DocumentResultInfo).Add
|
||||||
|
SyncLock Lock
|
||||||
|
If Index.ContainsKey(item.FullPath) Then
|
||||||
|
List.Remove(Index(item.FullPath))
|
||||||
|
Index(item.FullPath) = List.AddLast(item)
|
||||||
|
Return
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Count >= Capacity AndAlso Capacity <> 0 Then
|
||||||
|
RaiseEvent DiscardingOldestItem(Me, New EventArgs())
|
||||||
|
Remove(Oldest)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Index.Add(item.FullPath, List.AddLast(item))
|
||||||
|
|
||||||
|
If item.Contents IsNot Nothing Then
|
||||||
|
Count = Count + item.Contents?.Length
|
||||||
|
End If
|
||||||
|
End SyncLock
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Function Contains(item As DocumentResultInfo) As Boolean Implements ICollection(Of DocumentResultInfo).Contains
|
||||||
|
Return Index.ContainsKey(item.FullPath)
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Sub CopyTo(array As DocumentResultInfo(), ByVal arrayIndex As Integer) Implements ICollection(Of DocumentResultInfo).CopyTo
|
||||||
|
SyncLock Lock
|
||||||
|
|
||||||
|
For Each item As DocumentResultInfo In Me
|
||||||
|
array(Math.Min(System.Threading.Interlocked.Increment(arrayIndex), arrayIndex - 1)) = item
|
||||||
|
Next
|
||||||
|
End SyncLock
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub Clear() Implements ICollection(Of DocumentResultInfo).Clear
|
||||||
|
SyncLock Lock
|
||||||
|
List.Clear()
|
||||||
|
Index.Clear()
|
||||||
|
End SyncLock
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public ReadOnly Property IsReadOnly As Boolean Implements ICollection(Of DocumentResultInfo).IsReadOnly
|
||||||
|
Get
|
||||||
|
Return False
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
Public Function Remove(item As DocumentResultInfo) As Boolean Implements ICollection(Of DocumentResultInfo).Remove
|
||||||
|
SyncLock Lock
|
||||||
|
|
||||||
|
If Index.ContainsKey(item.FullPath) Then
|
||||||
|
List.Remove(Index(item.FullPath))
|
||||||
|
Index.Remove(item.FullPath)
|
||||||
|
|
||||||
|
If item.Contents IsNot Nothing Then
|
||||||
|
Count -= item.Contents.Length
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return True
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return False
|
||||||
|
End SyncLock
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Iterator Function GetEnumerator() As IEnumerator(Of DocumentResultInfo) Implements ICollection(Of DocumentResultInfo).GetEnumerator
|
||||||
|
Dim node As LinkedListNode(Of DocumentResultInfo) = List.First
|
||||||
|
|
||||||
|
While node IsNot Nothing
|
||||||
|
Yield node.Value
|
||||||
|
node = node.[Next]
|
||||||
|
End While
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function IEnumerable_GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
|
||||||
|
Return DirectCast(List, IEnumerable).GetEnumerator()
|
||||||
|
End Function
|
||||||
|
End Class
|
||||||
8
GUIs.Common/DocumentResultList/DocumentResultInfo.vb
Normal file
8
GUIs.Common/DocumentResultList/DocumentResultInfo.vb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Imports DigitalData.Modules.EDMI.API.Client
|
||||||
|
|
||||||
|
Public Class DocumentResultInfo
|
||||||
|
Inherits DocumentInfo
|
||||||
|
|
||||||
|
Public Contents As Byte()
|
||||||
|
Public LastWriteTime As Date
|
||||||
|
End Class
|
||||||
@ -45,14 +45,14 @@ Public Class frmDocumentResultList
|
|||||||
Private _IsLoading As Boolean = True
|
Private _IsLoading As Boolean = True
|
||||||
Private _ActiveGrid As GridControl = Nothing
|
Private _ActiveGrid As GridControl = Nothing
|
||||||
Private _ActiveGridBand As GridBand = Nothing
|
Private _ActiveGridBand As GridBand = Nothing
|
||||||
Private _DocumentInfo As DocumentInfo = Nothing
|
|
||||||
|
|
||||||
' TODO: Hashes for checking if the opened file was modified externally
|
' TODO: Hashes for checking if the opened file was modified externally
|
||||||
Private _HashOriginalFile As String = Nothing
|
Private _HashOriginalFile As String = Nothing
|
||||||
Private _HashOpenedFile As String = Nothing
|
Private _HashOpenedFile As String = Nothing
|
||||||
|
|
||||||
Private WithEvents _FileOpenTimer As New Timer
|
Private WithEvents _FileOpenTimer As New Timer
|
||||||
Private _FileOpenList As New Dictionary(Of Integer, String)
|
Private _OpenDocuments As New DocumentResultCache(50000000)
|
||||||
|
Private _CurrentDocument As DocumentResultInfo = Nothing
|
||||||
|
|
||||||
Private Property OperationMode As IResultForm.Mode Implements IResultForm.OperationMode
|
Private Property OperationMode As IResultForm.Mode Implements IResultForm.OperationMode
|
||||||
|
|
||||||
@ -79,8 +79,8 @@ Public Class frmDocumentResultList
|
|||||||
_Params = Params
|
_Params = Params
|
||||||
_ResultLists = Params.Results
|
_ResultLists = Params.Results
|
||||||
|
|
||||||
_FileOpenTimer.Interval = FILE_OPEN_TIMER_INTERVAL
|
'_FileOpenTimer.Interval = FILE_OPEN_TIMER_INTERVAL
|
||||||
_FileOpenTimer.Start()
|
'_FileOpenTimer.Start()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub frmDocumentResultList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
Private Sub frmDocumentResultList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||||
@ -145,40 +145,45 @@ Public Class frmDocumentResultList
|
|||||||
|
|
||||||
If e.FocusedRowHandle >= 0 Then
|
If e.FocusedRowHandle >= 0 Then
|
||||||
Dim oRow = sender.GetDataRow(e.FocusedRowHandle)
|
Dim oRow = sender.GetDataRow(e.FocusedRowHandle)
|
||||||
|
Dim oDocumentInfo As DocumentResultInfo = Nothing
|
||||||
|
|
||||||
DocumentViewer1.CloseDocument()
|
DocumentViewer1.CloseDocument()
|
||||||
|
|
||||||
If OperationMode = IResultForm.Mode.NoAppServer Then
|
If OperationMode = IResultForm.Mode.NoAppServer Then
|
||||||
LoadFile_Legacy(oRow)
|
oDocumentInfo = LoadFile_Legacy(oRow)
|
||||||
ElseIf OperationMode = IResultForm.Mode.WithAppServer Then
|
ElseIf OperationMode = IResultForm.Mode.WithAppServer Then
|
||||||
LoadFile_IDB(oRow)
|
oDocumentInfo = LoadFile_IDB(oRow)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If IsNothing(_DocumentInfo) Then
|
If IsNothing(oDocumentInfo) Then
|
||||||
Show_Warning("File could not be loaded!")
|
Show_Warning("File could not be loaded!")
|
||||||
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If Not IsNothing(_DocumentInfo) Then
|
If Not File.Exists(oDocumentInfo.FullPath) Then
|
||||||
If _FileOpenList.ContainsValue(_DocumentInfo.FullPath) Then
|
Show_Warning("File does not exist!")
|
||||||
Show_Warning("Die ausgewählte Datei befindet sich im Zugriff!")
|
_HashOriginalFile = Nothing
|
||||||
Else
|
Exit Sub
|
||||||
DocumentViewer1.LoadFile(_DocumentInfo.FullPath)
|
End If
|
||||||
|
|
||||||
If _DocumentInfo.AccessRight = Rights.AccessRight.VIEW_ONLY Then
|
If oDocumentInfo.Contents IsNot Nothing Then
|
||||||
DocumentViewer1.SetViewOnly(True)
|
Dim oFileInfo As New FileInfo(oDocumentInfo.FullPath)
|
||||||
RibbonPageGroup_Export.Visible = False
|
|
||||||
Else
|
DocumentViewer1.LoadFile(oFileInfo.Name, New MemoryStream(oDocumentInfo.Contents))
|
||||||
DocumentViewer1.SetViewOnly(False)
|
Else
|
||||||
RibbonPageGroup_Export.Visible = True
|
DocumentViewer1.LoadFile(oDocumentInfo.FullPath)
|
||||||
End If
|
End If
|
||||||
End If
|
|
||||||
|
If oDocumentInfo.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
|
||||||
|
|
||||||
' TODO: Create checksum after closing, compare and take action
|
' TODO: Create checksum after closing, compare and take action
|
||||||
If File.Exists(_DocumentInfo.FullPath) Then
|
_HashOriginalFile = _Filesystem.GetChecksum(oDocumentInfo.FullPath)
|
||||||
_HashOriginalFile = _Filesystem.GetChecksum(_DocumentInfo.FullPath)
|
|
||||||
Else
|
|
||||||
_HashOriginalFile = Nothing
|
|
||||||
End If
|
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Error(ex)
|
_Logger.Error(ex)
|
||||||
@ -203,31 +208,160 @@ Public Class frmDocumentResultList
|
|||||||
Return True
|
Return True
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Sub LoadFile_Legacy(GridRow As DataRow)
|
Private Function LoadFile_Legacy(GridRow As DataRow) As DocumentResultInfo
|
||||||
Try
|
Try
|
||||||
Dim oFullPath = GridRow.Item(COLUMN_FILEPATH)
|
Dim oFullPath = GridRow.Item(COLUMN_FILEPATH)
|
||||||
|
Dim oDocumentInfo = New DocumentResultInfo() With {
|
||||||
_DocumentInfo = New DocumentInfo() With {
|
|
||||||
.AccessRight = Rights.AccessRight.FULL,
|
.AccessRight = Rights.AccessRight.FULL,
|
||||||
.FullPath = oFullPath
|
.FullPath = oFullPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
If File.Exists(oDocumentInfo.FullPath) Then
|
||||||
|
oDocumentInfo = LoadFile_AsByteArray(oDocumentInfo)
|
||||||
|
_OpenDocuments.Add(oDocumentInfo)
|
||||||
|
_CurrentDocument = oDocumentInfo
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return oDocumentInfo
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Error(ex)
|
_Logger.Error(ex)
|
||||||
MsgBox("Error while loading file", MsgBoxStyle.Critical, Text)
|
Return Nothing
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Function
|
||||||
|
|
||||||
Private Sub LoadFile_IDB(GridRow As DataRow)
|
Private Function LoadFile_IDB(GridRow As DataRow) As DocumentResultInfo
|
||||||
Try
|
Try
|
||||||
Dim oObjectId = GridRow.Item(COLUMN_DOCID)
|
Dim oObjectId = GridRow.Item(COLUMN_DOCID)
|
||||||
_Logger.Debug($"Gettin' Infor for oObjectId: {oObjectId}")
|
_Logger.Debug($"Getting Information for oObjectId: {oObjectId}")
|
||||||
|
|
||||||
' This needs to be Sync bc otherwise the PopupMenuShowing event will fire before this method loaded the Document Info
|
' 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)
|
Dim oDocumentInfo As DocumentInfo = _IDBClient.GetDocumentInfo(_Environment.User.UserId, oObjectId)
|
||||||
|
Dim oResultDocumentInfo As New DocumentResultInfo() With {
|
||||||
|
.AccessRight = oDocumentInfo.AccessRight,
|
||||||
|
.FullPath = oDocumentInfo.FullPath
|
||||||
|
}
|
||||||
|
|
||||||
|
If File.Exists(oResultDocumentInfo.FullPath) Then
|
||||||
|
oResultDocumentInfo = LoadFile_AsByteArray(oResultDocumentInfo)
|
||||||
|
_OpenDocuments.Add(oResultDocumentInfo)
|
||||||
|
_CurrentDocument = oResultDocumentInfo
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return oResultDocumentInfo
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Error(ex)
|
_Logger.Error(ex)
|
||||||
|
Return Nothing
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Function
|
||||||
|
|
||||||
|
Private Function LoadFile_AsByteArray(DocumentInfo As DocumentResultInfo) As DocumentResultInfo
|
||||||
|
Try
|
||||||
|
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
|
||||||
|
|
||||||
|
' Get Information about the file on the filesystem
|
||||||
|
Dim oFileInfo As New FileInfo(oFullPath)
|
||||||
|
|
||||||
|
If oExistsInCache Then
|
||||||
|
Dim oCachedItem = oPathExists.First()
|
||||||
|
|
||||||
|
If oCachedItem.Contents Is Nothing Then
|
||||||
|
oSizeChanged = False
|
||||||
|
Else
|
||||||
|
oSizeChanged = Not (oFileInfo.Length = oCachedItem.Contents.Length)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If oCachedItem.LastWriteTime = Nothing Then
|
||||||
|
oWriteTimeChanged = False
|
||||||
|
Else
|
||||||
|
oWriteTimeChanged = Not oFileInfo.LastWriteTime.Equals(oCachedItem.LastWriteTime)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If oSizeChanged Or oWriteTimeChanged Then
|
||||||
|
Using oStream = File.OpenRead(DocumentInfo.FullPath)
|
||||||
|
Using oMemoryStream = New MemoryStream()
|
||||||
|
oStream.CopyTo(oMemoryStream)
|
||||||
|
DocumentInfo.Contents = oMemoryStream.ToArray()
|
||||||
|
DocumentInfo.LastWriteTime = oFileInfo.LastWriteTime
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
|
||||||
|
Return DocumentInfo
|
||||||
|
Else
|
||||||
|
Return oCachedItem
|
||||||
|
End If
|
||||||
|
|
||||||
|
Else
|
||||||
|
Using oStream = File.OpenRead(DocumentInfo.FullPath)
|
||||||
|
Using oMemoryStream = New MemoryStream()
|
||||||
|
oStream.CopyTo(oMemoryStream)
|
||||||
|
DocumentInfo.Contents = oMemoryStream.ToArray()
|
||||||
|
DocumentInfo.LastWriteTime = oFileInfo.LastWriteTime
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
|
||||||
|
Return DocumentInfo
|
||||||
|
End If
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
|
|
||||||
|
'Private Function LoadFile_AsByteArray(DocumentInfo As DocumentResultInfo)
|
||||||
|
' Try
|
||||||
|
' Dim oLoadedInfo As DocumentResultInfo = Nothing
|
||||||
|
|
||||||
|
' Dim oFileContents As Byte()
|
||||||
|
' Dim oFullPath As String = DocumentInfo.FullPath
|
||||||
|
' Dim oPathExists = From oFile In _OpenDocuments
|
||||||
|
' Where oFile.FullPath = oFullPath And oFile.Contents IsNot Nothing
|
||||||
|
' Select oFile
|
||||||
|
|
||||||
|
' If oPathExists.Count > 0 Then
|
||||||
|
' Dim oDocumentInfo = oPathExists.First()
|
||||||
|
' Dim oFileInfo As New FileInfo(DocumentInfo.FullPath)
|
||||||
|
' Dim oSizeChanged = False
|
||||||
|
' Dim oWriteTimeChanged = False
|
||||||
|
|
||||||
|
' If DocumentInfo.Contents Is Nothing Then
|
||||||
|
' oSizeChanged = False
|
||||||
|
' Else
|
||||||
|
' oSizeChanged = Not oFileInfo.Length.Equals(DocumentInfo.Contents?.Length)
|
||||||
|
' End If
|
||||||
|
|
||||||
|
' If DocumentInfo.LastWriteTime = Nothing Then
|
||||||
|
' oWriteTimeChanged = False
|
||||||
|
' Else
|
||||||
|
' oWriteTimeChanged = Not oFileInfo.LastWriteTime.Equals(DocumentInfo.LastWriteTime)
|
||||||
|
' End If
|
||||||
|
|
||||||
|
' If oSizeChanged Or oWriteTimeChanged Then
|
||||||
|
|
||||||
|
' Else
|
||||||
|
' Using oStream = File.OpenRead(oFullPath)
|
||||||
|
' Using oMemoryStream = New MemoryStream()
|
||||||
|
' oStream.CopyTo(oMemoryStream)
|
||||||
|
' oFileContents = oMemoryStream.ToArray()
|
||||||
|
' End Using
|
||||||
|
' End Using
|
||||||
|
' End If
|
||||||
|
' End If
|
||||||
|
|
||||||
|
' DocumentInfo.Contents = oFileContents
|
||||||
|
' DocumentInfo.LastWriteTime = oFileInfo.LastWriteTime
|
||||||
|
|
||||||
|
' Return DocumentInfo
|
||||||
|
' Catch ex As Exception
|
||||||
|
' _Logger.Error(ex)
|
||||||
|
' Return Nothing
|
||||||
|
' End Try
|
||||||
|
'End Function
|
||||||
|
|
||||||
Public Function RefreshResults(pResults As IEnumerable(Of BaseResult)) As Boolean Implements IResultForm.RefreshResults
|
Public Function RefreshResults(pResults As IEnumerable(Of BaseResult)) As Boolean Implements IResultForm.RefreshResults
|
||||||
_IsLoading = True
|
_IsLoading = True
|
||||||
@ -465,344 +599,343 @@ Public Class frmDocumentResultList
|
|||||||
_Config.Config.SplitContainer2Horizontal = SwitchDetailContainerHorizontal.Checked
|
_Config.Config.SplitContainer2Horizontal = SwitchDetailContainerHorizontal.Checked
|
||||||
_Config.Save()
|
_Config.Save()
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub BarButtonItemExportGrid1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItemExportGrid1.ItemClick
|
Private Sub BarButtonItemExportGrid1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItemExportGrid1.ItemClick
|
||||||
Dim oActiveGrid = GetActiveGridControl()
|
Dim oActiveGrid = GetActiveGridControl()
|
||||||
|
|
||||||
If oActiveGrid IsNot Nothing Then
|
If oActiveGrid IsNot Nothing Then
|
||||||
Dim oGridBand = _ActiveGridBand
|
Dim oGridBand = _ActiveGridBand
|
||||||
|
|
||||||
XtraSaveFileDialog.FileName = Utils.ConvertTextToSlug(oGridBand.Caption) & ".xlsx"
|
XtraSaveFileDialog.FileName = Utils.ConvertTextToSlug(oGridBand.Caption) & ".xlsx"
|
||||||
XtraSaveFileDialog.DefaultExt = ".xlsx"
|
XtraSaveFileDialog.DefaultExt = ".xlsx"
|
||||||
|
|
||||||
If XtraSaveFileDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
|
If XtraSaveFileDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
|
||||||
Dim oOptions As New XlsxExportOptions() With {
|
Dim oOptions As New XlsxExportOptions() With {
|
||||||
.ExportMode = XlsxExportMode.SingleFile
|
.ExportMode = XlsxExportMode.SingleFile
|
||||||
}
|
}
|
||||||
oActiveGrid.ExportToXlsx(XtraSaveFileDialog.FileName, oOptions)
|
oActiveGrid.ExportToXlsx(XtraSaveFileDialog.FileName, oOptions)
|
||||||
End If
|
|
||||||
|
|
||||||
Else
|
|
||||||
MessageBox.Show("Bitte wählen Sie eine Tabelle aus, die Sie exportieren möchten", Text, MessageBoxButtons.OK)
|
|
||||||
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
|
|
||||||
_Config.Save()
|
|
||||||
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
|
|
||||||
_Config.Save()
|
|
||||||
End If
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Function GetActiveRow() As DataRow
|
|
||||||
Dim oActiveGrid = GetActiveGridControl()
|
|
||||||
Dim oActiveRowhandle = _Helpers.ActiveRowHandle
|
|
||||||
|
|
||||||
If oActiveGrid IsNot Nothing And oActiveRowhandle <> Constants.NO_ROW_HANDLE Then
|
|
||||||
Dim oView = DirectCast(oActiveGrid.DefaultView, GridView)
|
|
||||||
Dim oRow = oView.GetDataRow(oActiveRowhandle)
|
|
||||||
Return oRow
|
|
||||||
Else
|
|
||||||
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
|
|
||||||
End If
|
|
||||||
|
|
||||||
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 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
|
|
||||||
BarButtonItemExportGrid1.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
|
||||||
SetActiveGridBand()
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub GridView1_FocusedRowChanged(sender As GridView, e As FocusedRowChangedEventArgs) Handles GridView1.FocusedRowChanged, GridView2.FocusedRowChanged, GridView3.FocusedRowChanged
|
|
||||||
Dim oGrid As GridControl = sender.GridControl
|
|
||||||
_ActiveGrid = oGrid
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub SetActiveGridBand()
|
|
||||||
If _ActiveGrid.Equals(GridControl1) Then
|
|
||||||
_ActiveGridBand = GridBand1
|
|
||||||
ElseIf _ActiveGrid.Equals(GridControl2) Then
|
|
||||||
_ActiveGridBand = GridBand2
|
|
||||||
ElseIf _ActiveGrid.Equals(GridControl3) Then
|
|
||||||
_ActiveGridBand = GridBand3
|
|
||||||
Else
|
|
||||||
_ActiveGridBand = Nothing
|
|
||||||
End If
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub OpenFolderPath()
|
|
||||||
Try
|
|
||||||
Dim oRow = GetActiveRow()
|
|
||||||
|
|
||||||
If oRow IsNot Nothing Then
|
|
||||||
Dim oFilename = _DocumentInfo.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 _DocumentInfo IsNot Nothing Then
|
|
||||||
Dim oFilename = _DocumentInfo.FullPath
|
|
||||||
DocumentPropertyMenu_FileOpened(Me, oFilename)
|
|
||||||
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 = _DocumentInfo.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)
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub GridView2_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView2.ColumnFilterChanged
|
|
||||||
Dim oRowCount = sender.RowCount
|
|
||||||
UpdateGridHeader(_ResultLists, 1, oRowCount)
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub GridView3_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView3.ColumnFilterChanged
|
|
||||||
Dim oRowCount = sender.RowCount
|
|
||||||
UpdateGridHeader(_ResultLists, 2, oRowCount)
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonBack.ItemClick
|
|
||||||
ShouldReturnToPreviousForm = True
|
|
||||||
Close()
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub frmDocumentResultList_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
|
|
||||||
Try
|
|
||||||
_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 _DocumentInfo IsNot Nothing And _DocumentInfo.AccessRight > Rights.AccessRight.VIEW_ONLY Then
|
|
||||||
OpenFile()
|
|
||||||
End If
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
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 oFilepath As String = _DocumentInfo.FullPath
|
|
||||||
Dim oObjectId As Long = oRow.Item(COLUMN_DOCID)
|
|
||||||
Dim oMenu As New DocumentPropertyMenu(_LogConfig, _Environment, _IDBClient, oFilepath, oObjectId)
|
|
||||||
|
|
||||||
e.Menu.Items.Clear()
|
|
||||||
|
|
||||||
For Each oItem In oMenu.GetMenuItems(OperationMode, _DocumentInfo.AccessRight)
|
|
||||||
e.Menu.Items.Add(oItem)
|
|
||||||
Next
|
|
||||||
|
|
||||||
AddHandler oMenu.FileOpened, AddressOf DocumentPropertyMenu_FileOpened
|
|
||||||
' AddHandler oMenu.FileClosed, AddressOf DocumentPropertyMenu_FileClosed
|
|
||||||
End If
|
|
||||||
Catch ex As Exception
|
|
||||||
_Logger.Error(ex)
|
|
||||||
MsgBox("Unexpected Error while preparing context menu", MsgBoxStyle.Critical, Text)
|
|
||||||
End Try
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Public Sub DocumentPropertyMenu_FileOpened(sender As Object, FilePath As String)
|
|
||||||
DocumentViewer1.CloseDocument()
|
|
||||||
|
|
||||||
Dim oProcess = Process.Start(New ProcessStartInfo With {
|
|
||||||
.FileName = FilePath
|
|
||||||
})
|
|
||||||
_FileOpenList.Add(oProcess.Id, FilePath)
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
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
|
End If
|
||||||
|
|
||||||
_FileOpenList = oNewFileOpenList
|
Else
|
||||||
|
MessageBox.Show("Bitte wählen Sie eine Tabelle aus, die Sie exportieren möchten", Text, MessageBoxButtons.OK)
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
End Sub
|
||||||
_Logger.Error(ex)
|
|
||||||
End Try
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Public Sub Show_CriticalError(Message As String)
|
Private Sub SplitContainerControl1_SplitterPositionChanged(sender As Object, e As EventArgs) Handles SplitContainerControl1.SplitterPositionChanged
|
||||||
labelCriticalError.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
If _IsLoading = False Then
|
||||||
labelCriticalError.Caption = Message
|
_Config.Config.SplitContainer1Distance = SplitContainerControl1.SplitterPosition
|
||||||
End Sub
|
_Config.Save()
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
Public Sub Show_Warning(Message As String)
|
Private Sub SplitContainerControl2_SplitterPositionChanged(sender As Object, e As EventArgs) Handles SplitContainerControl2.SplitterPositionChanged
|
||||||
labelWarning.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
If _IsLoading = False Then
|
||||||
labelWarning.Caption = Message
|
_Config.Config.SplitContainer2Distance = SplitContainerControl2.SplitterPosition
|
||||||
End Sub
|
_Config.Save()
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
Public Sub Reset_Errors()
|
Private Function GetActiveRow() As DataRow
|
||||||
labelCriticalError.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
|
Dim oActiveGrid = GetActiveGridControl()
|
||||||
labelWarning.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
|
Dim oActiveRowhandle = _Helpers.ActiveRowHandle
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub BarButtonItem5_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem5.ItemClick
|
If oActiveGrid IsNot Nothing And oActiveRowhandle <> Constants.NO_ROW_HANDLE Then
|
||||||
If Not IsNothing(_ActiveGrid) Then
|
Dim oView = DirectCast(oActiveGrid.DefaultView, GridView)
|
||||||
|
Dim oRow = oView.GetDataRow(oActiveRowhandle)
|
||||||
|
Return oRow
|
||||||
|
Else
|
||||||
|
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
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return _ActiveGrid
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Sub GridViewSave_Layout(pGridView As GridView)
|
||||||
Try
|
Try
|
||||||
Dim oFile = GetDevexpressGrid_LayoutName(_ActiveGrid.MainView)
|
Dim oXml As String = GetDevexpressGrid_LayoutName(pGridView)
|
||||||
If File.Exists(oFile) Then
|
pGridView.SaveLayoutToXml(oXml, OptionsLayoutBase.FullLayout)
|
||||||
File.Delete(oFile)
|
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 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
|
||||||
|
BarButtonItemExportGrid1.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
||||||
|
SetActiveGridBand()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub GridView1_FocusedRowChanged(sender As GridView, e As FocusedRowChangedEventArgs) Handles GridView1.FocusedRowChanged, GridView2.FocusedRowChanged, GridView3.FocusedRowChanged
|
||||||
|
Dim oGrid As GridControl = sender.GridControl
|
||||||
|
_ActiveGrid = oGrid
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub SetActiveGridBand()
|
||||||
|
If _ActiveGrid.Equals(GridControl1) Then
|
||||||
|
_ActiveGridBand = GridBand1
|
||||||
|
ElseIf _ActiveGrid.Equals(GridControl2) Then
|
||||||
|
_ActiveGridBand = GridBand2
|
||||||
|
ElseIf _ActiveGrid.Equals(GridControl3) Then
|
||||||
|
_ActiveGridBand = GridBand3
|
||||||
|
Else
|
||||||
|
_ActiveGridBand = Nothing
|
||||||
|
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
|
End If
|
||||||
UpdateGridData()
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Error(ex)
|
_Logger.Error(ex)
|
||||||
End Try
|
End Try
|
||||||
End If
|
End Sub
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub frmDocumentResultList_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
Private Sub OpenFile()
|
||||||
GridViewSave_Layout(_ActiveGrid.MainView)
|
Try
|
||||||
End Sub
|
If _CurrentDocument IsNot Nothing Then
|
||||||
|
Dim oFilename = _CurrentDocument.FullPath
|
||||||
|
DocumentPropertyMenu_FileOpened(Me, oFilename)
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
_Logger.Error(ex)
|
||||||
|
End Try
|
||||||
|
End Sub
|
||||||
|
|
||||||
Private _DragBoxFromMouseDown As Rectangle
|
|
||||||
Private _ScreenOffset As Point
|
|
||||||
|
|
||||||
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),
|
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)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub GridView2_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView2.ColumnFilterChanged
|
||||||
|
Dim oRowCount = sender.RowCount
|
||||||
|
UpdateGridHeader(_ResultLists, 1, oRowCount)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub GridView3_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView3.ColumnFilterChanged
|
||||||
|
Dim oRowCount = sender.RowCount
|
||||||
|
UpdateGridHeader(_ResultLists, 2, oRowCount)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonBack.ItemClick
|
||||||
|
ShouldReturnToPreviousForm = True
|
||||||
|
Close()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub frmDocumentResultList_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
|
||||||
|
Try
|
||||||
|
_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()
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
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 oFilepath As String = _CurrentDocument.FullPath
|
||||||
|
Dim oObjectId As Long = oRow.Item(COLUMN_DOCID)
|
||||||
|
Dim oMenu As New DocumentPropertyMenu(_LogConfig, _Environment, _IDBClient, oFilepath, oObjectId)
|
||||||
|
|
||||||
|
e.Menu.Items.Clear()
|
||||||
|
|
||||||
|
For Each oItem In oMenu.GetMenuItems(OperationMode, _CurrentDocument.AccessRight)
|
||||||
|
e.Menu.Items.Add(oItem)
|
||||||
|
Next
|
||||||
|
|
||||||
|
AddHandler oMenu.FileOpened, AddressOf DocumentPropertyMenu_FileOpened
|
||||||
|
' AddHandler oMenu.FileClosed, AddressOf DocumentPropertyMenu_FileClosed
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
_Logger.Error(ex)
|
||||||
|
MsgBox("Unexpected Error while preparing context menu", MsgBoxStyle.Critical, Text)
|
||||||
|
End Try
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub DocumentPropertyMenu_FileOpened(sender As Object, FilePath As String)
|
||||||
|
'DocumentViewer1.CloseDocument()
|
||||||
|
|
||||||
|
Dim oProcess = Process.Start(New ProcessStartInfo With {
|
||||||
|
.FileName = FilePath
|
||||||
|
})
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Public Sub Show_CriticalError(Message As String)
|
||||||
|
labelCriticalError.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
||||||
|
labelCriticalError.Caption = Message
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub Show_Warning(Message As String)
|
||||||
|
labelWarning.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
||||||
|
labelWarning.Caption = Message
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub Reset_Errors()
|
||||||
|
labelCriticalError.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
|
||||||
|
labelWarning.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub BarButtonItem5_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem5.ItemClick
|
||||||
|
If Not IsNothing(_ActiveGrid) Then
|
||||||
|
Try
|
||||||
|
Dim oFile = GetDevexpressGrid_LayoutName(_ActiveGrid.MainView)
|
||||||
|
If File.Exists(oFile) Then
|
||||||
|
File.Delete(oFile)
|
||||||
|
End If
|
||||||
|
UpdateGridData()
|
||||||
|
Catch ex As Exception
|
||||||
|
_Logger.Error(ex)
|
||||||
|
End Try
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub frmDocumentResultList_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
||||||
|
GridViewSave_Layout(_ActiveGrid.MainView)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private _DragBoxFromMouseDown As Rectangle
|
||||||
|
Private _ScreenOffset As Point
|
||||||
|
|
||||||
|
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)
|
e.Y - (oDragSize.Height / 2)), oDragSize)
|
||||||
|
|
||||||
Else
|
Else
|
||||||
|
_DragBoxFromMouseDown = Rectangle.Empty
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub GridView1_MouseUp(sender As GridView, e As MouseEventArgs) Handles GridView1.MouseUp
|
||||||
_DragBoxFromMouseDown = Rectangle.Empty
|
_DragBoxFromMouseDown = Rectangle.Empty
|
||||||
End If
|
End Sub
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub GridView1_MouseUp(sender As GridView, e As MouseEventArgs) Handles GridView1.MouseUp
|
Private Sub GridView1_MouseMove(sender As GridView, e As MouseEventArgs) Handles GridView1.MouseMove
|
||||||
_DragBoxFromMouseDown = Rectangle.Empty
|
If e.Button AndAlso e.Button = MouseButtons.Left Then
|
||||||
End Sub
|
If _DragBoxFromMouseDown <> Rectangle.Empty And Not _DragBoxFromMouseDown.Contains(e.X, e.Y) Then
|
||||||
|
|
||||||
Private Sub GridView1_MouseMove(sender As GridView, e As MouseEventArgs) Handles GridView1.MouseMove
|
Dim oHitInfo = sender.CalcHitInfo(e.Location)
|
||||||
If e.Button AndAlso e.Button = MouseButtons.Left Then
|
|
||||||
If _DragBoxFromMouseDown <> Rectangle.Empty And Not _DragBoxFromMouseDown.Contains(e.X, e.Y) Then
|
|
||||||
|
|
||||||
Dim oHitInfo = sender.CalcHitInfo(e.Location)
|
If oHitInfo.InRow Then
|
||||||
|
If _CurrentDocument IsNot Nothing AndAlso _CurrentDocument.AccessRight >= Rights.AccessRight.VIEW_EXPORT Then
|
||||||
|
_ScreenOffset = SystemInformation.WorkingArea.Location
|
||||||
|
|
||||||
If oHitInfo.InRow Then
|
Dim oFullPath As String = _CurrentDocument.FullPath
|
||||||
If _DocumentInfo IsNot Nothing AndAlso _DocumentInfo.AccessRight >= Rights.AccessRight.VIEW_EXPORT Then
|
Dim oFiles As String() = {oFullPath}
|
||||||
_ScreenOffset = SystemInformation.WorkingArea.Location
|
Dim oData As New DataObject(DataFormats.FileDrop, oFiles)
|
||||||
|
|
||||||
Dim oFullPath As String = _DocumentInfo.FullPath
|
sender.GridControl.DoDragDrop(oData, DragDropEffects.All)
|
||||||
Dim oFiles As String() = {oFullPath}
|
End If
|
||||||
Dim oData As New DataObject(DataFormats.FileDrop, oFiles)
|
|
||||||
|
|
||||||
sender.GridControl.DoDragDrop(oData, DragDropEffects.All)
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
End Sub
|
||||||
End Sub
|
End Class
|
||||||
End Class
|
|
||||||
Loading…
x
Reference in New Issue
Block a user