private void AddExistingInterlockProperty(NodeView nodeView) { var interlockTypeId = nodeView.Id; var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); cmsWebServiceClient.GetInterlockTypeCompleted += (s, e) => { var addEditExistingInterlockProperty = new AddEditExistingInterlockPropertyDialog(e.Result); addEditExistingInterlockProperty.Show(); addEditExistingInterlockProperty.Closed += (s1, e1) => { if (addEditExistingInterlockProperty.DialogResult.HasValue && addEditExistingInterlockProperty.DialogResult.Value) { EventHandler<AddUpdateInterlockTypePropertyCompletedEventArgs> addCompleted = null; addCompleted = (s2, eventArgs) => { var pcpt = eventArgs.Result; if (pcpt != null) { var child = new NodeView(nodeView) { Id = pcpt.Id, Name = addEditExistingInterlockProperty.InterlockTypeProperty.InterlockProperty.Name, Description = addEditExistingInterlockProperty.InterlockTypeProperty.InterlockProperty.Description, Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png", Type = NodeType.InterlockTypeProperty, HasChildren = false, SortField = pcpt.Ordinal.ToString() }; if (nodeView.ChildrenLoaded) { nodeView.Children.Add(child); nodeView.Sort(); } } cmsWebServiceClient.AddUpdateInterlockTypePropertyCompleted -= addCompleted; }; cmsWebServiceClient.AddUpdateInterlockTypePropertyCompleted += addCompleted; var interlockTypeProperty = new InterlockTypeProperty { InterlockTypeId = interlockTypeId, InterlockPropertyId = addEditExistingInterlockProperty.InterlockTypeProperty.InterlockPropertyId, Ordinal = addEditExistingInterlockProperty.InterlockTypeProperty.Ordinal }; cmsWebServiceClient.AddUpdateInterlockTypePropertyAsync(interlockTypeProperty); } }; }; cmsWebServiceClient.GetInterlockTypeAsync(interlockTypeId); }
private void EditInterlockTypeProperty(NodeView nodeView) { var dialog = new AddEditExistingInterlockPropertyDialog(nodeView.Id); dialog.Title = "Edit Interlock Property"; dialog.Closed += (s1, e1) => { if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); EventHandler<AddUpdateInterlockTypePropertyCompletedEventArgs> addCompleted = null; addCompleted = (s2, eventArgs) => { if (eventArgs.Result != null) { nodeView.Name = dialog.InterlockTypeProperty.InterlockProperty.Name; nodeView.Description = dialog.InterlockTypeProperty.InterlockProperty.Description; nodeView.SortField = dialog.InterlockTypeProperty.Ordinal.ToString(); } cmsWebServiceClient.AddUpdateInterlockTypePropertyCompleted -= addCompleted; nodeView.Parent.Sort(); }; cmsWebServiceClient.AddUpdateInterlockTypePropertyCompleted += addCompleted; var interlockTypeProperty = new InterlockTypeProperty { InterlockTypeId = dialog.InterlockTypeProperty.InterlockTypeId, InterlockPropertyId = dialog.InterlockTypeProperty.InterlockPropertyId, Ordinal = dialog.InterlockTypeProperty.Ordinal }; cmsWebServiceClient.AddUpdateInterlockTypePropertyAsync(interlockTypeProperty); } }; dialog.Show(); }