Example #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            MetaObject mo      = Mediachase.Ibn.Data.Services.RoleManager.GetObjectRole(mc, RoleName);
            MetaObject moState = StateMachineUtil.GetObjectRoleStateItem(ClassName, mo.PrimaryKeyId.Value, StateMachineId, StateId);

            if (moState == null)
            {
                MetaClass stateClass = StateMachineUtil.GetObjectRoleStateMetaClass(ClassName);
                moState = new MetaObject(stateClass);
            }

            MetaObjectPropertyCollection properties = moState.Properties;

            properties[StateMachineUtil.RoleField].Value         = mo.PrimaryKeyId.Value;
            properties[StateMachineUtil.StateMachineField].Value = StateMachineId;
            properties[StateMachineUtil.StateField].Value        = StateId;
            for (int i = 0; i < rights.Count; i++)
            {
                string rightName = rights[i].ToString();
                properties[rightName].Value = ((CheckControl)checkControls[i]).Value;
            }

            moState.Save();

            // Closing window
            if (RefreshButton == String.Empty)
            {
                CHelper.CloseItAndRefresh(Response);
            }
            else              // Dialog Mode
            {
                CHelper.CloseItAndRefresh(Response, RefreshButton);
            }
        }
Example #2
0
        private void BindData()
        {
            principal.BindData(mc.Fields[principalField]);
            principal.Value    = PrincipalId;
            principal.ReadOnly = true;

            MetaObject mo      = Mediachase.Ibn.Data.Services.Security.GetGlobalAceByPrincipal(mc, PrincipalId);
            MetaObject moState = StateMachineUtil.GetGlobalAclStateItem(ClassName, mo.PrimaryKeyId.Value, StateMachineId, StateId);

            if (moState == null)
            {
                moState = mo;
            }

            if (moState != null)
            {
                MetaObjectPropertyCollection properties = moState.Properties;

                for (int i = 0; i < rights.Count; i++)
                {
                    string rightName = rights[i].ToString();
                    ((CheckControl)checkControls[i]).Value = (int)properties[rightName].Value;
                }
            }
        }
Example #3
0
        private void BindData()
        {
            Role role = Mediachase.Ibn.Data.Services.RoleManager.GetObjectRole(mc, RoleName);

            if (role != null)
            {
                RoleNameLabel.Text = CHelper.GetResFileString(role.Properties["FriendlyName"].Value.ToString());
                if (role.Properties["ClassName"].Value != null)
                {
                    string className = (string)role.Properties["ClassName"].Value;
                    if (className.Contains("::"))
                    {
                        string[] s = new string[] { "::" };
                        className          = className.Split(s, StringSplitOptions.None)[0];
                        RoleNameLabel.Text = String.Format(CultureInfo.InvariantCulture,
                                                           "{0} ({1})",
                                                           RoleNameLabel.Text,
                                                           CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(className).PluralName));
                    }
                }

                MetaObjectPropertyCollection properties = role.Properties;
                for (int i = 0; i < rights.Count; i++)
                {
                    string rightName = rights[i].ToString();
                    ((CheckControl)checkControls[i]).Value = (int)properties[rightName].Value;
                }
            }
        }
Example #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (!this.Page.IsValid)
            {
                return;
            }

            bool isNew = (PrincipalId == -1);

            if (isNew)                  // New
            {
                // Check for unicity
                if (Mediachase.Ibn.Data.Services.Security.GetGlobalAceByPrincipal(mc, (int)(PrimaryKeyId)principal.Value) != null)
                {
                    // already exists
                    if (Page.Validators.Count > 0)
                    {
                        Page.Validators[0].IsValid = false;
                    }

                    return;
                }
            }


            // Saving
            MetaObject mo = null;

            if (!isNew)
            {
                mo = Mediachase.Ibn.Data.Services.Security.GetGlobalAceByPrincipal(mc, PrincipalId);
            }

            if (mo == null)
            {
                mo = new MetaObject(mc);
            }

            MetaObjectPropertyCollection properties = mo.Properties;

            properties[principalField].Value = principal.Value;
            for (int i = 0; i < rights.Count; i++)
            {
                string rightName = rights[i].ToString();
                properties[rightName].Value = ((CheckControl)checkControls[i]).Value;
            }

            mo.Save();

            // Closing window
            if (RefreshButton == String.Empty)
            {
                CHelper.CloseItAndRefresh(Response);
            }
            else              // Dialog Mode
            {
                CHelper.CloseItAndRefresh(Response, RefreshButton);
            }
        }
        private void BindData()
        {
            MetaObject mo      = Mediachase.Ibn.Data.Services.RoleManager.GetObjectRole(mc, RoleName);
            MetaObject moState = StateMachineUtil.GetObjectRoleStateItem(ClassName, mo.PrimaryKeyId.Value, StateMachineId, StateId);

            if (mo != null)
            {
                txtName.Text = mo.Properties["RoleName"].Value.ToString();
            }

            if (moState != null)
            {
                MetaObjectPropertyCollection properties = moState.Properties;

                for (int i = 0; i < states.Count; i++)
                {
                    string stateName = states[i].ToString();
                    ((CheckControl)checkControls[i]).Value = (int)properties[stateName].Value;
                }
            }
        }
Example #6
0
        private void BindData()
        {
            principal.BindData(mc.Fields[principalField]);
            principal.Label = GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Principal").ToString() + ":";
            if (PrincipalId != -1)
            {
                principal.Value    = PrincipalId;
                principal.ReadOnly = true;

                MetaObject mo = Mediachase.Ibn.Data.Services.Security.GetGlobalAceByPrincipal(mc, PrincipalId);

                if (mo != null)
                {
                    MetaObjectPropertyCollection properties = mo.Properties;

                    for (int i = 0; i < rights.Count; i++)
                    {
                        string rightName = rights[i].ToString();
                        ((CheckControl)checkControls[i]).Value = (int)properties[rightName].Value;
                    }
                }
            }
        }