private void cleanoutStructure() { //clean out current structure and then add the new structure. midNodes = new Dictionary <String, ScoringNode>(); leafNodes = new Dictionary <int, LeafNode>(); topNode = null; }
public TopLevelScoreNode GetPartialScores(int assessment_id) { TopLevelScoreNode t = staticAddMilTerms(); SetAnswers(assessment_id); return(getPartialScore()); }
/// <summary> /// This is a recipe for disaster. These two data structures are a little too shared. /// </summary> /// <returns></returns> private TopLevelScoreNode staticAddMilTerms() { cleanoutStructure(); TopLevelScoreNode t = staticLoadTreeMidStructure(); localLoadStructure(t); return(t); }
public void LoadDataStructure() { this.topNode = staticLoadTree(); //get the top level nodes //then add in all the children using (CSET_Context db = new CSET_Context()) { var result = from a in db.MATURITY_QUESTIONS join b in db.MATURITY_GROUPINGS on a.Grouping_Id equals b.Grouping_Id where a.Maturity_Model_Id == 3 select new { a, b }; Dictionary <int, string> questionIDtoTitle = new Dictionary <int, string>(); foreach (var q in result.ToList()) { questionIDtoTitle.Add(q.a.Mat_Question_Id, q.a.Question_Title); ScoringNode t = midNodes[q.b.Title_Id]; if (q.a.Parent_Question_Id == null) { LeafNode l = processLeafNode(q.a.Mat_Question_Id, q.a.Question_Title, t); t.Children.Add(l); } else { //remove the parent question from leaves dictionary //remove the parent question from it's parent's child collection //add it to the children of t as new mid node //then add all the children to this new mid node //note that at this poing Parent_Question_Id should never be null ScoringNode outNode; string parentTitle = questionIDtoTitle[q.a.Parent_Question_Id ?? 0]; if (midNodes.TryGetValue(parentTitle, out outNode)) { LeafNode l = processLeafNode(q.a.Mat_Question_Id, q.a.Question_Title, outNode); outNode.Children.Add(l); } else { LeafNode parentLeaf = leafNodes[q.a.Parent_Question_Id ?? 0]; parentLeaf.Parent.Children.Remove(parentLeaf); leafNodes.Remove(q.a.Parent_Question_Id ?? 0); MidlevelScoreNode node = new MidlevelScoreNode() { Title_Id = parentTitle, Grouping_Id = q.a.Grouping_Id ?? 0, Description = "Parent of " + q.a.Question_Title }; midNodes.Add(parentTitle, node); LeafNode l = processLeafNode(q.a.Mat_Question_Id, q.a.Question_Title, node); node.Children.Add(l); t.Children.Add(node); } } } } }
private TopLevelScoreNode staticLoadTree() { TopLevelScoreNode mil1 = new TopLevelScoreNode() { Title_Id = "MIL1", Description = "MIL1 - Performed" }; midNodes.Add(mil1.Title_Id, mil1); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "RF:G1", Description = "Goal 1 - Acquirer service and asset priorities are established." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "RF:G2", Description = "Goal 2 - Forming relationships with external entities is planned." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "RF:G3", Description = "Goal 3 – Risk management includes external dependencies." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "RF:G4", Description = "Goal 4 - External entities are evaluated." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "RF:G5", Description = "Goal 5 – Formal agreements include resilience requirements." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "RF:G6", Description = "Goal 6 –Technology asset supply chain risks are managed." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G1", Description = "Goal 1 - External dependencies are identified and prioritized." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G2", Description = "Goal 2 - Supplier risk management is continuous." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G3", Description = "Goal 3 – Supplier performance is governed and managed." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G4", Description = "Goal 4 – Change and capacity management are applied to external dependencies." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G5", Description = "Goal 5 – Supplier transitions are managed." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G6", Description = "Goal 6 – Infrastructure and governmental dependencies are managed." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G7", Description = "Goal 7 – External entity access to acquirer assets is managed." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "SPS:G1", Description = "Goal 1 - Disruption planning includes external dependencies." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "SPS:G2", Description = "Goal 2 - Planning and controls are maintained and updated." }); mil1.Children.Add(new MidlevelScoreNode() { Title_Id = "SPS:G3", Description = "Goal 3 – Situational awareness extends to external dependencies." }); foreach (ScoringNode s in mil1.Children) { midNodes.Add(s.Title_Id, s); } TopLevelScoreNode mIL2 = new TopLevelScoreNode() { Title_Id = "MIL2", Description = "MIL2 - Planned" }; mIL2.TopLevelChild = mil1; midNodes.Add(mIL2.Title_Id, mIL2); TopLevelScoreNode mIL3 = new TopLevelScoreNode() { Title_Id = "MIL3", Description = "MIL3 - Managed" }; mIL3.TopLevelChild = mIL2; midNodes.Add(mIL3.Title_Id, mIL3); TopLevelScoreNode mIL4 = new TopLevelScoreNode() { Title_Id = "MIL4", Description = "MIL4 - Measured" }; mIL4.TopLevelChild = mIL3; midNodes.Add(mIL4.Title_Id, mIL4); TopLevelScoreNode mIL5 = new TopLevelScoreNode() { Title_Id = "MIL5", Description = "MIL5 - Defined" }; mIL5.TopLevelChild = mIL4; midNodes.Add(mIL5.Title_Id, mIL5); return(mIL5); }