Ejemplo n.º 1
0
        /// <summary>
        ///     获取座级趋势图的数据源集合
        /// </summary>
        /// <returns></returns>
        private void CreateFleetAircraftTypeTrendCollection()
        {
            var regionalCollection = new List<FleetAircraftRegionalTrend>();
            var amountCollection = new List<FleetAircraftRegionalTrend>();

            #region 座级机型XML文件的读写

            var xmlConfig =
                XmlConfigs.FirstOrDefault(p => p.ConfigType.Equals("座级机型", StringComparison.OrdinalIgnoreCase));

            XElement aircraftColor = null;
            var colorConfig =
                XmlSettings.FirstOrDefault(p => p.SettingType.Equals("颜色配置", StringComparison.OrdinalIgnoreCase));
            if (colorConfig != null &&
                XElement.Parse(colorConfig.SettingContent)
                    .Descendants("Type")
                    .Any(p => p.Attribute("TypeName").Value.Equals("运力变化", StringComparison.OrdinalIgnoreCase)))
            {
                aircraftColor =
                    XElement.Parse(colorConfig.SettingContent)
                        .Descendants("Type")
                        .FirstOrDefault(
                            p => p.Attribute("TypeName").Value.Equals("运力变化", StringComparison.OrdinalIgnoreCase));
            }

            if (aircraftColor != null)
            {
                var firstOrDefault =
                    aircraftColor.Descendants("Item")
                        .FirstOrDefault(p => p.Attribute("Name").Value.Equals("飞机数", StringComparison.OrdinalIgnoreCase));
                if (firstOrDefault != null)
                    AircraftColor = firstOrDefault.Attribute("Color").Value;
            }

            XElement regionalColor = null;
            if (colorConfig != null &&
                XElement.Parse(colorConfig.SettingContent)
                    .Descendants("Type")
                    .Any(p => p.Attribute("TypeName").Value.Equals("座级", StringComparison.OrdinalIgnoreCase)))
            {
                regionalColor =
                    XElement.Parse(colorConfig.SettingContent)
                        .Descendants("Type")
                        .FirstOrDefault(
                            p => p.Attribute("TypeName").Value.Equals("座级", StringComparison.OrdinalIgnoreCase));
            }
            if (xmlConfig != null)
            {
                var xelement = XElement.Parse(xmlConfig.ConfigContent);
                if (xelement != null)
                {
                    foreach (var dateTime in xelement.Descendants("DateTime"))
                    {
                        var currentTime =
                            Convert.ToDateTime(dateTime.Attribute("EndOfMonth").Value).ToString("yyyy/M");

                        //早于开始时间时执行下一个
                        if (Convert.ToDateTime(currentTime) < StartDate)
                        {
                            continue;
                        }
                        //晚于结束时间时跳出循环
                        if (Convert.ToDateTime(currentTime) > EndDate)
                        {
                            break;
                        }

                        if (SelectedIndex == 1) //按半年统计
                        {
                            if (Convert.ToDateTime(currentTime).Month != 6 &&
                                Convert.ToDateTime(currentTime).Month != 12)
                            {
                                continue;
                            }
                        }
                        else if (SelectedIndex == 2) //按年份统计
                        {
                            if (Convert.ToDateTime(currentTime).Month != 12)
                            {
                                continue;
                            }
                        }

                        foreach (var type in dateTime.Descendants("Type"))
                        {
                            if (type.Attribute("TypeName").Value.Equals("座级", StringComparison.OrdinalIgnoreCase))
                            {
                                var currentAmount = type.Attribute("Amount").Value;

                                //飞机总数柱状集合
                                var aircraftAmount = new FleetAircraftRegionalTrend
                                {
                                    DateTime = currentTime,
                                    Amount = Convert.ToInt32(currentAmount),
                                    Color = AircraftColor
                                };
                                amountCollection.Add(aircraftAmount);

                                foreach (var item in type.Descendants("Item"))
                                {
                                    //座级折线集合
                                    var fleetAircraftRegionalTrend = new FleetAircraftRegionalTrend
                                    {
                                        AircraftRegional = item.Attribute("Name").Value,
                                        DateTime = currentTime,
                                        AirNum = Convert.ToInt32(item.Value),
                                        Amount = Convert.ToInt32(currentAmount)
                                    };
                                    if (regionalColor != null)
                                    {
                                        var firstOrDefault =
                                            regionalColor.Descendants("Item")
                                                .FirstOrDefault(
                                                    p =>
                                                        p.Attribute("Name")
                                                            .Value.Equals(fleetAircraftRegionalTrend.AircraftRegional,
                                                                StringComparison.OrdinalIgnoreCase));
                                        if (firstOrDefault != null)
                                            fleetAircraftRegionalTrend.Color = firstOrDefault.Attribute("Color").Value;
                                    }
                                    regionalCollection.Add(fleetAircraftRegionalTrend);
                                }
                            }
                        }
                    }
                }
            }

            #endregion

            FleetAircraftTypeTrendCollection = regionalCollection;
            AircraftAmountCollection = amountCollection;

            //对界面数据集合进行重新初始化
            SelectedTime = "所选时间";
            FleetAircraftRegionalCollection = null;
            FleetAircraftTypeCollection = null;
            AircraftCollection = null;
            ZoomInit();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取座级趋势图的数据源集合
        /// </summary>
        /// <returns></returns>
        private void CreateFleetAircraftTypeTrendCollection()
        {
            List<FleetAircraftRegionalTrend> RegionalCollection = new List<FleetAircraftRegionalTrend>();
            List<FleetAircraftRegionalTrend> AmountCollection = new List<FleetAircraftRegionalTrend>();

            #region 座级机型XML文件的读写
            var xmlconfig = this.ViewXmlConfig.FirstOrDefault(p => p.ConfigType == "座级机型");

            XElement aircraftcolor = null;
            XmlConfig colorconfig = this.ViewXmlConfig.FirstOrDefault(p => p.ConfigType == "颜色配置");
            if (colorconfig != null && colorconfig.XmlContent.Descendants("Type").Any(p => p.Attribute("TypeName").Value == "运力变化"))
            {
                aircraftcolor = colorconfig.XmlContent.Descendants("Type").FirstOrDefault(p => p.Attribute("TypeName").Value == "运力变化");
            }

            if (aircraftcolor != null)
            {
                this.AircraftColor = aircraftcolor.Descendants("Item").FirstOrDefault(p => p.Attribute("Name").Value == "飞机数").Attribute("Color").Value;
            }
            else
            {
                this.AircraftColor = commonmethod.GetRandomColor();
            }

            XElement regionalcolor = null;
            if (colorconfig != null && colorconfig.XmlContent.Descendants("Type").Any(p => p.Attribute("TypeName").Value == "座级"))
            {
                regionalcolor = colorconfig.XmlContent.Descendants("Type").FirstOrDefault(p => p.Attribute("TypeName").Value == "座级");
            }

            if (xmlconfig != null)
            {
                XElement xelement = xmlconfig.XmlContent;
                if (xelement != null)
                {
                    foreach (XElement datetime in xelement.Descendants("DateTime"))
                    {
                        string CurrentTime = Convert.ToDateTime(datetime.Attribute("EndOfMonth").Value).ToString("yyyy/M");

                        //早于开始时间时执行下一个
                        if (Convert.ToDateTime(CurrentTime) < StartDate)
                        {
                            continue;
                        }
                        //晚于结束时间时跳出循环
                        if (Convert.ToDateTime(CurrentTime) > EndDate)
                        {
                            break;
                        }

                        if (SelectedIndex == 1)//按半年统计
                        {
                            if (Convert.ToDateTime(CurrentTime).Month != 6 && Convert.ToDateTime(CurrentTime).Month != 12)
                            {
                                continue;
                            }
                        }
                        else if (SelectedIndex == 2)//按年份统计
                        {
                            if (Convert.ToDateTime(CurrentTime).Month != 12)
                            {
                                continue;
                            }
                        }

                        foreach (XElement type in datetime.Descendants("Type"))
                        {
                            if (type.Attribute("TypeName").Value == "座级")
                            {
                                string CurrentAmount = type.Attribute("Amount").Value;

                                //飞机总数柱状集合
                                FleetAircraftRegionalTrend aircraftamount = new FleetAircraftRegionalTrend();
                                aircraftamount.DateTime = CurrentTime;
                                aircraftamount.Amount = Convert.ToInt32(CurrentAmount);
                                aircraftamount.Color = this.AircraftColor;
                                AmountCollection.Add(aircraftamount);

                                foreach (XElement item in type.Descendants("Item"))
                                {
                                    //座级折线集合
                                    FleetAircraftRegionalTrend fleetaircraftregionaltrend = new FleetAircraftRegionalTrend();
                                    fleetaircraftregionaltrend.AircraftRegional = item.Attribute("Name").Value;
                                    fleetaircraftregionaltrend.DateTime = CurrentTime;
                                    fleetaircraftregionaltrend.AirNum = Convert.ToInt32(item.Value);
                                    fleetaircraftregionaltrend.Amount = Convert.ToInt32(CurrentAmount);
                                    if (regionalcolor != null)
                                    {
                                        fleetaircraftregionaltrend.Color = regionalcolor.Descendants("Item")
                                            .FirstOrDefault(p => p.Attribute("Name").Value == fleetaircraftregionaltrend.AircraftRegional).Attribute("Color").Value;
                                    }
                                    RegionalCollection.Add(fleetaircraftregionaltrend);
                                }
                            }
                        }
                    }
                }
            }
            #endregion

            SelectedTime = "所选时间";
            FleetAircraftRegionalCollection = null;
            FleetAircraftTypeCollection = null;
            AircraftCollection = null;
            this.Zoom = new Size(1, 1);

            if (RegionalCollection.Count() > 0 && AmountCollection.Count() > 0)
            {
                FleetAircraftTypeTrendCollection = RegionalCollection;
                AircraftAmountCollection = AmountCollection;
            }
        }