From 1555e40ad13ec69ce0105196a395f4fe8f3da5a4 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Thu, 30 Mar 2023 13:50:50 +0200 Subject: [PATCH] updated the tool project --- bsmd.Tool.sln | 33 +++++++++++++++-- bsmd.Tool/App.config | 30 ++++++++-------- bsmd.Tool/CheckRules.cs | 11 +++--- bsmd.Tool/CleanupFiles.cs | 4 +-- bsmd.Tool/Options.cs | 19 +++------- bsmd.Tool/Program.cs | 44 +++++++++-------------- bsmd.Tool/Properties/Settings.Designer.cs | 2 +- bsmd.Tool/bsmd.Tool.csproj | 23 ++++++------ bsmd.Tool/packages.config | 4 +-- 9 files changed, 86 insertions(+), 84 deletions(-) diff --git a/bsmd.Tool.sln b/bsmd.Tool.sln index 39a1ec6c..5da0a53c 100644 --- a/bsmd.Tool.sln +++ b/bsmd.Tool.sln @@ -1,22 +1,51 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.33328.57 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.Tool", "bsmd.Tool\bsmd.Tool.csproj", "{5F5E65EE-9351-4F30-817A-9C6C6D6835AE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.database", "bsmd.database\bsmd.database.csproj", "{19945AF2-379B-46A5-B27A-303B5EC1D557}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug 64|Any CPU = Debug 64|Any CPU + Debug 64|x64 = Debug 64|x64 Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5F5E65EE-9351-4F30-817A-9C6C6D6835AE}.Debug 64|Any CPU.ActiveCfg = Debug|Any CPU + {5F5E65EE-9351-4F30-817A-9C6C6D6835AE}.Debug 64|Any CPU.Build.0 = Debug|Any CPU + {5F5E65EE-9351-4F30-817A-9C6C6D6835AE}.Debug 64|x64.ActiveCfg = Debug|Any CPU + {5F5E65EE-9351-4F30-817A-9C6C6D6835AE}.Debug 64|x64.Build.0 = Debug|Any CPU {5F5E65EE-9351-4F30-817A-9C6C6D6835AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5F5E65EE-9351-4F30-817A-9C6C6D6835AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F5E65EE-9351-4F30-817A-9C6C6D6835AE}.Debug|x64.ActiveCfg = Debug|Any CPU + {5F5E65EE-9351-4F30-817A-9C6C6D6835AE}.Debug|x64.Build.0 = Debug|Any CPU {5F5E65EE-9351-4F30-817A-9C6C6D6835AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {5F5E65EE-9351-4F30-817A-9C6C6D6835AE}.Release|Any CPU.Build.0 = Release|Any CPU + {5F5E65EE-9351-4F30-817A-9C6C6D6835AE}.Release|x64.ActiveCfg = Release|Any CPU + {5F5E65EE-9351-4F30-817A-9C6C6D6835AE}.Release|x64.Build.0 = Release|Any CPU + {19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug 64|Any CPU.ActiveCfg = Debug 64|Any CPU + {19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug 64|Any CPU.Build.0 = Debug 64|Any CPU + {19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug 64|x64.ActiveCfg = Debug 64|x64 + {19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug 64|x64.Build.0 = Debug 64|x64 + {19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug|x64.ActiveCfg = Debug|x64 + {19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug|x64.Build.0 = Debug|x64 + {19945AF2-379B-46A5-B27A-303B5EC1D557}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19945AF2-379B-46A5-B27A-303B5EC1D557}.Release|Any CPU.Build.0 = Release|Any CPU + {19945AF2-379B-46A5-B27A-303B5EC1D557}.Release|x64.ActiveCfg = Release|x64 + {19945AF2-379B-46A5-B27A-303B5EC1D557}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6B3F5B6D-3615-4A93-A6A7-46BD448CEED6} + EndGlobalSection EndGlobal diff --git a/bsmd.Tool/App.config b/bsmd.Tool/App.config index b9f6a508..ec50e784 100644 --- a/bsmd.Tool/App.config +++ b/bsmd.Tool/App.config @@ -1,30 +1,30 @@ - +
- -
+ +
- - + + - - - - - - - + + + + + + + - + - + @@ -33,4 +33,4 @@ - \ No newline at end of file + diff --git a/bsmd.Tool/CheckRules.cs b/bsmd.Tool/CheckRules.cs index bd071dd5..3dcc51dc 100644 --- a/bsmd.Tool/CheckRules.cs +++ b/bsmd.Tool/CheckRules.cs @@ -14,9 +14,9 @@ using log4net; namespace bsmd.Tool { - public class CheckRules + public static class CheckRules { - private static ILog log = LogManager.GetLogger("CheckRules"); + private static readonly ILog log = LogManager.GetLogger("CheckRules"); public static void Check(Guid messageCoreId) { if(DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString)) @@ -28,16 +28,15 @@ namespace bsmd.Tool List messages = DBManager.Instance.GetMessagesForCore(core, DBManager.MessageLoad.ALL); RuleEngine ruleEngine = new RuleEngine(); - foreach(Message message in messages) { - + foreach(Message message in messages) + { // clear old results DBManager.Instance.DeleteMessageErrors(message); DBManager.Instance.DeleteMessageViolations(message); // perform validation ruleEngine.Validate(message); - - } + } } else { diff --git a/bsmd.Tool/CleanupFiles.cs b/bsmd.Tool/CleanupFiles.cs index ffa7ddc7..ed91c0f7 100644 --- a/bsmd.Tool/CleanupFiles.cs +++ b/bsmd.Tool/CleanupFiles.cs @@ -7,9 +7,8 @@ using System.IO; namespace bsmd.Tool { - class CleanupFiles + internal static class CleanupFiles { - /// /// Alle XML Dateien in einem Dateipfad(rootPath) (recursive) löschen, die älter als (staleDays) Tage sind /// @@ -35,6 +34,5 @@ namespace bsmd.Tool Cleanup(directory, staleDays, recursive); } } - } } diff --git a/bsmd.Tool/Options.cs b/bsmd.Tool/Options.cs index ca93d56e..de08e6aa 100644 --- a/bsmd.Tool/Options.cs +++ b/bsmd.Tool/Options.cs @@ -19,30 +19,19 @@ namespace bsmd.Tool [Option('c', "core", Required=false, HelpText="MessageCoreId to process")] public string MessageCoreId { get; set; } - [Option('v',"verbose", DefaultValue=true, HelpText="print messages to console")] + [Option('v',"verbose", Default=true, HelpText="print messages to console")] public bool Verbose { get; set; } - [Option('r', "checkrules", MutuallyExclusiveSet = "command", HelpText = "Use rule engine on message core")] + [Option('r', "checkrules", HelpText = "Use rule engine on message core")] public bool CheckRules { get; set; } - [Option('s', "staledays", DefaultValue = 30, HelpText ="Delete files older than X days")] + [Option('s', "staledays", Default = 30, HelpText ="Delete files older than X days")] public int StaleDays { get; set; } [Option('p', "path", HelpText ="Path to cleanup root folder")] public string CleanupFolderRoot { get; set; } - [Option('x', "recursive", DefaultValue = false, HelpText ="Cleanup subdirectories recursively")] + [Option('x', "recursive", Default = false, HelpText ="Cleanup subdirectories recursively")] public bool CleanupRecursive { get; set; } - - [ParserState] - public IParserState LastParserState { get; set; } - - [HelpOption] - public string GetUsage() - { - return HelpText.AutoBuild(this, (HelpText current) => HelpText.DefaultParsingErrorsHandler(this, current)); - } - - } } diff --git a/bsmd.Tool/Program.cs b/bsmd.Tool/Program.cs index f6357b9a..bcc81fff 100644 --- a/bsmd.Tool/Program.cs +++ b/bsmd.Tool/Program.cs @@ -1,28 +1,25 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using CommandLine; using log4net; +using System; namespace bsmd.Tool { - class Program + public static class Program { - private static ILog log = LogManager.GetLogger("Tool"); + private static readonly ILog log = LogManager.GetLogger("Tool"); - static int Main(string[] args) + public static int Main(string[] args) { + int result = 0; log4net.Config.XmlConfigurator.Configure(); Options options = new Options(); - if (CommandLine.Parser.Default.ParseArguments(args, options)) + try { - try + Parser.Default.ParseArguments(args).WithParsed(o => { - if (options.CheckRules) + if (o.CheckRules) { - Guid coreId; - if (Guid.TryParse(options.MessageCoreId, out coreId)) + if (Guid.TryParse(options.MessageCoreId, out Guid coreId)) { CheckRules.Check(coreId); } @@ -32,27 +29,18 @@ namespace bsmd.Tool log.FatalFormat("CheckRules: cannot parse message core id"); } } - else if((options.CleanupFolderRoot != null) && (options.CleanupFolderRoot.Length > 0)) + if (!string.IsNullOrEmpty(o.CleanupFolderRoot)) { CleanupFiles.Cleanup(options.CleanupFolderRoot, options.StaleDays, options.CleanupRecursive); } - else - { - - } - return 0; - } - catch (Exception ex) - { - log.ErrorFormat("an exception occurred: {0}", ex.Message); - return 1; - } + }); } - else + catch (Exception ex) { - Console.WriteLine(options.GetUsage()); - return 1; + log.Fatal(ex.Message); + result = 1; } + return result; } } } diff --git a/bsmd.Tool/Properties/Settings.Designer.cs b/bsmd.Tool/Properties/Settings.Designer.cs index 9607f28a..4d40f00d 100644 --- a/bsmd.Tool/Properties/Settings.Designer.cs +++ b/bsmd.Tool/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace bsmd.Tool.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/bsmd.Tool/bsmd.Tool.csproj b/bsmd.Tool/bsmd.Tool.csproj index 8b66e734..7e9737b3 100644 --- a/bsmd.Tool/bsmd.Tool.csproj +++ b/bsmd.Tool/bsmd.Tool.csproj @@ -9,8 +9,9 @@ Properties bsmd.Tool bsmd.Tool - v4.5 + v4.8 512 + AnyCPU @@ -38,15 +39,19 @@ ..\bsmdKey.snk - - ..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll + + ..\bsmd.database\bin\Debug\bsmd.database.dll - - ..\packages\log4net.2.0.8\lib\net45-full\log4net.dll - True + + ..\packages\CommandLineParser.2.9.1\lib\net461\CommandLine.dll + + + ..\packages\log4net.2.0.15\lib\net45\log4net.dll + + @@ -83,12 +88,6 @@ Settings.Designer.cs - - - {19945af2-379b-46a5-b27a-303b5ec1d557} - bsmd.database - -