/// <summary> /// Gets the ACL. /// </summary> /// <param name="reportId">The report id.</param> /// <returns></returns> public static ReportAcl GetAcl(PrimaryKeyId reportId) { ReportAcl retVal = new ReportAcl(); retVal.OwnerReportId = reportId; foreach (mcweb_ReportAceRow row in mcweb_ReportAceRow.List(FilterElement.EqualElement(mcweb_ReportAceRow.Columns.ReportId, reportId))) { retVal.Add(new ReportAce(row.ReportAceId, row.Role, row.PrincipalId, row.Allow)); } retVal.Reset(); return(retVal); }
/// <summary> /// Sets the ACL. /// </summary> /// <param name="acl">The acl.</param> public static void SetAcl(ReportAcl acl) { if (acl == null) { throw new ArgumentNullException("acl"); } if (acl.IsChanged) { Guid reportId = (Guid)acl.OwnerReportId; using (TransactionScope tran = DataContext.Current.BeginTransaction()) { // Step 3. Remove old ace foreach (mcweb_ReportAceRow row in mcweb_ReportAceRow.List(FilterElement.EqualElement(mcweb_ReportAceRow.Columns.ReportId, reportId))) { row.Delete(); } // Save New Ace foreach (ReportAce ace in acl) { mcweb_ReportAceRow newRow = new mcweb_ReportAceRow(); newRow.ReportId = reportId; newRow.Role = ace.Role; newRow.PrincipalId = ace.PrincipalId; // Hot Fix if (newRow.Role == string.Empty) { newRow.Role = null; } if (newRow.PrincipalId.HasValue && newRow.PrincipalId.Value <= 0) { newRow.PrincipalId = null; } newRow.Allow = ace.Allow; newRow.Update(); } tran.Commit(); } } }
/// <summary> /// Gets the ACL. /// </summary> /// <param name="reportId">The report id.</param> /// <returns></returns> public static ReportAcl GetAcl(PrimaryKeyId reportId) { ReportAcl retVal = new ReportAcl(); retVal.OwnerReportId = reportId; foreach (mcweb_ReportAceRow row in mcweb_ReportAceRow.List(FilterElement.EqualElement(mcweb_ReportAceRow.Columns.ReportId, reportId))) { retVal.Add(new ReportAce(row.ReportAceId, row.Role, row.PrincipalId, row.Allow)); } retVal.Reset(); return retVal; }
/// <summary> /// Sets the ACL. /// </summary> /// <param name="acl">The acl.</param> public static void SetAcl(ReportAcl acl) { if(acl==null) throw new ArgumentNullException("acl"); if (acl.IsChanged) { Guid reportId = (Guid)acl.OwnerReportId; using (TransactionScope tran = DataContext.Current.BeginTransaction()) { // Step 3. Remove old ace foreach (mcweb_ReportAceRow row in mcweb_ReportAceRow.List(FilterElement.EqualElement(mcweb_ReportAceRow.Columns.ReportId, reportId))) { row.Delete(); } // Save New Ace foreach (ReportAce ace in acl) { mcweb_ReportAceRow newRow = new mcweb_ReportAceRow(); newRow.ReportId = reportId; newRow.Role = ace.Role; newRow.PrincipalId = ace.PrincipalId; // Hot Fix if (newRow.Role == string.Empty) newRow.Role = null; if (newRow.PrincipalId.HasValue && newRow.PrincipalId.Value <= 0) newRow.PrincipalId = null; newRow.Allow = ace.Allow; newRow.Update(); } tran.Commit(); } } }