updated the tool project

This commit is contained in:
Daniel Schick 2023-03-30 13:50:50 +02:00
parent 3ef5a35176
commit 1555e40ad1
9 changed files with 86 additions and 84 deletions

View File

@ -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

View File

@ -1,30 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="bsmd.Tool.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="bsmd.Tool.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="LogFileAppender" />
<level value="DEBUG"/>
<appender-ref ref="LogFileAppender"/>
</root>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" >
<param name="File" value="log.bsmd.Tool.txt" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="log.bsmd.Tool.txt"/>
<param name="AppendToFile" value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="10"/>
<maximumFileSize value="10MB"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%date [%thread] %-5level [%logger] - %message%newline" />
<param name="ConversionPattern" value="%date [%thread] %-5level [%logger] - %message%newline"/>
</layout>
</appender>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<userSettings>
<bsmd.Tool.Properties.Settings>
@ -33,4 +33,4 @@
</setting>
</bsmd.Tool.Properties.Settings>
</userSettings>
</configuration>
</configuration>

View File

@ -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<Message> 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
{

View File

@ -7,9 +7,8 @@ using System.IO;
namespace bsmd.Tool
{
class CleanupFiles
internal static class CleanupFiles
{
/// <summary>
/// Alle XML Dateien in einem Dateipfad(rootPath) (recursive) löschen, die älter als (staleDays) Tage sind
/// </summary>
@ -35,6 +34,5 @@ namespace bsmd.Tool
Cleanup(directory, staleDays, recursive);
}
}
}
}

View File

@ -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));
}
}
}

View File

@ -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<Options>(args).WithParsed<Options>(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;
}
}
}

View File

@ -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())));

View File

@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>bsmd.Tool</RootNamespace>
<AssemblyName>bsmd.Tool</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -38,15 +39,19 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLine">
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
<Reference Include="bsmd.database">
<HintPath>..\bsmd.database\bin\Debug\bsmd.database.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
<Private>True</Private>
<Reference Include="CommandLine, Version=2.9.1.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.2.9.1\lib\net461\CommandLine.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@ -83,12 +88,6 @@
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\bsmd.database\bsmd.database.csproj">
<Project>{19945af2-379b-46a5-b27a-303b5ec1d557}</Project>
<Name>bsmd.database</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineParser" version="1.9.71" targetFramework="net45" />
<package id="log4net" version="2.0.8" targetFramework="net45" />
<package id="CommandLineParser" version="2.9.1" targetFramework="net48" />
<package id="log4net" version="2.0.15" targetFramework="net48" />
</packages>