public IFlightTreeNode FindNodeByFlight(Flight flight)
        {
            if (flight != null && !string.IsNullOrEmpty(flight.FlightID)
                && this.m_nodes != null && this.m_nodes.Count > 0)
            {
                foreach (IFlightTreeNode nd in this.m_nodes)
                {
                    if (nd.Children != null && nd.Children.Count > 0)
                    {
                        foreach (var child in nd.Children)
                        {
                            if (child is FlightViewNode)
                            {
                                FlightViewNode fnode = child as FlightViewNode;
                                if (fnode.Flight != null && fnode.Flight.FlightID == flight.FlightID)
                                    return fnode;
                            }
                        }
                    }
                }
            }

            return null;
        }
 public FlightViewNode(Flight flight)
 {
     m_flight = flight;
 }
        /// <summary>
        /// 根据架次、参数ID列表、起始和结束秒,获取数据
        /// 数据返回轻量级DataTable,行是秒值,列是参数值,可以直接绑定到RadGridView
        /// 在此不作分页,因为起始秒和结束秒就可以起到分页的作用
        /// </summary>
        /// <param name="flight"></param>
        /// <param name="parameterIds"></param>
        /// <param name="startSecond"></param>
        /// <param name="endSecond"></param>
        /// <returns></returns>
        public static FlightDataEntitiesRT.DataTable GetDataTable(Flight flight,
            string[] parameterIds, int startSecond, int endSecond)
        {
            ObservableCollection<string> collection = null;
            if (parameterIds != null && parameterIds.Length > 0)
                collection = new ObservableCollection<string>(parameterIds);
            AircraftService.AircraftServiceClient client = GetClient();

            var task = client.GetFlightDataAsync(RTConverter.ToAircraftService(flight),
                collection, startSecond, endSecond);
            task.Wait();
            client.CloseAsync();
            ObservableCollection<KeyValuePair<string, ObservableCollection<
                AircraftService.FlightRawData>>>
                result = task.Result;

            DataTable dt = BuildDataTable(result);

            return dt;
        }
        /// <summary>
        /// 取得一个架次的所有判定成功记录
        /// </summary>
        /// <param name="flight"></param>
        /// <returns></returns>
        public static FlightDataEntitiesRT.Decisions.DecisionRecord[] GetDecisionRecords(Flight flight)
        {
            AircraftService.AircraftServiceClient client = GetClient();
            var task = client.GetDecisionRecordsAsync(RTConverter.ToAircraftService(flight));
            task.Wait();

            client.CloseAsync();
            var decisionRecords = from one in task.Result
                                  select RTConverter.FromAircraftService(one);

            return decisionRecords.ToArray();
        }
            GetExtremumPointInfos(Flight flight)
        {
            AircraftService.AircraftServiceClient client = GetClient();
            var task = client.GetExtremumReportDefinitionAsync(flight.Aircraft.AircraftModel.ModelName);
            var levelTopRecs = GetLevelTopFlightRecords(flight, null);

            task.Wait();
            client.CloseAsync();

            var definition = task.Result;
            var parames = from def in definition.Items
                          orderby def.Number ascending
                          select def.ParameterID;

            Dictionary<string, int> dic = new Dictionary<string, int>();
            foreach (var v in definition.Items)
            {
                dic.Add(v.ParameterID, v.Number);
            }

            List<ExtremumPointInfo> infs = new List<ExtremumPointInfo>();
            foreach (var r in levelTopRecs)
            {
                if (parames.Contains(r.ExtremumPointInfo.ParameterID))
                {
                    r.ExtremumPointInfo.Number = dic[r.ExtremumPointInfo.ParameterID];
                    infs.Add(r.ExtremumPointInfo);
                }
            }

            var result = from one in infs
                         orderby one.Number ascending
                         select one;

            return result.ToArray();
        }
        public static FlightDataEntitiesRT.LevelTopFlightRecord[] GetLevelTopFlightRecords(Flight flight, string[] parameterIDs)
        {
            AircraftService.AircraftServiceClient client = GetClient();
            var taskInfos = client.GetLevelTopFlightRecordsAsync(RTConverter.ToAircraftService(flight),
                (parameterIDs == null || parameterIDs.Length == 0) ? new ObservableCollection<string>() :
                new ObservableCollection<string>(parameterIDs));
            taskInfos.Wait();
            client.CloseAsync();
            var result = from one in taskInfos.Result
                         select RTConverter.FromAircraftService(one);

            return result.ToArray();
        }
        /// <summary>
        /// 添加或更新一个架次
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnAddAircraftClicked(object sender, RoutedEventArgs e)
        {//TODO:
            var aircraftModel = ServerHelper.GetCurrentAircraftModel();

            Flight flight = new Flight()
            {
                Aircraft = new AircraftInstance()
                {
                    AircraftModel = aircraftModel,
                    AircraftNumber = "0004",
                    LastUsed = DateTime.Now
                },
                FlightID = "04110325",
                FlightName = "04110325.phy",
                StartSecond = 0,
                EndSecond = 2236,
            };
            flight = Services.DataInputHelper.AddOrReplaceFlight(flight);
        }