Пример #1
0
        public string BuildXMLRepresentationRecurse(SimulationMsg cdlMsg, bool bDebug)
        {
            if (bDebug)
            {
                cdlMsg.SendMessage(string.Format("Calculate Loss TermNode: intId={0}, begin {1}", this.m_intId, this.CalcState));
            }

            //aggregate losses from children
            for (int cIdx = 0; cIdx < this.m_vChildNode.Count; ++cIdx)
            {
                TermNode child = (TermNode)this.m_vChildNode[cIdx];
                tree_xml += "\n<child" + " id = \"" + child.IntId.ToString() + "\">\n" + child.BuildXMLRepresentationRecurse(cdlMsg, bDebug) + "\n</child>\n";

                if (bDebug)
                {
                    cdlMsg.SendMessage(string.Format("For TermNode: intId={0} initial {1}, Adding Child TermNode: intId={2}, {3}",
                                                     this.m_intId, this.m_calcState, child.IntId, child.CalcState));
                }
            }

            _Schedule sar = this.m_subject.Schedule;

            if (sar.SetSchedule.Count > 0)
            {
                string leaf = "";
                foreach (RiskItem riskItem in sar.SetSchedule)
                {
                    if (riskItem is LocationCvg)
                    {
                        string newLeaf = riskItem.IntId.ToString().PadLeft(2, '0');
                        for (int n1 = 0; n1 < tree_xml.Length / 2; n1++)
                        {
                            if (newLeaf.Equals(tree_xml.Substring(n1 * 2, 2))) //no need to add twice
                            {
                                newLeaf = "";
                            }
                        }

                        leaf += newLeaf;
                    }
                }

                if (leaf.Length > 0)
                {
                    tree_xml += leaf;
                }
            }

            return(tree_xml);
        }