void newOperationDefinitionAction_Triggered(object sender, MMC.SyncActionEventArgs e) { MMC.ScopeNode itemNode = (MMC.ScopeNode)sender; frmItemProperties frm = new frmItemProperties(); frm.application = this.application; frm.item = null; frm.itemType = ItemType.Operation; DialogResult dr = this.SnapIn.Console.ShowDialog(frm); if (dr == DialogResult.OK) { this.Children.Add(new ItemDefinitionScopeNode(frm.item)); //Add relative child in Item Authorizations if opened try { if ( this.Parent != null && this.Parent.Parent != null && this.Parent.Parent.Children.Count >= 3 && this.Parent.Parent.Children[2].Children.Count >= 3 ) { MMC.ScopeNode itemDefinitionsScopeNode = this.Parent; OperationAuthorizationsScopeNode itemAuthorizationsScopeNode = (itemDefinitionsScopeNode.Parent.Children[2].Children[2]) as OperationAuthorizationsScopeNode; if (itemAuthorizationsScopeNode!=null) itemAuthorizationsScopeNode.Children.Add(new ItemAuthorizationScopeNode(frm.item)); } } catch { } /*System.Windows.Forms.Application.DoEvents();*/ } }
void itemDefinitionPropertiesAction_Triggered(object sender, MMC.SyncActionEventArgs e) { frmItemProperties frm = new frmItemProperties(); frm.Text += " - " + this.item.Name; frm.application = this.item.Application; frm.item = this.item; frm.itemType = this.item.ItemType; string oldItemName = this.item.Name; DialogResult dr = this.SnapIn.Console.ShowDialog(frm); /*Application.DoEvents();*/ frm.Dispose(); /*Application.DoEvents();*/ if (dr == DialogResult.OK) { this.Render(); try { try { this.NotifyChanged(); /*Application.DoEvents();*/ } catch { } //Update relative child in Item Authorizations ItemDefinitionsScopeNode itemDefinitionsScopeNode = (ItemDefinitionsScopeNode)this.Parent.Parent; MMC.ScopeNode itemAuthorizationsScopeNode = itemDefinitionsScopeNode.Parent.Children[2]; switch (this.item.ItemType) { case ItemType.Role: if (itemAuthorizationsScopeNode != null && itemAuthorizationsScopeNode.Children.Count >= 1) itemAuthorizationsScopeNode = itemAuthorizationsScopeNode.Children[0]; else return; break; case ItemType.Task: if (itemAuthorizationsScopeNode != null && itemAuthorizationsScopeNode.Children.Count >= 2) itemAuthorizationsScopeNode = itemAuthorizationsScopeNode.Children[1]; else return; break; case ItemType.Operation: if (itemAuthorizationsScopeNode != null && itemAuthorizationsScopeNode.Children.Count >= 3) itemAuthorizationsScopeNode = itemAuthorizationsScopeNode.Children[2]; else return; break; } foreach (ItemAuthorizationScopeNode itemAuthorizationScopeNode in itemAuthorizationsScopeNode.Children) { if (oldItemName == itemAuthorizationScopeNode.Item.Name) { itemAuthorizationScopeNode.Item = this.item; itemAuthorizationScopeNode.RenderItemAuthorizationScopeNode(); break; } } } catch { } /*Application.DoEvents();*/ } }