WIP: add new doc result form
This commit is contained in:
parent
4534f2529b
commit
f0e4dfcbd4
@ -71,6 +71,9 @@
|
||||
<Reference Include="DigitalData.Controls.RegexEditor">
|
||||
<HintPath>P:\Projekte DIGITAL DATA\DIGITAL DATA - Entwicklung\DLL_Bibliotheken\Digital Data\Controls\DigitalData.Controls.RegexEditor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DigitalData.GUIs.Common">
|
||||
<HintPath>..\..\..\DDMonorepo\GUIs.Common\bin\Debug\DigitalData.GUIs.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DigitalData.Modules.Config">
|
||||
<HintPath>..\..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
|
||||
</Reference>
|
||||
@ -82,8 +85,9 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\DDMonorepo\Filesystem\bin\Debug\DigitalData.Modules.Filesystem.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DigitalData.Modules.Language">
|
||||
<HintPath>P:\Projekte DIGITAL DATA\DIGITAL DATA - Entwicklung\DLL_Bibliotheken\Digital Data\DigitalData.Modules.Language.dll</HintPath>
|
||||
<Reference Include="DigitalData.Modules.Language, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\DDMonorepo\Modules.Language\bin\Debug\DigitalData.Modules.Language.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DigitalData.Modules.Logging">
|
||||
<HintPath>..\..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
|
||||
@ -91,6 +95,9 @@
|
||||
<Reference Include="DigitalData.Modules.Windows">
|
||||
<HintPath>..\..\..\DDMonorepo\Windows\bin\Debug\DigitalData.Modules.Windows.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DigitalData.Modules.ZooFlow">
|
||||
<HintPath>..\..\..\DDMonorepo\Modules.ZooFlow\bin\Debug\DigitalData.Modules.ZooFlow.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="GdPicture.NET.14">
|
||||
<HintPath>D:\ProgramFiles\GdPicture.NET 14\Redist\GdPicture.NET\GdPicture.NET.14.dll</HintPath>
|
||||
</Reference>
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
Imports DD_Clipboard_Watcher.ClassProfileFilter
|
||||
Imports DD_Clipboard_Watcher.ClassConstants
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DigitalData.GUIs.Common
|
||||
Imports DigitalData.Modules
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
|
||||
Public Class frmProfileMatch
|
||||
Private PrimaryFont As New Font("Segoe UI", 12, FontStyle.Bold)
|
||||
@ -9,6 +14,15 @@ Public Class frmProfileMatch
|
||||
Private OpenForms As New List(Of IResultForm)
|
||||
Private ShouldHideInitially As Boolean = False
|
||||
|
||||
Public Class DocumentSearch
|
||||
Public Guid As Integer
|
||||
Public DataTable As DataTable
|
||||
Public TabIndex As Integer
|
||||
Public TabCaption As String
|
||||
Public ProfileId As Integer
|
||||
Public SQLCommand As String
|
||||
End Class
|
||||
|
||||
Private Enum ProfileType
|
||||
ANY = 0
|
||||
DOCS_ONLY = 1
|
||||
@ -177,7 +191,41 @@ Public Class frmProfileMatch
|
||||
Hide()
|
||||
End Sub
|
||||
|
||||
Private Sub OpenResultForms(ProfileId As Integer, OpenType As ProfileType)
|
||||
Private Async Function LoadSearchesAsync(MatchingProfiles As List(Of ProfileData)) As Task(Of List(Of DocumentSearch))
|
||||
Return Await Task.Run(Function()
|
||||
Return DoLoadSearches(MatchingProfiles)
|
||||
End Function)
|
||||
End Function
|
||||
|
||||
Private Function DoLoadSearches(MatchingProfiles As List(Of ProfileData)) As List(Of DocumentSearch)
|
||||
Dim oMatchingIds = String.Join(",", MatchingProfiles.Select(Function(p) p.Guid).ToArray())
|
||||
Dim oSQL As String = $"SELECT * FROM TBCW_PROF_DOC_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID in ({oMatchingIds}) ORDER BY TAB_INDEX"
|
||||
Dim oSearchesDataTable = Database.GetDatatable(oSQL)
|
||||
Dim oDocSearches As New List(Of DocumentSearch)
|
||||
|
||||
For Each oRow As DataRow In oSearchesDataTable.Rows
|
||||
Dim oGuid As Integer = oRow.Item("GUID")
|
||||
Dim oProfileId As Integer = oRow.Item("PROFILE_ID")
|
||||
Dim oTabTitle As String = oRow.Item("TAB_TITLE")
|
||||
Dim oConnectionId As Integer = oRow.Item("CONN_ID")
|
||||
|
||||
oSQL = oRow.Item("SQL_COMMAND")
|
||||
oSQL = clsPatterns.ReplaceAllValues(oSQL, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, oProfileId)
|
||||
|
||||
Dim oDatatable As DataTable = GetDatatable(oSQL, oConnectionId)
|
||||
oDocSearches.Add(New DocumentSearch() With {
|
||||
.Guid = oGuid,
|
||||
.DataTable = oDatatable,
|
||||
.ProfileId = oProfileId,
|
||||
.TabCaption = oTabTitle,
|
||||
.SQLCommand = oSQL
|
||||
})
|
||||
Next
|
||||
|
||||
Return oDocSearches
|
||||
End Function
|
||||
|
||||
Private Async Sub OpenResultForms(ProfileId As Integer, OpenType As ProfileType)
|
||||
Dim oMatchingProfiles As New List(Of ProfileData)
|
||||
|
||||
' TODO: Implement Show All
|
||||
@ -186,13 +234,24 @@ Public Class frmProfileMatch
|
||||
Dim oProfile As ProfileData = CURRENT_MATCHING_PROFILES.
|
||||
Where(Function(p) p.Guid = ProfileId).
|
||||
First()
|
||||
oMatchingProfiles.Add(oProfile)
|
||||
oMatchingProfiles.Add(oProfile)
|
||||
|
||||
Dim oSearches As List(Of DocumentSearch) = Await LoadSearchesAsync(oMatchingProfiles)
|
||||
Dim oEnvironment = GetEnvironment()
|
||||
Dim oParams = GetParams(oProfile, oSearches)
|
||||
|
||||
If OpenType = ProfileType.ANY Or OpenType = ProfileType.DOCS_ONLY Then
|
||||
' Show Result Document Form
|
||||
Dim oForm As New frmResultDoc(Me, oMatchingProfiles)
|
||||
AddHandler oForm.FormClosed, AddressOf ProfileResultForm_Closed
|
||||
OpenForms.Add(oForm)
|
||||
|
||||
Dim oForm As New frmDocumentResultList(LogConfig, oEnvironment, oParams)
|
||||
' TODO: Reopen match form
|
||||
'AddHandler oForm.FormClosed, AddressOf ProfileResultForm_Closed
|
||||
'OpenForms.Add(oForm)
|
||||
|
||||
|
||||
'Dim oForm As New frmResultDoc(Me, oMatchingProfiles)
|
||||
'AddHandler oForm.FormClosed, AddressOf ProfileResultForm_Closed
|
||||
'OpenForms.Add(oForm)
|
||||
|
||||
oForm.Show()
|
||||
End If
|
||||
@ -207,6 +266,86 @@ Public Class frmProfileMatch
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function GetParams(Profile As ProfileData, DocumentSearches As List(Of DocumentSearch)) As DocumentResultParams
|
||||
Dim oResults As New List(Of DocumentResult)
|
||||
|
||||
For Each oSearch In DocumentSearches
|
||||
oResults.Add(New DocumentResult() With {
|
||||
.Datatable = oSearch.DataTable,
|
||||
.Title = oSearch.TabCaption
|
||||
})
|
||||
Next
|
||||
|
||||
Dim oParams As New DocumentResultParams() With {
|
||||
.WindowGuid = GetWindowId(Profile, DocumentSearches),
|
||||
.Results = oResults
|
||||
}
|
||||
|
||||
Return oParams
|
||||
End Function
|
||||
|
||||
Private Function GetWindowId(Profile As ProfileData, Searches As List(Of DocumentSearch)) As String
|
||||
Dim oNameSlug = Utils.ConvertTextToSlug(Profile.Name)
|
||||
Dim oSearchGuids = Searches.Select(Function(s) s.Guid).ToArray
|
||||
Dim oWindowGuid = $"{Profile.Guid}-{oNameSlug}-{String.Join("-", oSearchGuids)}"
|
||||
|
||||
Return oWindowGuid
|
||||
End Function
|
||||
|
||||
Private Function GetEnvironment() As Environment
|
||||
Dim oUser As New State.UserState() With {
|
||||
.DateFormat = USER_DATE_FORMAT,
|
||||
.Email = USER_EMAIL,
|
||||
.GivenName = USER_PRENAME,
|
||||
.Language = USER_LANGUAGE,
|
||||
.MachineName = System.Environment.MachineName,
|
||||
.ShortName = USER_SHORTNAME,
|
||||
.Surname = USER_SURNAME,
|
||||
.UserId = USER_ID,
|
||||
.UserName = USER_USERNAME
|
||||
}
|
||||
|
||||
Dim oSettings As New State.SettingsState() With {
|
||||
.GdPictureKey = ""
|
||||
}
|
||||
|
||||
Dim oEnvironment As New Environment() With {
|
||||
.Database = Nothing,
|
||||
.Modules = Nothing,
|
||||
.User = oUser,
|
||||
.Settings = oSettings
|
||||
}
|
||||
|
||||
Return oEnvironment
|
||||
End Function
|
||||
|
||||
Private Function GetDatatable(SqlCommand As String, ConnectionId As Integer)
|
||||
Try
|
||||
Dim oRow As MyDataset.TBDD_CONNECTIONRow = DT_CONNECTIONS.AsEnumerable().
|
||||
Where(Function(r) r.GUID = ConnectionId).
|
||||
FirstOrDefault()
|
||||
|
||||
Dim oConnectionType As String = oRow.SQL_PROVIDER
|
||||
|
||||
Select Case oRow.SQL_PROVIDER
|
||||
Case Constants.PROVIDER_MSSQL
|
||||
Dim oSQL As New MSSQLServer(LogConfig, oRow.SERVER, oRow.DATENBANK, oRow.USERNAME, oRow.PASSWORD)
|
||||
Return oSQL.GetDatatable(SqlCommand)
|
||||
|
||||
Case Constants.PROVIDER_ODBC
|
||||
Dim oODBC As New ODBC(LogConfig, oRow.SERVER, oRow.USERNAME, oRow.PASSWORD)
|
||||
Return oODBC.GetDatatable(SqlCommand)
|
||||
|
||||
Case Else
|
||||
Dim oOracle As New Database.Oracle(LogConfig, oRow.SERVER, oRow.DATENBANK, oRow.USERNAME, oRow.PASSWORD)
|
||||
Return oOracle.GetDatatable(SqlCommand)
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub ProfileResultForm_Closed(sender As Object, e As FormClosedEventArgs)
|
||||
Dim oShouldOpenAgain As Boolean = False
|
||||
Dim oThisForm = New List(Of IResultForm) From {sender}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user