93 lines
3.1 KiB
VB.net
93 lines
3.1 KiB
VB.net
Imports System
|
|
Imports DigitalData.Modules.Logging
|
|
Imports DigitalData.Modules.Windream
|
|
Imports DigitalData.Modules.Config
|
|
Imports System.IO
|
|
Imports System.Text.RegularExpressions
|
|
Imports DigitalData.Modules.Database
|
|
Imports DigitalData.GUIs.WiDigShared
|
|
|
|
Module ModuleMain
|
|
Private _ArgumentLength As Integer
|
|
Public _database As MSSQLServer
|
|
Public oRegExArg As String
|
|
Public LogConfig As LogConfig
|
|
Public Logger As Logger
|
|
Public Config As ConfigManager(Of ClassConfig)
|
|
|
|
Public Function Main(CommandLineArguments As String()) As Integer
|
|
Dim oWiDig As ClassWIDig
|
|
|
|
Try
|
|
System.Console.WriteLine($"Initializing WIDig...")
|
|
System.Console.WriteLine($"Logging...")
|
|
LogConfig = New LogConfig(LogConfig.PathType.AppData, Nothing, "Console", "Digital Data", "WIDig")
|
|
Logger = LogConfig.GetLogger
|
|
|
|
System.Console.WriteLine($"Config...")
|
|
Config = New ConfigManager(Of ClassConfig)(LogConfig, ClassWIDig.GetAppDataPath, ClassWIDig.GetProgramDataPath)
|
|
LogConfig.Debug = Config.Config.LOG_DEBUG
|
|
|
|
System.Console.WriteLine($"Main Class...")
|
|
oWiDig = New ClassWIDig(LogConfig, Config.Config)
|
|
|
|
|
|
Catch ex As Exception
|
|
Logger.Warn("Could not initialize WiDig because of an error: [{0}]", ex.Message)
|
|
Logger.Error(ex)
|
|
|
|
Return ClassWIDig.CODE_ERROR
|
|
End Try
|
|
|
|
Try
|
|
System.Console.WriteLine($"Starting up WIDig...")
|
|
|
|
Dim oUserPW = oWiDig.GetUserPWPlain()
|
|
If oWiDig.Connect2Windream(oUserPW) = False Then
|
|
Throw New ApplicationException("Could not initialize windream")
|
|
End If
|
|
|
|
System.Console.WriteLine($"Windream initialized!")
|
|
|
|
If oWiDig.InitDatabase() = False Then
|
|
Throw New ApplicationException("Could not initialize DB")
|
|
End If
|
|
|
|
System.Console.WriteLine($"Database initialized!")
|
|
|
|
If oWiDig.ParseArgs(CommandLineArguments) = False Then
|
|
Throw New ApplicationException("Could not parse command line arguments")
|
|
End If
|
|
|
|
System.Console.WriteLine($"Command line arguments parsed!")
|
|
|
|
If oWiDig.StreamORIndexFile() = False Then
|
|
Throw New ApplicationException("Could not stream or index file")
|
|
End If
|
|
|
|
System.Console.WriteLine($"File indexed or streamed!")
|
|
|
|
' Brauchen Sie das überhaupt?
|
|
If oWiDig.ErrorWhileParsing = True Or oWiDig.ErrorWhileImporting Then
|
|
Throw New ApplicationException(oWiDig.ErrorMessage)
|
|
|
|
End If
|
|
|
|
Return ClassWIDig.CODE_SUCCESS
|
|
Catch ex As Exception
|
|
Logger.Warn("Could not process file because of an error: [{0}]", oWiDig.ErrorMessage)
|
|
Logger.Warn("Error at Parse Stage: [{0}]", oWiDig.ErrorWhileParsing)
|
|
Logger.Warn("Error at Import Stage: [{0}]", oWiDig.ErrorWhileimporting)
|
|
Logger.Error(ex)
|
|
|
|
Return ClassWIDig.CODE_ERROR
|
|
End Try
|
|
End Function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End Module
|