ZooFlow: Add My.Helpers
This commit is contained in:
parent
72c50a298a
commit
f5c0a18a59
115
GUIs.ZooFlow/ClassHelpers.vb
Normal file
115
GUIs.ZooFlow/ClassHelpers.vb
Normal file
@ -0,0 +1,115 @@
|
||||
Imports DigitalData.GUIs.ZooFlow.Base
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class ClassHelpers
|
||||
Inherits BaseClass
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function GetValueFromDatatable(pDatatable As DataTable, pFilterString As String, pCheckColumn As String, pSortString As String) As Object
|
||||
Try
|
||||
If pDatatable.Rows.Count = 0 Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim oDataView As DataView = pDatatable.DefaultView
|
||||
oDataView.RowFilter = pFilterString
|
||||
|
||||
If oDataView.Count > 1 Then
|
||||
Logger.Warn("Multiple Results For Filter [{0}] and Column [{1}].", pFilterString, pCheckColumn)
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
If oDataView.Count = 0 Then
|
||||
Logger.Warn("No Results For Filter [{0}] and Column [{1}].", pFilterString, pCheckColumn)
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim oView As DataRowView = oDataView.Item(0)
|
||||
Dim oRow As DataRow = oView.Row
|
||||
|
||||
Try
|
||||
Return oRow.Item(pCheckColumn)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Datatable with Filter [{0}] does not contain Column [{1}]", pFilterString, pCheckColumn)
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetFilteredDatatable(pDatatable As DataTable, pFilterString As String, pSortString As String) As DataTable
|
||||
Try
|
||||
If pDatatable.Rows.Count = 0 Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim oSelectedRows = pDatatable.Select(pFilterString, pSortString)
|
||||
|
||||
If oSelectedRows.Count = 0 Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim oFilteredTable As DataTable = New DataTable()
|
||||
oFilteredTable = oSelectedRows.CopyToDataTable()
|
||||
Return oFilteredTable
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Shared Function FileExistsinDropTable(Filename As String) As Date
|
||||
Dim oSQL As String
|
||||
Dim oHash As String
|
||||
Dim oFilesystem As New DigitalData.Modules.Filesystem.File(My.LogConfig)
|
||||
|
||||
Try
|
||||
If Filename.Contains("'") Then
|
||||
Filename = Filename.Replace("'", "''")
|
||||
End If
|
||||
|
||||
Try
|
||||
oHash = oFilesystem.GetChecksum(Filename)
|
||||
Catch ex As Exception
|
||||
oHash = ""
|
||||
End Try
|
||||
|
||||
oSQL = "SELECT * FROM TBGI_FILES_USER WHERE UPPER(FILE_HASH) = UPPER('" & oHash & "') AND WORKED = 0 ORDER BY ADDED_WHEN"
|
||||
Dim oResult As DataTable = My.DatabaseECM.GetDatatable(oSQL)
|
||||
|
||||
If oResult Is Nothing Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
If oResult.Rows.Count = 0 Then
|
||||
oSQL = "SELECT * FROM TBGI_HISTORY WHERE UPPER(FILE_HASH) = UPPER('" & oHash & "') ORDER BY ADDED_WHEN"
|
||||
oResult = My.DatabaseECM.GetDatatable(oSQL)
|
||||
|
||||
If oResult Is Nothing Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
If oResult.Rows.Count = 0 Then
|
||||
Return Nothing
|
||||
Else
|
||||
Dim oFirstRow As DataRow = oResult.Rows.Item(0)
|
||||
Return oFirstRow.Item("ADDED_WHEN")
|
||||
End If
|
||||
Else
|
||||
Dim oFirstRow As DataRow = oResult.Rows.Item(0)
|
||||
Return oFirstRow.Item("ADDED_WHEN")
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in FileExistsinDropTable - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & oSQL, MsgBoxStyle.Critical)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
@ -40,6 +40,7 @@ Public Class ClassInit
|
||||
_Loader = New ClassInitLoader()
|
||||
|
||||
' === Init Schritte definieren
|
||||
_Loader.AddStep("Initializing Base", AddressOf InitializeBase, True)
|
||||
_Loader.AddStep("Initializing Database (1/2)", AddressOf InitializeDatabase, True)
|
||||
_Loader.AddStep("Initializing EDMI Service", AddressOf InitializeService, True)
|
||||
_Loader.AddStep("Initializing Database (2/2)", AddressOf InitializeDatabaseWithFallback, True)
|
||||
@ -58,6 +59,10 @@ Public Class ClassInit
|
||||
|
||||
|
||||
#Region "=== Init Steps ==="
|
||||
Private Sub InitializeBase(MyApplication As My.MyApplication)
|
||||
My.Helpers = New ClassHelpers(My.LogConfig)
|
||||
End Sub
|
||||
|
||||
Private Sub InitializeDatabase(MyApplication As My.MyApplication)
|
||||
Dim oConnectionString = MSSQLServer.DecryptConnectionString(My.SystemConfig.ConnectionString)
|
||||
My.DatabaseECM = New MSSQLServer(My.LogConfig, oConnectionString)
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
Public Class ClassHelpers
|
||||
Public Shared Function FileExistsinDropTable(Filename As String) As Date
|
||||
Dim oSQL As String
|
||||
Dim oHash As String
|
||||
Dim oFilesystem As New DigitalData.Modules.Filesystem.File(My.LogConfig)
|
||||
|
||||
Try
|
||||
If Filename.Contains("'") Then
|
||||
Filename = Filename.Replace("'", "''")
|
||||
End If
|
||||
|
||||
Try
|
||||
oHash = oFilesystem.GetChecksum(Filename)
|
||||
Catch ex As Exception
|
||||
oHash = ""
|
||||
End Try
|
||||
|
||||
oSQL = "SELECT * FROM TBGI_FILES_USER WHERE UPPER(FILE_HASH) = UPPER('" & oHash & "') AND WORKED = 0 ORDER BY ADDED_WHEN"
|
||||
Dim oResult As DataTable = My.DatabaseECM.GetDatatable(oSQL)
|
||||
|
||||
If oResult Is Nothing Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
If oResult.Rows.Count = 0 Then
|
||||
oSQL = "SELECT * FROM TBGI_HISTORY WHERE UPPER(FILE_HASH) = UPPER('" & oHash & "') ORDER BY ADDED_WHEN"
|
||||
oResult = My.DatabaseECM.GetDatatable(oSQL)
|
||||
|
||||
If oResult Is Nothing Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
If oResult.Rows.Count = 0 Then
|
||||
Return Nothing
|
||||
Else
|
||||
Dim oFirstRow As DataRow = oResult.Rows.Item(0)
|
||||
Return oFirstRow.Item("ADDED_WHEN")
|
||||
End If
|
||||
Else
|
||||
Dim oFirstRow As DataRow = oResult.Rows.Item(0)
|
||||
Return oFirstRow.Item("ADDED_WHEN")
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in FileExistsinDropTable - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & oSQL, MsgBoxStyle.Critical)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
@ -85,27 +85,4 @@ Module ModuleHelpers
|
||||
End Try
|
||||
Return connectionString
|
||||
End Function
|
||||
|
||||
Public Function FilterDatatable(pDatatable As DataTable, pFilterString As String, pCheckColumn As String, pSortString As String, pReturnDataTable As Boolean) As Object
|
||||
Try
|
||||
If pDatatable.Rows.Count = 0 Then
|
||||
Return Nothing
|
||||
End If
|
||||
Dim oDataView As DataView = pDatatable.DefaultView
|
||||
oDataView.RowFilter = pFilterString
|
||||
If oDataView.Count = 1 And pReturnDataTable = False Then
|
||||
Dim oView As DataRowView = oDataView.Item(0)
|
||||
Dim oRow As DataRow = oView.Row
|
||||
Return oRow.Item(pCheckColumn)
|
||||
Else
|
||||
Dim oDataTableCopy As DataTable = New DataTable()
|
||||
oDataTableCopy = pDatatable.Select(pFilterString, pSortString).CopyToDataTable()
|
||||
|
||||
Return oDataTableCopy
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in FilterDatatable: " + ex.Message, MsgBoxStyle.Critical)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
End Module
|
||||
|
||||
@ -36,6 +36,7 @@ Namespace My
|
||||
|
||||
Property Tables As New ClassTables
|
||||
Property Queries As New ClassQueries
|
||||
Property Helpers As ClassHelpers
|
||||
#End Region
|
||||
|
||||
Property Filestore_Work As String
|
||||
|
||||
@ -87,6 +87,9 @@
|
||||
<Reference Include="DevExpress.XtraRichEdit.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.XtraSpreadsheet.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.XtraTreeList.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DigitalData.Controls.SnapPanel">
|
||||
<HintPath>..\Controls.SnapPanel\obj\Debug\DigitalData.Controls.SnapPanel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Independentsoft.Msg">
|
||||
<HintPath>P:\Visual Studio Projekte\Bibliotheken\MSG .NET\Bin\22_11_19\Independentsoft.Msg.dll</HintPath>
|
||||
</Reference>
|
||||
@ -202,7 +205,7 @@
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Globix\ClassExclusions.vb" />
|
||||
<Compile Include="Globix\ClassHelpers.vb" />
|
||||
<Compile Include="ClassHelpers.vb" />
|
||||
<Compile Include="modCurrent.vb" />
|
||||
<Compile Include="MyDataset.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user