private void btnOk_Click(object sender, EventArgs e) { if (mode == TransMode.EditRecord) { if (SecurityResource != null) { SecurityResource.ResourceName = txtTitle.Text; SecurityResource.IsEnabled = chkEnabled.Checked; SecurityResource.ResourceTypeId = (int)ISE.SM.Client.UC.UCResource.MenuType.SubMenu; SecurityResource.DisplayName = txtTitle.Text; } DialogResult = System.Windows.Forms.DialogResult.OK; } else if (mode == TransMode.NewRecord) { SecurityResource = new SecurityResourceDto() { ResourceName = txtTitle.Text, DisplayName = txtTitle.Text, IsEnabled = chkEnabled.Checked, ResourceTypeId = (int)ISE.SM.Client.UC.UCResource.MenuType.SubMenu }; DialogResult = System.Windows.Forms.DialogResult.OK; } this.ParentForm.Close(); }
RadTreeNode CreateSubmenuTree(SecurityResourceDto resource, List <SecurityResourceDto> lst) { RadTreeNode node = new RadTreeNode(resource.DisplayName); var resources = lst; var subNodes = resources.Where(it => it.ParentId == resource.SecurityResourceId).ToList(); if (subNodes == null || subNodes.Count == 0) { return(node); } foreach (var item in subNodes) { var subNode = CreateSubmenuTree(item, lst); if (subNode != null) { subNode.Value = item; node.Nodes.Add(subNode); } } return(node); }
public bool Update(SecurityResourceDto resource) { if (presenter.Update(resource)) { return(true); } return(false); }
public bool Remove(SecurityResourceDto role) { if (presenter.Remove(role)) { return(true); } return(false); }
public bool Insert(SecurityResourceDto role) { if (presenter.Insert(role) != null) { ResourceList.Add(role); return(true); } return(false); }
public ResponseDto RemoveOperatin(SecurityResourceDto resource, OperationDto operation) { var result = SecurityResourceServiceAdapter.Execute(s => s.RemoveOperation(resource, operation)); if (result.Response.HasException) { return(null); } return(result); }
public bool Remove(SecurityResourceDto SecurityResource) { ResponseDto response = SecurityResourceServiceAdapter.Execute(s => s.Delete(SecurityResource)); if (response.Response.HasException) { return(false); } return(true); }
public PermissionDtoContainer AddOperatins(SecurityResourceDto resource, List <OperationDto> operations) { var result = SecurityResourceServiceAdapter.Execute(s => s.AddOperations(resource, operations)); if (result.Response.HasException) { return(null); } return(result); }
public SecurityResourceDto Insert(SecurityResourceDto SecurityResource) { SecurityResourceDto result = (SecurityResourceDto)SecurityResourceServiceAdapter.Execute(s => s.Insert(SecurityResource)); if (result.Response.HasException) { return(null); } SecurityResource.SecurityResourceId = result.SecurityResourceId; return(SecurityResource); }
public UCSubMenuEntry(TransMode mode, SecurityResourceDto resource) { this.mode = mode; this.SecurityResource = resource; InitializeComponent(); DialogResult = System.Windows.Forms.DialogResult.None; if (mode == TransMode.EditRecord || mode == TransMode.ViewRecord) { txtTitle.Text = resource.ResourceName; chkEnabled.Checked = resource.IsEnabled; } }
public AuthorizationResult CheckAccess(SecurityResourceDto resource, IdentityToken token) { AuthorizationRequest request = new AuthorizationRequest() { IdentityToken = token, Resource = resource }; var result = AuthorizationServiceAdapter.Execute(it => it.CheckAccess(request)); //if (result.HasError) // return null; return(result); }
public void AddResources(SecurityResourceDto resource, List <SecurityResourceDto> resources) { if (!resources.Exists(it => it.SecurityResourceId == resource.SecurityResourceId)) { resource.Checked = true; resources.Add(resource); if (resource.ParentId != null) { var dbRes = this.Repository.Context.SecurityResources.Where(it => it.SecurityResourceId == resource.ParentId).FirstOrDefault(); var dto = SecurityResourceRepository.GetDto(dbRes); AddResources(dto, resources); } } }
RadTreeNode CreateSubmenuTree(SecurityResourceDto resource, List <SecurityResourceDto> resources) { RadTreeNode node = new RadTreeNode(resource.DisplayName); if (resource.Checked) { node.Checked = true; } var image = GetImage(resource.ResourceTypeId); if (image != null) { node.Image = image; } var subNodes = resources.Where(it => it.ParentId == resource.SecurityResourceId).ToList(); if (subNodes == null || subNodes.Count == 0) { return(node); } foreach (var item in subNodes) { var subNode = CreateSubmenuTree(item, resources); var subimage = GetImage(item.ResourceTypeId); var permissions = resview.LoadPermissions(); var permissionItems = permissions.Where(it => it.ResourceId == item.SecurityResourceId).ToList(); if (permissionItems.Count() > 0) { foreach (var pitem in permissionItems) { CreateOperationNode(pitem, subNode); } } if (subNode != null) { subNode.Value = item; if (subimage != null) { subNode.Image = subimage; } AddContextMenu(subNode); node.Nodes.Add(subNode); } } return(node); }
private void iTransToolBar1_SaveRecord_1(object sender, EventArgs e) { int precedens = 0; int.TryParse(txtPrecedence.Text, out precedens); short hasParam = 0; if (chkHasParam.Checked) { hasParam = 1; } if (mode == TransMode.EditRecord || mode == TransMode.ViewRecord) { if (SecurityResource != null) { SecurityResource.DisplayName = txtDisplayName.Text; SecurityResource.ResourceName = txtResourceName.Text; SecurityResource.Namespace = txtNameSpace.Text; SecurityResource.AssemblyName = txtAssemblyName.Text; SecurityResource.ToolTip = txtTooltip.Text; SecurityResource.Precedence = precedens; SecurityResource.HasParam = chkHasParam.Checked; SecurityResource.IsEnabled = chkEnabled.Checked; DialogResult = System.Windows.Forms.DialogResult.OK; } } else { SecurityResourceDto rec = new SecurityResourceDto() { AssemblyName = txtAssemblyName.Text, DisplayName = txtDisplayName.Text, IsEnabled = chkEnabled.Checked, ResourceName = txtResourceName.Text, Namespace = txtNameSpace.Text, ToolTip = txtTooltip.Text, Precedence = precedens, ResourceTypeId = GetResourceType(), HasParameter = hasParam }; SecurityResource = rec; DialogResult = System.Windows.Forms.DialogResult.OK; } this.ParentForm.Close(); }
public UCResourceEntry(TransMode mode, SecurityResourceDto resource) { this.SecurityResource = resource; InitializeComponent(); this.mode = mode; this.DialogResult = System.Windows.Forms.DialogResult.None; if (mode == TransMode.ViewRecord || mode == TransMode.EditRecord) { txtDisplayName.Text = resource.DisplayName; txtResourceName.Text = resource.ResourceName; txtNameSpace.Text = resource.Namespace; txtAssemblyName.Text = resource.AssemblyName; txtTooltip.Text = resource.ToolTip; txtPrecedence.Text = resource.Precedence.ToString(); chkHasParam.Checked = resource.HasParam; chkEnabled.Checked = resource.IsEnabled; } }
private TreeNode CreateNode(SecurityResourceDto resource, List <SecurityResourceDto> lst) { TreeNode node = new TreeNode(resource.DisplayName); node.Tag = resource; var childs = lst.Where(it => it.ParentId == resource.SecurityResourceId).ToList(); if (childs == null || childs.Count == 0) { return(node); } else { foreach (var item in childs) { var ccnode = CreateNode(item, lst); node.Nodes.Add(ccnode); } } return(node); }
private void radTreeView1_NodeMouseDoubleClick(object sender, RadTreeViewEventArgs e) { flowLayoutPanelOp.Controls.Clear(); RadTreeViewElement element = (RadTreeViewElement)sender; SecurityResourceDto resource = (SecurityResourceDto)element.SelectedNode.Value; if (resource != null) { if (resource.ResourceTypeId == 1)// is submenu { return; } var access = presenter.CheckAccess(resource, TokenContainer.CurrentToken); if (rdUInfo.Checked) { var userInfo = UserInfoGenerator.GenerateUserInfo(access, TokenContainer.CurrentToken); FrmUserInfo frmUserInfo = new FrmUserInfo(userInfo); frmUserInfo.Show(); } else { FrmAccessToken frmAtoken = new FrmAccessToken(access); frmAtoken.Show(); } if (access != null) { foreach (var item in access.Operations) { Button opbtn = new Button() { Name = item.OperationId.ToString(), Text = item.OperationName, Tag = item, }; flowLayoutPanelOp.Controls.Add(opbtn); } } } }
public AccessToken GenerateToken(IdentityToken identityToken, SecurityResourceDto resource) { AccessToken token = new AccessToken(); ResourceBussiness resourceBa = new ResourceBussiness(); var secutiryResource = resourceBa.GetSingle(it => it.SecurityResourceId == resource.SecurityResourceId); int userId = 0; long resourceId = 0; if (secutiryResource != null) { resourceId = secutiryResource.SecurityResourceId; } int.TryParse(identityToken.SubjectId, out userId); var operationList = resourceBa.GetAllUserOperations(userId, resourceId); token.Operations.AddRange(operationList); token.Resource = secutiryResource; token.UserName = identityToken.UserName; return(token); }
public PermissionDtoContainer AddOperations(SecurityResourceDto resource, List <OperationDto> operationDtos) { return(resourceBussiness.AddOperations(resource, operationDtos)); }
public ResponseDto RemoveOperation(SecurityResourceDto resource, OperationDto operationDto) { return(resourceBussiness.RemoveOperation(resource, operationDto)); }
public PermissionDto AddOperation(SecurityResourceDto resource, OperationDto operationDto) { return(resourceBussiness.AddOperation(resource, operationDto)); }
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("غیر قابل حذف می باشد!"); } } }