Example #1
0
        public static int Main(string[] args)
        {
            int errorCount = 0;

            MessageEngine Message = MessageEngine.Create("__VULCAN MAIN");

            Message.Trace(Severity.Notification, Resources.VulcanStart + Assembly.GetAssembly(typeof(XmlIR)).GetName().Version);

#if DEBUG
            Message.Trace(Severity.Notification, "DEBUG VERSION");
#endif

            // TODO: Can we set permissions so that only PhaseworkflowLoader can see the workflow editing methods?  (Vsabella: yes you can if you make it its own dll and mark the classes internal)
            PhaseWorkflowLoader WorkflowLoader = new PhaseWorkflowLoader();
            PhaseWorkflow Workflow = WorkflowLoader.PhaseWorkflowsByName[WorkflowLoader.DefaultWorkflowName];

            SimpleCommandLineParser cmdLineParser = new SimpleCommandLineParser("-/", args);

            if (args.Length == 0 || cmdLineParser["?"] != null)
            {
                DisplayHelpMenu();
                return errorCount;
            }

            if (cmdLineParser["t"] != null && cmdLineParser["t"].Count > 0)
            {
                PathManager.TargetPath = Path.GetFullPath(cmdLineParser["t"][0]);// +Path.DirectorySeparatorChar;
            }
            else
            {
                PathManager.TargetPath = Path.GetFullPath(".");
            }

            XmlIR xmlIR = new XmlIR();

            if (cmdLineParser["r"] != null && cmdLineParser["r"].Count > 0)
            {
                string[] rootPath = cmdLineParser["r"][0].Split(new char[] { '=' });

                if (rootPath != null && rootPath.Length == 2 && Directory.Exists(rootPath[1]))
                {
                    xmlIR.SetDocumentRoot(rootPath[0].ToUpperInvariant(), Path.GetFullPath(rootPath[1]));
                }
            }

            foreach (string filename in cmdLineParser.NoSwitchArguments)
            {
                if (File.Exists(filename))
                {
                    VulcanEngine.IR.XmlIRDocumentType docType = XmlIRDocumentType.SOURCE;
                    xmlIR.AddXml(Path.GetFullPath(filename), docType);
                }
                else
                {
                    Message.Trace(Severity.Error, new FileNotFoundException("Vulcan File Not Found", filename), Resources.VulcanFileNotFound, filename);
                }
            }

            IList<string> includedFiles = cmdLineParser["i"];

            if (includedFiles != null)
            {
                foreach (string filename in includedFiles)
                {
                    if (File.Exists(filename))
                    {
                        VulcanEngine.IR.XmlIRDocumentType docType = XmlIRDocumentType.INCLUDE;
                        xmlIR.AddXml(Path.GetFullPath(filename), docType);
                    }
                }
            }

            Workflow.ExecutePhaseWorkflowGraph(xmlIR);
            errorCount = (MessageEngine.AllEnginesErrorCount + MessageEngine.AllEnginesWarningCount) * -1;
            return errorCount;
        }// end main