protected override OpResult _Store(AuthItem _obj) { if (_obj == null) { return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "ItemOpeningBalance object cannot be created as it is null")); } if (Exists(_obj)) { ExecuteNonQuery(GetQuery_UpdateQuery(_obj)); return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj)); } ExecuteNonQuery(GetQuery_InsertQuery(_obj)); if (_obj.ItemID == null) { _obj.ItemID = DbMgr.GetLastInsertID(); } foreach (AuthItem child_item in _obj.Children) { child_item.ParentItemID = _obj.ItemID; Store(child_item); } _obj.FromDb = true; return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj)); }
public string Validate(AuthItem AuthItem) { string result = ""; //if (this.authManager.Authenticate(AuthItem.Identity, AuthItem.Crypto)) //{ // result = String.Format("{0}:{1}", AuthItem.Identity, AuthItem.Crypto); // OperationContext context = OperationContext.Current; // MessageProperties prop = context.IncomingMessageProperties; // RemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; // string ip = endpoint.Address; // string userAgent = System.ServiceModel.Web.WebOperationContext.Current.IncomingRequest.UserAgent; // byte[] data = Encoding.Default.GetBytes(result); // byte[] key = Encoding.Default.GetBytes(ip); // byte[] iv = Encoding.Default.GetBytes(userAgent); // byte[] encrytionBytes = this.encryptionManager.AesEncryption(data, key, iv); // result = Encoding.Default.GetString(encrytionBytes); //} return(result); }
private int GetAuthItemImageIndex(AuthItem item) { string type = GetAuthItemType(item); if (type.Equals("Update")) { return(0); } else if (type.Equals("Create")) { return(1); } else if (type.Equals("Delete")) { return(2); } else if (type.Equals("Read")) { return(3); } else if (type.Equals("Access")) { return(4); } else if (type.Equals("Index")) { return(5); } return(4); }
private async void Delete(object sender, RoutedEventArgs e) { bool DoDelete = SelectedItem.Count == 0; if (!DoDelete) { StringResources stx = StringResources.Load("Message"); MessageDialog MsgBox = new MessageDialog(SelectedItem.DeleteMessage); MsgBox.Commands.Add(new UICommand(stx.Str("Yes"), x => { DoDelete = true; })); MsgBox.Commands.Add(new UICommand(stx.Str("No"))); await Popups.ShowDialog(MsgBox); } if (DoDelete) { if (SelectedItem.Value is CryptAES) { AESMgr.RemoveAuth(SelectedItem.Value.Value, ( CryptAES )SelectedItem.Value); ReloadAuths(KeyList, SHTarget.KEY, AESMgr); } else { TokMgr.RemoveAuth(SelectedItem.Value.Value, SelectedItem.Value); ReloadAuths(TokenList, SHTarget.TOKEN, TokMgr); } SelectedItem = null; } }
public AuthItem CreateBOAuthItem(AuthItem parent_item, string ItemName, string DisplayName) { AuthItem _item = mAccountant.AuthItemMgr.CreateEntity(); _item.Type = AuthItem.AuthItemType.Category; _item.ItemName = ItemName; _item.DisplayName = DisplayName; AuthItem child_item_attribute = mAccountant.AuthItemMgr.CreateEntity(); child_item_attribute.Type = AuthItem.AuthItemType.Attribute; child_item_attribute.ItemName = string.Format("{0}.{1}", ItemName, BOPropertyAttrType.Visible); child_item_attribute.Description = child_item_attribute.ItemName; child_item_attribute.DisplayName = child_item_attribute.ItemName; child_item_attribute.ParentItem = _item; _item.Children.Add(child_item_attribute); DecorateAuthItem(child_item_attribute, child_item_attribute.ItemName); child_item_attribute = mAccountant.AuthItemMgr.CreateEntity(); child_item_attribute.Type = AuthItem.AuthItemType.Attribute; child_item_attribute.ItemName = string.Format("{0}.{1}", ItemName, BOPropertyAttrType.Enabled); child_item_attribute.Description = child_item_attribute.ItemName; child_item_attribute.DisplayName = child_item_attribute.ItemName; child_item_attribute.ParentItem = _item; _item.Children.Add(child_item_attribute); DecorateAuthItem(child_item_attribute, child_item_attribute.ItemName); _item.ParentItem = parent_item; parent_item.Children.Add(_item); DecorateAuthItem(_item, ItemName); return(_item); }
private void PopulateTreeGridView(TreeGridNode tgnode, AuthItem node) { if (node.Type == AuthItem.AuthItemType.Category || node.Type == AuthItem.AuthItemType.Root) { tgnode.Cells[0].Style.Font = mBoldFont; } TreeGridNode tgchild_node; foreach (AuthItem child_node in node.Children) { if (child_node.Type == AuthItem.AuthItemType.Category) { tgchild_node = tgnode.Nodes.Add(child_node.DisplayName, IsAuthItemEnabled(child_node), IsAuthItemVisible(child_node), IsAuthItemViewAll(child_node)); tgchild_node.ReadOnly = false; tgchild_node.Frozen = false; tgchild_node.Cells[0].Tag = child_node; PopulateTreeGridView(tgchild_node, child_node); } else if (child_node.Type == AuthItem.AuthItemType.Property) { tgchild_node = tgnode.Nodes.Add(child_node.DisplayName, IsAuthItemEnabled(child_node), IsAuthItemVisible(child_node)); tgchild_node.Cells[0].Tag = child_node; PopulateTreeGridView(tgchild_node, child_node); } } }
private void ShowContextMenu(object sender, RightTappedRoutedEventArgs e) { Border B = ( Border )sender; SelectedItem = ( AuthItem )B.DataContext; FlyoutBase.ShowAttachedFlyout(B); }
public void CreateBOAuthItem(AuthItem parent_item, BusinessObject _obj) { AuthItem child_item = CreateBOAuthItem(_obj); child_item.ParentItem = parent_item; parent_item.Children.Add(child_item); DecorateAuthItem(child_item, child_item.ItemName); }
private void PopulateTreeGridView(TreeGridView tgv, AuthItem node) { TreeGridNode tgnode = tgv.Nodes.Add(node.DisplayName); tgnode.Cells[0].Tag = node; PopulateTreeGridView(tgnode, node); ExpandTreeGridView(tgnode); }
private void ReloadAuths <T>(ListView LView, SHTarget Target, global::GR.GSystem.AuthManager <T> Mgr) { LView.ItemsSource = Mgr.AuthList.Remap(x => { NameValue <string> NX = x as NameValue <string>; AuthItem Item = new AuthItem(NX, Target); Item.Count = Mgr.ControlCount(NX.Value); return(Item); }); }
public bool IsAuthItemViewAll(AuthItem node) { AuthItem viewall = GetAuthItemAttribute(node, BOPropertyAttrType.ViewAll); if (viewall == null) { return(true); } return(mModel.ForbidItem(viewall) == false); }
private bool IsAuthItemEnabled(AuthItem node) { AuthItem enabled = GetAuthItemAttribute(node, BOPropertyAttrType.Enabled); if (enabled == null) { return(true); } return(mModel.ForbidItem(enabled) == false); }
private void UpdateDb(AuthItem root, AuthItemManager aim) { //if (!aim.Exists(root)) { aim.Store(root); } foreach (AuthItem item in root.Children) { UpdateDb(item, aim); } }
public void Set(AuthItem authItem, int userId) { var cacheKey = $"{KeyString}:{userId}"; // Set cache options. var cacheEntryOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromHours(CacheExpiration)); // Save data in cache. _cache.Set(cacheKey, authItem, cacheEntryOptions); }
private void BindTreeNode(TreeNode node) { AuthItem item = (AuthItem)node.Tag; bool accessible = node.Checked || chkFullControl.Checked || SubRoleCheckAccess(item); node.ForeColor = accessible ? Color.Black : Color.Red; node.ToolTipText = string.Format("{0} {1}", (accessible ? "(accessible)" : "(not accessible)"), item.Description); foreach (TreeNode child_node in node.Nodes) { BindTreeNode(child_node); } }
private string GetAuthItemType(AuthItem item) { int index = item.DisplayName.LastIndexOf("."); if (index == -1) { return(""); } string type = item.DisplayName.Substring(index + 1); return(type); }
private void ReviseRoleItem(TreeNode node) { if (node.Checked) { AuthItem item = (AuthItem)node.Tag; mRole.Items.Add(item); } foreach (TreeNode child_node in node.Nodes) { ReviseRoleItem(child_node); } }
public AuthItem GetAuthItemAttribute(AuthItem node, string AttributeName) { foreach (AuthItem child_node in node.Children) { if (child_node.Type == AuthItem.AuthItemType.Attribute) { if (child_node.ItemName.Equals(string.Format("{0}.{1}", node.ItemName, AttributeName))) { return(child_node); } } } return(null); }
private void ReviseRoleItem(TreeGridNode node) { AuthItem item = (AuthItem)node.Cells[0].Tag; int attribute_count = node.Cells.Count; if (item.Type != AuthItem.AuthItemType.Root) { if (attribute_count > 1 && node.Cells[1].Value != null) { bool enabled = (bool)(node.Cells[1].Value); if (enabled == false) { AuthItem attribute_item = GetAuthItemAttribute(item, BOPropertyAttrType.Enabled); if (attribute_item != null) { mModel.ForbiddenItems.Add(attribute_item); } } } if (attribute_count > 2 && node.Cells[2].Value != null) { bool visible = (bool)(node.Cells[2].Value); if (visible == false) { AuthItem attribute_item = GetAuthItemAttribute(item, BOPropertyAttrType.Visible); if (attribute_item != null) { mModel.ForbiddenItems.Add(attribute_item); } } } if (attribute_count > 3 && node.Cells[3].Value != null) { bool viewall = (bool)(node.Cells[3].Value); if (viewall == false) { AuthItem attribute_item = GetAuthItemAttribute(item, BOPropertyAttrType.ViewAll); if (attribute_item != null) { mModel.ForbiddenItems.Add(attribute_item); } } } } foreach (TreeGridNode child_node in node.Nodes) { ReviseRoleItem(child_node); } }
public AuthItem CreateBOAuthItem_Jobs() { AuthItem root = mAccountant.AuthItemMgr.CreateEntity(); root.DisplayName = BOType.BOProject; root.ItemName = BOType.BOProject; root.Description = BOType.BOProject; DecorateAuthItem(root, root.ItemName); CreateBOAuthItem(root, mAccountant.CreateJob()); CreateBOListAuthItem(root, mAccountant.Jobs); return(root); }
public AuthItem CreateBOAuthItem_Inventory() { AuthItem root = mAccountant.AuthItemMgr.CreateEntity(); root.DisplayName = BOType.BOInventory; root.ItemName = BOType.BOInventory; root.Description = BOType.BOInventory; DecorateAuthItem(root, root.ItemName); CreateBOAuthItem(root, mAccountant.CreateItem()); CreateBOListAuthItem(root, mAccountant.Items); return(root); }
private bool SubRoleCheckAccess(AuthItem item) { foreach (TreeNode node in tvAuthRoles.Nodes) { if (node.Checked) { AuthRole role = (AuthRole)node.Tag; if (role.CheckAccess(item)) { return(true); } } } return(false); }
public AuthItem CreateBOAuthItem_Analysis() { AuthItem root = mAccountant.AuthItemMgr.CreateEntity(); root.DisplayName = BOType.BOAnalysis; root.ItemName = BOType.BOAnalysis; root.Description = BOType.BOAnalysis; DecorateAuthItem(root, root.ItemName); CreateBOAuthItem(root, BOType.BOAnalysisCashFlow, "CashFlow"); CreateBOAuthItem(root, BOType.BOAnalysisJobs, "Jobs"); CreateBOAuthItem(root, BOType.BOAnalysisProfitAndLoss, "ProfitAndLoss"); CreateBOAuthItem(root, BOType.BOAnalysisBalanceSheet, "BalanceSheet"); return(root); }
public AuthItem CreateBOAuthItem_Accounts() { AuthItem root = mAccountant.AuthItemMgr.CreateEntity(); root.DisplayName = BOType.BOAccounts; root.ItemName = BOType.BOAccounts; root.Description = BOType.BOAccounts; DecorateAuthItem(root, root.ItemName); CreateBOAuthItem(root, mAccountant.CreateAccount()); CreateBOListAuthItem(root, mAccountant.TransactionJournals); CreateBOListAuthItem(root, mAccountant.Accounts); return(root); }
private void Build(TreeNode node, AuthItem item) { bool accessible = mRole.CheckAccess(item); node.Text = item.DisplayName; node.ImageIndex = GetAuthItemImageIndex(item); node.Tag = item; node.ToolTipText = string.Format("{0} {1}", (accessible ? "(accessible)" : "(not accessible)"), item.Description); node.Checked = mRole.HasItem(item); node.ForeColor = accessible ? Color.Black : Color.Red; foreach (AuthItem child_item in item.Children) { TreeNode child_node = new TreeNode(); node.Nodes.Add(child_node); Build(child_node, child_item); } }
public AuthItem CreateBOAuthItem_Cards() { AuthItem root = mAccountant.AuthItemMgr.CreateEntity(); root.DisplayName = BOType.BOCards; root.ItemName = BOType.BOCards; root.Description = BOType.BOCards; DecorateAuthItem(root, root.ItemName); CreateBOAuthItem(root, mAccountant.CreateCustomer()); CreateBOAuthItem(root, mAccountant.CreateSupplier()); CreateBOAuthItem(root, mAccountant.CreateEmployee()); CreateBOListAuthItem(root, mAccountant.AllCards); return(root); }
void tree_AfterCheck(object sender, TreeViewEventArgs e) { if (sender == tvAuthItems) { TreeNode node = e.Node; AuthItem item = (AuthItem)node.Tag; bool accessible = node.Checked || (SubRoleCheckAccess(item)); node.ForeColor = accessible ? Color.Black : Color.Red; node.ToolTipText = string.Format("{0} {1}", (accessible ? "(accessible)" : "(not accessible)"), item.Description); } else if (sender == tvAuthRoles) { foreach (TreeNode child_node in tvAuthItems.Nodes) { BindTreeNode(child_node); } } }
public PtcIdentity( IIdentity identity, UserBase currentUser, string GroupName, MenuNodeAttribute actionAuthDefine) { //原始ID _orgIdentity = identity; //目前使用者 _currentUser = currentUser; //action沒設定,表示全部有效 if (actionAuthDefine == null) { _groupActionOperation = AuthNodeType.All; return; } //取得使用者的定義 if (_currentUser.UserPageAuth.ContainsKey(GroupName)) { _currentUserGroupAction = _currentUser.UserPageAuth[GroupName]; _groupActionOperation = _currentUserGroupAction.AuthType; //使用者沒有設定操作操限 if (_currentUserGroupAction.AuthType == null) { throw new Exception("沒設定功能的操作權限(CRUD)"); } //操作權限不符合 if (_currentUserGroupAction.AuthType.Value.HasFlag(actionAuthDefine.AuthType) == false) { throw new Exception("功能的操作權限不符合(CRUD)"); } } else { //找出使用者權限設定項目 throw new Exception("沒該功能權限"); } }
public AuthItem CreateBOAuthItem_Sales() { AuthItem root = mAccountant.AuthItemMgr.CreateEntity(); root.DisplayName = BOType.BOSales; root.ItemName = BOType.BOSales; root.Description = BOType.BOSales; DecorateAuthItem(root, root.ItemName); CreateBOAuthItem(root, mAccountant.CreateSaleQuote()); CreateBOAuthItem(root, mAccountant.CreateSaleOrder()); CreateBOAuthItem(root, mAccountant.CreateSaleOpenInvoice()); CreateBOAuthItem(root, mAccountant.CreateSaleCreditReturn()); CreateBOAuthItem(root, mAccountant.CreateSaleClosedInvoice()); CreateBOListAuthItem(root, mAccountant.Sales); return(root); }
public AuthItem CreateBOAuthItem_Purchases() { AuthItem root = mAccountant.AuthItemMgr.CreateEntity(); root.DisplayName = BOType.BOPurchases; root.ItemName = BOType.BOPurchases; root.Description = BOType.BOPurchases; DecorateAuthItem(root, root.ItemName); CreateBOAuthItem(root, mAccountant.CreatePurchaseQuote()); CreateBOAuthItem(root, mAccountant.CreatePurchaseOrder()); CreateBOAuthItem(root, mAccountant.CreatePurchaseOpenBill()); CreateBOAuthItem(root, mAccountant.CreatePurchaseDebitReturn()); CreateBOAuthItem(root, mAccountant.CreatePurchaseClosedBill()); CreateBOListAuthItem(root, mAccountant.Purchases); return(root); }