Persist Kiwi Syslog Server scripting dictionary contents between restarts

Version 2

    The scripting dictionaries are not persistant between restarts of the Kiwi Syslog Server application/service.   They are only resident in memory while the app/service is running, and are not unloaded to disk when a service or server shutdown/restart occurs.

    Unfortunately, this behaviour is by design, so there are no plans to include global/dictionary persistance between restarts to Kiwi Syslog Server (at this stage).

    In the meantime, there is one possible alternative, that leverages new functionality proivided by the scheduled Run-Script tasks. It is possible to schedule a script to run at startup or shutdown of the application/service.

    So, in theory you could:
    1) Create a script which unloads the "stats" dictionary to a file on disk.
    2) Schedule the "dictionary_unload" script to run at app/service shutdown.
    3) Create a script which loads the "stats" dictionary from a file on disk.
    4) Schedule the "dictionary_load" script to run at app/service startup.

    '###Script_UnloadDictionaryToFile.txt### (VBScript and requires full read/write permission).
    Function Main()
       
        UnloadTo = "C:\Stats.dic"

        With Dictionaries
            If .Exists("Stats") Then
            'Create file
            Set oFSO = CreateObject("Scripting.FileSystemObject")
            Set oFile = oFSO.CreateTextFile(UnloadTo, true)
            HostCounts = .GetItems("Stats")
                HostAddresses = .GetKeys("Stats")
            Fields.VarCustom01 = UBound(HostAddresses)
            For i = 0 to UBound(HostAddresses)
                thisHost = HostAddresses(i)
                thisHostCount = HostCounts(i)
                oFile.WriteLine(thisHost & vbTab & thisHostCount)               
                    Next
            oFile.Close
            Set oFile = nothing
            Set oFSO = nothing
            End If
        End With

        ' Return 'OK' (success)
        Main = "OK"

    End Function

    '###Script_LoadDictionaryFromFile.txt### (VBScript and requires full read/write permission).
    Function Main()
       
        LoadFrom = "C:\Stats.dic"

        With Dictionaries
           
            'Create file
            Set oFSO = CreateObject("Scripting.FileSystemObject")
            Set oFile = oFSO.OpenTextFile(LoadFrom, 1)
            While Not oFile.AtEndOfStream
                thisHost = oFile.ReadLine
                arrHost = Split(thisHost, vbtab)
                .StoreItem "Stats", arrHost(0), arrHost(1)
            Wend
            oFile.Close
            Set oFile = nothing
            Set oFSO = nothing

        End With

        ' Return 'OK' (success)
        Main = "OK"

    End Function