コード例 #1
0
ファイル: ManageSystemConfigVm.cs プロジェクト: unicloud/FRP
        /// <summary>
        ///     初始化ViewModel
        ///     <remarks>
        ///         统一在此处创建并注册CollectionView集合。
        ///     </remarks>
        /// </summary>
        private void InitializeVm()
        {
            // 创建并注册CollectionView
            AircraftCabinTypes = _service.CreateCollection(_context.AircraftCabinTypes);
            AircraftCabinTypes.PageSize = 18;
            _service.RegisterCollectionView(AircraftCabinTypes);
            AircraftCabinTypes.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName.Equals("HasChanges", StringComparison.OrdinalIgnoreCase))
                {
                    CanSelectAircraftCabinType = !AircraftCabinTypes.HasChanges;
                }
            };

            XmlSettings = _service.CreateCollection(_context.XmlSettings);
            XmlSettings.LoadedData += (o, e) =>
            {
                _airlines.Clear();
                _regionals.Clear();
                _aircraftTypes.Clear();
                _importTypes.Clear();
                _aircraftAges.Clear();
                _aircrafTrends.Clear();
                XmlSetting =
                    XmlSettings.FirstOrDefault(p => p.SettingType.Equals("颜色配置", StringComparison.OrdinalIgnoreCase));
                if (XmlSetting != null)
                {
                    var xelement = XElement.Parse(XmlSetting.SettingContent);
                    if (xelement != null)
                    {
                        foreach (var type in xelement.Descendants("Type"))
                        {
                            if (type.Attribute("TypeName").Value.Equals("航空公司", StringComparison.OrdinalIgnoreCase))
                            {
                                foreach (var item in type.Descendants("Item"))
                                {
                                    var xmlItem = new XmlItem
                                    {
                                        Name = item.Attribute("Name").Value,
                                        Color = item.Attribute("Color").Value
                                    };
                                    _airlines.Add(xmlItem);
                                }
                                AirLineList = _airlines;
                            }
                            else if (type.Attribute("TypeName").Value.Equals("座级", StringComparison.OrdinalIgnoreCase))
                            {
                                foreach (var item in type.Descendants("Item"))
                                {
                                    var xmlItem = new XmlItem
                                    {
                                        Name = item.Attribute("Name").Value,
                                        Color = item.Attribute("Color").Value
                                    };
                                    _regionals.Add(xmlItem);
                                }
                                RegionalList = _regionals;
                            }
                            else if (type.Attribute("TypeName").Value.Equals("机型", StringComparison.OrdinalIgnoreCase))
                            {
                                foreach (var item in type.Descendants("Item"))
                                {
                                    var xmlItem = new XmlItem
                                    {
                                        Name = item.Attribute("Name").Value,
                                        Color = item.Attribute("Color").Value
                                    };
                                    _aircraftTypes.Add(xmlItem);
                                }
                                AircraftTypeList = _aircraftTypes;
                            }
                            else if (type.Attribute("TypeName").Value.Equals("引进方式", StringComparison.OrdinalIgnoreCase))
                            {
                                foreach (var item in type.Descendants("Item"))
                                {
                                    var xmlItem = new XmlItem
                                    {
                                        Name = item.Attribute("Name").Value,
                                        Color = item.Attribute("Color").Value
                                    };
                                    _importTypes.Add(xmlItem);
                                }
                                ImportTypeList = _importTypes;
                            }
                            else if (type.Attribute("TypeName")
                                .Value.Equals("机龄", StringComparison.OrdinalIgnoreCase))
                            {
                                foreach (var item in type.Descendants("Item"))
                                {
                                    var xmlItem = new XmlItem
                                    {
                                        Name = item.Attribute("Name").Value,
                                        Color = item.Attribute("Color").Value
                                    };
                                    _aircraftAges.Add(xmlItem);
                                }
                                AircraftAgeList = _aircraftAges;
                            }
                            else if (type.Attribute("TypeName")
                                .Value.Equals("运力变化", StringComparison.OrdinalIgnoreCase))
                            {
                                foreach (var item in type.Descendants("Item"))
                                {
                                    var xmlItem = new XmlItem
                                    {
                                        Name = item.Attribute("Name").Value,
                                        Color = item.Attribute("Color").Value
                                    };
                                    _aircrafTrends.Add(xmlItem);
                                }
                                AircraftTrendList = _aircrafTrends;
                            }
                        }
                    }
                }
            };
        }
コード例 #2
0
ファイル: RequestVM.cs プロジェクト: unicloud/FRP
        /// <summary>
        ///     初始化ViewModel
        ///     <remarks>
        ///         统一在此处创建并注册CollectionView集合。
        ///     </remarks>
        /// </summary>
        private void InitializeVM()
        {
            Requests = _service.CreateCollection(_context.Requests.Expand(p => p.RelatedDocs), o => o.ApprovalHistories,
                o => o.RelatedDocs);
            var cfd = new CompositeFilterDescriptor {LogicalOperator = FilterCompositionLogicalOperator.And};
            var requestDescriptor = new FilterDescriptor("Title", FilterOperator.IsNotEqualTo, "指标飞机申请(系统添加)");
            cfd.FilterDescriptors.Add(requestDescriptor);
            var statusDateDescriptor = new FilterDescriptor("Status", FilterOperator.IsLessThan, (int) RequestStatus.已审批);
            cfd.FilterDescriptors.Add(statusDateDescriptor);
            Requests.FilterDescriptors.Add(cfd);
            Requests.LoadedData += (o, e) =>
            {
                if (SelRequest == null)
                    SelRequest = Requests.FirstOrDefault();
            };
            _service.RegisterCollectionView(Requests);

            Annuals = new QueryableDataServiceCollectionView<AnnualDTO>(_context, _context.Annuals);
            Annuals.LoadedData += (sender, e) =>
            {
                if (Annuals.Count != 0 && Annuals.FirstOrDefault(p => p.IsOpen) != null)
                {
                    _planDescriptor.Value = Annuals.First(p => p.IsOpen).Year;
                    if (!Plans.AutoLoad)
                        Plans.AutoLoad = true;
                    else
                        Plans.Load(true);
                    RefreshCommandState();
                }
            };

            Plans = new QueryableDataServiceCollectionView<PlanDTO>(_context, _context.Plans);
            _planDescriptor = new FilterDescriptor("Year", FilterOperator.IsEqualTo, -1);
            var sort = new SortDescriptor {Member = "VersionNumber", SortDirection = ListSortDirection.Ascending};
            Plans.SortDescriptors.Add(sort);
            Plans.FilterDescriptors.Add(_planDescriptor);
            Plans.LoadedData += (sender, e) =>
            {
                var curPlan = Plans.OrderBy(p => p.VersionNumber).LastOrDefault();
                if (curPlan != null)
                {
                    _planHistoryDescriptor.Value = curPlan.Id;
                    if (!CurPlanHistories.AutoLoad)
                        CurPlanHistories.AutoLoad = true;
                    else
                        CurPlanHistories.Load(true);
                }
                RefreshCommandState();
                _approvalHistoryCaches = new List<ApprovalHistoryCache>();
            };

            CurPlanHistories = _service.CreateCollection(_context.PlanHistories);
            _planHistoryDescriptor = new FilterDescriptor("PlanId", FilterOperator.IsEqualTo, Guid.Empty);
            var group = new GroupDescriptor {Member = "CanRequest", SortDirection = ListSortDirection.Ascending};
            CurPlanHistories.GroupDescriptors.Add(group);
            CurPlanHistories.FilterDescriptors.Add(_planHistoryDescriptor);
            _service.RegisterCollectionView(CurPlanHistories);

            PlanAircrafts = _service.CreateCollection(_context.PlanAircrafts);
            _service.RegisterCollectionView(PlanAircrafts);
        }
コード例 #3
0
ファイル: AirframeMaintainVm.cs プロジェクト: unicloud/FRP
 /// <summary>
 ///     初始化ViewModel
 ///     <remarks>
 ///         统一在此处创建并注册CollectionView集合。
 ///     </remarks>
 /// </summary>
 private void InitializeVm()
 {
     // 创建并注册CollectionView
     AirframeMaintainInvoices = _service.CreateCollection(_context.AirframeMaintainInvoices,
         o => o.MaintainInvoiceLines);
     AirframeMaintainInvoices.PageSize = 6;
     AirframeMaintainInvoices.LoadedData += (o, e) =>
     {
         if (AirframeMaintainInvoice == null)
             AirframeMaintainInvoice = AirframeMaintainInvoices.FirstOrDefault();
     };
     var supplierFilter = new FilterDescriptor("MaintainSupplier", FilterOperator.IsEqualTo, true);
     Suppliers.FilterDescriptors.Add(supplierFilter);
     _service.RegisterCollectionView(AirframeMaintainInvoices);
 }
コード例 #4
0
ファイル: QueryMaintainCtrlVm.cs プロジェクト: unicloud/FRP
        /// <summary>
        ///     初始化ViewModel
        ///     <remarks>
        ///         统一在此处创建并注册CollectionView集合。
        ///     </remarks>
        /// </summary>
        private void InitializeVM()
        {
            Items = new QueryableDataServiceCollectionView<ItemDTO>(_context, _context.Items);
            var itemDescriptor = new FilterDescriptor("IsLife", FilterOperator.IsEqualTo, true);
            Items.FilterDescriptors.Add(itemDescriptor);
            Items.LoadedData += (s, e) => { SelItem = Items.FirstOrDefault(); };

            SnRegs = new QueryableDataServiceCollectionView<SnRegDTO>(_context, _context.SnRegs);
            _snDescriptor = new FilterDescriptor("PnRegId", FilterOperator.IsEqualTo, -1);
            SnRegs.FilterDescriptors.Add(_snDescriptor);

            ItemMaintainCtrls = new QueryableDataServiceCollectionView<ItemMaintainCtrlDTO>(_context,
                _context.ItemMaintainCtrls);
            _itemCtrlDescriptor = new FilterDescriptor("ItemId", FilterOperator.IsEqualTo, -1);
            ItemMaintainCtrls.FilterDescriptors.Add(_itemCtrlDescriptor);

            PnMaintainCtrls = new QueryableDataServiceCollectionView<PnMaintainCtrlDTO>(_context,
                _context.PnMaintainCtrls);
            _pnCtrlDescriptor = new FilterDescriptor("PnRegId", FilterOperator.IsEqualTo, -1);
            PnMaintainCtrls.FilterDescriptors.Add(_pnCtrlDescriptor);

            CtrlUnits = new QueryableDataServiceCollectionView<CtrlUnitDTO>(_context, _context.CtrlUnits);
            MaintainWorks = new QueryableDataServiceCollectionView<MaintainWorkDTO>(_context, _context.MaintainWorks);
        }
コード例 #5
0
        /// <summary>
        ///     初始化Apu维修成本信息。
        /// </summary>
        private void InitialVm()
        {
            CellEditEndCommand = new DelegateCommand<object>(CellEditEnd);
            ApuMaintainInvoices = new QueryableDataServiceCollectionView<APUMaintainInvoiceDTO>(_context,
                _context.APUMaintainInvoices);
            ApuMaintainCosts = _service.CreateCollection(_context.ApuMaintainCosts);
            ApuMaintainCosts.PageSize = 20;
            _annualFilter = new FilterDescriptor("Year", FilterOperator.IsEqualTo, 0);
            ApuMaintainCosts.FilterDescriptors.Add(_annualFilter);
            ApuMaintainCosts.LoadedData += (sender, e) =>
            {
                if (ApuMaintainCost == null)
                    ApuMaintainCost = ApuMaintainCosts.FirstOrDefault();
                RefreshCommandState();
            };
            _service.RegisterCollectionView(ApuMaintainCosts);

            Annuals = new QueryableDataServiceCollectionView<AnnualDTO>(_fleetPlanService.Context,
                _fleetPlanService.Context.Annuals);
            Annuals.LoadedData += (o, e) =>
            {
                if (Annual == null)
                    Annual = Annuals.FirstOrDefault(p => p.Year == DateTime.Now.Year);
            };
        }
コード例 #6
0
ファイル: SnRegVm.cs プロジェクト: unicloud/FRP
 /// <summary>
 ///     初始化ViewModel
 ///     <remarks>
 ///         统一在此处创建并注册CollectionView集合。
 ///     </remarks>
 /// </summary>
 private void InitializeVM()
 {
     SnRegs = new QueryableDataServiceCollectionView<SnRegDTO>(_context, _context.SnRegs) {PageSize = 20};
     SnRegs.LoadedData += (o, e) =>
     {
         if (SelSnReg == null)
             SelSnReg = SnRegs.FirstOrDefault();
     };
     SnHistories = _service.CreateCollection(_context.SnHistories);
     SnHistories.SortDescriptors.Add(new SortDescriptor
     {
         Member = "ActionDate",
         SortDirection = ListSortDirection.Descending
     });
     SnHistories.LoadedData += (s, e) =>
     {
         if (SelSnReg != null)
         {
             ViewSnHistories = new ObservableCollection<SnHistoryDTO>();
             var snHistories =
                 SnHistories.SourceCollection.Cast<SnHistoryDTO>()
                     .Where(p => p.SnRegId == SelSnReg.Id)
                     .ToList();
             ViewSnHistories.AddRange(snHistories);
         }
     };
 }
コード例 #7
0
ファイル: QueryLifeMonitorVm.cs プロジェクト: unicloud/FRP
 /// <summary>
 ///     初始化ViewModel
 ///     <remarks>
 ///         统一在此处创建并注册CollectionView集合。
 ///     </remarks>
 /// </summary>
 private void InitializeVM()
 {
     SnRegs = new QueryableDataServiceCollectionView<SnRegDTO>(_context, _context.SnRegs);
     SnRegs.PageSize = 20;
     var snDescriptor = new FilterDescriptor("IsLife", FilterOperator.IsEqualTo, true);
     SnRegs.FilterDescriptors.Add(snDescriptor);
     SnRegs.LoadedData += (s, e) => SelSnReg = SnRegs.FirstOrDefault();
 }
コード例 #8
0
ファイル: AircraftConfigVm.cs プロジェクト: unicloud/FRP
        /// <summary>
        ///     初始化ViewModel
        ///     <remarks>
        ///         统一在此处创建并注册CollectionView集合。
        ///     </remarks>
        /// </summary>
        private void InitializeVM()
        {
            ContractAircrafts = new QueryableDataServiceCollectionView<ContractAircraftDTO>(_context,
                _context.ContractAircrafts);
            var sort = new SortDescriptor {Member = "CSCNumber", SortDirection = ListSortDirection.Ascending};
            ContractAircrafts.SortDescriptors.Add(sort);
            ContractAircrafts.LoadedData += (o, e) =>
            {
                if (SelContractAircraft == null)
                    SelContractAircraft = ContractAircrafts.FirstOrDefault();
            };

            BasicConfigGroups = new QueryableDataServiceCollectionView<BasicConfigGroupDTO>(_context,
                _context.BasicConfigGroups);
            _bcGroupDescriptor = new FilterDescriptor("AircraftTypeId", FilterOperator.IsEqualTo, Guid.Empty);
            BasicConfigGroups.FilterDescriptors.Add(_bcGroupDescriptor);
            BasicConfigGroups.LoadedData += (o, e) => RaisePropertyChanged(() => BasicConfigGroups);

            BasicConfigHistories = _service.CreateCollection(_context.BasicConfigHistories);
            _service.RegisterCollectionView(BasicConfigHistories);

            SpecialConfigs = _service.CreateCollection(_context.SpecialConfigs);
            SpecialConfigs.LoadedData += (o, e) =>
            {
                SpecialConfigs.ToList().ForEach(p => p.SubSpecialConfigs.Clear());
                SpecialConfigs.ToList().ForEach(GenerateSpecialConfigStructure);
                if (SelContractAircraft != null)
                {
                    ViewSpecialConfigs.Clear();
                    var bcs =
                        SpecialConfigs.SourceCollection.Cast<SpecialConfigDTO>()
                            .Where(p => p.ContractAircraftId == SelContractAircraft.Id && p.ParentId == null).ToList();
                    foreach (var bc in bcs)
                    {
                        ViewSpecialConfigs.Add(bc);
                    }
                }
            };
            _service.RegisterCollectionView(SpecialConfigs); //注册查询集合
        }
コード例 #9
0
ファイル: ConfigMailAddressVm.cs プロジェクト: unicloud/FRP
        /// <summary>
        ///     初始化ViewModel
        ///     <remarks>
        ///         统一在此处创建并注册CollectionView集合。
        ///     </remarks>
        /// </summary>
        private void InitializeVm()
        {
            // 创建并注册CollectionView
            MailAddresses = _service.CreateCollection(_context.MailAddresses);
            cfd.FilterDescriptors.Add(new FilterDescriptor("Id", FilterOperator.IsEqualTo, Guid.Parse("1978ADFC-A2FD-40CC-9A26-6DEDB55C335F")));
            cfd.FilterDescriptors.Add(new FilterDescriptor("Id", FilterOperator.IsEqualTo, Guid.Parse("31A9DE51-C207-4A73-919C-21521F17FEF9")));
            MailAddresses.LoadedData += (o, e) =>
            {
                MailAddress = MailAddresses.FirstOrDefault();

                if (MailAddresses.SourceCollection.Cast<MailAddressDTO>().Count() != 0)
                {
                    MailAddress = MailAddresses.SourceCollection.Cast<MailAddressDTO>().FirstOrDefault(p => p.Id == Guid.Parse("1978ADFC-A2FD-40CC-9A26-6DEDB55C335F"));
                    CAACMailAddress = MailAddresses.SourceCollection.Cast<MailAddressDTO>().FirstOrDefault(p => p.Id == Guid.Parse("31A9DE51-C207-4A73-919C-21521F17FEF9"));
                }
                IsReadOnly = true;
                RaisePropertyChanged(()=>IsReadOnly);
                RefreshCommandState();
            };
            _service.RegisterCollectionView(MailAddresses);

            EditCommand = new DelegateCommand<object>(OnEdit, CanEdit);
        }
コード例 #10
0
        /// <summary>
        ///     初始化非FHA.超包修维修成本信息。
        /// </summary>
        private void InitialVm()
        {
            CellEditEndCommand = new DelegateCommand<object>(CellEditEnd);
            EngineMaintainInvoices = new QueryableDataServiceCollectionView<EngineMaintainInvoiceDTO>(_context,
                _context.EngineMaintainInvoices);
            NonFhaMaintainCosts = _service.CreateCollection(_context.NonFhaMaintainCosts);
            NonFhaMaintainCosts.PageSize = 20;
            _annualFilter = new FilterDescriptor("Year", FilterOperator.IsEqualTo, 0);
            NonFhaMaintainCosts.FilterDescriptors.Add(_annualFilter);
            NonFhaMaintainCosts.LoadedData += (sender, e) =>
            {
                if (NonFhaMaintainCost == null)
                    NonFhaMaintainCost = NonFhaMaintainCosts.FirstOrDefault();
                RefreshCommandState();
            };
            _service.RegisterCollectionView(NonFhaMaintainCosts);

            Aircrafts = new QueryableDataServiceCollectionView<AircraftDTO>(_fleetPlanService.Context,
                _fleetPlanService.Context.Aircrafts);
            AircraftTypes = new QueryableDataServiceCollectionView<AircraftTypeDTO>(_fleetPlanService.Context,
                _fleetPlanService.Context.AircraftTypes);
            ActionCategories = new QueryableDataServiceCollectionView<ActionCategoryDTO>(_fleetPlanService.Context,
                _fleetPlanService.Context.ActionCategories);
            Suppliers = new QueryableDataServiceCollectionView<SupplierDTO>(_fleetPlanService.Context,
                _fleetPlanService.Context.Suppliers);
            Annuals = new QueryableDataServiceCollectionView<AnnualDTO>(_fleetPlanService.Context,
                _fleetPlanService.Context.Annuals);
            Annuals.LoadedData += (o, e) =>
            {
                if (Annual == null)
                    Annual = Annuals.FirstOrDefault(p => p.Year == DateTime.Now.Year);
            };
        }