private void dgMembers_DeleteCommand(object source, DataGridCommandEventArgs e) { ReportAcl ACLr = (ReportAcl)ViewState["ACL"]; int Id = int.Parse(e.Item.Cells[0].Text); ACLr.Remove(Id); ViewState["ACL"] = ACLr; ListItem _li = ddGroups.SelectedItem; if (_li != null) { BindUsers(int.Parse(_li.Value)); } BinddgMembers(); }
private void BinddgMembers() { ReportAcl ACLr = (ReportAcl)ViewState["ACL"]; DataTable dt = ACLToDateTable(ACLr); DataView dv = dt.DefaultView; dv.Sort = "Weight"; dgMembers.DataSource = dv; dgMembers.DataBind(); foreach (DataGridItem dgi in dgMembers.Items) { ImageButton ib = (ImageButton)dgi.FindControl("ibDelete"); ib.Attributes.Add("onclick", "if(confirm('" + LocRM.GetString("Warning") + "'))return true;else return false;"); ib.ToolTip = LocRM.GetString("tDelete"); } }
private DataTable ACLToDateTable(ReportAcl ACLr) { DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add(new DataColumn("ID", typeof(int))); dt.Columns.Add(new DataColumn("Weight", typeof(int))); dt.Columns.Add(new DataColumn("Name", typeof(string))); dt.Columns.Add(new DataColumn("Allow", typeof(bool))); foreach (ReportAce ACEr in ACLr) { dr = dt.NewRow(); dr["ID"] = ACEr.Id; dr["Weight"] = (ACEr.IsRoleAce) ? 0 : ((Mediachase.IBN.Business.User.IsGroup(ACEr.PrincipalId.Value)) ? 1 : 2); dr["Name"] = (ACEr.IsRoleAce) ? ACEr.Role : ACEr.PrincipalId.Value.ToString(); dr["Allow"] = ACEr.Allow; dt.Rows.Add(dr); } return(dt); }
private void GetACLData() { ReportAcl acl = ReportAcl.GetAcl(ReportId); ViewState["ACL"] = acl; }
private void BindUsers(int GroupID) { ddUsers.Items.Clear(); ReportAcl ACLr = (ReportAcl)ViewState["ACL"]; ArrayList alList = new ArrayList(); foreach (ReportAce ACEr in ACLr) { alList.Add((ACEr.IsRoleAce) ? ACEr.Role : ACEr.PrincipalId.Value.ToString()); } DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("UserId", typeof(string))); dt.Columns.Add(new DataColumn("UserName", typeof(string))); DataRow dr; if (GroupID == 0) { if (!alList.Contains(UserRoleHelper.AdminRoleName)) { dr = dt.NewRow(); dr["UserId"] = UserRoleHelper.AdminRoleName; dr["UserName"] = LocRM.GetString("tAdmins"); dt.Rows.Add(dr); } if (!alList.Contains(UserRoleHelper.PowerProjectManagerRoleName)) { dr = dt.NewRow(); dr["UserId"] = UserRoleHelper.PowerProjectManagerRoleName; dr["UserName"] = LocRM.GetString("tPPManager"); dt.Rows.Add(dr); } if (!alList.Contains(UserRoleHelper.HelpDeskManagerRoleName)) { dr = dt.NewRow(); dr["UserId"] = UserRoleHelper.HelpDeskManagerRoleName; dr["UserName"] = LocRM.GetString("tHDM"); dt.Rows.Add(dr); } if (!alList.Contains(UserRoleHelper.GlobalProjectManagerRoleName)) { dr = dt.NewRow(); dr["UserId"] = UserRoleHelper.GlobalProjectManagerRoleName; dr["UserName"] = LocRM.GetString("tGlobalPManager"); dt.Rows.Add(dr); } if (!alList.Contains(UserRoleHelper.GlobalExecutiveManagerRoleName)) { dr = dt.NewRow(); dr["UserId"] = UserRoleHelper.GlobalExecutiveManagerRoleName; dr["UserName"] = LocRM.GetString("tGlobalEManager"); dt.Rows.Add(dr); } if (!alList.Contains(UserRoleHelper.TimeManagerRoleName)) { dr = dt.NewRow(); dr["UserId"] = UserRoleHelper.TimeManagerRoleName; dr["UserName"] = LocRM.GetString("tTM"); dt.Rows.Add(dr); } } else { using (IDataReader reader = SecureGroup.GetListAllUsersInGroup(GroupID)) { while (reader.Read()) { int iUserId = (int)reader["UserId"]; if (alList.Contains(iUserId.ToString())) { continue; } bool IsExternal = (bool)reader["IsExternal"]; byte Activity = (byte)reader["Activity"]; if (!(IsExternal || Activity == (byte)Mediachase.IBN.Business.User.UserActivity.Pending)) { dr = dt.NewRow(); dr["UserId"] = iUserId.ToString(); dr["UserName"] = (string)reader["LastName"] + " " + (string)reader["FirstName"]; dt.Rows.Add(dr); } } } } DataView dv = new DataView(dt); ddUsers.DataSource = dv; ddUsers.DataTextField = "UserName"; ddUsers.DataValueField = "UserId"; ddUsers.DataBind(); btnAdd.Disabled = false; if (GroupID > 0) { ddUsers.Items.Insert(0, new ListItem(LocRM.GetString("tAny"), "0")); } else if (ddUsers.Items.Count == 0) { ddUsers.Items.Insert(0, new ListItem(LocRM.GetString("tEmpty"), "0")); btnAdd.Disabled = true; } }