Monorepo/GUIs.ZooFlow/Administration/ClassDetailForm.vb

257 lines
9.0 KiB
VB.net

Imports DigitalData.GUIs.ZooFlow.Administration.ClassConstants
Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Language
Public Class ClassDetailForm
Inherits BaseClass
Public Event DetailFormClosed As EventHandler(Of Form)
Public ReadOnly Property DetailDataList As New Dictionary(Of String, DetailData)
Public ReadOnly Property DetailSettingsList As New Dictionary(Of String, DetailSettings) From {
{PAGE_IDB_ATTRIBUTES, New DetailSettings With {
.GridTitle = "Attribute", ' This will be shown above the Data Grid
.NewRecordTitle = "Neues Attribut", ' This will be shown on the "New" Button
.[Module] = MODULE_IDB,
.Entity = PAGE_IDB_ATTRIBUTES ' This Key will be matched with the Entity Id from the Database
}},
{PAGE_IDB_BUSINESS_ENTITIES, New DetailSettings With {
.GridTitle = "BusinessEntity",
.NewRecordTitle = "New BusinessEntity",
.[Module] = MODULE_IDB,
.Entity = PAGE_IDB_BUSINESS_ENTITIES
}},
{PAGE_IDB_OBJECT_STORES, New DetailSettings With {
.GridTitle = "Object-Stores",
.NewRecordTitle = "New Object Store",
.[Module] = MODULE_IDB,
.Entity = PAGE_IDB_OBJECT_STORES
}},
{PAGE_META_SOURCE_SQL, New DetailSettings With {
.GridTitle = "Source SQL",
.NewRecordTitle = "New Source SQL",
.[Module] = MODULE_META,
.Entity = PAGE_META_SOURCE_SQL
}},
{PAGE_GI_PROFILES, New DetailSettings With {
.GridTitle = "Global Indexer Profile",
.NewRecordTitle = "New GLOBIX profile",
.[Module] = MODULE_GI,
.Entity = PAGE_GI_PROFILES
}},
{PAGE_CW_PROFILES, New DetailSettings With {
.GridTitle = "Clipboard Watcher Profile",
.NewRecordTitle = "New CW profile",
.[Module] = MODULE_CW,
.Entity = PAGE_CW_PROFILES
}},
{PAGE_IDB_ATTRIBUTE_REL, New DetailSettings With {
.GridTitle = "Attribute-Relations",
.NewRecordTitle = "",
.[Module] = MODULE_IDB,
.Entity = PAGE_IDB_ATTRIBUTES
}},
{PAGE_GI_RELATIONS, New DetailSettings With {
.GridTitle = "Globix profile-relations",
.NewRecordTitle = "",
.[Module] = MODULE_GI,
.Entity = PAGE_GI_RELATIONS
}},
{PAGE_IDB_DOCTYPE, New DetailSettings With {
.GridTitle = "Doctype Configuration",
.NewRecordTitle = "New Doctype",
.[Module] = MODULE_IDB,
.Entity = PAGE_IDB_DOCTYPE
}},
{PAGE_IDB_DOCTYPE_CONFIG, New DetailSettings With {
.GridTitle = "Detail Doctype Configuration",
.NewRecordTitle = "New Configuration",
.[Module] = MODULE_IDB,
.Entity = PAGE_IDB_DOCTYPE_CONFIG
}},
{PAGE_USERS_USERLIST, New DetailSettings With {
.GridTitle = "Benutzer Übersicht",
.NewRecordTitle = "Neuer Benutzer",
.[Module] = MODULE_USERS,
.Entity = PAGE_USERS_USERLIST
}}
}
Public Sub New(LogConfig As Modules.Logging.LogConfig)
MyBase.New(LogConfig)
End Sub
Public Function LoadData() As Boolean
Try
Dim oTable As DataTable = My.DatabaseECM.GetDatatable("SELECT * FROM TBZF_ADMIN_SOURCE_SQL WHERE SCOPE = 'OVERVIEW'")
DetailDataList.Clear()
For Each oRow As DataRow In oTable.Rows
Dim oCHeck = oRow.Item("ENTITY_TITLE").ToString
Dim oItem As New ClassDetailForm.DetailData With {
.Guid = CInt(oRow.Item("GUID")),
.ParentId = CInt(oRow.Item("PARENT_ID")),
.Entity = oRow.Item("ENTITY_TITLE").ToString,
.Scope = oRow.Item("SCOPE").ToString,
.SQLCommand = oRow.Item("SQL_COMMAND").ToString.Replace("@LANG_CODE", My.Application.User.Language),
.PrimaryKey = Utils.NotNull(oRow.Item("PK_COLUMN"), String.Empty)
}
Try
oItem.SQLResult = My.DatabaseECM.GetDatatable(oItem.SQLCommand)
Catch ex As Exception
oItem.SQLResult = Nothing
Logger.Error(ex)
End Try
Dim oKey As String = oItem.Entity & "-" & oItem.Scope
DetailDataList.Add(oKey, oItem)
Next
Return True
Catch ex As Exception
Logger.Error(ex)
Return False
End Try
End Function
Public Function Handle_OpenDetail(PrimaryKey As Integer, Page As String, IsInsert As Boolean) As Boolean
Select Case Page
Case PAGE_IDB_ATTRIBUTES
Load_IDBAttribute(PrimaryKey, IsInsert)
Return True
Case PAGE_IDB_BUSINESS_ENTITIES
Load_IDBEntity(PrimaryKey, IsInsert)
Return True
Case PAGE_IDB_OBJECT_STORES
Load_IDBObjectstore(PrimaryKey, IsInsert)
Return True
Case PAGE_CW_PROFILES
Load_CWProfile(PrimaryKey, IsInsert)
Return True
Case PAGE_GI_PROFILES
GLOBIX_JUMP_DOCTYPE_ID = PrimaryKey
Load_GLOBIXProfile(PrimaryKey, IsInsert)
Return True
Case PAGE_META_SOURCE_SQL
Load_SourceSQL(PrimaryKey, IsInsert)
Return True
Case PAGE_IDB_ATTRIBUTE_REL
Dim oForm As New frmAdmin_IDBBERelations
oForm.ShowDialog()
Return True
Case PAGE_GI_RELATIONS
Dim oForm As New frmAdmin_GlobixRelations
oForm.ShowDialog()
Return True
Case PAGE_IDB_DOCTYPE_CONFIG
Dim oForm As New frmAdmin_DoctypeConfig(PrimaryKey) With {.IsInsert = IsInsert}
oForm.ShowDialog()
Return True
Case PAGE_IDB_DOCTYPE
Dim oForm As New frmAdmin_Doctype(0)
oForm.ShowDialog()
Return True
Case Else
Return False
End Select
End Function
Private Sub Load_SourceSQL(PrimaryKey As Integer, IsInsert As Boolean)
Try
Dim oForm As New frmAdmin_SourceSQL(PrimaryKey) With {.IsInsert = IsInsert}
oForm.ShowDialog()
RaiseEvent DetailFormClosed(Me, oForm)
Catch ex As Exception
Logger.Error(ex)
Throw ex
End Try
End Sub
Private Sub Load_IDBAttribute(PrimaryKey As Integer, IsInsert As Boolean)
Try
Dim oForm As New frmAdmin_IDBAttribute(PrimaryKey) With {.IsInsert = IsInsert}
oForm.ShowDialog()
RaiseEvent DetailFormClosed(Me, oForm)
Catch ex As Exception
Logger.Error(ex)
Throw ex
End Try
End Sub
Private Sub Load_IDBObjectstore(PrimaryKey As Integer, IsInsert As Boolean)
Try
Dim oForm As New frmAdmin_IDBObjectStore(PrimaryKey) With {.IsInsert = IsInsert}
oForm.ShowDialog()
RaiseEvent DetailFormClosed(Me, oForm)
Catch ex As Exception
Logger.Error(ex)
Throw ex
End Try
End Sub
Private Sub Load_IDBEntity(PrimaryKey As Integer, IsInsert As Boolean)
Try
Dim oForm As New frmAdmin_IDBEntity(PrimaryKey) With {.IsInsert = IsInsert}
oForm.ShowDialog()
RaiseEvent DetailFormClosed(Me, oForm)
Catch ex As Exception
Logger.Error(ex)
Throw ex
End Try
End Sub
Private Sub Load_CWProfile(PrimaryKey As Integer, IsInsert As Boolean)
Try
Dim oForm As New frmAdmin_ClipboardWatcher(PrimaryKey) With {.IsInsert = IsInsert}
oForm.ShowDialog()
RaiseEvent DetailFormClosed(Me, oForm)
Catch ex As Exception
Logger.Error(ex)
Throw ex
End Try
End Sub
Private Sub Load_GLOBIXProfile(PrimaryKey As Integer, IsInsert As Boolean)
Try
Dim oForm As New frmAdmin_Globix(PrimaryKey) With {.IsInsert = IsInsert}
oForm.ShowDialog()
RaiseEvent DetailFormClosed(Me, oForm)
Catch ex As Exception
Logger.Error(ex)
Throw ex
End Try
End Sub
Public Class DetailSettings
Public Property GridTitle As String
Public Property [Module] As String
Public Property Entity As String
Public Property NewRecordTitle As String
End Class
Public Class DetailData
Public Property Guid As Integer
Public Property ParentId As Integer
Public Property Entity As String
Public Property Scope As String
Public Property PrimaryKey As String
Public Property SQLCommand As String
Public Property SQLResult As DataTable
End Class
End Class