public AddEditSubAreaDialog(Area area)
        {
            InitializeComponent();
            mSubArea = new Cell {AreaId = area.Id, IsActive = true};
            mSubAreaViewModel = new SubAreaViewModel(mSubArea, this);

            DataContext = mSubAreaViewModel;
        }
        private void ClearControls()
        {
            mKeyword = string.Empty;
            RaisePropertyChanged("Keyword");

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

            mMainSystId = string.Empty;
            RaisePropertyChanged("MainSystId");

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

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

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

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

            mSelectedSpecificationDocument = SpecificationDocuments[0];
            RaisePropertyChanged("SelectedSpecificationDocument");

            mSelectedClassified = Classifieds[0];
            RaisePropertyChanged("Classified");

            mSelectedIsActive = IsActiveChoices[0];
            RaisePropertyChanged("SelectedIsActive");

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

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

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

            mSelectedClassified = Classifieds[0];
            RaisePropertyChanged("SelectedClassified");
        }
        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 void ClearControls()
        {
            mKeyword = string.Empty;
            RaisePropertyChanged("Keyword");

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

            mSelectedDocumentDiscipline = DocumentDisciplines[0];
            RaisePropertyChanged("SelectedDocumentDiscipline");

            mSelectedDocumentType = DocumentTypes[0];
            RaisePropertyChanged("SelectedDocumentType");

            mSelectedPurchaseOrder = PurchaseOrders[0];
            RaisePropertyChanged("SelectedPurchaseOrder");

            mSelectedDocumentAuthor = Authors[0];
            RaisePropertyChanged("SelectedDocumentAuthor");

            mSelectedDocumentVersionFilter = DocumentVersionFilters[0];
            RaisePropertyChanged("SelectedDocumentVersionFilter");

            mSelectedInOutStatus = InOutStatuses[0];
            RaisePropertyChanged("SelectedInOutStatus");

            mSelectedDocumentStatus = DocumentStatuses[0];
            RaisePropertyChanged("SelectedDocumentStatus");

            mSelectedDocumentLocation = DocumentLocations[0];
            RaisePropertyChanged("SelectedDocumentLocation");
        }
        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 void LoadData()
        {
            //AREAS
            mAreas = new List<Area>(from x in CMS.Cache.Areas
                                    where x.IsActive && x.SiteId == CMS.AppSetting.DefaultSiteId
                                    select x);
            mAreas.Insert(0, new Area { Id = -1, Name = All });
            mSelectedArea = Areas[0];

            //SubAreas
            LoadSubAreasFromCache(true);

            var specificationDocumentsTask = DatabaseLoader.GetQuickDocuments(CommonUtils.DoctypeFuncspecCode);
            var getQuickControlSystemInterlocksTask = DatabaseLoader.GetQuickControlSystemInterlocks();
            var getQuickControlSystemTypesTask = DatabaseLoader.GetQuickControlSystemTypes();
            var getUpperEquipmentsTask = DatabaseLoader.GetUpperEquipments();

            List<Task> tasks = new List<Task>();

            tasks.Add(specificationDocumentsTask);
            tasks.Add(getQuickControlSystemTypesTask);
            tasks.Add(getUpperEquipmentsTask);
            tasks.Add(getQuickControlSystemInterlocksTask);

            Task.Factory.ContinueWhenAll(tasks.ToArray(), x =>
            {
                CMS.UiFactory.StartNew(() =>
                {

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

                    mEquipmentTypes = getQuickControlSystemTypesTask.Result;
                    mEquipmentTypes.Insert(0, new QuickControlSystemType { Id = -1, Name = All });
                    mSelectedEquipmentType = mEquipmentTypes[0];
                    RaisePropertyChanged("EquipmentTypes");
                    RaisePropertyChanged("SelectedEquipmentType");

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

                    mQuickInterlocks = getQuickControlSystemInterlocksTask.Result;

                    ProcessSearchFilter();

                });
            });
        }
        private void LoadData()
        {
            var getQuickControlSystemsTask = DatabaseLoader.GetQuickControlSystems(new EquipmentFilterObject());
            var specificationDocumentsTask = DatabaseLoader.GetQuickDocuments(CommonUtils.DoctypeFuncspecCode);
            var getUpperEquipmentsTask = DatabaseLoader.GetUpperEquipments();
            var getQuickControlSystemTypesTask = DatabaseLoader.GetQuickControlSystemTypes();

            List<Task> tasks = new List<Task>
            {
                getQuickControlSystemsTask,
                specificationDocumentsTask,
                getUpperEquipmentsTask,
                getQuickControlSystemTypesTask
            };

            Task.Factory.ContinueWhenAll(tasks.ToArray(), x =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    SpecificationDocuments = specificationDocumentsTask.Result;
                    SpecificationDocuments.Insert(0, new QuickDocument {Id = -1, Name = "All"});
                    mSelectedFunctionalSpec = SpecificationDocuments[0];
                    RaisePropertyChanged("SpecificationDocuments");
                    RaisePropertyChanged("SelectedFunctionalSpecification");

                    ControlSystemTypes = getQuickControlSystemTypesTask.Result;
                    ControlSystemTypes.Insert(0, new QuickControlSystemType {Id = -1, Name = "All"});
                    mSelectedControlSystemType = ControlSystemTypes[0];
                    RaisePropertyChanged("ControlSystemTypes");
                    RaisePropertyChanged("SelectedControlSystemType");

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

                    ControlSystems = (from c in getQuickControlSystemsTask.Result where c.IsActive select c).ToList();
                    RaisePropertyChanged("ControlSystems");

                    //Area
                    Areas = new List<Area>();
                    Areas.AddRange(CMS.Cache.Areas);
                    Areas.Insert(0, new Area {Id = -1, Name = "All"});
                    mSelectedArea = Areas[0];
                    RaisePropertyChanged("Areas");
                    RaisePropertyChanged("SelectedArea");

                    //Cells
                    LoadCellsFromCache();
                    RaisePropertyChanged("SelectedCell");

                    Utils.ResetOriginalValues(View);
                });
            });
        }
        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();
        }
        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");
            }
        }
        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();
        }
        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);
                });
            });
        }
Esempio n. 12
0
        void cmsWebServiceClient_GetDocumentsAndRelatedObjectsCompleted(object sender, GetDocumentsAndRelatedObjectsCompletedEventArgs e)
        {
            var documnetRelatedObjects = e.Result;

            mAreas = documnetRelatedObjects.Areas;
            mAreas.Insert(0, new Area { Id = -1, Name = "All" });
            mSelectedArea = mAreas[0];

            mInOutStatuses = new List<string>();
            mInOutStatuses.Add("All");
            mInOutStatuses.Add("Checked In");
            mInOutStatuses.Add("Checked Out");
            mSelectedInOutStatus = mInOutStatuses[0];

            mDocumentAuthors = documnetRelatedObjects.Authors;
            mDocumentAuthors.Insert(0, new DocumentAuthor { Id = -1, Name = "All" });
            mSelectedDocumentAuthor = mDocumentAuthors[0];

            mDocumentTypes = documnetRelatedObjects.DocumentTypes;
            mDocumentTypes.Insert(0, new DocumentType { Id = -1, Name = "All" });
            mSelectedDocumentType = mDocumentTypes[0];

            mFileTypes = new List<string>();
            mFileTypes.Add("All");
            mFileTypes.Add("PDF");
            mFileTypes.Add("Native");
            mSelectedFileType = mFileTypes[0];

            mDocumentStatuses = new List<string>();
            mDocumentStatuses.Add("All");
            mDocumentStatuses.Add("Active");
            mDocumentStatuses.Add("Disabled");
            mSelectedDocumentStatus = mDocumentStatuses[0];

            List<DocumentAuthor> versions = new List<DocumentAuthor>();

            versions.Add(new DocumentAuthor { Id = (int)CommonUtils.DocumentVersionFilter.All, Name = "All" });
            versions.Add(new DocumentAuthor { Id = (int)CommonUtils.DocumentVersionFilter.Latest, Name = "Latest" });
            versions.Add(new DocumentAuthor { Id = (int)CommonUtils.DocumentVersionFilter.RequireDrafting, Name = "Requires Drafting" });
            versions.Add(new DocumentAuthor { Id = (int)CommonUtils.DocumentVersionFilter.NoVersions, Name = "No Versions Exist" });
            versions.Add(new DocumentAuthor { Id = (int)CommonUtils.DocumentVersionFilter.NoNativeExist, Name = "No Native Exist" });
            versions.Add(new DocumentAuthor { Id = (int)CommonUtils.DocumentVersionFilter.NoPdfExist, Name = "No PDF Exist" });

            mFilterDocumentVersions = versions;
            mSelectedFilterDocumentVersion = versions[0];

            View.KeywordTextBox.KeyUp += (s1, e1) => ProcessSearchFilter();
            RelatedObjectLoaded = true;
            RaiseLoaded();
        }
Esempio n. 13
0
        private void LoadData()
        {
            var getQuickControlSystemsTask = DatabaseLoader.GetQuickControlSystems(new EquipmentFilterObject());
            var getQuickControlSystemInterlocksTask = DatabaseLoader.GetQuickControlSystemInterlocks();
            var specificationDocumentsTask = DatabaseLoader.GetQuickDocuments(CommonUtils.DoctypeFuncspecCode);
            var getUpperEquipmentsTask = DatabaseLoader.GetUpperEquipments();
            var getQuickControlSystemTypesTask = DatabaseLoader.GetQuickControlSystemTypes();

            var tasks = new List<Task> {
                getQuickControlSystemsTask,
                getQuickControlSystemInterlocksTask,
                specificationDocumentsTask,
                getUpperEquipmentsTask,
                getQuickControlSystemTypesTask,
                getQuickControlSystemInterlocksTask
            };

            Task.Factory.ContinueWhenAll(tasks.ToArray(), x =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    SpecificationDocuments = specificationDocumentsTask.Result;

                    var alllDocs = new QuickDocument { Id = -1, Name = ALL };
                    SpecificationDocuments.Insert(0, alllDocs);
                    mSelectedFunctionalSpec = alllDocs;
                    RaisePropertyChanged("SpecificationDocuments");
                    RaisePropertyChanged("SelectedFunctionalSpecification");

                    ControlSystemTypes = getQuickControlSystemTypesTask.Result;

                    var allControlSys = new QuickControlSystemType { Id = -1, Name = ALL };
                    ControlSystemTypes.Insert(0, allControlSys);
                    mSelectedControlSystemType = allControlSys;
                    RaisePropertyChanged("ControlSystemTypes");
                    RaisePropertyChanged("SelectedControlSystemType");

                    var allUpper = new UpperEquipment { Name = ALL };
                    mUpperEquipments = new List<UpperEquipment>();
                    mMasterListUpperEquipments = new List<UpperEquipment>();
                    mUpperEquipments.AddRange(getUpperEquipmentsTask.Result);
                    mMasterListUpperEquipments.AddRange(getUpperEquipmentsTask.Result);

                    mUpperEquipments.Insert(0, allUpper);
                    //mMasterListUpperEquipments.Insert(0, allUpper);

                    mSelectedUpperEquipment = allUpper;
                    RaisePropertyChanged("UpperEquipments");
                    RaisePropertyChanged("SelectedUpperEquipment");

                    ControlSystems = getQuickControlSystemsTask.Result;
                    RaisePropertyChanged("ControlSystems");

                    mQuickInterlocks = getQuickControlSystemInterlocksTask.Result;

                    //Area
                    Areas = new List<Area>();
                    Areas.AddRange(CMS.Cache.Areas);
                    var allArea = new Area { Id = -1, Name = ALL };
                    Areas.Insert(0, allArea);

                    mSelectedArea = allArea;
                    RaisePropertyChanged("Areas");
                    RaisePropertyChanged("SelectedArea");

                    //Cells
                    var allCells = new Cell { Id = -1, Name = ALL };
                    mCells = new List<Cell>();
                    mMasterListCells = new List<Cell>();

                    mCells.AddRange(CMS.Cache.SubAreas);
                    mMasterListCells.AddRange(CMS.Cache.SubAreas);

                    mCells.Insert(0, allCells);
                    //mMasterListCells.Insert(0, allCells);

                    mSelectedCell = allCells;
                    RaisePropertyChanged("Cells");
                    RaisePropertyChanged("SelectedCell");

                    Utils.ResetOriginalValues(View);

                    IsGridBusy = false;
                    RaisePropertyChanged("IsGridBusy");
                });
            });
        }
Esempio n. 14
0
        private bool GetArea(Worksheet worksheet, string area, Pipe newPipe, int rowIndex)
        {
            bool skipRow = false;

            if (!string.IsNullOrEmpty(area))
            {
                //Check if the Area exist in the database
                Area pipeArea = mPipeRelatedObjects.Areas.Where(x => x.AreaNumber.ToString() == area.Trim()).FirstOrDefault();
                if (pipeArea != null)
                {
                    newPipe.AreaId = pipeArea.Id;
                }
                else
                {
                    int intArea = 0;

                    if (Int32.TryParse(area, out intArea))
                    {
                        //Add new pipe area to the database
                        pipeArea = new Area();
                        pipeArea.Name = area;
                        pipeArea.AreaNumber = intArea;


                        mCee.Areas.AddObject(pipeArea);
                        mCee.SaveChanges();

                        mPipeRelatedObjects.Areas.Add(pipeArea);

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

                        newPipe.AreaId = pipeArea.Id;
                    }
                    else
                    {
                        RaiseMessage(MessageType.Error, string.Format("WorkSheet '{0}' Line '{1}': Could not convert area '{2}' to integer. Skipping this row.", worksheet.Name, rowIndex, area));

                        skipRow = true;
                    }
                }
            }
            else
            {
                RaiseMessage(MessageType.Warning, string.Format("WorkSheet '{0}' Line '{1}': Area is empty. Skipping this row.", worksheet.Name, rowIndex));

                skipRow = true;
            }
            return skipRow;
        }
Esempio n. 15
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");
        }
Esempio n. 16
0
        public void ImportMechanicalEquipment()
        {
            mForm.AddMessage(MessageType.Info, "-------------------- Importing ImportMechanicalEquipment --------------------");
            List<MechEquipment> mechEquipments = (from x in mOldIssuesDataContext.MechEquipments select x).ToList();

            //for (int i = 1; i < 10000; i++)
            //{

            //    CmsEquipmentDatabase.Web.DataModel.CmsEquipment.MobilePlant newMechanicalEquipment = new CmsEquipmentDatabase.Web.DataModel.CmsEquipment.MobilePlant()
            //    {

            //        Tag = "Mechanical Equipment " + i,
            //        //EllipseId = mechEquipment.Name,
            //        MobileTypeId =  new Random().Next(1,3),
            //        OwnerId = new Random().Next(1,6),
            //        AreaId = new Random().Next(1, 38),
            //        HirerId = new Random().Next(1, 5),
            //        Description = "Description " + i,
            //        Notes = "Notes " + i
            //    };
            //    mCee.MobilePlants.AddObject(newMechanicalEquipment);
            //}
            //mCee.SaveChanges();
            //return;

            foreach (var mechEquipment in mechEquipments)
            {
                string[] nameItems = mechEquipment.Name.Split('-');
                if (nameItems.Count() > 2)
                {

                    string areaString = nameItems[1];
                    int areaId = Int32.Parse(areaString);

                    var area = (from x in mCee.Areas where x.AreaNumber == areaId select x).FirstOrDefault();

                    if (area == null)
                    {
                        area = new Area {Name = areaString, AreaNumber = areaId, SiteId = 1};
                        mCee.Areas.AddObject(area);
                        mCee.SaveChanges();
                    }

                    string newName = String.Empty;
                    if (nameItems.Count() == 5)
                    {
                        newName = String.Format("{1}-{2}-{3}-{4}", nameItems[0], nameItems[1], nameItems[2], nameItems[3], nameItems[4]);
                    }
                    else if( nameItems.Count() == 4 )
                    {
                        newName =String.Format("{1}-{2}-{3}", nameItems[0], nameItems[1], nameItems[2], nameItems[3]);
                    }
                    else if( nameItems.Count() == 3 )
                    {
                        newName = String.Format("{1}-{2}", nameItems[0], nameItems[1], nameItems[2]);
                    }
                    else
                    {

                    }

                    MechanicalEquipment newMechanicalEquipment = new MechanicalEquipment()
                                                                     {
                                                                         Name = newName,
                                                                         EllipseId = mechEquipment.Name,
                                                                         MechEquipmentTypeId = (from x in mCee.MechanicalEquipmentTypes
                                                                                                where String.Compare(x.Name, mechEquipment.MechEquipmentCategory.Name, 0) == 0
                                                                                                select x.Id).FirstOrDefault(),
                                                                         AreaId = area.Id,
                                                                         Description = mechEquipment.Description,
                                                                         Notes = mechEquipment.Notes
                                                                     };

                    var mechanicalEquipmentExist = (from x in mCee.MechanicalEquipments where String.Compare(x.Name, newMechanicalEquipment.Name, true) == 0 select x).FirstOrDefault();

                    if (mechanicalEquipmentExist == null)
                    {
                        string message = String.Format("Adding Mechanical Equipment '{0}'", newMechanicalEquipment.Name);
                        mForm.AddMessage(MessageType.Info, message);
                        mCee.MechanicalEquipments.AddObject(newMechanicalEquipment);
                        mCee.SaveChanges();
                    }
                    else
                    {
                        string message = String.Format("Mechanical Equipment '{0}' already exist, skipping", mechanicalEquipmentExist.Name);
                        mForm.AddMessage(MessageType.Warning, message);
                    }
                }
                else
                {
                    string message = String.Format("Mechanical Equipment '{0}' doesnt have corrent name, skipping", mechEquipment.Name);
                    mForm.AddMessage(MessageType.Error, message);
                }
            }

            mCee.SaveChanges();
        }
Esempio n. 17
0
 private void LoadAreas()
 {
     List<Area> list = new List<Area>();
     list.AddRange(CMS.Cache.Areas);
     list.Insert(0, new Area { Id = -1, Name = "All" });
     Areas = new List<Area>(list);
     mSelectedArea = Areas[0];
     RaisePropertyChanged("Areas");
 }
Esempio n. 18
0
        public void ImportDocuments()
        {
            mForm.AddMessage(MessageType.Info, "-------------------- Importing Documents --------------------");
            List<Document> documents = (from x in mOldIssuesDataContext.Documents select x).ToList();
            var authors = ( from x in mCee.DocumentAuthors select x).ToList();

            foreach (Document document in documents)
            {
                if (!String.IsNullOrEmpty(document.Name))
                {
                    int areaId = Int32.Parse(document.Area);

                    var area = (from x in mCee.Areas where x.AreaNumber == areaId select x).FirstOrDefault();

                    if (area == null)
                    {
                        area = new Area {Name = document.Area, AreaNumber = areaId, SiteId = 1};
                        mCee.Areas.AddObject(area);
                        mCee.SaveChanges();
                    }

                    var documentExist = (from x in mCee.Documents where x.Name == document.Name select x).FirstOrDefault();

                    if (documentExist == null)
                    {
                        CmsEquipmentDatabase.CmsWebService.Document newDocument = new CmsEquipmentDatabase.CmsWebService.Document()
                        {
                            Name = document.Name,
                            Description = document.Description,
                            DocumentTypeId = (from x in  mCee.DocumentTypes where x.Name == document.DocumentType.Name select x).FirstOrDefault().Id,
                            AreaId = area.Id,
                            DocumentAuthorId = (from x in authors where x.Name == document.Author select x.Id).FirstOrDefault()
                        };

                        string message = String.Format("Adding Document '{0}'", newDocument.Name);
                        mForm.AddMessage(MessageType.Info, message);
                        mCee.Documents.AddObject(newDocument);
                        mCee.SaveChanges();
                    }
                    else
                    {
                        documentExist.AreaId = area.Id;
                        string message = String.Format("Document '{0}' already exist, skipping", document.Name);
                        mForm.AddMessage(MessageType.Warning, message);
                    }
                }
                else
                {
                    string message = String.Format("Document name '{0}' not valid, skipping", document.Name);
                    mForm.AddMessage(MessageType.Warning, message);
                }
            }
            mCee.SaveChanges();
        }
Esempio n. 19
0
 public AreaViewModel(Area Area, AddEditAreaDialog view)
 {
     mArea = Area;
     mView = view;
     OriginalAreaNumber = mArea.AreaNumber.ToString();
 }
 private void PopulateAreas()
 {
     List<Area> areas = (from x in CMS.Cache.Areas where x.IsActive && x.SiteId == CMS.AppSetting.DefaultSiteId select x).ToList();
     var noSelection = new Area { Id = -99, Description = string.Empty, Name = string.Empty };
     areas.Insert(0, noSelection);
     Areas =areas;
     RaisePropertyChanged("Areas");
     RaisePropertyChanged("SelectedArea");
 }