コード例 #1
0
        private int HandleRunOptions(RunOptions runOptions)
        {
            SetVerboseLevel(runOptions.VerboseLevel);

            Reporter.ToLog(eLogLevel.INFO, string.Format("########################## Starting Automatic {0} Execution Process ##########################", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
            Reporter.ToLog(eLogLevel.INFO, string.Format("Parsing {0} execution arguments...", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
            Reporter.ToLog(eLogLevel.INFO, $"Solution: {runOptions.Solution}");
            Reporter.ToLog(eLogLevel.INFO, $"Runset: {runOptions.Runset}");
            Reporter.ToLog(eLogLevel.INFO, $"Environment: {runOptions.Environment}");
            Reporter.ToLog(eLogLevel.INFO, "Loading Configurations...");

            mCLIHandler                    = new CLIArgs();
            mCLIHelper.Solution            = runOptions.Solution;
            mCLIHelper.Runset              = runOptions.Runset;
            mCLIHelper.Env                 = runOptions.Environment;
            mCLIHelper.RunAnalyzer         = !runOptions.DoNotAnalyze;
            mCLIHelper.ShowAutoRunWindow   = runOptions.ShowUI;
            mCLIHelper.TestArtifactsFolder = runOptions.TestArtifactsPath;

            WorkSpace.Instance.RunningInExecutionMode = true;
            if (!CLILoadAndPrepare())
            {
                Reporter.ToLog(eLogLevel.WARN, "Issue occured while doing CLI Load and Prepare so aborting execution");
                Environment.ExitCode = 1;
                return(Environment.ExitCode);
            }

            ExecuteRunSet();

            mCLIHelper.PostExecution();

            return(Environment.ExitCode);
        }
コード例 #2
0
        private int HandleFileOptions(string fileType, string fileName, eVerboseLevel verboseLevel)
        {
            SetVerboseLevel(verboseLevel);
            Reporter.ToLog(eLogLevel.DEBUG, string.Format("Running with " + fileType + " file = '{0}'", fileName));
            switch (fileType)
            {
            case "config":
                mCLIHandler = new CLIConfigFile();
                break;

            case "dynamic":
                mCLIHandler = new CLIDynamicXML();
                // CLILoadAndPrepare();
                break;

            case "script":
                mCLIHandler = new CLIScriptFile();
                break;
            }
            mCLIHandler.LoadContent(ReadFile(fileName), mCLIHelper, WorkSpace.Instance.RunsetExecutor);
            if (fileType == "config" || fileType == "dynamic")  // not needed for script
            {
                CLILoadAndPrepare();
            }
            ExecuteRunSet();

            return(Environment.ExitCode);
        }
コード例 #3
0
        private int HandleFileOptions(string fileType, string fileName, eVerboseLevel verboseLevel)
        {
            try
            {
                SetVerboseLevel(verboseLevel);
                Reporter.ToLog(eLogLevel.INFO, string.Format("Running with " + fileType + " file = '{0}'", fileName));
                switch (fileType)
                {
                case "config":
                    mCLIHandler = new CLIConfigFile();
                    break;

                case "dynamic":
                    if (Path.GetExtension(fileName).ToLower() == ".xml")
                    {
                        mCLIHandler = new CLIDynamicFile(CLIDynamicFile.eFileType.XML);
                    }
                    else if (Path.GetExtension(fileName).ToLower() == ".json")
                    {
                        mCLIHandler = new CLIDynamicFile(CLIDynamicFile.eFileType.JSON);
                    }
                    else
                    {
                        Reporter.ToLog(eLogLevel.ERROR, string.Format("Dynamic file type is not supported, file path: '{0}'", fileName));
                        Environment.ExitCode = 1;     //failure
                        return(Environment.ExitCode);
                    }
                    break;

                case "script":
                    mCLIHandler = new CLIScriptFile();
                    break;
                }

                string fileContent = ReadFile(fileName);
                mCLIHandler.LoadGeneralConfigurations(fileContent, mCLIHelper);

                if (fileType == "config" || fileType == "dynamic")  // not needed for script
                {
                    if (!CLILoadAndPrepare(runsetConfigs: fileContent))
                    {
                        Reporter.ToLog(eLogLevel.WARN, "Issue occured while doing CLI Load and Prepare so aborting execution");
                        Environment.ExitCode = 1;
                        return(Environment.ExitCode);
                    }
                }

                ExecuteRunSet();

                return(Environment.ExitCode);
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Exception occured while Handling File Option", ex);
                Environment.ExitCode = 1;
                return(1);//error
            }
        }
コード例 #4
0
        private async Task <int> HandleRunOptions(RunOptions runOptions)
        {
            WorkSpace.Instance.GingerCLIMode = eGingerCLIMode.run;
            SetVerboseLevel(runOptions.VerboseLevel);

            Reporter.ToLog(eLogLevel.INFO, string.Format("######## Starting Automatic {0} Execution Process ########", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
            Reporter.ToLog(eLogLevel.INFO, string.Format("Parsing {0} execution arguments...", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
            Reporter.ToLog(eLogLevel.INFO, $"Solution: '{runOptions.Solution}'");
            Reporter.ToLog(eLogLevel.INFO, $"Runset: '{runOptions.Runset}'");
            Reporter.ToLog(eLogLevel.INFO, $"Environment: '{runOptions.Environment}'");
            Reporter.ToLog(eLogLevel.INFO, "Loading Configurations...");

            mCLIHandler         = new CLIArgs();
            mCLIHelper.Solution = runOptions.Solution;
            mCLIHelper.SetEncryptionKey(runOptions.EncryptionKey);
            mCLIHelper.Runset              = runOptions.Runset;
            mCLIHelper.Env                 = runOptions.Environment;
            mCLIHelper.RunAnalyzer         = !runOptions.DoNotAnalyze;
            mCLIHelper.ShowAutoRunWindow   = runOptions.ShowUI;
            mCLIHelper.TestArtifactsFolder = runOptions.TestArtifactsPath;

            mCLIHelper.SourceControlURL           = runOptions.URL;
            mCLIHelper.SourcecontrolUser          = runOptions.User;
            mCLIHelper.sourceControlType          = runOptions.SCMType;
            mCLIHelper.sourceControlPass          = runOptions.Pass;
            mCLIHelper.sourceControlPassEncrypted = runOptions.PasswordEncrypted;
            mCLIHelper.SourceControlProxyServer(runOptions.SourceControlProxyServer);
            mCLIHelper.SourceControlProxyPort(runOptions.SourceControlProxyPort);
            mCLIHelper.SelfHealingCheckInConfigured = runOptions.SelfHealingCheckInConfigured;

            if (!string.IsNullOrEmpty(runOptions.RunSetExecutionId))
            {
                if (!Guid.TryParse(runOptions.RunSetExecutionId, out Guid temp))
                {
                    Reporter.ToLog(eLogLevel.ERROR, string.Format("The provided ExecutionID '{0}' is not valid.", runOptions.RunSetExecutionId));
                    Environment.ExitCode = 1;
                    return(Environment.ExitCode);
                }
                else
                {
                    mCLIHelper.ExecutionId = runOptions.RunSetExecutionId;
                    Reporter.ToLog(eLogLevel.INFO, string.Format("Using provided ExecutionID '{0}'.", mCLIHelper.ExecutionId.ToString()));
                }
            }

            if (WorkSpace.Instance.UserProfile == null)
            {
                WorkSpace.Instance.UserProfile = new UserProfile();
                UserProfileOperations userProfileOperations = new UserProfileOperations(WorkSpace.Instance.UserProfile);
                WorkSpace.Instance.UserProfile.UserProfileOperations = userProfileOperations;
            }
            WorkSpace.Instance.UserProfile.SourceControlURL  = runOptions.URL;
            WorkSpace.Instance.UserProfile.SourceControlUser = runOptions.User;
            WorkSpace.Instance.UserProfile.SourceControlType = runOptions.SCMType;
            WorkSpace.Instance.UserProfile.UserProfileOperations.SourceControlIgnoreCertificate = runOptions.ignoreCertificate;
            WorkSpace.Instance.UserProfile.UserProfileOperations.SourceControlUseShellClient    = runOptions.useScmShell;



            WorkSpace.Instance.UserProfile.EncryptedSourceControlPass = runOptions.Pass;
            WorkSpace.Instance.UserProfile.SourceControlPass          = runOptions.Pass;
            if (runOptions.PasswordEncrypted)
            {
                mCLIHandler.LoadGeneralConfigurations("", mCLIHelper);
            }


            WorkSpace.Instance.RunningInExecutionMode = true;
            if (!CLILoadAndPrepare())
            {
                Reporter.ToLog(eLogLevel.WARN, "Issue occured while doing CLI Load and Prepare so aborting execution");
                Environment.ExitCode = 1;
                return(Environment.ExitCode);
            }

            await ExecuteRunSet();

            mCLIHelper.PostExecution();

            return(Environment.ExitCode);
        }
コード例 #5
0
 public Controller(IRecommendingSystem System, ICLI CLI)
 {
     _system              = System;
     _cli                 = CLI;
     _cli.CommandEntered += Input;
 }
コード例 #6
0
        private void HandleArg(string param, string value)
        {
            // TODO: get all classes impl ICLI and check Identifier then set

            switch (param)
            {
            case "--version":
                Console.WriteLine(string.Format("{0} Version: {1}", ApplicationInfo.ApplicationName, ApplicationInfo.ApplicationVersionWithInfo));
                break;

            case "--help":
            case "-h":
                ShowCLIHelp();
                break;

            case "ConfigFile":
            case "--configfile":
                mCLIHelper.CLIType = eCLIType.Config;
                Reporter.ToLog(eLogLevel.DEBUG, string.Format("Running with ConfigFile= '{0}'", value));
                mCLIHandler = new CLIConfigFile();
                PerformLoadAndExecution(ReadFile(value));
                break;

            case "Script":
            case "--scriptfile":
                mCLIHelper.CLIType = eCLIType.Script;
                Reporter.ToLog(eLogLevel.DEBUG, string.Format("Running with ScriptFile= '{0}'", value));
                mCLIHandler = new CLIScriptFile();
                PerformLoadAndExecution(ReadFile(value));
                break;

            case "--dynamicfile":
            case "Dynamic":
                mCLIHelper.CLIType = eCLIType.Dynamic;
                Reporter.ToLog(eLogLevel.DEBUG, string.Format("Running with DynamicXML= '{0}'", value));
                mCLIHandler = new CLIDynamicXML();
                PerformLoadAndExecution(ReadFile(value));
                break;

            case "--args":
                mCLIHelper.CLIType = eCLIType.Arguments;
                Reporter.ToLog(eLogLevel.DEBUG, string.Format("Running with Command Args= '{0}'", value));
                mCLIHandler = new CLIArgs();
                PerformLoadAndExecution(value);
                break;

            case "--excel":
                Reporter.ToLog(eLogLevel.DEBUG, string.Format("Running with CLI Excel= '{0}'", value));
                mCLIHandler = new CLIExcel();
                PerformLoadAndExecution(value);
                break;

            case "--servicegrid":
                int port = 15555;
                Console.WriteLine("Starting Ginger Grid at port: " + port);
                GingerGrid gingerGrid = new GingerGrid(15555);       // TODO: get port from CLI arg
                gingerGrid.Start();

                ServiceGridTracker serviceGridTracker = new ServiceGridTracker(gingerGrid);

                Console.ReadKey();
                break;
            }
        }