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; } } }
protected void btnSave_Click(object sender, EventArgs e) { MetaObject mo = Mediachase.Ibn.Data.Services.Security.GetGlobalAceByPrincipal(mc, PrincipalId); MetaObject moState = StateMachineUtil.GetGlobalAclStateItem(ClassName, mo.PrimaryKeyId.Value, StateMachineId, StateId); if (moState == null) { MetaClass stateClass = StateMachineUtil.GetGlobalAclStateMetaClass(ClassName); moState = new MetaObject(stateClass); } MetaObjectPropertyCollection properties = moState.Properties; properties[StateMachineUtil.GlobalAclField].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); } }
private void BindGrid() { if (sm == null) { sm = new Mediachase.Ibn.Data.Services.StateMachine(mc, int.Parse(ddlStateMachine.SelectedValue)); } // DataTable structure DataTable dt = new DataTable(); dt.Locale = CultureInfo.InvariantCulture; dt.Columns.Add(principalColumn, typeof(string)); MetaObject moState = StateMachineManager.GetState(mc, int.Parse(ddlState.SelectedValue)); string fromState = moState.Properties["Name"].Value.ToString(); foreach (State state in sm.States) { StateTransition st = sm.FindTransition(fromState, state.Name); if (st != null) { dt.Columns.Add(state.Name, typeof(string)); } } dt.Columns.Add(editColumn, typeof(string)); // Fill data DataRow dr; foreach (MetaObject mo in Mediachase.Ibn.Data.Services.Security.GetGlobalAcl(mc.Name)) { int principalId = (PrimaryKeyId)mo.Properties["PrincipalId"].Value; dr = dt.NewRow(); dr[principalColumn] = CHelper.GetUserName(principalId); MetaObject obj = StateMachineUtil.GetGlobalAclStateItem(mc.Name, mo.PrimaryKeyId.Value, int.Parse(ddlStateMachine.SelectedValue), int.Parse(ddlState.SelectedValue)); for (int i = 1; i < grdMain.Columns.Count - 1; i++) { BoundField rightsField = grdMain.Columns[i] as BoundField; if (rightsField != null) { string fieldName = rightsField.DataField; if (obj != null) { dr[fieldName] = CHelper.GetPermissionImage((int)obj.Properties[fieldName].Value); } else { dr[fieldName] = CHelper.GetPermissionImage((int)Mediachase.Ibn.Data.Services.Security.Rights.None); } } } string url = String.Format("javascript:ShowWizard("{7}?ClassName={0}&btn={1}&PrincipalId={2}&SmId={3}&StateId={4}", {5}, {6});", mc.Name, Page.ClientScript.GetPostBackEventReference(btnRefresh, ""), principalId, ddlStateMachine.SelectedValue, ddlState.SelectedValue, dialogWidth, dialogHeight, ResolveClientUrl("~/Apps/Security/Pages/Admin/GlobalRoleAclStateTransitionEdit.aspx")); dr[editColumn] = String.Format("<a href=\"{0}\"><img src=\"{1}\" title=\"{2}\" width=\"16\" height=\"16\" border=\"0\" /></a>", url, ResolveUrl("~/Images/IbnFramework/edit.gif"), GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Edit").ToString()); dt.Rows.Add(dr); } grdMain.DataSource = dt; grdMain.DataBind(); }
private void BindGrid() { // DataTable structure DataTable dt = new DataTable(); dt.Locale = CultureInfo.InvariantCulture; dt.Columns.Add(idColumn, typeof(string)); dt.Columns.Add(principalColumn, typeof(string)); dt.Columns.Add(isInheritedColumn, typeof(bool)); foreach (SecurityRight right in Mediachase.Ibn.Data.Services.Security.GetMetaClassRights(mc.Name)) { dt.Columns.Add(right.RightName, typeof(string)); } dt.Columns.Add(editColumn, typeof(string)); dt.Columns.Add(resetColumn, typeof(string)); // Fill data DataRow dr; foreach (MetaObject mo in Mediachase.Ibn.Data.Services.Security.GetGlobalAcl(mc.Name)) { int principalId = (PrimaryKeyId)mo.Properties["PrincipalId"].Value; dr = dt.NewRow(); dr[idColumn] = mo.PrimaryKeyId.Value; dr[principalColumn] = CHelper.GetUserName(principalId); bool isInhereted = false; MetaObject obj = StateMachineUtil.GetGlobalAclStateItem(mc.Name, mo.PrimaryKeyId.Value, int.Parse(StateMachineList.SelectedValue), int.Parse(StateList.SelectedValue)); if (obj == null) { obj = mo; isInhereted = true; } dr[isInheritedColumn] = isInhereted; for (int i = 1; i < MainGrid.Columns.Count - 2; i++) { BoundField rightsField = MainGrid.Columns[i] as BoundField; if (rightsField != null) { string fieldName = rightsField.DataField; dr[fieldName] = CHelper.GetPermissionImage((int)obj.Properties[fieldName].Value, isInhereted); } } string url = String.Format(CultureInfo.InvariantCulture, "javascript:ShowWizard("{7}?ClassName={0}&btn={1}&PrincipalId={2}&SmId={3}&StateId={4}", {5}, {6});", mc.Name, Page.ClientScript.GetPostBackEventReference(RefreshButton, ""), principalId, StateMachineList.SelectedValue, StateList.SelectedValue, dialogWidth, dialogHeight, ResolveClientUrl("~/Apps/Security/Pages/Admin/GlobalRoleAclStateEdit.aspx")); dr[editColumn] = String.Format(CultureInfo.InvariantCulture, "<a href=\"{0}\"><img src=\"{1}\" title=\"{2}\" width=\"16\" height=\"16\" border=\"0\" /></a>", url, ResolveUrl("~/Images/IbnFramework/edit.gif"), GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Edit").ToString()); dt.Rows.Add(dr); } MainGrid.DataSource = dt; MainGrid.DataBind(); }