示例#1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    CustomerRoleCollection roles = CustomerManager.GetAllCustomerRoles();
                    if (roles.Count == 0)
                    {
                        lblMessage.Text = GetLocaleResourceString("Admin.ACL.NoRolesDefined");
                        return;
                    }
                    SettingManager.SetParam("ACL.Enabled", cbACLEnabled.Checked.ToString());

                    foreach (GridViewRow row in gvACL.Rows)
                    {
                        foreach (CustomerRole cr in roles)
                        {
                            CheckBox    cbAllow            = row.FindControl(string.Format("cbAllow_{0}", cr.CustomerRoleId)) as CheckBox;
                            HiddenField hfCustomerActionId = row.FindControl(string.Format("hfCustomerActionId_{0}", cr.CustomerRoleId)) as HiddenField;
                            if (cbAllow == null || hfCustomerActionId == null || String.IsNullOrEmpty(hfCustomerActionId.Value))
                            {
                                return;
                            }

                            bool allow            = cbAllow.Checked;
                            int  customerActionId = int.Parse(hfCustomerActionId.Value);

                            ACLCollection acls = ACLManager.GetAllAcl(customerActionId, cr.CustomerRoleId, null);
                            if (acls.Count > 0)
                            {
                                ACL acl = acls[0];
                                ACLManager.UpdateAcl(acl.AclId, customerActionId, cr.CustomerRoleId, allow);
                            }
                            else
                            {
                                ACL acl = ACLManager.InsertAcl(customerActionId, cr.CustomerRoleId, allow);
                            }
                        }
                    }

                    Response.Redirect("ACL.aspx");
                }
                catch (Exception exc)
                {
                    ProcessException(exc);
                }
            }
        }
示例#2
0
        private static ACLCollection DBMapping(DBACLCollection dbCollection)
        {
            if (dbCollection == null)
            {
                return(null);
            }

            var collection = new ACLCollection();

            foreach (var dbItem in dbCollection)
            {
                var item = DBMapping(dbItem);
                collection.Add(item);
            }

            return(collection);
        }
示例#3
0
        protected void BindGrid()
        {
            CustomerActionCollection actions = ACLManager.GetAllCustomerActions();

            if (actions.Count == 0)
            {
                lblMessage.Text = GetLocaleResourceString("Admin.ACL.NoActionDefined");
                return;
            }
            CustomerRoleCollection roles = CustomerManager.GetAllCustomerRoles();

            if (roles.Count == 0)
            {
                lblMessage.Text = GetLocaleResourceString("Admin.ACL.NoRolesDefined");
                return;
            }
            List <CustomerActionACLMappingHelperClass> dt = new List <CustomerActionACLMappingHelperClass>();

            foreach (CustomerAction ca in actions)
            {
                CustomerActionACLMappingHelperClass map1 = new CustomerActionACLMappingHelperClass();
                map1.CustomerActionId   = ca.CustomerActionId;
                map1.CustomerActionName = ca.Name;
                map1.Allow = new Dictionary <int, bool>();

                foreach (CustomerRole cr in roles)
                {
                    ACLCollection acls = ACLManager.GetAllAcl(ca.CustomerActionId, cr.CustomerRoleId, null);
                    if (acls.Count > 0)
                    {
                        ACL acl = acls[0];
                        map1.Allow.Add(cr.CustomerRoleId, acl.Allow);
                    }
                    else
                    {
                        map1.Allow.Add(cr.CustomerRoleId, false);
                    }
                }
                dt.Add(map1);
            }

            gvACL.DataSource = dt;
            gvACL.DataBind();
        }