コード例 #1
0
        public PipeSpecialFeatureViewModel()
        {
            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);

            mPipeSpecialFeature = new PipeSpecialFeature();
        }
コード例 #2
0
        public PipeSpecialFeatureViewModel(int pipeSpecialFeatureId)
        {
            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            cmsWebServiceClient.GetPipeSpecialFeaturesCompleted +=
                (s, e) =>
                {
                    mPipeSpecialFeature = (from x in e.Result where x.Id == pipeSpecialFeatureId select x).FirstOrDefault();
                    if (DataLoaded!=null)
                    {
                        DataLoaded();
                    }
                };
            cmsWebServiceClient.GetPipeSpecialFeaturesAsync(pipeSpecialFeatureId);
        }
コード例 #3
0
        private void SetControlValuesFromSearchFilterList(SearchFilterList searchFilterList)
        {
            mSearchFilterControl.SetFilterIsOn(true);
            ClearControls();

            //1. Manufacturer
            SearchFilter manufactuerFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.PipeSearchFilterNames.Manufacturer.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (manufactuerFilter != null)
            {
                int result;
                if (int.TryParse(manufactuerFilter.Value, out result))
                {
                    Manufacturer match = (from x in Manufacturers where x.Id == result select x).FirstOrDefault();
                    mSelectedManufacturer = match;
                    RaisePropertyChanged("SelectedManufacturer");
                }
            }

            //2. Model
            SearchFilter modelFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.PipeSearchFilterNames.Model.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (modelFilter != null)
            {
                int result;
                if (int.TryParse(modelFilter.Value, out result))
                {
                    Model match = (from x in mModelsCache where x.Id == result select x).FirstOrDefault();
                    mSelectedModel = match;
                    RaisePropertyChanged("SelectedModel");
                }
            }

            //1. Area
            SearchFilter areaFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.PipeSearchFilterNames.Area.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (areaFilter != null)
            {
                int result;
                if (int.TryParse(areaFilter.Value, out result))
                {
                    Area match = (from x in Areas where x.Id == result select x).FirstOrDefault();
                    mSelectedArea = match;
                    RaisePropertyChanged("SelectedArea");
                }
            }

            //2. SubArea
            SearchFilter subareaFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.PipeSearchFilterNames.SubArea.ToString(), StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault();
            if (subareaFilter != null)
            {
                int result;
                if (int.TryParse(subareaFilter.Value, out result))
                {
                    Cell match = (from x in SubAreas where x.Id == result select x).FirstOrDefault();
                    mSelectedSubArea = match;
                    RaisePropertyChanged("SelectedSubArea");
                }
            }

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

                    //PipeClass
                    if (filter.Name.Equals(CommonUtils.PipeSearchFilterNames.Class.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            var match = (from x in PipeClasses where x.Id == result select x).FirstOrDefault();
                            mSelectedPipeClass = match;
                            RaisePropertyChanged("SelectedPipeClass");
                        }
                    }

                    //PipeSize
                    if (filter.Name.Equals(CommonUtils.PipeSearchFilterNames.Size.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            var match = (from x in PipeSizes where x.Id == result select x).FirstOrDefault();
                            mSelectedPipeSize = match;
                            RaisePropertyChanged("SelectedPipeSize");
                        }
                    }

                    //PipeFluidCode
                    if (filter.Name.Equals(CommonUtils.PipeSearchFilterNames.FluidCode.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            var match = (from x in PipeFluidCodes where x.Id == result select x).FirstOrDefault();
                            mSelectedPipeFluidCode = match;
                            RaisePropertyChanged("SelectedPipeFluidCode");
                        }
                    }

                    //PipeSpecialFeature
                    if (filter.Name.Equals(CommonUtils.PipeSearchFilterNames.SpecialFeature.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            var match = (from x in PipeSpecialFeatures where x.Id == result select x).FirstOrDefault();
                            mSelectedPipeSpecialFeature = match;
                            RaisePropertyChanged("SelectedPipeSpecialFeature");
                        }
                    }

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

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

                    //IsActive
                    if (filter.Name.Equals(CommonUtils.PipeSearchFilterNames.IsActive.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        //For compatibility as previously it was saved as Id
                        if (filter.Value == "-1") filter.Value = All;
                        if (filter.Value == "-2") filter.Value = Yes;
                        if (filter.Value == "-3") filter.Value = No;

                        var match = (from x in IsActiveChoices where x == filter.Value select x).FirstOrDefault();
                        mSelectedIsActive = match;
                        RaisePropertyChanged("SelectedIsActive");

                    }

                }
            }

            ProcessSearchFilter();
        }
コード例 #4
0
        private void LoadData()
        {
            var getPipeClassesTask = DatabaseLoader.GetPipeClasses();
            var getPipeSizesTask = DatabaseLoader.GetPipeSizes();
            var getPipeFluidCodesTask = DatabaseLoader.GetPipeFluidCodes();
            var getPipeSpecialFeaturesTask = DatabaseLoader.GetPipeSpecialFeatures();
            var pidDocumentsTask = DatabaseLoader.GetQuickDocuments(CommonUtils.DoctypePidCode);
            var getPipeComponentTypesTask = DatabaseLoader.GetPipeComponentTypes();
            var getManufacturersTask = DatabaseLoader.GetManufacturers(CommonUtils.EquipmentTypeCode.PIPE);
            var getModelsTask = DatabaseLoader.GetModels(CommonUtils.EquipmentTypeCode.PIPE);

            List<Task> tasks = new List<Task>();
            tasks.Add(getPipeClassesTask);
            tasks.Add(getPipeSizesTask);
            tasks.Add(getPipeFluidCodesTask);
            tasks.Add(getPipeSpecialFeaturesTask);
            tasks.Add(pidDocumentsTask);
            tasks.Add(getPipeComponentTypesTask);
            tasks.Add(getManufacturersTask);

            Task.Factory.ContinueWhenAll(tasks.ToArray(), x =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    //Pipe Classes
                    PipeClasses = getPipeClassesTask.Result;
                    PipeClasses.Insert(0, new PipeClass { Id = -1, Name = All });
                    mSelectedPipeClass = PipeClasses[0];
                    RaisePropertyChanged("PipeClasses");
                    RaisePropertyChanged("SelectedPipeClass");

                    //Pipe Sizes
                    PipeSizes = getPipeSizesTask.Result;
                    PipeSizes.Insert(0, new PipeSize { Id = -1, Name = All });
                    mSelectedPipeSize = PipeSizes[0];
                    RaisePropertyChanged("PipeSizes");
                    RaisePropertyChanged("SelectedPipeSize");

                    //Pipe FluidCodes
                    PipeFluidCodes = getPipeFluidCodesTask.Result;
                    PipeFluidCodes.Insert(0, new PipeFluidCode { Id = -1, Name = All });
                    mSelectedPipeFluidCode = PipeFluidCodes[0];
                    RaisePropertyChanged("PipeFluidCodes");
                    RaisePropertyChanged("SelectedPipeFluidCode");

                    //Pipe SpecialFeatures
                    PipeSpecialFeatures = getPipeSpecialFeaturesTask.Result;
                    PipeSpecialFeatures.Insert(0, new PipeSpecialFeature { Id = -1, Name = All });
                    mSelectedPipeSpecialFeature = PipeSpecialFeatures[0];
                    RaisePropertyChanged("PipeSpecialFeatures");
                    RaisePropertyChanged("SelectedPipeSpecialFeature");

                    //Pid Documents
                    PandIDDocuments = pidDocumentsTask.Result;
                    PandIDDocuments.Insert(0, new QuickDocument { Id = -1, Name = All });
                    mSelectedPAndIdDocument = PandIDDocuments[0];
                    RaisePropertyChanged("PandIDDocuments");
                    RaisePropertyChanged("SelectedPAndIdDocument");

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

                    //Model
                    mModelsCache = getModelsTask.Result;

                    //Manufacturer
                    Manufacturers = getManufacturersTask.Result;
                    Manufacturers.Insert(0, new Manufacturer { Id = -1, Name = All });
                    SelectedManufacturer = Manufacturers[0];
                    RaisePropertyChanged("Manufacturers");
                    RaisePropertyChanged("SelectedManufacturer");

                    //Classified
                    IsActiveChoices = new List<String> { All, Yes, No };
                    mSelectedIsActive = IsActiveChoices[0];
                    RaisePropertyChanged("IsActiveChoices");
                    RaisePropertyChanged("SelectedIsActive");

                    SetUpFilteredLinkControl();
                    InitialiseSearchFilterControl(CommonUtils.TabId.Piping);
                });
            });

            LoadAreas();
            LoadSubAreas();
        }
コード例 #5
0
        private void ClearControls()
        {
            mKeyword = string.Empty;
            RaisePropertyChanged("Keyword");

            mSelectedArea = Areas[0];
            RaisePropertyChanged("SelectedArea");

            mSelectedSubArea = SubAreas[0];
            RaisePropertyChanged("SelectedSubArea");

            mSelectedPipeClass = PipeClasses[0];
            RaisePropertyChanged("SelectedPipeClass");

            mSelectedPipeSize = PipeSizes[0];
            RaisePropertyChanged("SelectedPipeSize");

            mSelectedPipeFluidCode = PipeFluidCodes[0];
            RaisePropertyChanged("SelectedPipeFluidCode");

            mSelectedPipeSpecialFeature = PipeSpecialFeatures[0];
            RaisePropertyChanged("SelectedPipeSpecialFeature");

            mSelectedPAndIdDocument = PandIDDocuments[0];
            RaisePropertyChanged("SelectedPAndIdDocument");

            mSelectedComponentType = ComponentTypes[0];
            RaisePropertyChanged("SelectedComponentType");

            mSelectedManufacturer = Manufacturers[0];
            RaisePropertyChanged("SelectedManufacturer");

            mSelectedModel = Models[0];
            RaisePropertyChanged("SelectedModel");

            mSelectedIsActive = IsActiveChoices[0];
            RaisePropertyChanged("SelectedIsActive");
        }
コード例 #6
0
        public PipeSpecialFeature SavePipeSpecialFeature(PipeSpecialFeature pipeSpecialFeature)
        {
            using (CmsEntities cee = new CmsEntities())
            {
                //Check if the pipe area exist
                var originalPipeSpecialFeature = (from x in cee.PipeSpecialFeatures where x.Id == pipeSpecialFeature.Id select x).FirstOrDefault();

                if (originalPipeSpecialFeature == null)
                {
                    //Add new Pipe Special Feature
                    pipeSpecialFeature.Pipes = null;
                    cee.PipeSpecialFeatures.Add(pipeSpecialFeature);
                }
                else
                {
                    //Update existing Pipe Special Feature
                    originalPipeSpecialFeature.Name = pipeSpecialFeature.Name;
                    originalPipeSpecialFeature.Description = pipeSpecialFeature.Description;
                }

                cee.SaveChanges();
            }
            return pipeSpecialFeature;
        }
コード例 #7
0
        private void OkButtonHander(object parameter)
        {
            if (AreAllValid())
            {
                //save
                CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
                cmsWebServiceClient.SavePipeSpecialFeatureCompleted += (s1, e1) =>
                    {
                        if (e1.Result != null)
                        {
                            mPipeSpecialFeature = e1.Result;
                            View.PipeSpecialFeature = mPipeSpecialFeature;
                            View.DialogResult = true;
                        }
                        else
                        {
                            MessageBox.Show("Save Failed.");
                            View.DialogResult = false;
                        }
                    };
                cmsWebServiceClient.SavePipeSpecialFeatureAsync(mPipeSpecialFeature);

            }
        }
コード例 #8
0
ファイル: PipeImporter.cs プロジェクト: barrett2474/CMS2
        private bool GetSpecialFeature(Worksheet worksheet, string specialFeature, Pipe newPipe, int rowIndex)
        {
            bool skipRow = false;

            if (!string.IsNullOrEmpty(specialFeature))
            {
                //Check if the FluidCode exist in the database
                PipeSpecialFeature pipeSpecialFeature = mPipeRelatedObjects.PipeSpecialFeatures.Where(x => x.Name.ToLower() == specialFeature.Trim().ToLower()).FirstOrDefault();
                if (pipeSpecialFeature != null)
                {
                    newPipe.SpecialFeatureId = pipeSpecialFeature.Id;
                }
                else
                {
                    //Add new pipe area to the database
                    pipeSpecialFeature = new PipeSpecialFeature();
                    pipeSpecialFeature.Name = specialFeature;

                    mCee.PipeSpecialFeatures.AddObject(pipeSpecialFeature);
                    mCee.SaveChanges();

                    mPipeRelatedObjects.PipeSpecialFeatures.Add(pipeSpecialFeature);

                    RaiseMessage(MessageType.Added, string.Format("WorkSheet '{0}' Line '{1}': Added new '{2}' special feature to database.", worksheet.Name, rowIndex, specialFeature));

                    newPipe.SpecialFeatureId = pipeSpecialFeature.Id;
                }
            }
            else
            {
                RaiseMessage(MessageType.Warning, string.Format("WorkSheet '{0}' Line '{1}': special feature is empty. Skipping this row.", worksheet.Name, rowIndex));
                skipRow = true;
            }
            return skipRow;
        }