コード例 #1
0
ファイル: GraphicViewModel.cs プロジェクト: barrett2474/CMS2
        public GraphicViewModel(AddEditGraphicDialog view)
        {
            mGraphic = new Graphic();
            mView = view;

            DatabaseLoader.GetGraphics().ContinueWith(getGraphicstask =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    ParentalGraphics = getGraphicstask.Result;
                    ParentalGraphics.Insert(0, new Graphic {Name = "No Selection", Id = -1});

                    view.DataContext = this;
                    RaisePropertyChanged("ParentalGraphics");
                });
            });
        }
コード例 #2
0
ファイル: GraphicViewModel.cs プロジェクト: barrett2474/CMS2
        public GraphicViewModel(int graphicId, AddEditGraphicDialog view)
        {
            DatabaseLoader.GetGraphics().ContinueWith(getGraphicstask =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    ParentalGraphics = getGraphicstask.Result;
                    ParentalGraphics.Insert(0, new Graphic {Name = "No Selection", Id = -1});

                    mGraphic = ParentalGraphics.FirstOrDefault(x => x.Id == graphicId);
                    mView = view;
                    if (mGraphic != null)
                    {
                        OriginalParentId = mGraphic.ParentGraphicId;
                        RemoveSelfFromList(mGraphic);
                    }
                    view.DataContext = this;

                    RaisePropertyChanged("ParentalGraphics");
                });
            });
        }
コード例 #3
0
        private void RecursiveLoadGraphics(List<Graphic> graphics, Graphic graphic, NodeView node)
        {
            var linked = (from x in graphics where x.ParentGraphicId.HasValue && x.ParentGraphicId.Value == graphic.Id orderby x.Ordinal select x).ToList();

            var child = new NodeView(node)
            {
                Id = graphic.Id,
                Name = graphic.Name,
                Description = graphic.Description,
                Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                Type = NodeType.GraphicNode,
                IsActive = true,
                SortField = graphic.Ordinal.ToString(),
                HasChildren = linked.Any()
            };

            node.Children.Add(child);
            Utils.HideSpinner(child);

            foreach (var linkedGraphic in linked)
            {
                RecursiveLoadGraphics(graphics, linkedGraphic, child);
            }
        }
コード例 #4
0
        private void ClearControls()
        {
            mKeyword = "";
            RaisePropertyChanged("Keyword");

            mSelectedEquipmentType = EquipmentTypes[0];
            RaisePropertyChanged("SelectedEquipmentType");

            if (SelectedArea != null)
            {
                mSelectedArea = Areas[0];
                RaisePropertyChanged("SelectedArea");
            }

            if (SelectedSubArea != null)
            {
                mSelectedSubArea = SubAreas[0];
                RaisePropertyChanged("SelectedSubArea");
            }

            if (mSelectedUpperEquipment != null)
            {
                mUpperEquipments.AddRange(mMasterListUpperEquipments);
                mUpperEquipments.Insert(0, new UpperEquipment { Name = All, });
                mSelectedUpperEquipment = UpperEquipments[0];
                RaisePropertyChanged("SelectedUpperEquipment");
            }

            if (mSelectedGraphic != null)
            {
                mSelectedGraphic = Graphics[0];
                RaisePropertyChanged("SelectedGraphic");
            }

            if (mSelectedPAndIdDocument != null)
            {
                mSelectedPAndIdDocument = PandIDDocuments[0];
                RaisePropertyChanged("SelectedPAndIDDocument");
            }

            if (mSelectedComponentType != null)
            {
                mSelectedComponentType = ComponentTypes[0];
                RaisePropertyChanged("SelectedComponentType");
            }

            if (mSelectedSpecificationDocument != null)
            {
                mSelectedSpecificationDocument = SpecificationDocuments[0];
                RaisePropertyChanged("SelectedSpecificationDocument");
            }

            if (mSelectedClassified != null)
            {
                mSelectedClassified = Classifieds[0];
                RaisePropertyChanged("SelectedClassified");
            }
        }
コード例 #5
0
        private void SetControlValuesFromSearchFilterList(SearchFilterList searchFilterList)
        {
            ClearControls();

            // BECAUSE ORDER OF SETTING THESE 3 ( Area & SubArea & UpperEquipment) IS IMPORTANT - we will no rely on a 'loop order' SearchFilters - too risky.
            var areaFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.ControlSearchFilterNames.Area.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (areaFilter != null && !string.IsNullOrEmpty(areaFilter.Value))
            {
                int result;
                if (int.TryParse(areaFilter.Value, out result))
                {
                    var match = (from x in mAreas where x.Id == result select x).FirstOrDefault();
                    mSelectedArea = match;
                    RaisePropertyChanged("SelectedArea");

                    FilterSubAreasByArea(false); //might change the list of SubAreas ie 'mSubAreas'
                }
            }

            var subAreaFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.ControlSearchFilterNames.SubArea.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (subAreaFilter != null && !string.IsNullOrEmpty(subAreaFilter.Value))
            {
                int result;
                if (int.TryParse(subAreaFilter.Value, out result))
                {
                    var match = (from x in mSubAreas where x.Id == result select x).FirstOrDefault();
                    mSelectedSubArea = match;
                    RaisePropertyChanged("SelectedSubArea");

                }
            }

            RaisePropertyChanged("UpperEquipments");

            var upperEquipmentFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.ControlSearchFilterNames.UpperEquipment.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (upperEquipmentFilter != null && !string.IsNullOrEmpty(upperEquipmentFilter.Value))
            {
                //the UpperEquipments_get does the filtering.
                mSelectedUpperEquipment = (from x in UpperEquipments where x.Name == upperEquipmentFilter.Value select x).FirstOrDefault();
                if (mSelectedUpperEquipment == null)
                {
                    mSelectedUpperEquipment = UpperEquipments[0];
                }
                RaisePropertyChanged("SelectedUpperEquipment");
            }

            foreach (SearchFilter filter in searchFilterList.SearchFilters)
            {
                if (!string.IsNullOrEmpty(filter.Value))
                {
                    //KeyWords
                    if (filter.Name.Equals(CommonUtils.ControlSearchFilterNames.KeyWord.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        mKeyword = filter.Value;
                        RaisePropertyChanged("Keyword");
                    }

                    //ControlSystemType
                    if (filter.Name.Equals(CommonUtils.ControlSearchFilterNames.ControlSystemType.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            mSelectedEquipmentType = (from x in EquipmentTypes where x.Id == result select x).FirstOrDefault();
                            RaisePropertyChanged("SelectedEquipmentType");
                        }
                    }

                    //Graphic
                    if (filter.Name.Equals(CommonUtils.ControlSearchFilterNames.Graphic.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            mSelectedGraphic = (from x in Graphics where x.Id == result select x).FirstOrDefault();
                            RaisePropertyChanged("SelectedGraphic");
                        }
                    }

                    //PidDocument
                    if (filter.Name.Equals(CommonUtils.ControlSearchFilterNames.PidDocument.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            mSelectedPAndIdDocument = (from x in PandIDDocuments where x.Id == result select x).FirstOrDefault();
                            RaisePropertyChanged("SelectedPAndIdDocument");
                        }
                    }

                    //ControlSystemComponentType
                    if (filter.Name.Equals(CommonUtils.ControlSearchFilterNames.ComponentType.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            mSelectedComponentType = (from x in ComponentTypes where x.Id == result select x).FirstOrDefault();
                            RaisePropertyChanged("SelectedComponentType");
                        }
                    }

                    //Specification
                    if (filter.Name.Equals(CommonUtils.ControlSearchFilterNames.Specification.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            mSelectedSpecificationDocument = (from x in SpecificationDocuments where x.Id == result select x).FirstOrDefault();
                            RaisePropertyChanged("SelectedSpecificationDocument");
                        }
                    }

                    //Classified
                    if (filter.Name.Equals(CommonUtils.ControlSearchFilterNames.Classified.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        mSelectedClassified = filter.Value; //Yes or No
                        RaisePropertyChanged("SelectedClassified");
                    }

                    //IsActive
                    if (filter.Name.Equals(CommonUtils.ControlSearchFilterNames.IsActive.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        mSelectedIsActive = filter.Value; //Yes or No
                        RaisePropertyChanged("SelectedIsActive");
                    }
                }
            }
            ProcessSearchFilter();
        }
コード例 #6
0
        private void LoadData()
        {
            //PID & Specs
            var pidDocumentsTask = DatabaseLoader.GetQuickDocuments(CommonUtils.DoctypePidCode);
            var specificationDocumentsTask = DatabaseLoader.GetQuickDocuments(CommonUtils.DoctypeFuncspecCode);
            var getQuickControlSystemTypesTask = DatabaseLoader.GetQuickControlSystemTypes();
            var getUpperEquipmentsTask = DatabaseLoader.GetUpperEquipments();
            var getGraphicsTask = DatabaseLoader.GetGraphics();
            var getControlSystemComponentTypesTask = DatabaseLoader.GetControlSystemComponentTypes();

            List<Task> tasks = new List<Task>();
            tasks.Add(pidDocumentsTask);
            tasks.Add(specificationDocumentsTask);
            tasks.Add(getQuickControlSystemTypesTask);
            tasks.Add(getUpperEquipmentsTask);
            tasks.Add(getGraphicsTask);
            tasks.Add(getControlSystemComponentTypesTask);

            Task.Factory.ContinueWhenAll(tasks.ToArray(), x =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    //Type
                    mEquipmentTypes = getQuickControlSystemTypesTask.Result;
                    mEquipmentTypes.Insert(0, new QuickControlSystemType { Id = -1, Name = All });
                    mSelectedEquipmentType = mEquipmentTypes[0];
                    RaisePropertyChanged("EquipmentTypes");
                    RaisePropertyChanged("SelectedEquipmentType");

                    //UpperEquipment
                    mUpperEquipments = new List<UpperEquipment>();
                    mMasterListUpperEquipments = new List<UpperEquipment>();

                    mUpperEquipments.AddRange(getUpperEquipmentsTask.Result);
                    mMasterListUpperEquipments.AddRange(getUpperEquipmentsTask.Result);
                    mUpperEquipments.Insert(0, new UpperEquipment { Name = All, });
                    mSelectedUpperEquipment = mUpperEquipments[0];
                    RaisePropertyChanged("UpperEquipments");
                    RaisePropertyChanged("SelectedUpperEquipment");

                    //GRAPHICS
                    Graphics = getGraphicsTask.Result;
                    Graphics.Insert(0, new Graphic { Id = -1, Name = All });
                    mSelectedGraphic = Graphics[0];
                    RaisePropertyChanged("Graphics");
                    RaisePropertyChanged("SelectedGraphic");

                    //P&ID
                    PandIDDocuments = pidDocumentsTask.Result;
                    PandIDDocuments.Insert(0, new QuickDocument { Id = -1, Name = All });
                    mSelectedPAndIdDocument = PandIDDocuments[0];
                    RaisePropertyChanged("PandIDDocuments");
                    RaisePropertyChanged("SelectedPAndIDDocument");

                    //ControlSystemComponentType
                    ComponentTypes = getControlSystemComponentTypesTask.Result;
                    ComponentTypes.Insert(0, new ControlSystemComponentType { Id = -1, Name = All });
                    mSelectedComponentType = ComponentTypes[0];
                    RaisePropertyChanged("ComponentTypes");
                    RaisePropertyChanged("SelectedComponentType");

                    //Specification
                    SpecificationDocuments = specificationDocumentsTask.Result;
                    SpecificationDocuments.Insert(0, new QuickDocument { Id = -1, Name = All });
                    mSelectedSpecificationDocument = SpecificationDocuments[0];
                    RaisePropertyChanged("SpecificationDocuments");
                    RaisePropertyChanged("SelectedSpecificationDocument");

                    //Classified
                    Classifieds = new List<string> { All, Yes, "No" };
                    mSelectedClassified = Classifieds[0];
                    RaisePropertyChanged("Classifieds");
                    RaisePropertyChanged("SelectedClassified");

                    //IsActive
                    IsActiveChoices = new List<string> { All, Yes, "No" };
                    mSelectedIsActive = IsActiveChoices[1];
                    RaisePropertyChanged("IsActiveChoices");
                    RaisePropertyChanged("SelectedIsActive");

                    //AREAS
                    mAreas = new List<Area>(from a in CMS.Cache.Areas
                                            where a.IsActive && a.SiteId == CMS.AppSetting.DefaultSiteId
                                            select a);
                    mAreas.Insert(0, new Area { Id = -1, Name = All });
                    mSelectedArea = Areas[0];
                    RaisePropertyChanged("Areas");
                    RaisePropertyChanged("SelectedArea");

                    //SubAreas
                    LoadSubAreasFromCache(true);

                    SetUpFilteredLinkControl();
                    //safe to initialise the filter.
                    InitialiseSearchFilterControl(CommonUtils.TabId.Control);
                });
            });
        }
コード例 #7
0
ファイル: GraphicViewModel.cs プロジェクト: barrett2474/CMS2
        private void RemoveSelfFromList(Graphic graphic)
        {
            int index = -1;
            for (int i = 0; i < ParentalGraphics.Count; i++)
            {
                if (ParentalGraphics[i].Id == graphic.Id)
                {
                    index = i;
                    break;
                }
            }

            if (index != -1)
            {
                ParentalGraphics.RemoveAt(index);
            }
        }