Example #1
0
 public int IndexOf(DateNode xmlNode)
 {
     return _DateNodes.IndexOf(xmlNode);
 }
Example #2
0
        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;
                                }
                            }
                        }
                    }
                }
            }
            NodeToXmlContent(dnlXml, RootNode);
        }
Example #3
0
 public void AddNode(DateNode xmlNode)
 {
     _DateNodes.Add(xmlNode);
 }