Ejemplo n.º 1
0
        /// <summary>
        /// Pull any 'global' parameters for the requirement, overlaid with any 'local' parameters for the answer.
        /// </summary>
        /// <param name="reqId"></param>
        /// <param name="ansId"></param>
        /// <returns></returns>
        private List <ParameterToken> GetTokensForRequirement(int reqId, int ansId)
        {
            ParameterSubstitution ps = new ParameterSubstitution();

            using (var db = new CSET_Context())
            {
                // get the 'base' parameter values (parameter_name) for the requirement
                var qBaseLevel = from p in db.PARAMETERS
                                 join r in db.PARAMETER_REQUIREMENTS on p.Parameter_ID equals r.Parameter_Id
                                 where r.Requirement_Id == reqId
                                 select new { p, r };

                foreach (var b in qBaseLevel)
                {
                    ps.Set(b.p.Parameter_ID, b.p.Parameter_Name, b.p.Parameter_Name, reqId, 0);
                }

                // overlay with any assessment-specific parameters for the requirement
                var qAssessLevel = from pa in db.PARAMETER_ASSESSMENT
                                   join p in db.PARAMETERS on pa.Parameter_ID equals p.Parameter_ID
                                   where pa.Assessment_ID == _assessmentId
                                   select new { p, pa };

                foreach (var a in qAssessLevel)
                {
                    ps.Set(a.p.Parameter_ID, a.p.Parameter_Name, a.pa.Parameter_Value_Assessment, reqId, 0);
                }

                // overlay with any 'inline' values for the answer
                if (ansId != 0)
                {
                    var qLocal = from p in db.PARAMETERS
                                 join pv in db.PARAMETER_VALUES on p.Parameter_ID equals pv.Parameter_Id
                                 where pv.Answer_Id == ansId
                                 select new { p, pv };

                    foreach (var local in qLocal.ToList())
                    {
                        ps.Set(local.p.Parameter_ID, local.p.Parameter_Name, local.pv.Parameter_Value, 0, local.pv.Answer_Id);
                    }
                }


                ps.Tokens = ps.Tokens.OrderByDescending(x => x.Token.Length).ToList();

                return(ps.Tokens);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Pull any 'global' parameters for the requirement, overlaid with any 'local' parameters for the answer.
        /// </summary>
        /// <param name="reqId"></param>
        /// <param name="ansId"></param>
        /// <returns></returns>
        private List <ParameterToken> GetTokensForRequirement(int reqId, int ansId)
        {
            ParameterSubstitution ps = new ParameterSubstitution();

            using (var db = new CSET_Context())
            {
                // get the 'base' parameter values (parameter_name) for the requirement
                if (parametersDictionary == null)
                {
                    LoadParametersList(db);
                }
                List <PARAMETERS> qBaseLevel;
                if (parametersDictionary.TryGetValue(reqId, out qBaseLevel))
                {
                    foreach (var b in qBaseLevel)
                    {
                        ps.Set(b.Parameter_ID, b.Parameter_Name, b.Parameter_Name, reqId, 0);
                    }
                }

                // overlay with any assessment-specific parameters for the requirement
                var qAssessLevel = parametersAssessmentList;

                foreach (var a in qAssessLevel)
                {
                    ps.Set(a.p.Parameter_ID, a.p.Parameter_Name, a.pa.Parameter_Value_Assessment, reqId, 0);
                }

                // overlay with any 'inline' values for the answer
                if (ansId != 0)
                {
                    List <ParameterValues> qLocal;
                    if (parametersAnswerDictionary.TryGetValue(ansId, out qLocal))
                    {
                        foreach (var local in qLocal.ToList())
                        {
                            ps.Set(local.p.Parameter_ID, local.p.Parameter_Name, local.pv.Parameter_Value, 0, local.pv.Answer_Id);
                        }
                    }
                }


                ps.Tokens = ps.Tokens.OrderByDescending(x => x.Token.Length).ToList();

                return(ps.Tokens);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <ParameterToken> GetDefaultParametersForAssessment()
        {
            ParameterSubstitution ps = new ParameterSubstitution();

            using (var db = new CSET_Context())
            {
                // Get the list of requirement IDs
                List <RequirementPlus> reqs           = GetControls(db).Requirements.ToList();
                List <int>             requirementIds = reqs.Select(r => r.Requirement.Requirement_Id).ToList();


                // get the 'base' parameter values (parameter_name) for the requirement
                var qBaseLevel = from p in db.PARAMETERS
                                 join r in db.PARAMETER_REQUIREMENTS on p.Parameter_ID equals r.Parameter_Id
                                 where requirementIds.Contains(r.Requirement_Id)
                                 select new { p, r };

                foreach (var b in qBaseLevel)
                {
                    ps.Set(b.p.Parameter_ID, b.p.Parameter_Name, b.p.Parameter_Name, b.r.Requirement_Id, 0);
                }

                // overlay with any assessment-specific parameters for the requirement
                var qAssessLevel = from pa in db.PARAMETER_ASSESSMENT
                                   join p in db.PARAMETERS on pa.Parameter_ID equals p.Parameter_ID
                                   join pr in db.PARAMETER_REQUIREMENTS on p.Parameter_ID equals pr.Parameter_Id
                                   where pa.Assessment_ID == _assessmentId &&
                                   requirementIds.Contains(pr.Requirement_Id)
                                   select new { p, pa, pr };

                foreach (var a in qAssessLevel)
                {
                    ps.Set(a.p.Parameter_ID, a.p.Parameter_Name, a.pa.Parameter_Value_Assessment, a.pr.Requirement_Id, 0);
                }
            }

            return(ps.Tokens);
        }