当前位置: 首页>>代码示例>>C#>>正文


C# TypeNode.AddChildNode方法代码示例

本文整理汇总了C#中TypeNode.AddChildNode方法的典型用法代码示例。如果您正苦于以下问题:C# TypeNode.AddChildNode方法的具体用法?C# TypeNode.AddChildNode怎么用?C# TypeNode.AddChildNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeNode的用法示例。


在下文中一共展示了TypeNode.AddChildNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateXmlContentNew

        protected void GenerateXmlContentNew(XElement RootNode)
        {
            RootNode.RemoveAll();
            //所有飞机运行历史
            var AllOperationHistory = this.GetAllAircraftOperationHistory().OrderBy(p => p.StartDate).ToList();
            //获取所有飞机
            var AllAircrafts = GetAllAircraft().ToList();
            DateTime startTime = GetOperationStartDate();
            DateTime endTime = GetOperationEndDate();

            //所有座级
            IEnumerable<string> AircraftRegionalList = this.GetAllAircraftRegionalList();
            //所有机型
            IEnumerable<string> AircraftTypeList = this.GetAllAircraftTypeList();

            DateNodeList dnlXml = new DateNodeList(startTime, endTime);

            for (DateTime time = startTime; time <= endTime; time = GetMonthEndofDateTime(time.AddMonths(1)))
            {
                DateNode dtNode = new DateNode();
                dtNode.Name = FormatDate(time);
                dtNode.Time = time;
                dnlXml.AddNode(dtNode);

                //座级
                RegionalNode rnNode = new RegionalNode();
                rnNode.Name = "座级";
                rnNode.Amount = 0;
                dtNode.AddChildNode(rnNode);
                // 所有座级
                foreach (var name in AircraftRegionalList)
                {
                    LeafNode lfNode = new LeafNode();
                    lfNode.Name = name;
                    lfNode.Amount = 0;
                    lfNode.Percent = 0;
                    rnNode.AddChildNode(lfNode);
                }
                //机型
                TypeNode tpNode = new TypeNode();
                tpNode.Name = "机型";
                tpNode.Amount = 0;
                dtNode.AddChildNode(tpNode);

                // 所有机型
                foreach (var name in AircraftTypeList)
                {
                    LeafNode lfNode = new LeafNode();
                    lfNode.Name = name;
                    lfNode.Amount = 0;
                    lfNode.Percent = 0;
                    tpNode.AddChildNode(lfNode);
                }

            }

            foreach (var OperationHistory in AllOperationHistory)
            {
                DateTime dtStart = OperationHistory.StartDate == null ? DateTime.Now : (DateTime)OperationHistory.StartDate;
                DateTime dtEnd = OperationHistory.EndDate == null ? DateTime.Now : (DateTime)OperationHistory.EndDate;
                DateNode dtNode;
                int intBeginIndex, intEndIndex;
                dnlXml.GetDataNodeRange(dtStart, dtEnd, out intBeginIndex, out intEndIndex);
                var aircraft = AllAircrafts.FirstOrDefault(p => p.Id == OperationHistory.AircraftId);
                if (aircraft != null && aircraft.AircraftType != null && aircraft.AircraftType.AircraftCategory != null)
                {
                    string RegionalName = aircraft.AircraftType.AircraftCategory.Regional;
                    string TypeName = aircraft.AircraftType.Name;

                    for (int i = intBeginIndex; i <= intEndIndex; i++)
                    {
                        dtNode = dnlXml.GetItem(i);
                        if (dtNode != null)
                        {
                            List<BaseNode> childNodes;
                            childNodes = dtNode.ChildNodes[0].ChildNodes;

                            int intCount = childNodes.Count();
                            for (int j = 0; j < intCount; j++)
                            {
                                LeafNode lfNode = (LeafNode)childNodes[j];
                                if (lfNode.Name == RegionalName)
                                {
                                    lfNode.Amount += 1;
                                    dtNode.ChildNodes[0].Amount += 1;
                                    break;
                                }
                            }

                            childNodes = dtNode.ChildNodes[1].ChildNodes;
                            intCount = childNodes.Count();
                            for (int j = 0; j < intCount; j++)
                            {
                                LeafNode lfNode = (LeafNode)childNodes[j];
                                if (lfNode.Name == TypeName)
                                {
                                    lfNode.Amount += 1;
                                    dtNode.ChildNodes[1].Amount += 1;
                                    break;
                                }
//.........这里部分代码省略.........
开发者ID:unicloud,项目名称:FRP,代码行数:101,代码来源:AirCraftTypeXml.cs


注:本文中的TypeNode.AddChildNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。