Zooflow: EDMI Service WIP

This commit is contained in:
Jonathan Jenne
2021-12-02 16:23:00 +01:00
parent 77621193f2
commit 34517ce209
16 changed files with 240 additions and 50 deletions

View File

@@ -14,11 +14,9 @@ Namespace Modules
Public Property PatternIdentifier As String = "CTRL" Implements IModule.PatternIdentifier
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
Private ReadOnly Logger As Logger
Public Sub New(pLogConfig As LogConfig)
MyBase.New(pLogConfig)
Logger = pLogConfig.GetLogger()
End Sub
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace

View File

@@ -0,0 +1,55 @@
Imports DigitalData.Modules.Logging
Namespace Modules
''' <summary>
''' Patterns for Generating a Filename in Global Indexer
''' </summary>
Public Class Globix
Inherits BaseModule
Implements IModule
Public Const GBX_VALUE_INDICIES = "GLOBIX_INDICIES"
Public Property PatternIdentifier As String = "GBX" Implements IModule.PatternIdentifier
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
Public Sub New(pLogConfig As LogConfig)
MyBase.New(pLogConfig)
End Sub
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
Dim oResult = pInput
Dim oCounter = 0
Dim pIndexes As Dictionary(Of String, List(Of String)) = pReplaceMap.Item(GBX_VALUE_INDICIES)
While ContainsPattern(oResult, PatternIdentifier)
Try
Dim oIndexName As String = GetNextPattern(oResult, PatternIdentifier).Value
If pIndexes.ContainsKey(oIndexName) = False Then
Logger.Warn("Value for Index [{0}] does not exist and will not be used for replacing. Skipping.", oIndexName)
End If
' TODO: If Index contains multiple values, only the first value will be used as value
Dim oIndexValues As List(Of String) = pIndexes.Item(oIndexName)
Dim oFirstValue As String = oIndexValues.FirstOrDefault()
If oFirstValue Is Nothing Then
Logger.Warn("Value for Index [{0}] is empty and will not be used for replacing. Skipping.")
Return oResult
End If
oResult = ReplacePattern(oResult, PatternIdentifier, oFirstValue)
Catch ex As Exception
Logger.Error(ex)
Return oResult
Finally
IncrementCounterOrThrow(oCounter)
End Try
End While
Return oResult
End Function
End Class
End Namespace

View File

@@ -15,11 +15,8 @@ Namespace Modules
Public Property PatternIdentifier As String = "IDB" Implements IModule.PatternIdentifier
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
Private ReadOnly Logger As Logger
Public Sub New(pLogConfig As LogConfig)
MyBase.New(pLogConfig)
Logger = pLogConfig.GetLogger()
End Sub
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace

View File

@@ -15,11 +15,8 @@ Namespace Modules
Public Property PatternIdentifier As String = "WMI" Implements IModule.PatternIdentifier
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
Private ReadOnly Logger As Logger
Public Sub New(pLogConfig As LogConfig)
MyBase.New(pLogConfig)
Logger = pLogConfig.GetLogger()
End Sub
Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace

View File

@@ -82,6 +82,7 @@
<ItemGroup>
<Compile Include="Constants.vb" />
<Compile Include="Modules\IDB.vb" />
<Compile Include="Modules\Globix.vb" />
<Compile Include="Modules\Windream.vb" />
<Compile Include="Modules\User.vb" />
<Compile Include="IModule.vb" />

View File

@@ -135,6 +135,16 @@ Public Class Patterns2
Return oResult
End Function
Public Function ReplaceGlobixValues(pInput As String) As String
Dim oResult = pInput
Dim oGlobixModule = GetModule(Of Modules.Globix)()
Dim oGlobixArgs = GetReplaceMapForModule(oGlobixModule)
oResult = DoReplaceForModule(oResult, oGlobixModule, oGlobixArgs)
Return oResult
End Function
Private Function DoReplaceForModule(pInput As String, pModule As IModule, pArgs As Dictionary(Of String, Object)) As String
Try
pInput = pModule.Replace(pInput, pArgs)
@@ -152,7 +162,12 @@ Public Class Patterns2
SingleOrDefault()
End Function
Private Function GetReplaceMapForModule(pModule As IModule, Optional pPanel As Panel = Nothing, Optional pUser As State.UserState = Nothing, Optional pWMObject As WMObject = Nothing) As Dictionary(Of String, Object)
Private Function GetReplaceMapForModule(pModule As IModule,
Optional pPanel As Panel = Nothing,
Optional pUser As State.UserState = Nothing,
Optional pWMObject As WMObject = Nothing,
Optional pGlobixIndexes As Dictionary(Of String, List(Of String)) = Nothing
) As Dictionary(Of String, Object)
Dim oArgs As New Dictionary(Of String, Object)
If TypeOf pModule Is Modules.Clipboard Then
@@ -199,6 +214,12 @@ Public Class Patterns2
Logger.Error(ex)
End Try
ElseIf TypeOf pModule Is Modules.Globix Then
Try
oArgs.Add(Patterns.Modules.Globix.GBX_VALUE_INDICIES, pGlobixIndexes)
Catch ex As Exception
Logger.Error(ex)
End Try
End If
Return oArgs