From cb212edbf7d2b1ff9d9e870aeab225d3221e8f2a Mon Sep 17 00:00:00 2001 From: Geoffrey Vancoetsem Date: Wed, 3 Oct 2012 01:37:19 +0200 Subject: [PATCH] =?UTF-8?q?MAJ=202.9.7=20finale:=20-=20gestion=20de=20la?= =?UTF-8?q?=20d=C3=A9sactivation=20des=20notifications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Configuration/InstallerConfig.cs | 75 +++++++++++++------- Configuration/InstallerConfigLegacy.cs | 98 -------------------------- Installer.cs | 20 +++--- Installer/Installer.wixproj | 38 ++++++++++ Installer/Messages.wxl | 4 ++ Installer/Product.wxs | 30 ++++++++ LogRotator.csproj | 35 ++++----- LogRotator.sln | 25 +++++-- Properties/AssemblyInfo.cs | 5 +- packages.config | 2 +- 10 files changed, 175 insertions(+), 157 deletions(-) delete mode 100644 Configuration/InstallerConfigLegacy.cs create mode 100644 Installer/Installer.wixproj create mode 100644 Installer/Messages.wxl create mode 100644 Installer/Product.wxs diff --git a/Configuration/InstallerConfig.cs b/Configuration/InstallerConfig.cs index 1d542f7..cdfe834 100644 --- a/Configuration/InstallerConfig.cs +++ b/Configuration/InstallerConfig.cs @@ -3,68 +3,95 @@ using System.Linq; using System.Text; using System.Configuration; +using System.Xml; +using System.IO; namespace Smartgeek.LogRotator.Configuration { public static class InstallerConfig { - private static readonly Object s_rotationSectionInitializeSyncRoot = new Object(); + private static readonly Object s_initializeSyncRoot = new Object(); - private static System.Configuration.Configuration s_config; - private static RotationSection s_rotationSection; - private static bool s_rotationSectionInitialized; - private static Exception s_rotationSectionInitializeException; - - public static RotationSection Rotation + private static bool s_initialized; + private static Exception s_initializeException; + private static String s_xmlFilePath; + private static XmlDocument s_xmlDoc; + private static XmlNode s_rotationNode; + + public static bool EnableEventLog { get { Initialize(); - return s_rotationSection; + XmlAttribute attr = s_rotationNode.Attributes["enableEventLog"]; + if (attr != null) + { + return Convert.ToBoolean(attr.Value); + } + return false; + } + set + { + Initialize(); + XmlAttribute attr = s_rotationNode.Attributes["enableEventLog"]; + if (value) + { + if (attr == null) + { + attr = s_xmlDoc.CreateAttribute("enableEventLog"); + s_rotationNode.Attributes.Append(attr); + } + attr.Value = "true"; + } + else + { + if (attr != null) + { + s_rotationNode.Attributes.Remove(attr); + } + } } } private static void Initialize() { - if (!s_rotationSectionInitialized) + if (!s_initialized) { - lock (s_rotationSectionInitializeSyncRoot) + lock (s_initializeSyncRoot) { - if (!s_rotationSectionInitialized) + if (!s_initialized) { try { - String exeLocation = System.Reflection.Assembly.GetExecutingAssembly().Location; - s_config = ConfigurationManager.OpenExeConfiguration(exeLocation); - s_rotationSection = (RotationSection)s_config.GetSection(@"rotation"); + s_xmlFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location + ".config"; + + s_xmlDoc = new XmlDocument(); + s_xmlDoc.Load(s_xmlFilePath); - if (s_rotationSection == null) - { - s_rotationSection = new RotationSection(); - } + s_rotationNode = s_xmlDoc.SelectSingleNode("configuration/rotation"); } catch (Exception ex) { - s_rotationSectionInitializeException = ex; + s_initializeException = ex; } finally { - s_rotationSectionInitialized = true; + s_initialized = true; } } } } - if (s_rotationSectionInitializeException != null) + if (s_initializeException != null) { - throw s_rotationSectionInitializeException; + throw s_initializeException; } } public static void Save() { - if (s_rotationSectionInitialized) + if (s_initialized) { - s_config.Save(); + s_xmlDoc.Save(s_xmlFilePath); } } } diff --git a/Configuration/InstallerConfigLegacy.cs b/Configuration/InstallerConfigLegacy.cs deleted file mode 100644 index 8ab5666..0000000 --- a/Configuration/InstallerConfigLegacy.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Configuration; -using System.Xml; -using System.IO; - -namespace Smartgeek.LogRotator.Configuration -{ - public static class InstallerConfigLegacy - { - private static readonly Object s_initializeSyncRoot = new Object(); - - private static bool s_initialized; - private static Exception s_initializeException; - private static String s_xmlFilePath; - private static XmlDocument s_xmlDoc; - private static XmlNode s_rotationNode; - - public static bool EnableEventLog - { - get - { - Initialize(); - XmlAttribute attr = s_rotationNode.Attributes["enableEventLog"]; - if (attr != null) - { - return Convert.ToBoolean(attr.Value); - } - return false; - } - set - { - Initialize(); - XmlAttribute attr = s_rotationNode.Attributes["enableEventLog"]; - if (value) - { - if (attr == null) - { - attr = s_xmlDoc.CreateAttribute("enableEventLog"); - s_rotationNode.Attributes.Append(attr); - } - attr.Value = "true"; - } - else - { - if (attr != null) - { - s_rotationNode.Attributes.Remove(attr); - } - } - } - } - - private static void Initialize() - { - if (!s_initialized) - { - lock (s_initializeSyncRoot) - { - if (!s_initialized) - { - try - { - s_xmlFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location + ".config"; - - s_xmlDoc = new XmlDocument(); - s_xmlDoc.Load(s_xmlFilePath); - - s_rotationNode = s_xmlDoc.SelectSingleNode("configuration/rotation"); - } - catch (Exception ex) - { - s_initializeException = ex; - } - finally - { - s_initialized = true; - } - } - } - } - if (s_initializeException != null) - { - throw s_initializeException; - } - } - - public static void Save() - { - if (s_initialized) - { - s_xmlDoc.Save(s_xmlFilePath); - } - } - } -} diff --git a/Installer.cs b/Installer.cs index e172900..8a4088d 100644 --- a/Installer.cs +++ b/Installer.cs @@ -27,13 +27,13 @@ public override void Install(IDictionary stateSaver) { base.Install(stateSaver); - previousEnableEventLog = InstallerConfigLegacy.EnableEventLog; + previousEnableEventLog = InstallerConfig.EnableEventLog; // enable windows event logs - if (!InstallerConfigLegacy.EnableEventLog) + if (!InstallerConfig.EnableEventLog) { - InstallerConfigLegacy.EnableEventLog = true; - InstallerConfigLegacy.Save(); + InstallerConfig.EnableEventLog = true; + InstallerConfig.Save(); Trace.TraceInformation("Windows event logs for this application are now enabled."); this.Context.LogMessage("Information: Windows event logs for this application are now enabled."); @@ -53,10 +53,10 @@ public override void Rollback(IDictionary savedState) base.Rollback(savedState); // restore previous event log settings - if (InstallerConfigLegacy.EnableEventLog != previousEnableEventLog) + if (InstallerConfig.EnableEventLog != previousEnableEventLog) { - InstallerConfigLegacy.EnableEventLog = previousEnableEventLog; - InstallerConfigLegacy.Save(); + InstallerConfig.EnableEventLog = previousEnableEventLog; + InstallerConfig.Save(); Trace.TraceInformation("Windows event logs settings for this application has been rollbacked"); this.Context.LogMessage("Information: Windows event logs settings for this application has been rollbacked"); @@ -83,10 +83,10 @@ public override void Uninstall(IDictionary savedState) } // disable windows event logs - if (InstallerConfigLegacy.EnableEventLog) + if (InstallerConfig.EnableEventLog) { - InstallerConfigLegacy.EnableEventLog = false; - InstallerConfigLegacy.Save(); + InstallerConfig.EnableEventLog = false; + InstallerConfig.Save(); Trace.TraceInformation("Windows event logs for this application are now disabled"); this.Context.LogMessage("Information: Windows event logs for this application are now disabled"); diff --git a/Installer/Installer.wixproj b/Installer/Installer.wixproj new file mode 100644 index 0000000..4380edf --- /dev/null +++ b/Installer/Installer.wixproj @@ -0,0 +1,38 @@ + + + + Debug + x86 + 3.6 + 6adf48ec-d284-4285-9367-cd7687223288 + 2.0 + Installer + Package + $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets + $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets + + + bin\$(Configuration)\ + obj\$(Configuration)\ + Debug + + + bin\$(Configuration)\ + obj\$(Configuration)\ + + + + + + + + + + \ No newline at end of file diff --git a/Installer/Messages.wxl b/Installer/Messages.wxl new file mode 100644 index 0000000..a1ef572 --- /dev/null +++ b/Installer/Messages.wxl @@ -0,0 +1,4 @@ + + + Your localized string + \ No newline at end of file diff --git a/Installer/Product.wxs b/Installer/Product.wxs new file mode 100644 index 0000000..5747a90 --- /dev/null +++ b/Installer/Product.wxs @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LogRotator.csproj b/LogRotator.csproj index 284fd01..8814a54 100644 --- a/LogRotator.csproj +++ b/LogRotator.csproj @@ -45,7 +45,7 @@ true ;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules true - false + true bin\Release\ @@ -62,14 +62,15 @@ true ;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules true + true App.ico true - D:\TEMP\LogRotator\ - TRACE;DEBUG;z + C:\TEMP\LogRotator\ + TRACE;DEBUG full AnyCPU bin\Debug\LogRotator.exe.CodeAnalysisLog.xml @@ -92,15 +93,25 @@ false + + C:\TEMP\LogRotator\ + true + TRACE;DEBUG + prompt + full + true + packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll C:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll + False - - packages\TaskScheduler.1.8.1\lib\2\Microsoft.Win32.TaskScheduler.dll + + False + packages\TaskScheduler.1.8.3\lib\2\Microsoft.Win32.TaskScheduler.dll @@ -116,7 +127,6 @@ - @@ -166,14 +176,6 @@ PreserveNewest - - - - - - - - PreserveNewest @@ -181,8 +183,6 @@ - - @@ -229,7 +229,8 @@ - REM xcopy /I /Y $(OutDir)* \\rovms502\c$\Scripts\LogRotator + xcopy /I /Y $(OutDir)* \\ZEUS\c$\TEMP\LogRotator +REM xcopy /I /Y $(OutDir)* \\rovms502\c$\TEMP\LogRotator diff --git a/LogRotator.sln b/LogRotator.sln index 5502dcf..c43ba94 100644 --- a/LogRotator.sln +++ b/LogRotator.sln @@ -1,21 +1,36 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogRotator", "LogRotator.csproj", "{AC5644F5-F491-4E67-BD18-0B5BCC9A1198}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU - Remote Debug (ROVMS502)|Any CPU = Remote Debug (ROVMS502)|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 + Remote Debug (ZEUS)|Any CPU = Remote Debug (ZEUS)|Any CPU + Remote Debug (ZEUS)|Mixed Platforms = Remote Debug (ZEUS)|Mixed Platforms + Remote Debug (ZEUS)|x86 = Remote Debug (ZEUS)|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Debug|x86.ActiveCfg = Debug|Any CPU {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Release|Any CPU.ActiveCfg = Release|Any CPU {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Release|Any CPU.Build.0 = Release|Any CPU - {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Remote Debug (ROVMS502)|Any CPU.ActiveCfg = Remote Debug (ROVMS502)|Any CPU - {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Remote Debug (ROVMS502)|Any CPU.Build.0 = Remote Debug (ROVMS502)|Any CPU + {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Release|x86.ActiveCfg = Release|Any CPU + {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Remote Debug (ZEUS)|Any CPU.ActiveCfg = Remote Debug (ROVMS502)|Any CPU + {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Remote Debug (ZEUS)|Any CPU.Build.0 = Remote Debug (ROVMS502)|Any CPU + {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Remote Debug (ZEUS)|Mixed Platforms.ActiveCfg = Remote Debug (ZEUS)|Any CPU + {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Remote Debug (ZEUS)|Mixed Platforms.Build.0 = Remote Debug (ZEUS)|Any CPU + {AC5644F5-F491-4E67-BD18-0B5BCC9A1198}.Remote Debug (ZEUS)|x86.ActiveCfg = Remote Debug (ZEUS)|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 100f54c..a3e7368 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -24,5 +24,6 @@ [assembly: AssemblyConfiguration("Release")] #endif -[assembly: AssemblyVersion("1.6.0.0")] -[assembly: AssemblyFileVersion("1.6.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.7.0.0")] +[assembly: AssemblyFileVersion("1.7.0.0")] +[assembly: AssemblyInformationalVersion("1.7 alpha")] \ No newline at end of file diff --git a/packages.config b/packages.config index de97f99..953dd82 100644 --- a/packages.config +++ b/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file