Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reqInfoData"></param>
        /// <param name="levelManager"></param>
        /// <returns></returns>
        internal List <QuestionInformationTabData> CreateRequirementInformationTab(RequirementInfoData reqInfoData, IStandardSpecficLevelRepository levelManager)
        {
            List <QuestionInformationTabData> tempTabDataList = new List <QuestionInformationTabData>();
            QuestionInformationTabData        tab             = new QuestionInformationTabData();

            tab.BuildRequirementInfoTab(reqInfoData, levelManager, DataContext);
            tempTabDataList.Add(tab);
            return(tempTabDataList);
        }
        public void BuildRequirementInfoTab(RequirementInfoData requirementData, IStandardSpecficLevelRepository levelManager, CSET_Context controlContext)
        {
            ShowRequirementFrameworkTitle = true;

            NEW_REQUIREMENT requirement = requirementData.Requirement;

            Question_or_Requirement_Id = requirement.Requirement_Id;

            this.SetsList = new List <string>(requirementData.Sets.Select(s => s.Value.Short_Name));

            // Get related questions
            var query = from rq in controlContext.REQUIREMENT_QUESTIONS
                        join q in controlContext.NEW_QUESTION on rq.Question_Id equals q.Question_Id
                        where rq.Requirement_Id == requirementData.RequirementID
                        select new RelatedQuestion
            {
                QuestionID   = q.Question_Id,
                QuestionText = q.Simple_Question
            };

            this.QuestionsList = query.ToList();


            RequirementTabData tabData = new RequirementTabData();

            tabData.RequirementID    = requirement.Requirement_Id;
            tabData.Text             = FormatRequirementText(requirement.Requirement_Text);
            tabData.SupplementalInfo = FormatSupplementalInfo(requirement.Supplemental_Info);
            tabData.Set_Name         = requirementData.SetName;

            RequirementsData = tabData;
            int requirement_id = requirement.Requirement_Id;
            // var questions = requirement.NEW_QUESTION;
            SETS set;

            if (!requirementData.Sets.TryGetValue(requirementData.SetName, out set))
            {
                set = controlContext.SETS.Where(x => x.Set_Name == requirementData.SetName).FirstOrDefault();
            }
            String shortStandardName = set.Short_Name;

            HeaderName = shortStandardName;
            if (!IsComponent)
            {
                RequirementFrameworkTitle = requirement.Requirement_Title;
            }

            RelatedFrameworkCategory = requirement.Standard_Sub_Category;

            if (requirementData.SetName == StandardManager.CNSSI_1253_DB || requirementData.SetName == StandardManager.CNSSI_ICS_PIT_DB ||
                requirementData.SetName == StandardManager.CNSSI_ICS_V1_DB || requirementData.SetName == StandardManager.CNSSI_1253_V2_DB)
            {
                var levels = requirement.REQUIREMENT_LEVELS.Select(x => new
                {
                    FullName   = levelManager.GetFullName(levelManager.GetStandard(x.Standard_Level), levelManager.GetLevelOrder(x.Standard_Level)),
                    LevelOrder = levelManager.GetLevelOrder(x.Standard_Level),
                    LevelType  = x.Level_Type
                }).ToList();

                Tuple <int, string> availableLevel   = Tuple.Create(-1, "None");
                Tuple <int, string> confidenceLevel  = Tuple.Create(-1, "None");
                Tuple <int, string> integretityLevel = Tuple.Create(-1, "None");

                foreach (var item in levels)
                {
                    if (item.LevelType == "A")
                    {
                        if (availableLevel.Item1 == -1)
                        {
                            availableLevel = Tuple.Create(item.LevelOrder, item.FullName);
                        }
                        else
                        {
                            if (availableLevel.Item1 > item.LevelOrder)
                            {
                                availableLevel = Tuple.Create(item.LevelOrder, item.FullName);
                            }
                        }
                    }
                    else if (item.LevelType == "C")
                    {
                        if (confidenceLevel.Item1 == -1)
                        {
                            confidenceLevel = Tuple.Create(item.LevelOrder, item.FullName);
                        }
                        else
                        {
                            if (confidenceLevel.Item1 > item.LevelOrder)
                            {
                                confidenceLevel = Tuple.Create(item.LevelOrder, item.FullName);
                            }
                        }
                    }
                    else if (item.LevelType == "I")
                    {
                        if (integretityLevel.Item1 == -1)
                        {
                            integretityLevel = Tuple.Create(item.LevelOrder, item.FullName);
                        }
                        else
                        {
                            if (integretityLevel.Item1 > item.LevelOrder)
                            {
                                integretityLevel = Tuple.Create(item.LevelOrder, item.FullName);
                            }
                        }
                    }
                }

                this.LevelName = "Availability: " + availableLevel.Item2 + "\n" +
                                 "Confidentiality: " + confidenceLevel.Item2 + "\n" +
                                 "Integrity:" + integretityLevel.Item2;
            }
            else
            {
                var parameters = requirementData.Requirement.REQUIREMENT_LEVELS.Select(s => new Tuple <string, int>(levelManager.GetStandard(s.Standard_Level), levelManager.GetLevelOrder(s.Standard_Level))).OrderBy(s => s.Item2).FirstOrDefault();
                if (parameters != null)
                {
                    this.LevelName = levelManager.GetFullName(parameters.Item1, parameters.Item2);
                }
            }


            QuestionsVisible         = true;
            ShowRequirementStandards = true;
            ShowSALLevel             = true;
            BuildDocuments(requirementData.RequirementID, controlContext);
        }