Esempio n. 1
0
        public static List <AnalyzerItemBase> Analyze(RunSetConfig RSC)
        {
            List <AnalyzerItemBase> IssuesList = new List <AnalyzerItemBase>();

            // check that we have Runners
            if (RSC.GingerRunners.Count() == 0)
            {
                RunSetConfigAnalyzer AGR = CreateNewIssue(IssuesList, RSC);
                AGR.Description = "Missing Runners";
                AGR.Details     = "No Runners to run";
                AGR.HowToFix    = "Add Runners";
                AGR.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                AGR.IssueType   = eType.Warning;
                AGR.Impact      = "Nothing to run";
                AGR.Severity    = eSeverity.Medium;
                AGR.Selected    = false;
            }

            //check we do not have duplicates Agents
            if (RSC.RunModeParallel)
            {
                List <Guid> Agents = new List <Guid>();
                foreach (GingerRunner GR in RSC.GingerRunners)
                {
                    foreach (ApplicationAgent AA in GR.ApplicationAgents)
                    {
                        if (AA.Agent == null)
                        {
                            continue;                  //no Agent so skip it
                        }
                        Guid agnetGuide = (from x in Agents where x == AA.Agent.Guid select x).FirstOrDefault();
                        if (agnetGuide == Guid.Empty)
                        {
                            Agents.Add(AA.Agent.Guid);
                        }
                        else
                        {
                            //create error
                            RunSetConfigAnalyzer AGR = CreateNewIssue(IssuesList, RSC);
                            AGR.ItemParent  = GR.Name;
                            AGR.Description = "Same Agent was configured on more than one Runner";
                            AGR.Details     = string.Format("The '{0}' Runner '{1}' Target Application is mapped to the '{2}' Agent which is already configured on another Runner", GR.Name, AA.AppName, AA.AgentName);
                            AGR.HowToFix    = "Map the Target Application to different Agent";
                            AGR.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                            AGR.IssueType   = eType.Error;
                            AGR.Impact      = "Execution will fail.";
                            AGR.Severity    = eSeverity.Critical;
                            AGR.Selected    = false;
                        }
                    }
                }
            }

            //check all configured mapped data still valid
            foreach (GingerRunner GR in RSC.GingerRunners)
            {
                foreach (BusinessFlow bf in GR.BusinessFlows)
                {
                    List <VariableBase> inputVars               = bf.GetBFandActivitiesVariabeles(true).ToList();
                    List <VariableBase> optionalVariables       = null;
                    List <VariableBase> optionalOutputVariables = null;
                    foreach (VariableBase inputVar in inputVars)
                    {
                        bool issueExist = false;
                        Guid mappedGuid = Guid.Empty;
                        switch (inputVar.MappedOutputType)
                        {
                        case VariableBase.eOutputType.Variable:
                            if (optionalVariables == null)
                            {
                                optionalVariables = GR.GetPossibleOutputVariables(RSC, bf, includeGlobalVars: true, includePrevRunnersVars: false);
                            }
                            issueExist = optionalVariables.Where(x => x.Name == inputVar.MappedOutputValue).FirstOrDefault() == null;
                            break;

                        case VariableBase.eOutputType.OutputVariable:
                            if (optionalOutputVariables == null)
                            {
                                optionalOutputVariables = GR.GetPossibleOutputVariables(RSC, bf, includeGlobalVars: false, includePrevRunnersVars: true);
                            }
                            Guid.TryParse(inputVar.MappedOutputValue, out mappedGuid);
                            issueExist = optionalOutputVariables.Where(x => x.Guid == mappedGuid).FirstOrDefault() == null;
                            break;

                        case VariableBase.eOutputType.GlobalVariable:
                            Guid.TryParse(inputVar.MappedOutputValue, out mappedGuid);
                            issueExist = WorkSpace.Instance.Solution.Variables.Where(x => x.Guid == mappedGuid).FirstOrDefault() == null;
                            break;

                        case VariableBase.eOutputType.ApplicationModelParameter:
                            Guid.TryParse(inputVar.MappedOutputValue, out mappedGuid);
                            issueExist = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <GlobalAppModelParameter>().Where(x => x.Guid == mappedGuid).FirstOrDefault() == null;
                            break;

                        case VariableBase.eOutputType.DataSource:
                            issueExist = string.IsNullOrEmpty(inputVar.MappedOutputValue);
                            break;
                        }

                        if (issueExist)
                        {
                            //create error
                            RunSetConfigAnalyzer AGR = CreateNewIssue(IssuesList, RSC);
                            AGR.ItemParent  = GR.Name;
                            AGR.Description = string.Format("Configured input {0} data mapping from type '{1}' is missing", GingerDicser.GetTermResValue(eTermResKey.Variable), inputVar.MappedOutputType);
                            AGR.Details     = string.Format("In '{0}' Runner, '{1}' {2}, the configured input {3} '{4}' data mapping from type '{5}' and value '{6}' is missing", GR.Name, bf.Name, GingerDicser.GetTermResValue(eTermResKey.BusinessFlow), GingerDicser.GetTermResValue(eTermResKey.Variable), inputVar.Name, inputVar.MappedOutputType, inputVar.MappedOutputValue);
                            AGR.HowToFix    = string.Format("Re-configure the missing input {0} data mapping", GingerDicser.GetTermResValue(eTermResKey.Variable));
                            AGR.CanAutoFix  = AnalyzerItemBase.eCanFix.No;
                            AGR.IssueType   = eType.Error;
                            AGR.Impact      = "Execution might fail due to wrong data mapping";
                            AGR.Severity    = eSeverity.High;
                            AGR.Selected    = false;
                        }
                    }
                }
            }

            return(IssuesList);
        }