private void AddExistingComponentTypeTest(NodeView nodeView) { int? groupId = null; var componentTypeId = -1; if (nodeView.Type == NodeType.ComponentTypeGroup) { groupId = nodeView.GroupId; componentTypeId = nodeView.Parent.Parent.Id; } else { componentTypeId = nodeView.Parent.Id; } var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); cmsWebServiceClient.GetControlSystemComponentTypeCompleted += (s, e) => { var dialog = new AddEditExistingComponentTypeTestingPropertyDialog(e.Result, groupId); dialog.Show(); dialog.Closed += (s1, e1) => { if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { EventHandler<AddUpdateControlSystemComponentTypeTestingPropertyCompletedEventArgs> addCompleted = null; addCompleted = (s2, eventArgs) => { var pcpt = eventArgs.Result; if (pcpt != null) { var child = new NodeView(nodeView) { Id = pcpt.Id, Name = dialog.ComponentTypeTestingProperty.ControlSystemComponentTestingProperty.Name, Description = dialog.ComponentTypeTestingProperty.ControlSystemComponentTestingProperty.Description, Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png", Type = NodeType.ComponentTypeTest, HasChildren = false, SortField = groupId.HasValue ? pcpt.GroupOrdinal.ToString() : pcpt.Ordinal.ToString() }; nodeView.Children.Add(child); nodeView.Sort(true); } cmsWebServiceClient.AddUpdateControlSystemComponentTypeTestingPropertyCompleted -= addCompleted; }; cmsWebServiceClient.AddUpdateControlSystemComponentTypeTestingPropertyCompleted += addCompleted; var controlSystemEquipmentComponentTypeProperty = new ControlSystemComponentTypeTestingProperty { ComponentTypeId = componentTypeId, TestPropertyId = dialog.ComponentTypeTestingProperty.TestPropertyId, ComponentTypeGroupId = dialog.ComponentTypeTestingProperty.ComponentTypeGroupId, Ordinal = dialog.ComponentTypeTestingProperty.Ordinal, GroupOrdinal = dialog.ComponentTypeTestingProperty.GroupOrdinal }; if (dialog.GroupChanged) { //Group has changed, reload the Nodes ReloadComponentTypeEquipmentProperties(CommonUtils.EquipmentPropertyType.SystemTestingProperty, nodeView, NodeType.ComponentTypeTests); } cmsWebServiceClient.AddUpdateControlSystemComponentTypeTestingPropertyAsync(controlSystemEquipmentComponentTypeProperty); } }; }; cmsWebServiceClient.GetControlSystemComponentTypeAsync(componentTypeId); }
private void EditComponentTypeTest(NodeView nodeView) { var dialog = new AddEditExistingComponentTypeTestingPropertyDialog(nodeView.Id); dialog.Title = "Edit Component Type Testing Property"; dialog.Closed += (s1, e1) => { if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); EventHandler<AddUpdateControlSystemComponentTypeTestingPropertyCompletedEventArgs> addCompleted = null; addCompleted = (s2, eventArgs) => { var pcpt = eventArgs.Result; if (pcpt != null) { nodeView.Name = dialog.ComponentTypeTestingProperty.ControlSystemComponentTestingProperty.Name; nodeView.Description = dialog.ComponentTypeTestingProperty.ControlSystemComponentTestingProperty.Description; nodeView.SortField = dialog.ComponentTypeTestingProperty.ComponentTypeGroupId.HasValue ? dialog.ComponentTypeTestingProperty.GroupOrdinal.ToString() : dialog.ComponentTypeTestingProperty.Ordinal.ToString(); } cmsWebServiceClient.AddUpdateControlSystemComponentTypeTestingPropertyCompleted -= addCompleted; nodeView.Parent.Sort(); }; cmsWebServiceClient.AddUpdateControlSystemComponentTypeTestingPropertyCompleted += addCompleted; var controlSystemEquipmentComponentTypeProperty = new ControlSystemComponentTypeTestingProperty { Id = dialog.ComponentTypeTestingProperty.Id, ComponentTypeId = dialog.ComponentTypeTestingProperty.ComponentTypeId, TestPropertyId = dialog.ComponentTypeTestingProperty.TestPropertyId, Ordinal = dialog.ComponentTypeTestingProperty.Ordinal, ComponentTypeGroupId = dialog.ComponentTypeTestingProperty.ComponentTypeGroupId, GroupOrdinal = dialog.ComponentTypeTestingProperty.GroupOrdinal }; cmsWebServiceClient.AddUpdateControlSystemComponentTypeTestingPropertyAsync(controlSystemEquipmentComponentTypeProperty); var controlSystemTypeTestingPropertiesNode = nodeView.Parent; if (controlSystemTypeTestingPropertiesNode.Type != NodeType.ComponentTypeTests) { controlSystemTypeTestingPropertiesNode = controlSystemTypeTestingPropertiesNode.Parent; } if (dialog.GroupChanged) { //Group has changed, reload the Nodes ReloadComponentTypeEquipmentProperties(CommonUtils.EquipmentPropertyType.SystemTestingProperty, controlSystemTypeTestingPropertiesNode, NodeType.ComponentTypeTests); } } }; dialog.Show(); }