public AddEditControlSystemComponentTypeViewModel(ControlSystemComponentType mct) { mControlSystemComponentType = mct; OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModifyConfig); CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true); }
public AddEditControlSystemComponentTypeDialog() { InitializeComponent(); mControlSystemComponentType = new ControlSystemComponentType(); model = new AddEditControlSystemComponentTypeViewModel(mControlSystemComponentType); model.View = this; DataContext = model; Utils.ResetOriginalValues(this); }
public AddEditExistingControlSystemComponentTypeTestingPropertyViewModel(ControlSystemComponentType controlSystemEquipmentComponentType, int? groupId) { //ADDING mGroupId = groupId; mComponentTypeId = controlSystemEquipmentComponentType.Id; OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModify); CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true); PropertyComboEnabled = true; GroupComboEnabled = true; LoadAddingData(controlSystemEquipmentComponentType.Id); }
public AddEditExistingControlSystemComponentAlarmPropertyDialog(ControlSystemComponentType controlSystemComponentType) { InitializeComponent(); var model = new AddEditExistingControlSystemComponentAlarmPropertyViewModel(controlSystemComponentType); model.Loaded += () => { model.View = this; DataContext = model; Utils.ResetOriginalValues(this); }; }
public AddEditExistingControlSystemComponentPropertyDialog(ControlSystemComponentType pcpt, int? groupId) { InitializeComponent(); AddEditExistingControlSystemComponentPropertyViewModel model = new AddEditExistingControlSystemComponentPropertyViewModel(pcpt, groupId); model.Loaded += () => { model.View = this; DataContext = model; Utils.ResetOriginalValues(this); }; }
public AddEditExistingControlSystemComponentAlarmPropertyViewModel(ControlSystemComponentType controlSystemEquipmentComponentType) { //new mControlSystemComponentTypeAlarmProperty = new ControlSystemComponentTypeAlarmProperty { ComponentTypeId = controlSystemEquipmentComponentType.Id }; OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModify); CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true); CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); Properties = new List<ControlSystemAlarmProperty>(); //Load Component types EventHandler<GetAllControlSystemAlarmPropertiesCompletedEventArgs> getAllControlSystemAlarmPropertiesCompleted = (s, allEventArgs) => { cmsWebServiceClient.GetControlSystemComponentTypeAlarmPropertiesCompleted += (s1, e1) => { List<int> listOfAssignedPropertyIds = new List<int>(); e1.Result.ForEach(x => listOfAssignedPropertyIds.Add(x.AlarmPropertyId)); foreach (var componentProperty in allEventArgs.Result) { if (!listOfAssignedPropertyIds.Contains(componentProperty.Id)) { Properties.Add(componentProperty); } } if (Properties.Count > 0) { mControlSystemComponentTypeAlarmProperty.AlarmPropertyId = Properties[0].Id; mControlSystemComponentTypeAlarmProperty.ControlSystemAlarmProperty = Properties[0]; } Loaded(); }; cmsWebServiceClient.GetControlSystemComponentTypeAlarmPropertiesAsync(controlSystemEquipmentComponentType.Id); }; cmsWebServiceClient.GetAllControlSystemAlarmPropertiesCompleted += getAllControlSystemAlarmPropertiesCompleted; cmsWebServiceClient.GetAllControlSystemAlarmPropertiesAsync(); }
public ControlSystemComponentType AddControlSystemComponentType(ControlSystemComponentType controlSystemComponentType) { var newControlSystemComponentType = new ControlSystemComponentType(); using (var cee = new CmsEntities()) { //Check if this component type already exist var componentType = (from x in cee.ControlSystemComponentTypes where x.Id == controlSystemComponentType.Id select x).FirstOrDefault(); if (componentType != null) { //Edit the Component Type componentType.Name = controlSystemComponentType.Name; componentType.Description = controlSystemComponentType.Description; componentType.Ordinal = controlSystemComponentType.Ordinal; cee.SaveChanges(); } else { //Add new Component Type componentType = new ControlSystemComponentType(); componentType.Name = controlSystemComponentType.Name; componentType.Description = controlSystemComponentType.Description; componentType.Code = controlSystemComponentType.Name.Replace(" ", ""); componentType.IsActive = true; cee.ControlSystemComponentTypes.Add(componentType); cee.SaveChanges(); } newControlSystemComponentType.Id = componentType.Id; newControlSystemComponentType.Name = componentType.Name; newControlSystemComponentType.Description = componentType.Description; newControlSystemComponentType.Ordinal = componentType.Ordinal; newControlSystemComponentType.Code = componentType.Code; return newControlSystemComponentType; } }
public AddEditExistingControlSystemComponentPropertyViewModel(ControlSystemComponentType controlSystemEquipmentComponentType, int? groupId) { //Adding PropertyComboEnabled = true; GroupComboEnabled = true; mGroupId = groupId; mComponentTypeId = controlSystemEquipmentComponentType.Id; OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModify); CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true); var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); Properties = new List<ControlSystemProperty>(); //Load Component types EventHandler<GetAllControlSystemPropertiesCompletedEventArgs> fetchCompleted = (s, eventArgs) => { var getControlSystemPropertiesTask = DatabaseLoader.GetControlSystemProperties(controlSystemEquipmentComponentType.Id); var getControlSystemComponentTypeGroupsTask = DatabaseLoader.GetControlSystemComponentTypeGroups( CommonUtils.EquipmentPropertyType.ControlEngineeringProperty, controlSystemEquipmentComponentType.Id); var tasks = new List<Task> {getControlSystemPropertiesTask, getControlSystemComponentTypeGroupsTask}; Task.Factory.ContinueWhenAll(tasks.ToArray(), xx => { CMS.UiFactory.StartNew(() => { Groups = getControlSystemComponentTypeGroupsTask.Result; Groups.Insert(0, new ComponentTypeGroup {Name = "Null"}); var listOfAssignedPropertyIds = new List<int>(); getControlSystemPropertiesTask.Result.ForEach(x => listOfAssignedPropertyIds.Add(x.Id)); foreach (var componentProperty in eventArgs.Result) { if (!listOfAssignedPropertyIds.Contains(componentProperty.Id)) { Properties.Add(componentProperty); } } if (Properties.Count > 0) SelectedProperty = Properties[0]; if (Groups.Count > 0) { if (groupId.HasValue) { Group = Groups.FirstOrDefault(x => x.Id == groupId.Value); GroupComboEnabled = false; } else { Group = Groups[0]; } OriginalSelectedGroup = Group; } Loaded(); }); }); cmsWebServiceClient.GetControlSystemPropertiesAsync(controlSystemEquipmentComponentType.Id); }; cmsWebServiceClient.GetAllControlSystemPropertiesCompleted += fetchCompleted; cmsWebServiceClient.GetAllControlSystemPropertiesAsync(); }
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); }); }); }
private bool MatchComponentTypeFailed(CmsEntities cee, OldCmsEntities old, Alarm oldAlarm, out ControlSystemComponentType matchedComponentType) { matchedComponentType = null; var element = (from x in old.Elements.Include("ElementTypical") where x.Id == oldAlarm.ElementId select x).FirstOrDefault(); if (element == null) { Logger.Out(string.Format("MatchComponentTypeFailed on Alarm ID {0}:- failed to match 'Element' on ID '{1}'.", oldAlarm.Id, oldAlarm.ElementId)); return true; } matchedComponentType = (from x in cee.ControlSystemComponentTypes where x.Name.Equals(element.ElementTypical.Name, StringComparison.CurrentCultureIgnoreCase) select x).FirstOrDefault(); if (matchedComponentType == null) { Logger.Out(string.Format("MatchComponentTypeFailed on Alarm ID {0}:- failed to match new CMS 'ControlSystemComponentType' on Name '{1}'.", oldAlarm.Id, oldAlarm.AlarmType)); return true; } return false; }