Beispiel #1
0
        static void Main(string[] args)
        {
            if (args.Length == 1 && File.Exists(args[0]))
            {
                path = args[0];
            }
            else if (args.Length != 0)
            {
                MessageBox.Show("CommandLine not supported currently :(");
                return;
            }

            /*  if (args.Length == 1)
             * {
             *    if (args[0].Length > 0)
             *    {
             *        if (args[0].Equals("--help", StringComparison.InvariantCultureIgnoreCase))
             *        {
             *            MessageBox.Show("Command line usage examples: \n MPViewer.exe c:\\Microsoft.Windows.Server.2003.mp c:\\win2003.html AlertGeneratingWorkflowsOnly \n MPViewer.exe c:\\Microsoft.Windows.Server.2003.mp c:\\win2003.html \n MPViewer.exe c:\\Microsoft.Windows.Server.2003.mp c:\\win2003.xls", "MPViewer Help");
             *            return;
             *        }
             *        else
             *        {
             *            MessageBox.Show("Unsupported number of arguments or format. Launching MPViewer.exe with no parameters will bring up the UI, or use MPViewer.exe --help to get help on the implemented command line options.");
             *            return;
             *        }
             *    }
             *
             * }
             *
             * // gotta love the undocumented command line usage for bulk HTML export... only works for MPs at this point, not MPBs
             * // TODO - refactor so only one piece of code is used to load the MP/MPB, rather than this duplicate logic...
             * if (args.Length >= 2)
             * {
             *    try
             *    {
             *        if (args[0].Length == 0)
             *        {
             *            throw new ApplicationException("Invalid management pack file path");
             *        }
             *        if (args[1].Length == 0)
             *        {
             *            throw new ApplicationException("Invalid file path");
             *        }
             *
             *        //HTML output desired
             *        if ((args[1].EndsWith(".html", StringComparison.InvariantCultureIgnoreCase)) || (args[1].EndsWith(".htm", StringComparison.InvariantCultureIgnoreCase)))
             *        {
             *            GenerateHTMLForMP(args);
             *        }
             *
             *        //Excel output desired
             *        if ((args[1].EndsWith(".xls", StringComparison.InvariantCultureIgnoreCase)) || (args[1].EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase)))
             *        {
             *            GenerateExcelForMP(args);
             *        }
             *    }
             *    catch(Exception exception)
             *    {
             *        //Console.WriteLine(exception.Message);
             *        MessageBox.Show(exception.Message);
             *    }
             *
             * }
             * // load the GUI - standard execution path
             * else
             * { */
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MPViewer MPViewer;

            if (path.Length > 0)
            {
                MPViewer = new MPViewer(path);
            }
            else
            {
                MPViewer = new MPViewer();
            }
            Application.Run(MPViewer);
            //  }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            if(args.Length == 1 && File.Exists(args[0]))
            {
                path = args[0];
            } else if(args.Length != 0)
            {
                MessageBox.Show("CommandLine not supported currently :(");
                return;
            }
              /*  if (args.Length == 1)
            {
                if (args[0].Length > 0)
                {
                    if (args[0].Equals("--help", StringComparison.InvariantCultureIgnoreCase))
                    {
                        MessageBox.Show("Command line usage examples: \n MPViewer.exe c:\\Microsoft.Windows.Server.2003.mp c:\\win2003.html AlertGeneratingWorkflowsOnly \n MPViewer.exe c:\\Microsoft.Windows.Server.2003.mp c:\\win2003.html \n MPViewer.exe c:\\Microsoft.Windows.Server.2003.mp c:\\win2003.xls", "MPViewer Help");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Unsupported number of arguments or format. Launching MPViewer.exe with no parameters will bring up the UI, or use MPViewer.exe --help to get help on the implemented command line options.");
                        return;
                    }
                }

            }

            // gotta love the undocumented command line usage for bulk HTML export... only works for MPs at this point, not MPBs
            // TODO - refactor so only one piece of code is used to load the MP/MPB, rather than this duplicate logic...
            if (args.Length >= 2)
            {
                try
                {
                    if (args[0].Length == 0)
                    {
                        throw new ApplicationException("Invalid management pack file path");
                    }
                    if (args[1].Length == 0)
                    {
                        throw new ApplicationException("Invalid file path");
                    }

                    //HTML output desired
                    if ((args[1].EndsWith(".html", StringComparison.InvariantCultureIgnoreCase)) || (args[1].EndsWith(".htm", StringComparison.InvariantCultureIgnoreCase)))
                    {
                        GenerateHTMLForMP(args);
                    }

                    //Excel output desired
                    if ((args[1].EndsWith(".xls", StringComparison.InvariantCultureIgnoreCase)) || (args[1].EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase)))
                    {
                        GenerateExcelForMP(args);
                    }
                }
                catch(Exception exception)
                {
                    //Console.WriteLine(exception.Message);
                    MessageBox.Show(exception.Message);
                }

            }
            // load the GUI - standard execution path
            else
            { */
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                MPViewer MPViewer;
                if (path.Length > 0)
                {
                    MPViewer = new MPViewer(path);
                } else
                {
                    MPViewer = new MPViewer();
                }
                Application.Run(MPViewer);
              //  }
        }