Exemplo n.º 1
0
        /// <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();
                }
            }
        }
Exemplo n.º 2
0
        /// <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();
                }
            }
        }