diff --git a/CHANGELOG.md b/CHANGELOG.md index 1032d23..c093343 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +# v1.6.1.0 +## 22/04/2015 + +* Added the FluentCommandLineParser.dll library to the project to easier get the passed parameters. https://github.com/fclp/fluent-command-line-parser +* Added a new argument 'Filename' (-f, /f, --filename): Set the path and/or filename for the generated report file. If the passed path is a directory the default filename will be appended to it. Absolute or relative paths are allowed +* Added a new argument 'Max Tasks' (-t, /t, --max-tasks ): Sets the maximum number of concurrent tasks enabled to generate the reports. If it is -1, there is no limit on the number of concurrently running operations (Default). If it is 1 it will run in a single thread, best used with single core CPUs or for debuging. +* Added a new argument 'Help' (-?, /?, --help): Display a help message with all possible arguments and its usages +* Added support for combined (grouped) options when passing three or more boolean arguments. ex: -sno (same as: -s -n -o) +* Changed the way arguments can be passed. Now it support the following syntax: [-|--|/][switch_name][=|:| ][value] +* Removed the empty columns for installed programs table under Mac OSX +* Removed 'Single Thread' argument in favor of the new 'Max Tasks' argument, use -t 1 to produce the same effect + + # v1.6.0.0 ## 21/04/2015 @@ -9,6 +22,7 @@ * Fixed a critical bug under linux and OSX that cause the processes report to broke all the html when any process name is null * Changed the InstalledProgram class was been rewrited and moved into Core + # v1.5.0.0 ## 18/04/2015 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..930d7b0 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,374 @@ +Mozilla Public License 2.0 (MPL-2.0) +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" +means each individual or legal entity that creates, contributes to +the creation of, or owns Covered Software. + +1.2. "Contributor Version" +means the combination of the Contributions of others (if any) used +by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" +means Covered Software of a particular Contributor. + +1.4. "Covered Software" +means Source Code Form to which the initial Contributor has attached +the notice in Exhibit A, the Executable Form of such Source Code +Form, and Modifications of such Source Code Form, in each case +including portions thereof. + +1.5. "Incompatible With Secondary Licenses" +means + +(a) that the initial Contributor has attached the notice described +in Exhibit B to the Covered Software; or + +(b) that the Covered Software was made available under the terms of +version 1.1 or earlier of the License, but not also under the +terms of a Secondary License. + +1.6. "Executable Form" +means any form of the work other than Source Code Form. + +1.7. "Larger Work" +means a work that combines Covered Software with other material, in +a separate file or files, that is not Covered Software. + +1.8. "License" +means this document. + +1.9. "Licensable" +means having the right to grant, to the maximum extent possible, +whether at the time of the initial grant or subsequently, any and +all of the rights conveyed by this License. + +1.10. "Modifications" +means any of the following: + +(a) any file in Source Code Form that results from an addition to, +deletion from, or modification of the contents of Covered +Software; or + +(b) any new file in Source Code Form that contains any Covered +Software. + +1.11. "Patent Claims" of a Contributor +means any patent claim(s), including without limitation, method, +process, and apparatus claims, in any patent Licensable by such +Contributor that would be infringed, but for the grant of the +License, by the making, using, selling, offering for sale, having +made, import, or transfer of either its Contributions or its +Contributor Version. + +1.12. "Secondary License" +means either the GNU General Public License, Version 2.0, the GNU +Lesser General Public License, Version 2.1, the GNU Affero General +Public License, Version 3.0, or any later versions of those +licenses. + +1.13. "Source Code Form" +means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") +means an individual or a legal entity exercising rights under this +License. For legal entities, "You" includes any entity that +controls, is controlled by, or is under common control with You. For +purposes of this definition, "control" means (a) the power, direct +or indirect, to cause the direction or management of such entity, +whether by contract or otherwise, or (b) ownership of more than +fifty percent (50%) of the outstanding shares or beneficial +ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) +Licensable by such Contributor to use, reproduce, make available, +modify, display, perform, distribute, and otherwise exploit its +Contributions, either on an unmodified basis, with Modifications, or +as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer +for sale, have made, import, and otherwise transfer either its +Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; +or + +(b) for infringements caused by: (i) Your and any other third party's +modifications of Covered Software, or (ii) the combination of its +Contributions with other software (except as part of its Contributor +Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of +its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code +Form, as described in Section 3.1, and You must inform recipients of +the Executable Form how they can obtain a copy of such Source Code +Form by reasonable means in a timely manner, at a charge no more +than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this +License, or sublicense it under different terms, provided that the +license for the Executable Form does not attempt to limit or alter +the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + +This Source Code Form is subject to the terms of the Mozilla Public +License, v. 2.0. If a copy of the MPL was not distributed with this +file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + +This Source Code Form is "Incompatible With Secondary Licenses", as +defined by the Mozilla Public License, v. 2.0. \ No newline at end of file diff --git a/SystemInfoSnapshot/ApplicationArguments.cs b/SystemInfoSnapshot/ApplicationArguments.cs index 6f7633c..d464cad 100644 --- a/SystemInfoSnapshot/ApplicationArguments.cs +++ b/SystemInfoSnapshot/ApplicationArguments.cs @@ -5,9 +5,8 @@ * http://systeminfosnapshot.com/ * https://github.com/sn4k3/SystemInfoSnapshot */ -using System; -using System.Collections.Generic; -using System.Linq; + +using Fclp; namespace SystemInfoSnapshot { @@ -17,75 +16,121 @@ namespace SystemInfoSnapshot public sealed class ApplicationArguments { #region Singleton - /// - /// A instance of this class - /// - private static ApplicationArguments _instance; - /// /// Gets the singleton instance of this class /// public static ApplicationArguments Instance { - get { return _instance ?? (_instance = new ApplicationArguments()); } + get { return CmdParser.Object; } } #endregion #region Properties + + /// + /// Gets the parameter parser + /// + public static FluentCommandLineParser CmdParser = new FluentCommandLineParser { IsCaseSensitive = false }; + + /// + /// Gets if program will lunch without the GUI. (Terminal only) + /// + public bool NoGUI + { + get + { + return Silent && Null; + } + } + /// /// Gets if Null mode as passed as argument. /// - public bool Null { get; private set; } + public bool Null { get; set; } /// /// Gets if Silent mode as passed as argument. /// - public bool Silent { get; private set; } + public bool Silent { get; set; } /// /// Gets if OpenReport mode as passed as argument. /// - public bool OpenReport { get; private set; } + public bool OpenReport { get; set; } /// /// Gets if the reports will be generated under a single thread. /// - public bool UseSingleThread { get; private set; } - #endregion + public int MaxDegreeOfParallelism { get; set; } - #region Arguments Variable /// - /// Variable - Arguments list + /// Gets the full or partial filename to save the report /// - public readonly Dictionary Arguments = new Dictionary - { - {"Null", new []{"-n", "/n", "--null"}}, - {"Silent", new []{"-s", "/s", "--silent"}}, - {"OpenReport", new []{"-o", "/o", "--open-report"}}, - {"UseSingleThread", new []{"-st", "/st", "--single-thread"}} - }; + public string Filename { get; set; } #endregion #region Constructor /// /// Constructor. Auto initalize arguments. /// - private ApplicationArguments() + public ApplicationArguments() { - var args = Environment.GetCommandLineArgs().ToList(); + } + #endregion - foreach (var argument in Arguments) + #region Methods + /// + /// Fix some paramters and define limits. + /// + public void Fix() + { + // Set to -1 if 0 or lower + if (MaxDegreeOfParallelism <= 0) { - foreach (var s in argument.Value) - { - if(!args.Contains(s)) - continue; - - var type = GetType(); - var prop = type.GetProperty(argument.Key); - prop.SetValue(this, true); - } + MaxDegreeOfParallelism = -1; } + + if (string.IsNullOrWhiteSpace(Filename)) + { + Filename = null; + } + } + #endregion + + #region Static methods + public static ICommandLineParserResult Init(string[] args) + { + CmdParser.SetupHelp("?", "help").Callback(SystemHelper.DisplayMessage); + CmdParser.Setup(arg => arg.Null). + As('n', "null"). + SetDefault(false). + WithDescription("Only generate the report without showing or doing anything. Good for scripts or tasks."); + + CmdParser.Setup(arg => arg.Silent). + As('s', "silent"). + SetDefault(false). + WithDescription("Run program without showing the GUI. After the report is generated that will be shown on explorer after completion."); + + CmdParser.Setup(arg => arg.OpenReport). + As('o', "open-report"). + SetDefault(false). + WithDescription("After the report is generated that will be opened automatically in the default browser."); + + CmdParser.Setup(arg => arg.MaxDegreeOfParallelism). + As('t', "max-tasks"). + SetDefault(-1). + WithDescription("Sets the maximum number of concurrent tasks enabled to generate the reports. If it is -1, there is no limit on the number of concurrently running operations (Default). " + + "If it is 1 it will run in a single thread, best used with single core CPUs or for debuging."); + + CmdParser.Setup(arg => arg.Filename). + As('f', "target"). + SetDefault(null). + WithDescription("Set the path and/or filename for the generated report file. If the passed path is a directory the default filename will be appended to it. Absolute or relative paths are allowed."); + + var result = CmdParser.Parse(args); + + return result; + } #endregion } diff --git a/SystemInfoSnapshot/EmbeddedAssembly.cs b/SystemInfoSnapshot/EmbeddedAssembly.cs index d8ba005..45c11b5 100644 --- a/SystemInfoSnapshot/EmbeddedAssembly.cs +++ b/SystemInfoSnapshot/EmbeddedAssembly.cs @@ -11,6 +11,7 @@ using System.Linq; using System.Reflection; using System.Security.Cryptography; +using System.Windows.Forms; namespace SystemInfoSnapshot { @@ -143,7 +144,6 @@ public static Assembly OnResolveAssembly(object sender, ResolveEventArgs e) // Get the Name of the AssemblyFile var assemblyName = new AssemblyName(e.Name); var dllName = assemblyName.Name + ".dll"; - // Load from Embedded Resources var resources = thisAssembly.GetManifestResourceNames().Where(s => s.EndsWith(dllName)); if (resources.Any()) diff --git a/SystemInfoSnapshot/FrmMain.cs b/SystemInfoSnapshot/FrmMain.cs index 591142f..4ecabf9 100644 --- a/SystemInfoSnapshot/FrmMain.cs +++ b/SystemInfoSnapshot/FrmMain.cs @@ -109,12 +109,12 @@ private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventA { ButtonsSetEnabled(true); var location = Path.GetDirectoryName(Program.HtmlTemplate.LastSaveFilePath); - if (string.IsNullOrEmpty(location)) + /*if (string.IsNullOrEmpty(location)) { location = Application.StartupPath; - } + }*/ lbFilename.Text = Path.GetFileName(Program.HtmlTemplate.LastSaveFilePath); - //lbLocation.Text = location; + lbLocation.Text = location; EndDateTime = DateTime.Now; tmClock.Stop(); lbStatus.Text = string.Format("Report completed in {0:0.##}s", (EndDateTime - StartDateTime).TotalSeconds); diff --git a/SystemInfoSnapshot/HTMLTemplate.cs b/SystemInfoSnapshot/HTMLTemplate.cs index f1a7423..2f9f234 100644 --- a/SystemInfoSnapshot/HTMLTemplate.cs +++ b/SystemInfoSnapshot/HTMLTemplate.cs @@ -59,12 +59,39 @@ public void WriteFromVar(string templateVar, string html) /// public void WriteToFile() { - var filename = Filename ?? "SystemInfoSnapshot"; - filename += string.Format("_{0}.html", DateTime.Now).Replace(':', '-').Replace('/', '-').Replace(' ', '_'); + var defaultFilename = string.Format("SystemInfoSnapshot_{0}.html", DateTime.Now). + Replace(':', '-'). + Replace('/', '-'). + Replace(' ', '_');; + var filename = Filename ?? defaultFilename; + + //filename += string.Format("_{0}.html", DateTime.Now).Replace(':', '-').Replace('/', '-').Replace(' ', '_'); #if !DEBUG - var path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); - - filename = Directory.Exists(path) ? Path.Combine(path, filename) : filename; + string path = null; + if (!string.IsNullOrEmpty(Filename)) + { + // If is a directory then keep filename the default name and set the folder only. + if (Directory.Exists(filename)) + { + path = filename; + filename = defaultFilename; + } + else // If is not a directory then get the path from the filename if any and append .html to the filename + { + path = Path.GetDirectoryName(Filename); + if (!filename.EndsWith(".html")) + filename += ".html"; + } + } + + // Last check for invalid path, if invalid set path as dekstop + if (string.IsNullOrEmpty(path) || !Directory.Exists(path)) + { + path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); + } + + + filename = !string.IsNullOrEmpty(path) && Directory.Exists(path) ? Path.Combine(path, filename) : filename; #endif using (var htmlWriter = new StreamWriter(filename)) { diff --git a/SystemInfoSnapshot/Program.cs b/SystemInfoSnapshot/Program.cs index c09cbbc..2a9ae7e 100644 --- a/SystemInfoSnapshot/Program.cs +++ b/SystemInfoSnapshot/Program.cs @@ -7,6 +7,7 @@ */ using System; +using System.Runtime.CompilerServices; using System.Windows.Forms; using SystemInfoSnapshot.Reports; @@ -14,20 +15,57 @@ namespace SystemInfoSnapshot { static class Program { + #region Properties + /// + /// Gets the project website + /// public const string Website = "http://systeminfosnapshot.com"; - public static HtmlTemplate HtmlTemplate; - public static Report[] Reports; + public static HtmlTemplate HtmlTemplate { get; private set; } + public static Report[] Reports { get; private set; } + #endregion + + #region Constructor + /// + /// Constructor + /// + static Program() + { + AppDomain.CurrentDomain.AssemblyResolve += EmbeddedAssembly.OnResolveAssembly; + } + #endregion + + #region Bootsrap /// /// The main entry point for the application. /// [STAThread] static void Main() { - AppDomain.CurrentDomain.AssemblyResolve += EmbeddedAssembly.OnResolveAssembly; + // Skip this method and do all work on a secondary method for .NET able to register embbeded assemblies correctly + MainCore(); + } + + /// + /// + /// + [MethodImpl(MethodImplOptions.NoInlining)] + static void MainCore() + { Reports = Report.GetReports(); + var resultArgs = ApplicationArguments.Init(Environment.GetCommandLineArgs()); + if (resultArgs.HasErrors) + { + SystemHelper.DisplayMessage(resultArgs.ErrorText); + } + if (resultArgs.HelpCalled) + { + // Quit + return; + } + ApplicationArguments.Instance.Fix(); // Null or Silent mode, skip GUI. - if (ApplicationArguments.Instance.Null || ApplicationArguments.Instance.Silent) + if (ApplicationArguments.Instance.NoGUI) { WriteTemplate(); return; @@ -37,13 +75,15 @@ static void Main() Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FrmMain()); } + #endregion + #region Static Methods /// /// Write all info into template and output the html file. /// public static void WriteTemplate() { - HtmlTemplate = Report.GenerateReports(Reports, true, ApplicationArguments.Instance.UseSingleThread); + HtmlTemplate = Report.GenerateReports(Reports, true, ApplicationArguments.Instance.Filename, ApplicationArguments.Instance.MaxDegreeOfParallelism); if (ApplicationArguments.Instance.Silent) { @@ -55,5 +95,6 @@ public static void WriteTemplate() HtmlTemplate.OpenInDefaultBrowser(); } } + #endregion } } diff --git a/SystemInfoSnapshot/Properties/AssemblyInfo.cs b/SystemInfoSnapshot/Properties/AssemblyInfo.cs index 9655512..c749720 100644 --- a/SystemInfoSnapshot/Properties/AssemblyInfo.cs +++ b/SystemInfoSnapshot/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -32,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.0.0")] -[assembly: AssemblyFileVersion("1.6.0.0")] +[assembly: AssemblyVersion("1.6.1.0")] +[assembly: AssemblyFileVersion("1.6.1.0")] diff --git a/SystemInfoSnapshot/Reports/Programs.cs b/SystemInfoSnapshot/Reports/Programs.cs index 517ff4d..fa80e81 100644 --- a/SystemInfoSnapshot/Reports/Programs.cs +++ b/SystemInfoSnapshot/Reports/Programs.cs @@ -27,9 +27,12 @@ protected override void Build() HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "#"); HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Program"); - HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Version"); - HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Publisher"); - HtmlWriter.RenderTag(HtmlTextWriterTag.Th, SystemHelper.IsWindows ? "Install Date" : "Description"); + if (!SystemHelper.IsMacOSX) + { + HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Version"); + HtmlWriter.RenderTag(HtmlTextWriterTag.Th, "Publisher"); + HtmlWriter.RenderTag(HtmlTextWriterTag.Th, SystemHelper.IsWindows ? "Install Date" : "Description"); + } HtmlWriter.RenderEndTag(); // HtmlWriter.RenderEndTag(); // @@ -52,13 +55,21 @@ protected override void Build() HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "index", i.ToString()); HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "program", program.Name); - HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "version", program.Version); - HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "publisher", program.Publisher); - if(SystemHelper.IsWindows) - HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "installdate", program.InstallDate); - else - HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "description", program.Description); + if (!SystemHelper.IsMacOSX) + { + HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "version", program.Version); + HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "publisher", + program.Publisher); + + if (SystemHelper.IsWindows) + HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "installdate", + program.InstallDate); + else + HtmlWriter.RenderTag(HtmlTextWriterTag.Td, HtmlTextWriterAttribute.Class, "description", + program.Description); + + } HtmlWriter.RenderEndTag(); diff --git a/SystemInfoSnapshot/Reports/Report.cs b/SystemInfoSnapshot/Reports/Report.cs index 85c10d9..419e7f9 100644 --- a/SystemInfoSnapshot/Reports/Report.cs +++ b/SystemInfoSnapshot/Reports/Report.cs @@ -141,7 +141,7 @@ public static Report[] GetReports() Where(t => (t.IsClass) && (!t.IsAbstract) && - (String.Equals(t.Namespace, "SystemInfoSnapshot.Reports", StringComparison.Ordinal)) && + (string.Equals(t.Namespace, "SystemInfoSnapshot.Reports", StringComparison.Ordinal)) && (t.IsSubclassOf(typeof(Report))) ).ToArray(); @@ -159,11 +159,15 @@ public static Report[] GetReports() /// /// List of reports to generate. /// True for save reports in the html file. - /// True to generate the reports without parallel tasks + /// Sets the file full or relative path, if folder is given default name will be used in it. + /// Sets the maximum number of concurrent tasks enabled by this ParallelOptions instance. /// with the reports already written in the template. - public static HtmlTemplate GenerateReports(Report[] reports, bool saveReport = true, bool useSingleThread = false) + public static HtmlTemplate GenerateReports(Report[] reports, bool saveReport = true, string filename = null, int maxDegreeOfParallelism = -1) { - var htmlTemplate = new HtmlTemplate(); + var htmlTemplate = new HtmlTemplate() + { + Filename = filename + }; //List asyncReports = new List(); /*if (useSingleThread) @@ -182,10 +186,9 @@ public static HtmlTemplate GenerateReports(Report[] reports, bool saveReport = t else {*/ #if DEBUG - var options = new ParallelOptions { MaxDegreeOfParallelism = 1 }; -#else - var options = new ParallelOptions { MaxDegreeOfParallelism = useSingleThread ? 1 : -1 }; + maxDegreeOfParallelism = 1; #endif + var options = new ParallelOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism }; Parallel.ForEach(reports, options, report => { Debug.WriteLine(report.GetTemplateVar()); diff --git a/SystemInfoSnapshot/Resources/libraries/FluentCommandLineParser.dll b/SystemInfoSnapshot/Resources/libraries/FluentCommandLineParser.dll new file mode 100644 index 0000000..d3ab14a Binary files /dev/null and b/SystemInfoSnapshot/Resources/libraries/FluentCommandLineParser.dll differ diff --git a/SystemInfoSnapshot/SystemHelper.cs b/SystemInfoSnapshot/SystemHelper.cs index eafff7b..3109d8b 100644 --- a/SystemInfoSnapshot/SystemHelper.cs +++ b/SystemInfoSnapshot/SystemHelper.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; +using System.Windows.Forms; namespace SystemInfoSnapshot { @@ -248,6 +249,16 @@ public static void OpenLink(string address) // We don't want any surprises } } + + public static void DisplayMessage(string text) + { + //Debug.WriteLine(text); + Console.WriteLine(text); + if (IsWindows || IsMacOSX) + { + MessageBox.Show(text); + } + } #endregion } } \ No newline at end of file diff --git a/SystemInfoSnapshot/SystemInfoSnapshot.csproj b/SystemInfoSnapshot/SystemInfoSnapshot.csproj index c616a49..e137cf4 100644 --- a/SystemInfoSnapshot/SystemInfoSnapshot.csproj +++ b/SystemInfoSnapshot/SystemInfoSnapshot.csproj @@ -71,6 +71,10 @@ sign.pfx + + Resources\libraries\FluentCommandLineParser.dll + False + Resources\libraries\OpenHardwareMonitorLib.dll False @@ -147,6 +151,9 @@ CHANGELOG.md + + LICENSE.md + Makefile @@ -177,6 +184,7 @@ +