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 staticLoadTreeMidStructure() { TopLevelScoreNode mil1 = new TopLevelScoreNode() { Title_Id = "MIL1", Description = "MIL1 - Performed" }; midNodes.Add(mil1.Title_Id, mil1); MidlevelScoreNode rf = new MidlevelScoreNode() { Title_Id = "RF", Description = "Relationship Formation" }; mil1.Children.Add(rf); rf.Children.Add(new MidlevelScoreNode() { Title_Id = "RF:G1", Description = "Goal 1 - Acquirer service and asset priorities are established." }); rf.Children.Add(new MidlevelScoreNode() { Title_Id = "RF:G2", Description = "Goal 2 - Forming relationships with external entities is planned." }); rf.Children.Add(new MidlevelScoreNode() { Title_Id = "RF:G3", Description = "Goal 3 – Risk management includes external dependencies." }); rf.Children.Add(new MidlevelScoreNode() { Title_Id = "RF:G4", Description = "Goal 4 - External entities are evaluated." }); rf.Children.Add(new MidlevelScoreNode() { Title_Id = "RF:G5", Description = "Goal 5 – Formal agreements include resilience requirements." }); rf.Children.Add(new MidlevelScoreNode() { Title_Id = "RF:G6", Description = "Goal 6 –Technology asset supply chain risks are managed." }); MidlevelScoreNode rmg = new MidlevelScoreNode() { Title_Id = "RMG", Description = "Relationship Management and Governance" }; mil1.Children.Add(rmg); rmg.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G1", Description = "Goal 1 - External dependencies are identified and prioritized." }); rmg.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G2", Description = "Goal 2 - Supplier risk management is continuous." }); rmg.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G3", Description = "Goal 3 – Supplier performance is governed and managed." }); rmg.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G4", Description = "Goal 4 – Change and capacity management are applied to external dependencies." }); rmg.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G5", Description = "Goal 5 – Supplier transitions are managed." }); rmg.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G6", Description = "Goal 6 – Infrastructure and governmental dependencies are managed." }); rmg.Children.Add(new MidlevelScoreNode() { Title_Id = "RMG:G7", Description = "Goal 7 – External entity access to acquirer assets is managed." }); MidlevelScoreNode sps = new MidlevelScoreNode() { Title_Id = "SPS", Description = "Service Protection and Sustainment" }; mil1.Children.Add(sps); sps.Children.Add(new MidlevelScoreNode() { Title_Id = "SPS:G1", Description = "Goal 1 - Disruption planning includes external dependencies." }); sps.Children.Add(new MidlevelScoreNode() { Title_Id = "SPS:G2", Description = "Goal 2 - Planning and controls are maintained and updated." }); sps.Children.Add(new MidlevelScoreNode() { Title_Id = "SPS:G3", Description = "Goal 3 – Situational awareness extends to external dependencies." }); addChildrenToList(mil1, midNodes); 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); }