Compare commits
4 Commits
b0f79c3f3a
...
718e373e87
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
718e373e87 | ||
|
|
29f0e4d7f1 | ||
|
|
b00ffff0d9 | ||
|
|
cc24b8eb31 |
@@ -1,5 +1,5 @@
|
||||
DevExpress.XtraSpreadsheet.SpreadsheetControl, DevExpress.XtraSpreadsheet.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
|
||||
DevExpress.XtraRichEdit.RichEditControl, DevExpress.XtraRichEdit.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
|
||||
DevExpress.XtraEditors.Repository.RepositoryItemTextEdit, DevExpress.XtraEditors.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
|
||||
DevExpress.XtraEditors.Repository.RepositoryItemComboBox, DevExpress.XtraEditors.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
|
||||
DevExpress.XtraRichEdit.RichEditControl, DevExpress.XtraRichEdit.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
|
||||
DevExpress.XtraBars.BarManager, DevExpress.XtraBars.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Public Class Constants
|
||||
Public Const TEMP_PATH_SUBFOLDER = "DigitalData_Common"
|
||||
|
||||
Public Const NO_ROW_HANDLE = -1
|
||||
|
||||
Public Shared ReadOnly MESSAGE_TOO_MANY_SEARCHES = "You have more than three searches configured. This Window will only show the first three result lists!"
|
||||
|
||||
@@ -13,7 +13,7 @@ Namespace DocumentResultList
|
||||
|
||||
''' <summary>
|
||||
''' Extension is needed for determining the type of file
|
||||
''' and showing it in the DocumentViewer
|
||||
''' and showing it in the DocumentViewer. It is saved without the dot-separator.
|
||||
''' </summary>
|
||||
Public Property Extension As String
|
||||
''' <summary>
|
||||
|
||||
@@ -1,51 +1,121 @@
|
||||
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 Sub OpenDocument(pDocument As Document)
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
|
||||
End Sub
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function OpenFileFromByteArry(pDocument As Document) As Integer
|
||||
Try
|
||||
' TODO: Open file from temp folder
|
||||
Dim oTempPath = IO.Path.GetTempPath()
|
||||
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 = Process.Start(New ProcessStartInfo With {
|
||||
.FileName = pDocument.FullPath
|
||||
})
|
||||
|
||||
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
|
||||
@@ -63,12 +63,6 @@ Public Class frmDocumentResultList
|
||||
Private _FileOpenList As New Dictionary(Of Integer, String)
|
||||
Private ReadOnly _Language As String
|
||||
|
||||
' TODO: Hashes for checking if the opened file was modified externally
|
||||
Private _HashOriginalFile As String = Nothing
|
||||
Private _HashOpenedFile As String = Nothing
|
||||
|
||||
Private WithEvents _FileOpenTimer As New Timer
|
||||
|
||||
Private Property OperationMode As OperationMode Implements IResultForm.OperationMode
|
||||
|
||||
Public Property ShouldReturnToPreviousForm As Boolean = False Implements IResultForm.ShouldReturnToPreviousForm
|
||||
@@ -609,38 +603,7 @@ Public Class frmDocumentResultList
|
||||
End Function
|
||||
|
||||
|
||||
Public Sub FileOpenTimer_Elapsed() Handles _FileOpenTimer.Tick
|
||||
Try
|
||||
Dim oIds = Process.GetProcesses().
|
||||
Select(Function(process) process.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
|
||||
|
||||
@@ -228,12 +228,12 @@ Public Class frmFlowSearch
|
||||
}
|
||||
Dim oShortGuid = Guid.NewGuid()
|
||||
Dim oWindowGuid = $"FLOWSEARCH-{My.User.Name}"
|
||||
Dim oParams = New DocumentResultParams() With {
|
||||
Dim oParams = New DocumentResultList.Params() With {
|
||||
.WindowGuid = oWindowGuid,
|
||||
.Results = New List(Of DocumentResultList) From {
|
||||
New DocumentResultList() With {
|
||||
.Title = "FlowSearchResult",
|
||||
.Datatable = pDTRESULT
|
||||
.DataTable = pDTRESULT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -951,10 +951,10 @@ Public Class frmSearchStart
|
||||
If oDTSearchResult.Rows.Count > 0 Then
|
||||
Dim oShortGuid = Guid.NewGuid()
|
||||
Dim oWindowGuid = $"{SEARCH_ID.ToString}-{My.User.Name}"
|
||||
Dim oParams = New DocumentResultParams() With {
|
||||
Dim oParams = New DocumentResultList.Params() With {
|
||||
.WindowGuid = oWindowGuid,
|
||||
.Results = New List(Of DocumentResultList) From {
|
||||
New DocumentResultList() With {
|
||||
.Results = New List(Of DocumentResultList.DocumentResult) From {
|
||||
New DocumentResultList.DocumentResult() With {
|
||||
.Title = SelectedTab.Text,
|
||||
.Datatable = oDTSearchResult
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ Public Class MSSQLServer
|
||||
Dim oConnectionStringBuilder As New SqlConnectionStringBuilder() With {
|
||||
.DataSource = Server,
|
||||
.InitialCatalog = Database,
|
||||
.UserID = UserId,
|
||||
.UserId = UserId,
|
||||
.Password = Password
|
||||
}
|
||||
|
||||
|
||||
12
Modules.Language/DateTimeEx.vb
Normal file
12
Modules.Language/DateTimeEx.vb
Normal file
@@ -0,0 +1,12 @@
|
||||
Imports System.Runtime.CompilerServices
|
||||
|
||||
Public Module DateTimeEx
|
||||
Const UnixEraStartTicks As Long = 621355968000000000
|
||||
<Extension> Public Function UnixTimestamp(value As Date) As Long
|
||||
Dim UnixEraTicks = value.Ticks - UnixEraStartTicks
|
||||
Return UnixEraTicks \ 10000
|
||||
End Function
|
||||
Public Function DateFromUnix(timestamp As Long) As Date
|
||||
Return New Date(UnixEraStartTicks + timestamp * 10000)
|
||||
End Function
|
||||
End Module
|
||||
@@ -75,6 +75,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DataTableEx.vb" />
|
||||
<Compile Include="DateTimeEx.vb" />
|
||||
<Compile Include="InvalidChars.vb" />
|
||||
<Compile Include="Utils.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
|
||||
Reference in New Issue
Block a user