private void RadMenuItemClicked(object sender, EventArgs e) { var name = ((Telerik.WinControls.RadItem)(sender)).AccessibleDescription; if (name == "DeleteApp") { if (ISE.Framework.Client.Win.Viewer.MessageViewer.ShowAlert("آیا از حذف دامنه مطمئن هستی؟") != DialogResult.OK) { return; } var node = this.radTreeViewResource.SelectedNode; ApplicationDomainDto app = (ApplicationDomainDto)node.Value; if (node.Nodes.Count == 0) { if (view.RemoveAppDomain(app)) { this.radTreeViewResource.Nodes.Remove(node); } } else { ISE.Framework.Client.Win.Viewer.MessageViewer.ShowException("غیر قابل حذف می باشد!"); } } else if (name == "EditApp") { var node = this.radTreeViewResource.SelectedNode; ApplicationDomainDto app = (ApplicationDomainDto)node.Value; UCAppDomainEntry entry = new UCAppDomainEntry(TransMode.EditRecord, app, view); ISE.UILibrary.Utils.UIUtils.SetFrmTrans(entry, "دامنه", FormBorderStyle.FixedDialog); if (entry.DialogResult != DialogResult.OK) { return; } if (view.UpdateAppDomain(app)) { node.Text = app.Title; } } else if (name == "AddAppDomain") { UCAppDomainEntry entry = new UCAppDomainEntry(view); ISE.UILibrary.Utils.UIUtils.SetFrmTrans(entry, "دامنه", FormBorderStyle.FixedDialog); if (entry.DialogResult != DialogResult.OK) { return; } if (view.InsertAppDomain(entry.ApplicationDomain)) { var appNode = CreateApplicationNode(entry.ApplicationDomain); appNode.Value = entry.ApplicationDomain; addContextMenu(appNode, MenuType.AppDomain); this.radTreeViewResource.Nodes.Add(appNode); } } else if (name == "CreateSubmenu") { var node = this.radTreeViewResource.SelectedNode; UCSubMenuEntry entry = new UCSubMenuEntry(); ISE.UILibrary.Utils.UIUtils.SetFrmTrans(entry, "زیر منو", FormBorderStyle.FixedDialog); if (entry.DialogResult != DialogResult.OK) { return; } if (node.Value is ApplicationDomainDto) { var val = (ApplicationDomainDto)node.Value; entry.SecurityResource.AppDomainId = val.ApplicationDomainId; } else if (node.Value is SecurityResourceDto) { var val = (SecurityResourceDto)node.Value; entry.SecurityResource.AppDomainId = val.AppDomainId; entry.SecurityResource.ParentId = val.SecurityResourceId; } if (view.Insert(entry.SecurityResource)) { var resources = view.LoadResources(0); var submenuNode = CreateSubmenuTree(entry.SecurityResource, resources); addContextMenu(submenuNode, (MenuType)entry.SecurityResource.ResourceTypeId); if (submenuNode != null) { submenuNode.Value = entry.SecurityResource; node.Nodes.Add(submenuNode); node.Expand(); } } } else if (name == "EditSubmenu") { var node = this.radTreeViewResource.SelectedNode; SecurityResourceDto subMenu = (SecurityResourceDto)node.Value; UCSubMenuEntry entry = new UCSubMenuEntry(TransMode.EditRecord, subMenu); ISE.UILibrary.Utils.UIUtils.SetFrmTrans(entry, "زیر منو", FormBorderStyle.FixedDialog); if (entry.DialogResult != DialogResult.OK) { return; } if (view.Update(subMenu)) { node.Text = subMenu.DisplayName; } } else if (name == "DeleteSubmenu") { if (ISE.Framework.Client.Win.Viewer.MessageViewer.ShowAlert("آیا از حذف زیر منو مطمئن هستید؟") != DialogResult.OK) { return; } var node = this.radTreeViewResource.SelectedNode; var parent = node.Parent; SecurityResourceDto subMenu = (SecurityResourceDto)node.Value; if (node.Nodes.Count == 0) { if (view.Remove(subMenu)) { parent.Nodes.Remove(node); } } else { ISE.Framework.Client.Win.Viewer.MessageViewer.ShowException("غیر قابل حذف می باشد!"); } } else if (name == "CreateResource") { UCResourceEntry entry = new UCResourceEntry(); ISE.UILibrary.Utils.UIUtils.SetFrmTrans(entry, "زیر منو", FormBorderStyle.FixedDialog); if (entry.DialogResult != DialogResult.OK) { return; } var node = this.radTreeViewResource.SelectedNode; SecurityResourceDto subMenu = (SecurityResourceDto)node.Value; entry.SecurityResource.AppDomainId = subMenu.AppDomainId; entry.SecurityResource.ParentId = subMenu.SecurityResourceId; if (view.Insert(entry.SecurityResource)) { var resources = view.LoadResources(0); var newNode = CreateSubmenuTree(entry.SecurityResource, resources); node.Nodes.Add(newNode); } } else if (name == "EditResource") { var node = this.radTreeViewResource.SelectedNode; SecurityResourceDto subMenu = (SecurityResourceDto)node.Value; UCResourceEntry entry = new UCResourceEntry(TransMode.EditRecord, subMenu); ISE.UILibrary.Utils.UIUtils.SetFrmTrans(entry, "زیر منو", FormBorderStyle.FixedDialog); if (entry.DialogResult != DialogResult.OK) { return; } if (view.Update(entry.SecurityResource)) { node.Text = subMenu.DisplayName; } } else if (name == "DeleteResource") { if (ISE.Framework.Client.Win.Viewer.MessageViewer.ShowAlert("آیا از حذف منبع مطمئن هستید؟") != DialogResult.OK) { return; } var node = this.radTreeViewResource.SelectedNode; var parent = node.Parent; SecurityResourceDto subMenu = (SecurityResourceDto)node.Value; if (node.Nodes.Count == 0) { if (view.Remove(subMenu)) { parent.Nodes.Remove(node); } } else { ISE.Framework.Client.Win.Viewer.MessageViewer.ShowException("غیر قابل حذف می باشد!"); } } else if (name == "AddOperation") { var node = this.radTreeViewResource.SelectedNode; SecurityResourceDto subMenu = (SecurityResourceDto)node.Value; UCSelectOperation entry = new UCSelectOperation(); ISE.UILibrary.Utils.UIUtils.SetFrmTrans(entry, "افزودن عملیات", FormBorderStyle.FixedDialog); if (entry.DialogResult != DialogResult.OK) { return; } ResourcePresenter presenter = new ResourcePresenter(); var container = presenter.AddOperatins(subMenu, entry.SelectedOperations); if (container != null) { foreach (var item in container.PermissionDtoList) { var operation = entry.SelectedOperations.FirstOrDefault(it => it.OperationId == item.OperationId); CreateOperationNode(operation, node); } } } else if (name == "deleteOperation") { if (ISE.Framework.Client.Win.Viewer.MessageViewer.ShowAlert("آیا از حذف عملیات مطمئن هستید؟") != DialogResult.OK) { return; } ResourcePresenter presenter = new ResourcePresenter(); var node = this.radTreeViewResource.SelectedNode; var parent = node.Parent; SecurityResourceDto resource = (SecurityResourceDto)parent.Value; OperationDto operation = (OperationDto)node.Value; if (presenter.RemoveOperatin(resource, operation) != null) { parent.Nodes.Remove(node); } else { ISE.Framework.Client.Win.Viewer.MessageViewer.ShowException("غیر قابل حذف می باشد!"); } } }