private void OnDataLoaded(SearchFilterList searchFilterList)
 {
     if (DataLoaded != null)
     {
         DataLoaded(searchFilterList);
     }
 }
 private void OnLoadRequested(SearchFilterList searchFilterList )
 {
     if (LoadRequested != null)
     {
         EventAggregator.GetEvent<PrismEvents.SearchFilterLoadedPrismEvent>().Publish(searchFilterList);//publish event to Filter Control
         LoadRequested(searchFilterList);
     }
 }
        //ADD
        public AddEditSearchFilterListModel(CommonUtils.TabId tabId, List<SearchFilterList> existingSearchFilterLists)
        {
            ExistingSearchFilters = existingSearchFilterLists;
            SearchFilterList = new SearchFilterList {UserId = CMS.User.Id, TabId = (int) tabId, Ordinal = 0, IsDefault = false};

            OkCommand = new DelegateCommand<object>(OkCommandHandler, CanExecuteOkCommand);
            CancelCommand = new DelegateCommand<object>(CancelCommandHandler, CanExecuteOkCommand);

            OnDataSourceLoaded();
        }
        //EDIT
        public AddEditSearchFilterListModel(int id, List<SearchFilterList> existingSearchFilterLists)
        {
            ExistingSearchFilters = existingSearchFilterLists;
            var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            cmsWebServiceClient.GetSearchFilterListCompleted += (s, e) =>
            {
                SearchFilterList = e.Result;
                View.SearchFilterList = SearchFilterList;
                OnDataSourceLoaded();
            };
            cmsWebServiceClient.GetSearchFilterListAsync(id);

            OkCommand = new DelegateCommand<object>(OkCommandHandler, CanExecuteOkCommand);
            CancelCommand = new DelegateCommand<object>(CancelCommandHandler, CanExecuteOkCommand);
        }
        private SearchFilterList BuildFiltersFromControls(SearchFilterList searchFilterList)
        {
            searchFilterList.SearchFilters.Clear();

            //KEYWORDS
            var searchFilterKeyWords = new SearchFilter { Name = CommonUtils.DocumentSearchFilterNames.KeyWord.ToString() };
            if (!string.IsNullOrEmpty(mKeyword))
            {
                searchFilterKeyWords.Value = mKeyword;
            }
            else
            {
                searchFilterKeyWords.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterKeyWords);

            //DocumentType
            var searchFilterDocumentType = new SearchFilter { Name = CommonUtils.DocumentSearchFilterNames.DocumentType.ToString() };
            if (mSelectedDocumentType != null && mSelectedDocumentType.Name != All)
            {
                searchFilterDocumentType.Value = mSelectedDocumentType.Id.ToString();
            }
            else
            {
                searchFilterDocumentType.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterDocumentType);

            //Author
            var searchFilterAuthor = new SearchFilter { Name = CommonUtils.DocumentSearchFilterNames.Author.ToString() };
            if (mSelectedDocumentAuthor != null && mSelectedDocumentAuthor.Name != All)
            {
                searchFilterAuthor.Value = mSelectedDocumentAuthor.Id.ToString();
            }
            else
            {
                searchFilterAuthor.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterAuthor);

            //Discipline
            var searchFilterDiscipline = new SearchFilter { Name = CommonUtils.DocumentSearchFilterNames.Discipline.ToString() };
            if (mSelectedDocumentDiscipline != null && mSelectedDocumentDiscipline.Name != All)
            {
                searchFilterDiscipline.Value = mSelectedDocumentDiscipline.Id.ToString();
            }
            else
            {
                searchFilterDiscipline.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterDiscipline);

            //PurchaseOrder
            var searchFilterPurchaseOrder = new SearchFilter { Name = CommonUtils.DocumentSearchFilterNames.PurchaseOrder.ToString() };
            if (mSelectedPurchaseOrder != null && mSelectedPurchaseOrder.Name != All)
            {
                searchFilterPurchaseOrder.Value = mSelectedPurchaseOrder.Id.ToString();
            }
            else
            {
                searchFilterPurchaseOrder.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterPurchaseOrder);

            //Version
            var searchFilterVersion = new SearchFilter { Name = CommonUtils.DocumentSearchFilterNames.Version.ToString() };
            if (mSelectedDocumentVersionFilter != null && mSelectedDocumentVersionFilter.Name != All)
            {
                searchFilterVersion.Value = mSelectedDocumentVersionFilter.Id.ToString();
            }
            else
            {
                searchFilterVersion.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterVersion);

            //Area
            var searchFilterArea = new SearchFilter { Name = CommonUtils.DocumentSearchFilterNames.Area.ToString() };
            if (mSelectedArea != null && mSelectedArea.Name != All)
            {
                searchFilterArea.Value = mSelectedArea.Id.ToString();
            }
            else
            {
                searchFilterArea.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterArea);

            //DocumentStatus
            var searchFilterDocumentStatus = new SearchFilter { Name = CommonUtils.DocumentSearchFilterNames.DocumentStatus.ToString() };
            if (mSelectedDocumentStatus != null && mSelectedDocumentStatus != All)
            {
                searchFilterDocumentStatus.Value = mSelectedDocumentStatus;
            }
            else
            {
                searchFilterDocumentStatus.Value = string.Empty;
            }

            searchFilterList.SearchFilters.Add(searchFilterDocumentStatus);

            //CheckInOutStatus
            var searchFilterStatus = new SearchFilter { Name = CommonUtils.DocumentSearchFilterNames.CheckInOutStatus.ToString() };
            if (mSelectedInOutStatus != null && mSelectedInOutStatus != All)
            {
                searchFilterStatus.Value = mSelectedInOutStatus;
            }
            else
            {
                searchFilterStatus.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterStatus);

            //Location
            var searchFilterLocation = new SearchFilter { Name = CommonUtils.DocumentSearchFilterNames.Location.ToString() };
            if (mSelectedDocumentLocation != null && mSelectedDocumentLocation.Name != All)
            {
                searchFilterLocation.Value = mSelectedDocumentLocation.Id.ToString();
            }
            else
            {
                searchFilterLocation.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterLocation);

            return searchFilterList;
        }
        private void SetControlValuesFromSearchFilterList(SearchFilterList searchFilterList)
        {
            mSearchFilterControl.SetFilterIsOn(true);
            ClearControls();

            //1. Manufacturer
            SearchFilter manufactuerFilter = (from x in searchFilterList.SearchFilters where x.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.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.MobilePlantSearchFilterNames.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.MobilePlantSearchFilterNames.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.MobilePlantSearchFilterNames.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.MobilePlantSearchFilterNames.KeyWord.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        mKeyword = filter.Value;
                        RaisePropertyChanged("Keyword");
                    }

                    //MainSystId
                    if (filter.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.MaintSystemId.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        mMainSystId = filter.Value;
                        RaisePropertyChanged("MainSystId");
                    }

                    //Owner
                    if (filter.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.Owner.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            mSelectedMobileOwner = (from x in MobileOwners where x.Id == result select x).FirstOrDefault();
                            RaisePropertyChanged("SelectedMobileOwner");
                        }
                    }

                    //Hirer
                    if (filter.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.Hirer.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            mSelectedMobileHirer = (from x in MobileHirers where x.Id == result select x).FirstOrDefault();
                            RaisePropertyChanged("SelectedMobileHirer");
                        }
                    }

                    //Classified
                    if (filter.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.Classified.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 Classifieds where x == filter.Value select x).FirstOrDefault();
                        mSelectedClassified = match;
                        RaisePropertyChanged("Classified");
                    }

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

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

                    //IsActive
                    if (filter.Name.Equals(CommonUtils.MobilePlantSearchFilterNames.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();
        }
        private SearchFilterList BuildFiltersFromControls(SearchFilterList searchFilterList)
        {
            searchFilterList.SearchFilters.Clear();

            //KEYWORDS
            var searchFilterKeyWords = new SearchFilter { Name = CommonUtils.MobilePlantSearchFilterNames.KeyWord.ToString(), };
            if (!string.IsNullOrEmpty(mKeyword))
            {
                searchFilterKeyWords.Value = mKeyword.Trim();
            }
            else
            {
                searchFilterKeyWords.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterKeyWords);

            //MaintSystemId
            var maintSystIdFilter = new SearchFilter { Name = CommonUtils.MobilePlantSearchFilterNames.MaintSystemId.ToString(), };
            if (!string.IsNullOrEmpty(mMainSystId))
            {
                maintSystIdFilter.Value = mMainSystId.Trim();
            }
            else
            {
                maintSystIdFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(maintSystIdFilter);

            //Area
            var areaFilterKeyWords = new SearchFilter { Name = CommonUtils.MobilePlantSearchFilterNames.Area.ToString(), };
            if (mSelectedArea != null && mSelectedArea.Name != All)
            {
                areaFilterKeyWords.Value = mSelectedArea.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                areaFilterKeyWords.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(areaFilterKeyWords);

            //SubArea
            var subAreaFilter = new SearchFilter { Name = CommonUtils.MobilePlantSearchFilterNames.SubArea.ToString(), };
            if (mSelectedSubArea != null && mSelectedSubArea.Name != All)
            {
                subAreaFilter.Value = mSelectedSubArea.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                subAreaFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(subAreaFilter);

            //Type
            var typeFilter = new SearchFilter { Name = CommonUtils.MobilePlantSearchFilterNames.MobilePlantType.ToString(), };
            if (mSelectedEquipmentType != null && mSelectedEquipmentType.Name != All)
            {
                typeFilter.Value = mSelectedEquipmentType.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                typeFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(typeFilter);

            //ComponentType
            var componentTypeFilter = new SearchFilter { Name = CommonUtils.MobilePlantSearchFilterNames.ComponentType.ToString(), };
            if (mSelectedComponentType != null && mSelectedComponentType.Name != All)
            {
                componentTypeFilter.Value = mSelectedComponentType.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                componentTypeFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(componentTypeFilter);

            //Owner
            var ownerFilter = new SearchFilter { Name = CommonUtils.MobilePlantSearchFilterNames.Owner.ToString() };
            if (mSelectedMobileOwner != null && mSelectedMobileOwner.Name != All)
            {
                ownerFilter.Value = mSelectedMobileOwner.Id.ToString(CultureInfo.CurrentUICulture);
            }
            else
            {
                ownerFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(ownerFilter);

            //Hirer
            var hirerFilter = new SearchFilter { Name = CommonUtils.MobilePlantSearchFilterNames.Hirer.ToString() };
            if (mSelectedMobileHirer != null && mSelectedMobileHirer.Name != All)
            {
                hirerFilter.Value = mSelectedMobileHirer.Id.ToString(CultureInfo.CurrentUICulture);
            }
            else
            {
                hirerFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(hirerFilter);

            //Classified
            var classifiedFilter = new SearchFilter { Name = CommonUtils.MobilePlantSearchFilterNames.Classified.ToString(), };
            if (mSelectedClassified != null && mSelectedClassified != All)
            {
                classifiedFilter.Value = mSelectedClassified;
            }
            else
            {
                classifiedFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(classifiedFilter);

            //Manufacturer
            var manufacturerFilter = new SearchFilter { Name = CommonUtils.MobilePlantSearchFilterNames.Manufacturer.ToString(), };
            if (mSelectedManufacturer != null && mSelectedManufacturer.Name != All)
            {
                manufacturerFilter.Value = mSelectedManufacturer.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                manufacturerFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(manufacturerFilter);

            //Model
            var modelFilter = new SearchFilter { Name = CommonUtils.MobilePlantSearchFilterNames.Model.ToString(), };
            if (mSelectedModel != null && mSelectedModel.Name != All)
            {
                modelFilter.Value = mSelectedModel.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                modelFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(modelFilter);

            //IsActive
            var activeFilter = new SearchFilter { Name = CommonUtils.MobilePlantSearchFilterNames.IsActive.ToString(), };
            if (mSelectedIsActive != null && mSelectedIsActive != All)
            {
                activeFilter.Value = mSelectedIsActive;
            }
            else
            {
                activeFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(activeFilter);

            return searchFilterList;
        }
 private void OnSaveButtonFired(SearchFilterList searchFilterList)
 {
     if (SaveButtonFired != null)
     {
         SaveButtonFired(searchFilterList);
     }
 }
Esempio n. 9
0
 private void OnLoadButtonFired(SearchFilterList selectedSearchFilterList)
 {
     if (LoadButtonFired != null)
     {
         LoadButtonFired(selectedSearchFilterList);
     }
 }
Esempio n. 10
0
        private SearchFilterList BuildFiltersFromControls(SearchFilterList searchFilterList)
        {
            searchFilterList.SearchFilters.Clear();

            //KEYWORDS
            var searchFilterKeyWords = new SearchFilter { Name = CommonUtils.PipeSearchFilterNames.KeyWord.ToString(), };
            if (!string.IsNullOrEmpty(mKeyword))
            {
                searchFilterKeyWords.Value = mKeyword.Trim();
            }
            else
            {
                searchFilterKeyWords.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterKeyWords);

            //Area
            var areaFilterKeyWords = new SearchFilter { Name = CommonUtils.PipeSearchFilterNames.Area.ToString(), };
            if (mSelectedArea != null && mSelectedArea.Name != All)
            {
                areaFilterKeyWords.Value = mSelectedArea.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                areaFilterKeyWords.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(areaFilterKeyWords);

            //SubArea
            var subAreaFilter = new SearchFilter { Name = CommonUtils.PipeSearchFilterNames.SubArea.ToString(), };
            if (mSelectedSubArea != null && mSelectedSubArea.Name != All)
            {
                subAreaFilter.Value = mSelectedSubArea.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                subAreaFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(subAreaFilter);

            //PipeClass
            var pipeClassFilter = new SearchFilter { Name = CommonUtils.PipeSearchFilterNames.Class.ToString(), };
            if (mSelectedPipeClass != null && mSelectedPipeClass.Name != All)
            {
                pipeClassFilter.Value = mSelectedPipeClass.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                pipeClassFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(pipeClassFilter);

            //PipeSize
            var pipeSizeFilter = new SearchFilter { Name = CommonUtils.PipeSearchFilterNames.Size.ToString(), };
            if (mSelectedPipeSize != null && mSelectedPipeSize.Name != All)
            {
                pipeSizeFilter.Value = mSelectedPipeSize.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                pipeSizeFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(pipeSizeFilter);

            //PipeFluidCode
            var pipeFluidCodeFilter = new SearchFilter { Name = CommonUtils.PipeSearchFilterNames.FluidCode.ToString(), };
            if (mSelectedPipeFluidCode != null && mSelectedPipeFluidCode.Name != All)
            {
                pipeFluidCodeFilter.Value = mSelectedPipeFluidCode.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                pipeFluidCodeFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(pipeFluidCodeFilter);

            //PipeSpecialFeature
            var pipeSpecialFeatureFilter = new SearchFilter { Name = CommonUtils.PipeSearchFilterNames.SpecialFeature.ToString(), };
            if (mSelectedPipeSpecialFeature != null && mSelectedPipeSpecialFeature.Name != All)
            {
                pipeSpecialFeatureFilter.Value = mSelectedPipeSpecialFeature.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                pipeSpecialFeatureFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(pipeSpecialFeatureFilter);

            //PidDocument
            var pidFilter = new SearchFilter { Name = CommonUtils.PipeSearchFilterNames.PidDocument.ToString(), };
            if (mSelectedPAndIdDocument != null && mSelectedPAndIdDocument.Name != All)
            {
                pidFilter.Value = mSelectedPAndIdDocument.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                pidFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(pidFilter);

            //ComponentType
            var componentTypeFilter = new SearchFilter { Name = CommonUtils.PipeSearchFilterNames.ComponentType.ToString(), };
            if (mSelectedComponentType != null && mSelectedComponentType.Name != All)
            {
                componentTypeFilter.Value = mSelectedComponentType.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                componentTypeFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(componentTypeFilter);

            //Manufacturer
            var manufacturerFilter = new SearchFilter { Name = CommonUtils.PipeSearchFilterNames.Manufacturer.ToString(), };
            if (mSelectedManufacturer != null && mSelectedManufacturer.Name != All)
            {
                manufacturerFilter.Value = mSelectedManufacturer.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                manufacturerFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(manufacturerFilter);

            //Model
            var modelFilter = new SearchFilter { Name = CommonUtils.PipeSearchFilterNames.Model.ToString(), };
            if (mSelectedModel != null && mSelectedModel.Name != All)
            {
                modelFilter.Value = mSelectedModel.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                modelFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(modelFilter);

            //IsActive
            var activeFilter = new SearchFilter { Name = CommonUtils.PipeSearchFilterNames.IsActive.ToString(), };
            if (mSelectedIsActive != null && mSelectedIsActive != All)
            {
                activeFilter.Value = mSelectedIsActive;
            }
            else
            {
                activeFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(activeFilter);

            return searchFilterList;
        }
        private SearchFilterList BuildFiltersFromControls(SearchFilterList searchFilterList)
        {
            searchFilterList.SearchFilters.Clear();
            //this is just a temp object to message across to model.

            //KeyWord
            var searchFilterKeyWord = new SearchFilter {Name = CommonUtils.ControlSearchFilterNames.KeyWord.ToString()};
            if (!string.IsNullOrEmpty(Keyword))
            {
                searchFilterKeyWord.Value = Keyword;
            }
            else
            {
                searchFilterKeyWord.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterKeyWord);

            //ControlSystemType
            var searchFilterControlSystemType = new SearchFilter
            {
                Name = CommonUtils.ControlSearchFilterNames.ControlSystemType.ToString()
            };
            if (mSelectedEquipmentType != null && mSelectedEquipmentType.Name != All)
            {
                searchFilterControlSystemType.Value = mSelectedEquipmentType.Id.ToString(CultureInfo.CurrentUICulture);
            }
            else
            {
                searchFilterControlSystemType.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterControlSystemType);

            //Area
            var searchFilterArea = new SearchFilter {Name = CommonUtils.ControlSearchFilterNames.Area.ToString()};
            if (mSelectedArea != null && mSelectedArea.Name != All)
            {
                searchFilterArea.Value = mSelectedArea.Id.ToString(CultureInfo.CurrentUICulture);
            }
            else
            {
                searchFilterArea.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterArea);

            //SubArea
            var searchFilterSubArea = new SearchFilter {Name = CommonUtils.ControlSearchFilterNames.SubArea.ToString()};
            if (mSelectedSubArea != null && mSelectedSubArea.Name != All)
            {
                searchFilterSubArea.Value = mSelectedSubArea.Id.ToString(CultureInfo.CurrentUICulture);
            }
            else
            {
                searchFilterSubArea.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterSubArea);

            //UpperEquipment
            var searchFilterUpperEquipment = new SearchFilter
            {
                Name = CommonUtils.ControlSearchFilterNames.UpperEquipment.ToString()
            };
            if (mSelectedUpperEquipment != null && mSelectedUpperEquipment.Name != All)
            {
                searchFilterUpperEquipment.Value = mSelectedUpperEquipment.Name;
            }
            else
            {
                searchFilterUpperEquipment.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterUpperEquipment);

            //Graphic
            var searchFilterGraphic = new SearchFilter {Name = CommonUtils.ControlSearchFilterNames.Graphic.ToString()};
            if (mSelectedGraphic != null && mSelectedGraphic.Name != All)
            {
                searchFilterGraphic.Value = mSelectedGraphic.Id.ToString(CultureInfo.CurrentUICulture);
            }
            else
            {
                searchFilterGraphic.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterGraphic);

            //PidDocument
            var searchFilterPidDocument = new SearchFilter
            {
                Name = CommonUtils.ControlSearchFilterNames.PidDocument.ToString()
            };
            if (mSelectedPAndIdDocument != null && mSelectedPAndIdDocument.Name != All)
            {
                searchFilterPidDocument.Value = mSelectedPAndIdDocument.Id.ToString(CultureInfo.CurrentUICulture);
            }
            else
            {
                searchFilterPidDocument.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterPidDocument);

            //ComponentType
            var searchFilterComponentType = new SearchFilter
            {
                Name = CommonUtils.ControlSearchFilterNames.ComponentType.ToString()
            };
            if (SelectedComponentType != null && mSelectedComponentType.Name != All)
            {
                searchFilterComponentType.Value = SelectedComponentType.Id.ToString(CultureInfo.CurrentUICulture);
            }
            else
            {
                searchFilterComponentType.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterComponentType);

            //Specification
            var searchFilterSpecification = new SearchFilter
            {
                Name = CommonUtils.ControlSearchFilterNames.Specification.ToString()
            };
            if (mSelectedSpecificationDocument != null && mSelectedSpecificationDocument.Name != All)
            {
                searchFilterSpecification.Value = mSelectedSpecificationDocument.Id.ToString(CultureInfo.CurrentUICulture);
            }
            else
            {
                searchFilterSpecification.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterSpecification);

            //Classified
            var searchFilterClassified = new SearchFilter
            {
                Name = CommonUtils.ControlSearchFilterNames.Classified.ToString()
            };
            if (!string.IsNullOrEmpty(SelectedClassified) && SelectedClassified != All)
            {
                searchFilterClassified.Value = SelectedClassified;
            }
            else
            {
                searchFilterClassified.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterClassified);

            //IsActive
            var isActiveSearchFilter = new SearchFilter
            {
                Name = CommonUtils.ControlSearchFilterNames.IsActive.ToString()
            };
            if (!string.IsNullOrEmpty(SelectedIsActive))
            {
                isActiveSearchFilter.Value = SelectedIsActive;
            }
            else
            {
                isActiveSearchFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(isActiveSearchFilter);

            return searchFilterList;
        }
        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();
        }
Esempio n. 13
0
 public void SaveCurrentSearchValuesToSelectedFilterList(SearchFilterList filter)
 {
     mDialogModel.SaveCurrentSearchValuesToSelectedFilterList(filter);
 }
        private void WcfSave()
        {
            if (AreAllValid())
            {
                var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
                cmsWebServiceClient.SaveTabSearchFilterListCompleted +=
                    (s1, e1) =>
                    {
                        if (e1.Result.HasErrors)
                        {
                            var errorDialog = new PopupDialog(PopupDialogType.Error, Utils.DisplayErrorMessages(e1.Result.ServerErrorMessages));
                            errorDialog.Show();
                            return;
                        }

                        View.SearchFilterList = e1.Result.EntityResult;
                        SearchFilterList = e1.Result.EntityResult;
                        View.DialogResult = true;
                    };
                cmsWebServiceClient.SaveTabSearchFilterListAsync(SearchFilterList);
            }
        }
Esempio n. 15
0
 public void SaveControlValuesToFilter(SearchFilterList searchFilterList)
 {
     mModel.SaveCurrentSearchValuesToSelectedFilterList(searchFilterList);
 }
        private void SetControlValuesFromSearchFilterList(SearchFilterList searchFilterList)
        {
            mSearchFilterControl.SetFilterIsOn(true);
            ClearControls();

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

                    //Area
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.Area.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            Area match = (from x in Areas where x.Id == result select x).FirstOrDefault();
                            mSelectedArea= match;
                            RaisePropertyChanged("SelectedArea");
                        }
                    }

                    //Author
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.Author.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            DocumentAuthor match = (from x in Authors where x.Id == result select x).FirstOrDefault();
                            mSelectedDocumentAuthor = match;
                            RaisePropertyChanged("SelectedDocumentAuthor");
                        }
                    }

                    //Discipline
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.Discipline.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            DocumentDiscipline match = (from x in DocumentDisciplines where x.Id == result select x).FirstOrDefault();
                            mSelectedDocumentDiscipline = match;
                            RaisePropertyChanged("SelectedDocumentDiscipline");
                        }
                    }

                    //DocumentStatus
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.DocumentStatus.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 = "Active";
                        if (filter.Value == "-3") filter.Value = "Disabled";

                        var match = (from x in DocumentStatuses where x == filter.Value select x).FirstOrDefault();
                        mSelectedDocumentStatus = match;
                        RaisePropertyChanged("SelectedDocumentStatus");
                    }

                    //DocumentType
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.DocumentType.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            DocumentType match = (from x in DocumentTypes where x.Id == result select x).FirstOrDefault();
                            mSelectedDocumentType = match;
                            RaisePropertyChanged("SelectedDocumentType");
                        }
                    }

                    //Location
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.Location.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            DocumentLocation match = (from x in DocumentLocations where x.Id == result select x).FirstOrDefault();
                            mSelectedDocumentLocation = match;
                            RaisePropertyChanged("SelectedDocumentLocation");
                        }
                    }

                    //PurchaseOrder
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.PurchaseOrder.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            DocumentPurchaseOrder match = (from x in PurchaseOrders where x.Id == result select x).FirstOrDefault();
                            mSelectedPurchaseOrder = match;
                            RaisePropertyChanged("SelectedPurchaseOrder");
                        }
                    }

                    //CheckInOutStatus
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.CheckInOutStatus.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 = "Checked Out";
                        if (filter.Value == "-3") filter.Value = "Checked In";

                        var match = (from x in InOutStatuses where x == filter.Value select x).FirstOrDefault();
                        mSelectedInOutStatus = match;
                        RaisePropertyChanged("SelectedInOutStatus");
                    }

                    //Version
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.Version.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            var match = (from x in DocumentVersionFilters where x.Id == result select x).FirstOrDefault();
                            mSelectedDocumentVersionFilter = match;
                            RaisePropertyChanged("SelectedDocumentVersionFilter");

                        }
                    }
                }
            }

            ProcessSearchFilter();
        }
        private SearchFilterList BuildFiltersFromControls(SearchFilterList searchFilterList)
        {
            searchFilterList.SearchFilters.Clear();

            //KEYWORDS
            var searchFilterKeyWords = new SearchFilter { Name = CommonUtils.MechanicalSearchFilterNames.KeyWord.ToString(), };
            if (!string.IsNullOrEmpty(mKeyword))
            {
                searchFilterKeyWords.Value = mKeyword.Trim();
            }
            else
            {
                searchFilterKeyWords.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(searchFilterKeyWords);

            //MaintSystemId
            var maintSystIdFilter = new SearchFilter { Name = CommonUtils.MechanicalSearchFilterNames.MaintSystemId.ToString(), };
            if (!string.IsNullOrEmpty(mMainSystId))
            {
                maintSystIdFilter.Value = mMainSystId.Trim();
            }
            else
            {
                maintSystIdFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(maintSystIdFilter);

            //Area
            var areaFilterKeyWords = new SearchFilter { Name = CommonUtils.MechanicalSearchFilterNames.Area.ToString(), };
            if (mSelectedArea != null && mSelectedArea.Name != All)
            {
                areaFilterKeyWords.Value = mSelectedArea.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                areaFilterKeyWords.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(areaFilterKeyWords);

            //SubArea
            var subAreaFilter = new SearchFilter { Name = CommonUtils.MechanicalSearchFilterNames.SubArea.ToString(), };
            if (mSelectedSubArea != null && mSelectedSubArea.Name != All)
            {
                subAreaFilter.Value = mSelectedSubArea.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                subAreaFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(subAreaFilter);

            //Type
            var typeFilter = new SearchFilter { Name = CommonUtils.MechanicalSearchFilterNames.Type.ToString(), };
            if (mSelectedEquipmentType != null && mSelectedEquipmentType.Name != All)
            {
                typeFilter.Value = mSelectedEquipmentType.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                typeFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(typeFilter);

            //PidDocument
            var pidFilter = new SearchFilter { Name = CommonUtils.MechanicalSearchFilterNames.PidDocument.ToString(), };
            if (mSelectedPAndIdDocument != null && mSelectedPAndIdDocument.Name != All)
            {
                pidFilter.Value = mSelectedPAndIdDocument.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                pidFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(pidFilter);

            //Specification
            var specDocumentFilter = new SearchFilter { Name = CommonUtils.MechanicalSearchFilterNames.Specification.ToString(), };
            if (mSelectedSpecificationDocument != null && mSelectedSpecificationDocument.Name != All)
            {
                specDocumentFilter.Value = mSelectedSpecificationDocument.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                specDocumentFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(specDocumentFilter);

            //ComponentType
            var componentTypeFilter = new SearchFilter { Name = CommonUtils.MechanicalSearchFilterNames.ComponentType.ToString(), };
            if (mSelectedComponentType != null && mSelectedComponentType.Name != All)
            {
                componentTypeFilter.Value = mSelectedComponentType.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                componentTypeFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(componentTypeFilter);

            //Classified
            var classifiedFilter = new SearchFilter { Name = CommonUtils.MechanicalSearchFilterNames.Classified.ToString(), };
            if (mSelectedClassified != null && mSelectedClassified != All)
            {
                classifiedFilter.Value = mSelectedClassified;
            }
            else
            {
                classifiedFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(classifiedFilter);

            //Manufacturer
            var manufacturerFilter = new SearchFilter { Name = CommonUtils.MechanicalSearchFilterNames.Manufacturer.ToString(), };
            if (mSelectedManufacturer != null && mSelectedManufacturer.Name != All)
            {
                manufacturerFilter.Value = mSelectedManufacturer.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                manufacturerFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(manufacturerFilter);

            //Model
            var modelFilter = new SearchFilter { Name = CommonUtils.MechanicalSearchFilterNames.Model.ToString(), };
            if (mSelectedModel != null && mSelectedModel.Name != All)
            {
                modelFilter.Value = mSelectedModel.Id.ToString(CultureInfo.CurrentCulture);
            }
            else
            {
                modelFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(modelFilter);

            //IsActive
            var activeFilter = new SearchFilter { Name = CommonUtils.MechanicalSearchFilterNames.IsActive.ToString(), };
            if (mSelectedIsActive != null && mSelectedIsActive != All)
            {
                activeFilter.Value = mSelectedIsActive;
            }
            else
            {
                activeFilter.Value = string.Empty;
            }
            searchFilterList.SearchFilters.Add(activeFilter);

            return searchFilterList;
        }
 public void SaveCurrentSearchValuesToSelectedFilterList(SearchFilterList searchFilterList)
 {
     Model.SaveCurrentSearchValuesToSelectedFilterList(searchFilterList);
 }
Esempio n. 19
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();
        }
Esempio n. 20
0
        public void SaveCurrentSearchValuesToSelectedFilterList(SearchFilterList searchFilterList)
        {
            if (SelectedSearchFilterList == null) return;

            foreach (SearchFilter searchFilter in searchFilterList.SearchFilters)
            {
                SearchFilter match = (from x in SelectedSearchFilterList.SearchFilters
                                      where x.Name.Equals(searchFilter.Name, StringComparison.CurrentCultureIgnoreCase)
                                      select x).FirstOrDefault();

                if (match != null)
                {
                    match.Value = searchFilter.Value;
                }
            }

            var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            cmsWebServiceClient.SaveTabSearchFilterListCompleted += (s, e) =>
            {
                if (e.Result.HasErrors)
                {
                    var errorDialog = new PopupDialog(PopupDialogType.Error,
                        Utils.DisplayErrorMessages(e.Result.ServerErrorMessages));
                    errorDialog.Show();
                    return;
                }

                SelectedSearchFilterList = e.Result.EntityResult;

            };
            cmsWebServiceClient.SaveTabSearchFilterListAsync(SelectedSearchFilterList);
        }