Common: Work on Watcher
This commit is contained in:
parent
27d33672f2
commit
408dacf1b5
@ -111,7 +111,7 @@
|
||||
<Compile Include="DocumentResultList\Config.vb" />
|
||||
<Compile Include="DocumentResultList\Document.vb" />
|
||||
<Compile Include="DocumentResultList\Helpers.vb" />
|
||||
<Compile Include="DocumentResultList\Opener.vb" />
|
||||
<Compile Include="DocumentResultList\Watcher.vb" />
|
||||
<Compile Include="DocumentResultList\Params.vb" />
|
||||
<Compile Include="frmDocumentResultList.Designer.vb">
|
||||
<DependentUpon>frmDocumentResultList.vb</DependentUpon>
|
||||
|
||||
@ -21,12 +21,11 @@ Namespace DocumentResultList
|
||||
''' </summary>
|
||||
Public Property Contents As Byte()
|
||||
|
||||
|
||||
|
||||
' Optional properties
|
||||
Public Property LastWriteTime As Date = Nothing
|
||||
Public Property FullPath As String = Nothing
|
||||
Public Property TempPath As String = Nothing
|
||||
Public Property FileHash As String = Nothing
|
||||
|
||||
Public Sub New(pPrimaryKey As Long)
|
||||
Id = pPrimaryKey
|
||||
|
||||
@ -55,11 +55,11 @@ Namespace DocumentResultList
|
||||
Dim oDocumentInfo As Client.DocumentInfo = Client.GetDocumentInfo(User.UserId, pObjectId)
|
||||
Dim oFileInfo As New FileInfo(oDocumentInfo.FullPath)
|
||||
Dim oResultDocumentInfo As New Document(pObjectId) With {
|
||||
.Contents = Load_FromDisk(oDocumentInfo.FullPath),
|
||||
.AccessRight = oDocumentInfo.AccessRight,
|
||||
.FullPath = oDocumentInfo.FullPath,
|
||||
.Extension = oFileInfo.Extension.Substring(1)
|
||||
}
|
||||
.Contents = Load_FromDisk(oDocumentInfo.FullPath),
|
||||
.AccessRight = oDocumentInfo.AccessRight,
|
||||
.FullPath = oDocumentInfo.FullPath,
|
||||
.Extension = oFileInfo.Extension.Substring(1)
|
||||
}
|
||||
|
||||
Return oResultDocumentInfo
|
||||
Catch ex As Exception
|
||||
@ -76,11 +76,12 @@ Namespace DocumentResultList
|
||||
End If
|
||||
|
||||
Dim oResultDocumentInfo As New Document(pObjectId) With {
|
||||
.Contents = oFileObject._FileContents,
|
||||
.Extension = oFileObject._FileExtension,
|
||||
.AccessRight = Rights.AccessRight.FULL,
|
||||
.FullPath = Nothing
|
||||
}
|
||||
.Contents = oFileObject._FileContents,
|
||||
.Extension = oFileObject._FileExtension,
|
||||
.AccessRight = Rights.AccessRight.FULL,
|
||||
.FileHash = oFileObject._FileHash,
|
||||
.FullPath = Nothing
|
||||
}
|
||||
|
||||
Return oResultDocumentInfo
|
||||
End Function
|
||||
|
||||
@ -1,121 +0,0 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow.Base
|
||||
Imports DigitalData.Modules.Language.DateTimeEx
|
||||
Imports System.IO
|
||||
Imports System.Text
|
||||
Imports System.Timers
|
||||
|
||||
Namespace DocumentResultList
|
||||
Public Class Opener
|
||||
Inherits BaseClass
|
||||
|
||||
Private WithEvents FileOpenTimer As New Timer
|
||||
|
||||
' TODO: Hashes for checking if the opened file was modified externally
|
||||
Private HashOriginalFile As String = Nothing
|
||||
Private HashOpenedFile As String = Nothing
|
||||
|
||||
Private OpenFiles As New Dictionary(Of Integer, Document)
|
||||
|
||||
Public Event ProcessEnded As EventHandler(Of Document)
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function OpenDocument(pDocument As Document) As Boolean
|
||||
Dim oProcessId As Integer = Nothing
|
||||
|
||||
If pDocument.FullPath Is Nothing OrElse pDocument.FullPath.Trim = String.Empty Then
|
||||
oProcessId = OpenFileFromPath(pDocument)
|
||||
|
||||
ElseIf pDocument.Extension IsNot Nothing AndAlso pDocument.Contents IsNot Nothing Then
|
||||
oProcessId = OpenFileFromByteArry(pDocument)
|
||||
|
||||
End If
|
||||
|
||||
If IsNothing(oProcessId) Then
|
||||
Logger.Warn("Process Id was empty. Returning false.")
|
||||
Return False
|
||||
End If
|
||||
|
||||
OpenFiles.Add(oProcessId, pDocument)
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function OpenFileFromByteArry(pDocument As Document) As Integer
|
||||
Try
|
||||
' TODO: Open file from temp folder
|
||||
Dim oTempPath = Path.Combine(Path.GetTempPath(), Constants.TEMP_PATH_SUBFOLDER)
|
||||
Dim oDirectory = Directory.CreateDirectory(oTempPath)
|
||||
Dim oFileName = $"{pDocument.Id}-{Now.UnixTimestamp}.{pDocument.Extension}"
|
||||
Dim oFilePath = Path.Combine(oTempPath, oFileName)
|
||||
|
||||
Using oMemoryStream As New MemoryStream(pDocument.Contents)
|
||||
Using oStreamWriter As New StreamWriter(oFilePath, append:=False, Encoding.UTF8)
|
||||
oMemoryStream.CopyTo(oMemoryStream)
|
||||
End Using
|
||||
End Using
|
||||
|
||||
Dim oProcess = OpenFile(oFilePath)
|
||||
Return oProcess.Id
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function OpenFileFromPath(pDocument As Document) As Integer
|
||||
Try
|
||||
Dim oProcess = OpenFile(pDocument.FullPath)
|
||||
Return oProcess.Id
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function OpenFile(pFilePath As String) As Process
|
||||
Dim oProcess = Process.Start(New ProcessStartInfo With {
|
||||
.FileName = pFilePath
|
||||
})
|
||||
|
||||
Return oProcess
|
||||
End Function
|
||||
|
||||
Private Sub FileOpenTimer_Elapsed() Handles FileOpenTimer.Elapsed
|
||||
Try
|
||||
Dim oIds = Process.GetProcesses().
|
||||
Select(Function(process) process.Id).
|
||||
ToList()
|
||||
|
||||
Dim oNewFileOpenList As New Dictionary(Of Integer, Document)
|
||||
For Each oOpenFile In OpenFiles
|
||||
If oIds.Contains(oOpenFile.Key) Then
|
||||
oNewFileOpenList.Add(oOpenFile.Key, oOpenFile.Value)
|
||||
End If
|
||||
Next
|
||||
|
||||
If oNewFileOpenList.Count < OpenFiles.Count Then
|
||||
Dim oClosedFiles = OpenFiles.
|
||||
Except(oNewFileOpenList).
|
||||
ToList()
|
||||
|
||||
If oClosedFiles.Count = 1 Then
|
||||
Dim oOpenFile = oClosedFiles.First()
|
||||
RaiseEvent ProcessEnded(Me, oOpenFile.Value)
|
||||
End If
|
||||
|
||||
OpenFiles = oNewFileOpenList
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
177
GUIs.Common/DocumentResultList/Watcher.vb
Normal file
177
GUIs.Common/DocumentResultList/Watcher.vb
Normal file
@ -0,0 +1,177 @@
|
||||
Imports System.IO
|
||||
Imports System.Text
|
||||
Imports System.Timers
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow.Base
|
||||
Imports DigitalData.Modules.Language.DateTimeEx
|
||||
|
||||
Namespace DocumentResultList
|
||||
Public Class Watcher
|
||||
Inherits BaseClass
|
||||
|
||||
Private WithEvents FileOpenTimer As New Timer
|
||||
Private FileEx As Modules.Filesystem.File
|
||||
|
||||
' TODO: Hashes for checking if the opened file was modified externally
|
||||
Private HashOriginalFile As String = Nothing
|
||||
Private HashOpenedFile As String = Nothing
|
||||
|
||||
''' <summary>
|
||||
''' List of opened files containing the filepath that was opened and the document id
|
||||
''' </summary>
|
||||
Private ReadOnly OpenFiles As New List(Of OpenFile)
|
||||
|
||||
Public Event FileChanged As EventHandler(Of FileChangedArgs)
|
||||
|
||||
Public Class OpenFile
|
||||
Public Document As Document
|
||||
Public ProcessId As Integer
|
||||
Public FilePath As String
|
||||
Public CurrentlyProcessing As Boolean = False
|
||||
End Class
|
||||
|
||||
Public Class FileChangedArgs
|
||||
Public File As OpenFile
|
||||
End Class
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
FileEx = New Modules.Filesystem.File(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function OpenDocument(pDocument As Document) As Boolean
|
||||
Dim oResult As Tuple(Of Process, String) = Nothing
|
||||
|
||||
If pDocument.FullPath IsNot Nothing OrElse pDocument.FullPath.Trim <> String.Empty Then
|
||||
' TODO: DONT put into openfiles
|
||||
oResult = OpenFileFromPath(pDocument)
|
||||
|
||||
ElseIf pDocument.Extension IsNot Nothing AndAlso pDocument.Contents IsNot Nothing Then
|
||||
oResult = OpenFileFromByteArray(pDocument)
|
||||
|
||||
End If
|
||||
|
||||
If IsNothing(oResult) Then
|
||||
Logger.Warn("Process Id was empty. File [{0}] could not be opened.", pDocument.Id)
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim oProcess = oResult.Item1
|
||||
Dim oFilePath = oResult.Item2
|
||||
|
||||
Logger.Debug("File [{0}] opened with ProcessId [{1}]", oFilePath, oProcess.Id)
|
||||
|
||||
OpenFiles.Add(New OpenFile With {
|
||||
.Document = pDocument,
|
||||
.FilePath = oFilePath,
|
||||
.ProcessId = oProcess.Id
|
||||
})
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Public Sub FileSaved(pOpenFile As OpenFile)
|
||||
pOpenFile.CurrentlyProcessing = False
|
||||
End Sub
|
||||
|
||||
Private Function OpenFileFromByteArray(pDocument As Document) As Tuple(Of Process, String)
|
||||
Try
|
||||
Dim oTempPath = Path.Combine(Path.GetTempPath(), Constants.TEMP_PATH_SUBFOLDER)
|
||||
Dim oDirectory = Directory.CreateDirectory(oTempPath)
|
||||
Dim oFileName = $"{pDocument.Id}-{Now.UnixTimestamp}.{pDocument.Extension}"
|
||||
Dim oFilePath = Path.Combine(oTempPath, oFileName)
|
||||
|
||||
Using oMemoryStream As New MemoryStream(pDocument.Contents)
|
||||
Using oStreamWriter As New StreamWriter(oFilePath, append:=False, Encoding.UTF8)
|
||||
oMemoryStream.CopyTo(oMemoryStream)
|
||||
End Using
|
||||
End Using
|
||||
|
||||
Dim oProcess = DoOpenFile(oFilePath)
|
||||
Return New Tuple(Of Process, String)(oProcess, oFilePath)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function OpenFileFromPath(pDocument As Document) As Tuple(Of Process, String)
|
||||
Try
|
||||
Dim oProcess = DoOpenFile(pDocument.FullPath)
|
||||
Return New Tuple(Of Process, String)(oProcess, pDocument.FullPath)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function DoOpenFile(pFilePath As String) As Process
|
||||
Dim oProcess = Process.Start(New ProcessStartInfo With {
|
||||
.FileName = pFilePath
|
||||
})
|
||||
|
||||
Return oProcess
|
||||
End Function
|
||||
|
||||
Private Sub FileOpenTimer_Elapsed() Handles FileOpenTimer.Elapsed
|
||||
Try
|
||||
For Each oOpenFile In OpenFiles
|
||||
If oOpenFile.CurrentlyProcessing = False Then
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Dim oIsLocked = FileEx.TestFileIsLocked(oOpenFile.FilePath)
|
||||
|
||||
If oIsLocked Then
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Dim oOldHash = oOpenFile.Document.FileHash
|
||||
Dim oNewHash = FileEx.GetChecksum(oOpenFile.FilePath)
|
||||
|
||||
If oNewHash.Equals(oOldHash) = False Then
|
||||
' File changed
|
||||
RaiseEvent FileChanged(Me, New FileChangedArgs() With {.File = oOpenFile})
|
||||
oOpenFile.CurrentlyProcessing = True
|
||||
Else
|
||||
OpenFiles.Remove(oOpenFile)
|
||||
End If
|
||||
Next
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
|
||||
'Try
|
||||
' Dim oIds = Process.GetProcesses().
|
||||
' Select(Function(process) process.Id).
|
||||
' ToList()
|
||||
|
||||
' Dim oNewFileOpenList As New Dictionary(Of Integer, Document)
|
||||
' For Each oOpenFile In OpenFiles
|
||||
' If oIds.Contains(oOpenFile.Key) Then
|
||||
' oNewFileOpenList.Add(oOpenFile.Key, oOpenFile.Value)
|
||||
' End If
|
||||
' Next
|
||||
|
||||
' If oNewFileOpenList.Count < OpenFiles.Count Then
|
||||
' Dim oClosedFiles = OpenFiles.
|
||||
' Except(oNewFileOpenList).
|
||||
' ToList()
|
||||
|
||||
' If oClosedFiles.Count = 1 Then
|
||||
' Dim oOpenFile = oClosedFiles.First()
|
||||
' RaiseEvent ProcessEnded(Me, oOpenFile.Value)
|
||||
' End If
|
||||
|
||||
' OpenFiles = oNewFileOpenList
|
||||
' End If
|
||||
'Catch ex As Exception
|
||||
' Logger.Error(ex)
|
||||
'End Try
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@ -40,17 +40,20 @@ Public Class frmDocumentResultList
|
||||
|
||||
' Helper Classes
|
||||
Private _IDBClient As Client
|
||||
Private ReadOnly _LogConfig As LogConfig
|
||||
Private ReadOnly _Logger As Logger
|
||||
Private ReadOnly _Config As ConfigManager(Of DocumentResultList.Config)
|
||||
Private ReadOnly _Environment As Environment
|
||||
Private ReadOnly _Params As DocumentResultList.Params
|
||||
Private ReadOnly _ResultLists As List(Of DocumentResultList.DocumentResult)
|
||||
Private ReadOnly _Helpers As DocumentResultList.Helpers
|
||||
Private ReadOnly _Filesystem As Modules.Filesystem.File
|
||||
Private ReadOnly _GridBuilder As GridBuilder
|
||||
Private ReadOnly _File As Modules.Windows.File
|
||||
Private ReadOnly _Cache As New DocumentResultList.Cache(50000000)
|
||||
Private ReadOnly LogConfig As LogConfig
|
||||
Private ReadOnly Logger As Logger
|
||||
Private ReadOnly Config As ConfigManager(Of DocumentResultList.Config)
|
||||
Private ReadOnly Environment As Environment
|
||||
Private ReadOnly ResultLists As List(Of DocumentResultList.DocumentResult)
|
||||
Private ReadOnly Filesystem As Modules.Filesystem.File
|
||||
Private ReadOnly GridBuilder As GridBuilder
|
||||
Private ReadOnly FileEx As Modules.Windows.File
|
||||
Private ReadOnly Cache As New DocumentResultList.Cache(50000000)
|
||||
|
||||
Private ReadOnly Helpers As DocumentResultList.Helpers
|
||||
Private ReadOnly Params As DocumentResultList.Params
|
||||
Private WithEvents Watcher As DocumentResultList.Watcher
|
||||
|
||||
Private _Documentloader As DocumentResultList.Loader
|
||||
|
||||
' Runtime variables
|
||||
@ -60,50 +63,53 @@ Public Class frmDocumentResultList
|
||||
Private _DragBoxFromMouseDown As Rectangle
|
||||
Private _ScreenOffset As Point
|
||||
Private _CurrentDocument As DocumentResultList.Document = Nothing
|
||||
Private _FileOpenList As New Dictionary(Of Integer, String)
|
||||
Private ReadOnly _FileOpenList As New Dictionary(Of Integer, String)
|
||||
Private ReadOnly _Language As String
|
||||
|
||||
Private Property OperationMode As OperationMode Implements IResultForm.OperationMode
|
||||
|
||||
Public Property ShouldReturnToPreviousForm As Boolean = False Implements IResultForm.ShouldReturnToPreviousForm
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Environment As Environment, Params As DocumentResultList.Params)
|
||||
Public Sub New(pLogConfig As LogConfig, pEnvironment As Environment, pParams As DocumentResultList.Params)
|
||||
' Dieser Aufruf ist für den Designer erforderlich.
|
||||
InitializeComponent()
|
||||
|
||||
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
||||
Dim oConfigPath As String = Path.Combine(Application.UserAppDataPath, "ResultList", Params.WindowGuid)
|
||||
Dim oConfigPath As String = Path.Combine(Application.UserAppDataPath, "ResultList", pParams.WindowGuid)
|
||||
|
||||
COLUMN_DOCID = Params.ColumnNames.ObjectIdColumn
|
||||
COLUMN_FILENAME = Params.ColumnNames.FilenameColumn
|
||||
COLUMN_FILEPATH = Params.ColumnNames.FullPathColumn
|
||||
COLUMN_ICON = Params.ColumnNames.IconColumn
|
||||
COLUMN_DOCID = pParams.ColumnNames.ObjectIdColumn
|
||||
COLUMN_FILENAME = pParams.ColumnNames.FilenameColumn
|
||||
COLUMN_FILEPATH = pParams.ColumnNames.FullPathColumn
|
||||
COLUMN_ICON = pParams.ColumnNames.IconColumn
|
||||
|
||||
_LogConfig = LogConfig
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_Config = New ConfigManager(Of DocumentResultList.Config)(LogConfig, oConfigPath, oConfigPath)
|
||||
_Helpers = New DocumentResultList.Helpers(LogConfig)
|
||||
_Filesystem = New Modules.Filesystem.File(_LogConfig)
|
||||
_GridBuilder = New GridBuilder(New List(Of GridView) From {GridView1, GridView2, GridView3})
|
||||
_Environment = Environment
|
||||
_Params = Params
|
||||
_File = New Modules.Windows.File(LogConfig)
|
||||
_ResultLists = Params.Results
|
||||
LogConfig = pLogConfig
|
||||
Logger = pLogConfig.GetLogger()
|
||||
|
||||
_Language = Utils.NotNull(_Environment.User.Language, State.UserState.LANG_EN_US)
|
||||
Config = New ConfigManager(Of DocumentResultList.Config)(pLogConfig, oConfigPath, oConfigPath)
|
||||
Helpers = New DocumentResultList.Helpers(pLogConfig)
|
||||
Filesystem = New Modules.Filesystem.File(pLogConfig)
|
||||
GridBuilder = New GridBuilder(New List(Of GridView) From {GridView1, GridView2, GridView3})
|
||||
FileEx = New Modules.Windows.File(pLogConfig)
|
||||
Watcher = New DocumentResultList.Watcher(pLogConfig)
|
||||
|
||||
Environment = pEnvironment
|
||||
Params = pParams
|
||||
ResultLists = pParams.Results
|
||||
|
||||
_Language = Utils.NotNull(Me.Environment.User.Language, State.UserState.LANG_EN_US)
|
||||
End Sub
|
||||
|
||||
Private Function GetOperationMode() As OperationMode
|
||||
Dim oOperationMode As OperationMode
|
||||
|
||||
If _Environment.Service.IsActive AndAlso _Environment.Service.Address <> String.Empty Then
|
||||
If Environment.Service.IsActive AndAlso Environment.Service.Address <> String.Empty Then
|
||||
oOperationMode = OperationMode.WithAppServer
|
||||
Else
|
||||
oOperationMode = OperationMode.NoAppServer
|
||||
End If
|
||||
|
||||
If _Params.OperationModeOverride <> OperationMode.None Then
|
||||
oOperationMode = _Params.OperationModeOverride
|
||||
If Params.OperationModeOverride <> OperationMode.None Then
|
||||
oOperationMode = Params.OperationModeOverride
|
||||
End If
|
||||
|
||||
Return oOperationMode
|
||||
@ -118,33 +124,32 @@ Public Class frmDocumentResultList
|
||||
InitAppServer()
|
||||
End If
|
||||
|
||||
_Documentloader = New DocumentResultList.Loader(_LogConfig, OperationMode, _IDBClient, _Environment.User)
|
||||
_Documentloader = New DocumentResultList.Loader(LogConfig, OperationMode, _IDBClient, Environment.User)
|
||||
|
||||
|
||||
If _Params.WindowTitle <> "" Then
|
||||
Text = $"{Text} - {_Params.WindowTitle}"
|
||||
If Params.WindowTitle <> "" Then
|
||||
Text = $"{Text} - {Params.WindowTitle}"
|
||||
End If
|
||||
|
||||
' Initialize Viewer with GDPicture.NET License
|
||||
If _Environment.Settings.GdPictureKey = String.Empty Then
|
||||
If Environment.Settings.GdPictureKey = String.Empty Then
|
||||
Throw New ApplicationException("GDPicture Licensekey is missing!")
|
||||
End If
|
||||
DocumentViewer1.Init(_LogConfig, _Environment.Settings.GdPictureKey)
|
||||
DocumentViewer1.Init(LogConfig, Environment.Settings.GdPictureKey)
|
||||
|
||||
'Load config
|
||||
SplitContainerControl1.SplitterPosition = _Config.Config.SplitContainer1Distance
|
||||
SwitchMainContainerHorizontal.Checked = _Config.Config.SplitContainer1Horizontal
|
||||
SplitContainerControl2.SplitterPosition = _Config.Config.SplitContainer2Distance
|
||||
SwitchDetailContainerHorizontal.Checked = _Config.Config.SplitContainer2Horizontal
|
||||
SplitContainerControl1.SplitterPosition = Config.Config.SplitContainer1Distance
|
||||
SwitchMainContainerHorizontal.Checked = Config.Config.SplitContainer1Horizontal
|
||||
SplitContainerControl2.SplitterPosition = Config.Config.SplitContainer2Distance
|
||||
SwitchDetailContainerHorizontal.Checked = Config.Config.SplitContainer2Horizontal
|
||||
|
||||
If OperationMode <> OperationMode.NoAppServer Then
|
||||
' Location and size will be managed by the ZooFlow Search Window
|
||||
If Utils.IsVisibleOnAnyScreen(_Config.Config.WindowLocation) Then
|
||||
If Utils.LocationIsVisible(_Config.Config.WindowLocation) Then
|
||||
Location = _Config.Config.WindowLocation
|
||||
If Utils.IsVisibleOnAnyScreen(Config.Config.WindowLocation) Then
|
||||
If Utils.LocationIsVisible(Config.Config.WindowLocation) Then
|
||||
Location = Config.Config.WindowLocation
|
||||
End If
|
||||
If Utils.SizeIsVisible(_Config.Config.WindowSize) Then
|
||||
Size = _Config.Config.WindowSize
|
||||
If Utils.SizeIsVisible(Config.Config.WindowSize) Then
|
||||
Size = Config.Config.WindowSize
|
||||
End If
|
||||
End If
|
||||
|
||||
@ -152,7 +157,7 @@ Public Class frmDocumentResultList
|
||||
SwitchDetailContainerHorizontal.Visibility = BarItemVisibility.Never
|
||||
End If
|
||||
|
||||
_GridBuilder.
|
||||
GridBuilder.
|
||||
WithDefaults().
|
||||
WithReadOnlyOptions()
|
||||
|
||||
@ -163,7 +168,7 @@ Public Class frmDocumentResultList
|
||||
UpdateTotalResults()
|
||||
UpdateGridData()
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
MessageBox.Show("Error while loading results:" & vbNewLine & vbNewLine & ex.Message, Text)
|
||||
Finally
|
||||
_IsLoading = False
|
||||
@ -174,25 +179,25 @@ Public Class frmDocumentResultList
|
||||
Try
|
||||
GridViewSave_Layout(_ActiveGrid.MainView)
|
||||
|
||||
_Config.Config.WindowLocation = Location
|
||||
_Config.Config.WindowSize = Size
|
||||
_Config.Save()
|
||||
Config.Config.WindowLocation = Location
|
||||
Config.Config.WindowSize = Size
|
||||
Config.Save()
|
||||
|
||||
DocumentViewer1.Done()
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub GridView_FocusedRowChanged(sender As GridView, e As FocusedRowChangedEventArgs)
|
||||
_Helpers.SetRowHandle(e)
|
||||
Helpers.SetRowHandle(e)
|
||||
|
||||
Try
|
||||
Reset_Errors()
|
||||
Cursor = Cursors.WaitCursor
|
||||
|
||||
If e.FocusedRowHandle >= 0 Then
|
||||
Dim oRow = sender.GetDataRow(_Helpers.ActiveRowHandle)
|
||||
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 DocumentResultList.Document = Nothing
|
||||
@ -223,22 +228,29 @@ Public Class frmDocumentResultList
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
Show_CriticalError(ex.Message)
|
||||
Finally
|
||||
Cursor = Cursors.Default
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub Watcher_FileChanged(sender As Object, e As DocumentResultList.Watcher.FileChangedArgs) Handles Watcher.FileChanged
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Function InitAppServer() As Boolean
|
||||
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)
|
||||
|
||||
_IDBClient = New Client(_LogConfig, oAddress, oPort)
|
||||
_IDBClient = New Client(LogConfig, oAddress, oPort)
|
||||
' TODO: INitialize databasewithfallback
|
||||
'_Database
|
||||
|
||||
If Not _IDBClient.Connect() Then
|
||||
_Logger.Warn("Client could not connect to Service at [{0}]", _Environment.Service.Address)
|
||||
Logger.Warn("Client could not connect to Service at [{0}]", Environment.Service.Address)
|
||||
Return False
|
||||
End If
|
||||
|
||||
@ -254,7 +266,7 @@ Public Class frmDocumentResultList
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
MessageBox.Show("Error while loading results:" & vbNewLine & vbNewLine & ex.Message, Text)
|
||||
Return False
|
||||
Finally
|
||||
@ -277,31 +289,31 @@ Public Class frmDocumentResultList
|
||||
|
||||
Private Sub UpdateGridData()
|
||||
' Load Grids
|
||||
For oIndex = 0 To _ResultLists.Count - 1
|
||||
For oIndex = 0 To ResultLists.Count - 1
|
||||
Select Case oIndex
|
||||
Case 0
|
||||
Dim oResult As DocumentResultList.DocumentResult = _ResultLists.Item(0)
|
||||
Dim oResult As DocumentResultList.DocumentResult = ResultLists.Item(0)
|
||||
|
||||
LoadGridData(oResult)
|
||||
CreateDocumentGrid(GridView1, oResult)
|
||||
RestoreLayout(GridView1)
|
||||
UpdateGridHeader(_ResultLists, oIndex, oResult.Datatable.Rows.Count)
|
||||
UpdateGridHeader(ResultLists, oIndex, oResult.Datatable.Rows.Count)
|
||||
|
||||
Case 1
|
||||
Dim oResult As DocumentResultList.DocumentResult = _ResultLists.Item(1)
|
||||
Dim oResult As DocumentResultList.DocumentResult = ResultLists.Item(1)
|
||||
|
||||
LoadGridData(oResult)
|
||||
CreateDocumentGrid(GridView2, oResult)
|
||||
RestoreLayout(GridView2)
|
||||
UpdateGridHeader(_ResultLists, oIndex, oResult.Datatable.Rows.Count)
|
||||
UpdateGridHeader(ResultLists, oIndex, oResult.Datatable.Rows.Count)
|
||||
|
||||
Case 2
|
||||
Dim oResult As DocumentResultList.DocumentResult = _ResultLists.Item(2)
|
||||
Dim oResult As DocumentResultList.DocumentResult = ResultLists.Item(2)
|
||||
|
||||
LoadGridData(oResult)
|
||||
CreateDocumentGrid(GridView3, oResult)
|
||||
RestoreLayout(GridView3)
|
||||
UpdateGridHeader(_ResultLists, oIndex, oResult.Datatable.Rows.Count)
|
||||
UpdateGridHeader(ResultLists, oIndex, oResult.Datatable.Rows.Count)
|
||||
|
||||
Case Else
|
||||
MessageBox.Show(Constants.MESSAGE_TOO_MANY_SEARCHES, Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
@ -310,7 +322,7 @@ Public Class frmDocumentResultList
|
||||
Next
|
||||
|
||||
' Hide Grids depending on Result count
|
||||
Select Case _ResultLists.Count
|
||||
Select Case ResultLists.Count
|
||||
Case 0
|
||||
|
||||
SplitContainerControl1.SetPanelCollapsed(True)
|
||||
@ -342,7 +354,7 @@ Public Class frmDocumentResultList
|
||||
Private Sub UpdateTotalResults()
|
||||
Dim oTotalResults = 0
|
||||
|
||||
For Each oList In _ResultLists
|
||||
For Each oList In ResultLists
|
||||
oTotalResults += oList.Datatable.Rows.Count
|
||||
Next
|
||||
|
||||
@ -411,25 +423,25 @@ Public Class frmDocumentResultList
|
||||
Dim oCreatedColumn = GridView.Columns(oCreated)
|
||||
If Not IsNothing(oCreatedColumn) Then
|
||||
oCreatedColumn.DisplayFormat.FormatType = FormatType.DateTime
|
||||
oCreatedColumn.DisplayFormat.FormatString = _Environment.User.DateFormat & " HH:MM:ss"
|
||||
oCreatedColumn.DisplayFormat.FormatString = Environment.User.DateFormat & " HH:MM:ss"
|
||||
End If
|
||||
|
||||
Dim oChangedColumn = GridView.Columns(oChanged)
|
||||
If Not IsNothing(oChangedColumn) Then
|
||||
oChangedColumn.DisplayFormat.FormatType = FormatType.DateTime
|
||||
oChangedColumn.DisplayFormat.FormatString = _Environment.User.DateFormat & " HH:MM:ss"
|
||||
oChangedColumn.DisplayFormat.FormatString = Environment.User.DateFormat & " HH:MM:ss"
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
|
||||
GridView.OptionsView.BestFitMaxRowCount = 30
|
||||
GridView.BestFitColumns()
|
||||
Catch ex As ApplicationException
|
||||
MsgBox($"Error while loading grid data for search {Result.Title}: {vbNewLine}{vbNewLine}{ex.Message}", MsgBoxStyle.Critical, Text)
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@ -447,14 +459,14 @@ Public Class frmDocumentResultList
|
||||
Dim oValue = oRow.Item(COLUMN_FILENAME)
|
||||
|
||||
If e.Column.FieldName = COLUMN_ICON Then
|
||||
Dim oIcon = _Helpers.GetIconByExtension(oValue)
|
||||
Dim oIcon = Helpers.GetIconByExtension(oValue)
|
||||
Dim offsetX = 0
|
||||
Dim offsetY = 0
|
||||
|
||||
e.Cache.DrawImage(oIcon, e.Bounds.X + offsetX, e.Bounds.Y + offsetY, 18, 18)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@ -485,7 +497,7 @@ Public Class frmDocumentResultList
|
||||
|
||||
Private Function GetActiveRow() As DataRow
|
||||
Dim oActiveGrid = GetActiveGridControl()
|
||||
Dim oActiveRowhandle = _Helpers.ActiveRowHandle
|
||||
Dim oActiveRowhandle = Helpers.ActiveRowHandle
|
||||
|
||||
If oActiveGrid IsNot Nothing And oActiveRowhandle <> Constants.NO_ROW_HANDLE Then
|
||||
Dim oView = DirectCast(oActiveGrid.DefaultView, GridView)
|
||||
@ -529,17 +541,17 @@ Public Class frmDocumentResultList
|
||||
|
||||
Private Sub GridView1_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView1.ColumnFilterChanged
|
||||
Dim oRowCount = sender.RowCount
|
||||
UpdateGridHeader(_ResultLists, 0, oRowCount)
|
||||
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)
|
||||
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)
|
||||
UpdateGridHeader(ResultLists, 2, oRowCount)
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonBack.ItemClick
|
||||
@ -579,7 +591,7 @@ Public Class frmDocumentResultList
|
||||
End If
|
||||
UpdateGridData()
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End If
|
||||
End Sub
|
||||
@ -604,6 +616,7 @@ Public Class frmDocumentResultList
|
||||
|
||||
|
||||
|
||||
|
||||
#Region "Context Menu"
|
||||
|
||||
Private Sub GridView_PopupMenuShowing(sender As Object, e As PopupMenuShowingEventArgs) Handles GridView2.PopupMenuShowing, GridView3.PopupMenuShowing, GridView1.PopupMenuShowing
|
||||
@ -637,7 +650,7 @@ Public Class frmDocumentResultList
|
||||
_CurrentDocument.Id = Nothing
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
MsgBox("Unexpected Error while preparing context menu", MsgBoxStyle.Critical, Text)
|
||||
End Try
|
||||
End Sub
|
||||
@ -652,7 +665,7 @@ Public Class frmDocumentResultList
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
_File.OpenFileProperties(_CurrentDocument.FullPath)
|
||||
FileEx.OpenFileProperties(_CurrentDocument.FullPath)
|
||||
End Sub
|
||||
|
||||
Private Sub MenuItemFilepathCopyIDB_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFilepathCopy.ItemClick
|
||||
@ -678,7 +691,7 @@ Public Class frmDocumentResultList
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(_LogConfig, _Environment, _IDBClient, _CurrentDocument.Id)
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(LogConfig, Environment, _IDBClient, _CurrentDocument.Id)
|
||||
oPropertyDialog.Show()
|
||||
End Sub
|
||||
|
||||
@ -692,7 +705,7 @@ Public Class frmDocumentResultList
|
||||
.FileName = _CurrentDocument.FullPath
|
||||
})
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@ -701,7 +714,7 @@ Public Class frmDocumentResultList
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(_LogConfig, _Environment, _IDBClient, _CurrentDocument.Id)
|
||||
Dim oPropertyDialog As New frmObjectPropertyDialog(LogConfig, Environment, _IDBClient, _CurrentDocument.Id)
|
||||
oPropertyDialog.Show()
|
||||
End Sub
|
||||
|
||||
@ -751,35 +764,35 @@ Public Class frmDocumentResultList
|
||||
#Region "Layout"
|
||||
Private Sub SplitContainerControl1_SplitterPositionChanged(sender As Object, e As EventArgs) Handles SplitContainerControl1.SplitterPositionChanged
|
||||
If _IsLoading = False Then
|
||||
_Config.Config.SplitContainer1Distance = SplitContainerControl1.SplitterPosition
|
||||
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
|
||||
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
|
||||
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
|
||||
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)
|
||||
Return Path.Combine(Config.UserConfigPath.Replace("UserConfig.xml", ""), Filename)
|
||||
End Function
|
||||
|
||||
|
||||
@ -788,8 +801,8 @@ Public Class frmDocumentResultList
|
||||
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)
|
||||
Logger.Error(ex)
|
||||
Logger.Info("Error while saving GridLayout: " & ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
Private Sub RestoreLayout(pGridView As GridView)
|
||||
@ -799,8 +812,8 @@ Public Class frmDocumentResultList
|
||||
pGridView.RestoreLayoutFromXml(oLayoutFile, OptionsLayoutBase.FullLayout)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Info("Error while restoring layout: " & ex.Message)
|
||||
Logger.Error(ex)
|
||||
Logger.Info("Error while restoring layout: " & ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user