コード例 #1
0
        public AddEditMechanicalComponentTypeViewModel(MechanicalEquipmentComponentType mct)
        {
            mMechanicalEquipmentComponentType = mct;

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModifyConfig);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);
        }
コード例 #2
0
 public AddEditMechanicalComponentTypeDialog()
 {
     InitializeComponent();
     mMechanicalEquipmentComponentType = new MechanicalEquipmentComponentType();
     viewModel = new AddEditMechanicalComponentTypeViewModel(mMechanicalEquipmentComponentType);
     viewModel.View = this;
     DataContext = viewModel;
 }
コード例 #3
0
 public AddEditMechanicalComponentTypeDialog(MechanicalEquipmentComponentType mc)
 {
     InitializeComponent();
     Title = "Edit Mechanical Component Type";
     mMechanicalEquipmentComponentType = mc;
     viewModel = new AddEditMechanicalComponentTypeViewModel(mMechanicalEquipmentComponentType);
     viewModel.View = this;
     DataContext = viewModel;
     Utils.ResetOriginalValues(this);
 }
        public AddEditExistingMechanicalComponentPropertyDialog(MechanicalEquipmentComponentType pcpt)
        {
            InitializeComponent();

            AddEditExistingMechanicalComponentPropertyViewModel viewModel =
                new AddEditExistingMechanicalComponentPropertyViewModel(pcpt);
            viewModel.Loaded +=
                () =>
                {
                    viewModel.View = this;
                    DataContext = viewModel;
                };
        }
        public AddEditExistingMechanicalComponentPropertyViewModel(MechanicalEquipmentComponentType mect)
        {
            mComponentTypeId = mect.Id;
            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanAdd);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            Properties = new List<MechanicalEquipmentProperty>();

            //Load Component types
            EventHandler<GetAllMechanicalEquipmentPropertiesCompletedEventArgs> fetchCompleted = null;
            fetchCompleted = (s, eventArgs) =>
            {
                cmsWebServiceClient.GetMechanicalEquipmentPropertiesCompleted +=
                    (s1, e1)
                    =>
                    {
                        List<int> listOfAssignedPropertyIds = new List<int>();
                        e1.Result.ForEach(x => listOfAssignedPropertyIds.Add(x.Id));

                        //Remove already assigned properties
                        foreach (var componentProperty in eventArgs.Result)
                        {
                            if (!listOfAssignedPropertyIds.Contains(componentProperty.Id))
                            {
                                Properties.Add(componentProperty);
                            }
                        }

                        if (Properties.Count > 0)
                        {
                            SelectedProperty = Properties[0];
                        }
                        Loaded();
                    };

                cmsWebServiceClient.GetMechanicalEquipmentPropertiesAsync(mect.Id);

            };
            cmsWebServiceClient.GetAllMechanicalEquipmentPropertiesCompleted += fetchCompleted;
            cmsWebServiceClient.GetAllMechanicalEquipmentPropertiesAsync();
        }
コード例 #6
0
        /// <summary>
        ///   Add/Edit the Mechanical Component Type
        /// </summary>
        /// <param name = "mect"></param>
        /// <returns></returns>
        public MechanicalEquipmentComponentType AddMechanicalComponentType(MechanicalEquipmentComponentType mect)
        {
            MechanicalEquipmentComponentType newMect = new MechanicalEquipmentComponentType();

            using (CmsEntities cee = new CmsEntities())
            {
                //Check if this component type already exist
                MechanicalEquipmentComponentType originalMect = (from x in cee.MechanicalEquipmentComponentTypes
                                                                 where x.Id == mect.Id
                                                                 select x).FirstOrDefault();

                if (originalMect != null)
                {
                    //Edit the Component Type
                    originalMect.Name = mect.Name;
                    originalMect.Description = mect.Description;
                    cee.SaveChanges();
                }
                else
                {
                    //Add new Component Type
                    originalMect = new MechanicalEquipmentComponentType();
                    originalMect.Name = mect.Name;
                    originalMect.Code = mect.Name.Replace(" ", "");
                    originalMect.IsActive = true;
                    originalMect.Description = mect.Description;
                    cee.MechanicalEquipmentComponentTypes.Add(originalMect);

                    cee.SaveChanges();
                }

                newMect.Id = originalMect.Id;
                newMect.Name = originalMect.Name;
                newMect.Description = originalMect.Description;

                return newMect;
            }
        }
コード例 #7
0
        private void SetControlValuesFromSearchFilterList(SearchFilterList searchFilterList)
        {
            mSearchFilterControl.SetFilterIsOn(true);
            ClearControls();

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

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

                    //Classified
                    if (filter.Name.Equals(CommonUtils.MechanicalSearchFilterNames.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.MechanicalSearchFilterNames.Type.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            MechanicalEquipmentType match = (from x in EquipmentTypes where x.Id == result select x).FirstOrDefault();
                            mSelectedEquipmentType = match;
                            RaisePropertyChanged("SelectedEquipmentType");
                        }
                    }

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

                    //IsActive
                    if (filter.Name.Equals(CommonUtils.MechanicalSearchFilterNames.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");

                    }

                    //PidDocument
                    if (filter.Name.Equals(CommonUtils.MechanicalSearchFilterNames.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");
                        }
                    }

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

            ProcessSearchFilter();
        }
コード例 #8
0
        private void LoadData()
        {
            var getMechanicalEquipmentTypesTask = DatabaseLoader.GetMechanicalEquipmentTypes();
            var pidDocumentsTask = DatabaseLoader.GetQuickDocuments(CommonUtils.DoctypePidCode);
            var specificationDocumentsTask = DatabaseLoader.GetQuickDocuments(CommonUtils.DoctypeFuncspecCode);
            var getMechanicalEquipmentComponentTypesTask = DatabaseLoader.GetMechanicalEquipmentComponentTypes();
            var getManufacturersTask = DatabaseLoader.GetManufacturers(CommonUtils.EquipmentTypeCode.MECH);
            var getModelsTask = DatabaseLoader.GetModels(CommonUtils.EquipmentTypeCode.MECH);

            List<Task> tasks = new List<Task>();
            tasks.Add(getMechanicalEquipmentTypesTask);
            tasks.Add(pidDocumentsTask);
            tasks.Add(specificationDocumentsTask);
            tasks.Add(getMechanicalEquipmentComponentTypesTask);
            tasks.Add(getManufacturersTask);

            Task.Factory.ContinueWhenAll(tasks.ToArray(), x =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    //EquipmentType
                    var allItem = new MechanicalEquipmentType { Id = -1, Name = All };
                    EquipmentTypes = getMechanicalEquipmentTypesTask.Result;
                    EquipmentTypes.Insert(0, allItem);
                    mSelectedEquipmentType = EquipmentTypes[0];
                    RaisePropertyChanged("EquipmentTypes");
                    RaisePropertyChanged("SelectedEquipmentType");

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

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

                    //Specification Documents
                    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[0];
                    RaisePropertyChanged("IsActiveChoices");
                    RaisePropertyChanged("SelectedIsActive");

                    //Model
                    mModelsCache = getModelsTask.Result;

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

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

            LoadAreas();
            LoadSubAreas();
        }
コード例 #9
0
        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");
        }
コード例 #10
0
        private bool GetMechanicalEquipmentComponentType(string typeName, MechanicalEquipmentComponent component, int rowIndex)
        {
            MechanicalEquipmentComponentType componentType = (from x in mExistingEquipmentComponentTypes
                where string.Compare(typeName, x.Name, true, CultureInfo.CurrentCulture) == 0
                      && !string.IsNullOrEmpty(x.Name)
                select x).FirstOrDefault();

            if (componentType != null)
            {
                component.MechanicalEquipmentComponentType = componentType;
                component.MechanicalEquipmentComponentTypeId = componentType.Id;
            }
            else
            {
                if (CanCreateProperties)
                {
                    string code = typeName.Replace(" ", "_").ToUpper();
                    componentType = new MechanicalEquipmentComponentType {Name = typeName, Code = code, Description = typeName + " (created by importer)", IsActive = true};
                    mExistingEquipmentComponentTypes.Add(componentType);
                    component.MechanicalEquipmentComponentType = componentType;
                }
                else
                {
                    RaiseMessage(CommonUtils.MessageType.Error, string.Format("WorkSheet '{0}' Line '{1}': Could not find Mechanical EquipmentComponent Type '{2}' in database. Skipping this row.", WorkSheetName, rowIndex, typeName));
                    return true;
                }
            }

            return false;
        }