Ejemplo n.º 1
0
        public static void DeletePolicy(Group g, Policy pol)
        {
            if (!DoesUserHavePolicy(WindchimeSession.Current.User, Policy.DeletePolicy))
            {
                throw new NoPolicyException(Policy.DeletePolicy);
            }

            using (WindchimeEntities wce = new WindchimeEntities())
            {
                var deletePol = (from PolicyEntry pe in wce.PolicyEntries
                                 where pe.GroupID == g.GroupID && pe.Policy == pol
                                 select pe);
                foreach (var p in deletePol)
                {
                    wce.DeleteObject(p);
                }
                wce.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public static void DeletePermissionEntry(Group g, PermissionableEntity ent, Permission perm)
        {
            if (!DoesUserHavePerm(WindchimeSession.Current.User, ent, Permission.EditPermissions))
            {
                throw new NoPermissionException(Permission.EditPermissions);
            }

            if (g == null || ent == null)
            {
                return;
            }

            using (WindchimeEntities wce = new WindchimeEntities())
            {
                var deletePerm = (from PermissionEntry pe in wce.PermissionEntrySet
                                  where pe.GroupID == g.GroupID && pe.EntityID == ent.EntityID && pe.Permission == (int)perm
                                  select pe);

                foreach (var pe in deletePerm)
                {
                    wce.DeleteObject(pe);
                }
            }
        }
Ejemplo n.º 3
0
        protected void ClearDBButton_Click(object sender, EventArgs e)
        {
            using (WindchimeEntities wce = new WindchimeEntities())
            {
                var deleteAssetTypes = (from x in wce.AssetTypeSet select x);
                var deleteComments   = (from x in wce.CommentSet select x);
                var deleteCreators   = (from x in wce.CreatorSet select x);
                var deleteGroups     = (from x in wce.Groups select x);
                var deleteEnts       = (from x in wce.PermissionableEntities select x);
                var deletePerms      = (from x in wce.PermissionEntrySet select x);
                var deletePols       = (from x in wce.PolicyEntries select x);
                var deleteVers       = (from x in wce.VersionSet select x);
                var deleteAssets     = (from x in wce.Assets select x);
                var deleteColls      = (from x in wce.Collections select x);

                foreach (Group go in wce.Groups)
                {
                    go.Parents.Load();
                    var Parents = go.Parents.ToList();
                    foreach (Group gi in Parents)
                    {
                        go.Parents.Remove(gi);
                    }
                }
                wce.SaveChanges();

                foreach (Collection co in wce.Collections)
                {
                    co.Parents.Load();
                    var Parents = co.Parents.ToList();
                    foreach (Collection ci in Parents)
                    {
                        co.Parents.Remove(ci);
                    }
                }
                wce.SaveChanges();

                foreach (Asset ao in wce.Assets)
                {
                    ao.Collections.Load();
                    var Parents = ao.Collections.ToList();
                    foreach (Collection ci in Parents)
                    {
                        ao.Collections.Remove(ci);
                    }
                }
                wce.SaveChanges();

                foreach (Group go in wce.Groups)
                {
                    go.Users.Load();
                    var Parents = go.Users.ToList();
                    foreach (User ui in Parents)
                    {
                        go.Users.Remove(ui);
                    }
                }
                wce.SaveChanges();

                foreach (var a in deleteAssetTypes)
                {
                    wce.DeleteObject(a);
                }
                foreach (var c in deleteComments)
                {
                    wce.DeleteObject(c);
                }
                foreach (var c in deleteCreators)
                {
                    wce.DeleteObject(c);
                }
                foreach (var g in deleteGroups)
                {
                    wce.DeleteObject(g);
                }
                foreach (var d in deleteEnts)
                {
                    wce.DeleteObject(d);
                }
                foreach (var p in deletePerms)
                {
                    wce.DeleteObject(p);
                }
                foreach (var p in deletePols)
                {
                    wce.DeleteObject(p);
                }
                foreach (var v in deleteVers)
                {
                    wce.DeleteObject(v);
                }
                foreach (var a in deleteAssets)
                {
                    wce.DeleteObject(a);
                }
                foreach (var c in deleteColls)
                {
                    wce.DeleteObject(c);
                }

                wce.SaveChanges();
            }

            LoadTestDataButton.Enabled = true;
        }
        public static void DeletePolicy(Group g, Policy pol)
        {
            if (!DoesUserHavePolicy(WindchimeSession.Current.User, Policy.DeletePolicy))
                throw new NoPolicyException(Policy.DeletePolicy);

            using (WindchimeEntities wce = new WindchimeEntities())
            {
                var deletePol = (from PolicyEntry pe in wce.PolicyEntries
                                 where pe.GroupID == g.GroupID && pe.Policy == pol
                                 select pe);
                foreach (var p in deletePol)
                    wce.DeleteObject(p);
                wce.SaveChanges();
            }
        }
        public static void DeletePermissionEntry(Group g, PermissionableEntity ent, Permission perm)
        {
            if (!DoesUserHavePerm(WindchimeSession.Current.User, ent, Permission.EditPermissions))
                throw new NoPermissionException(Permission.EditPermissions);

            if (g == null || ent == null)
                return;

            using (WindchimeEntities wce = new WindchimeEntities())
            {
                var deletePerm = (from PermissionEntry pe in wce.PermissionEntrySet
                                  where pe.GroupID == g.GroupID && pe.EntityID == ent.EntityID && pe.Permission == (int)perm
                                  select pe);

                foreach (var pe in deletePerm)
                    wce.DeleteObject(pe);
            }
        }
Ejemplo n.º 6
0
        protected void ClearDBButton_Click(object sender, EventArgs e)
        {
            using (WindchimeEntities wce = new WindchimeEntities())
            {
                var deleteAssetTypes = (from x in wce.AssetTypeSet select x);
                var deleteComments = (from x in wce.CommentSet select x);
                var deleteCreators = (from x in wce.CreatorSet select x);
                var deleteGroups = (from x in wce.Groups select x);
                var deleteEnts = (from x in wce.PermissionableEntities select x);
                var deletePerms = (from x in wce.PermissionEntrySet select x);
                var deletePols = (from x in wce.PolicyEntries select x);
                var deleteVers = (from x in wce.VersionSet select x);
                var deleteAssets = (from x in wce.Assets select x);
                var deleteColls = (from x in wce.Collections select x);

                foreach (Group go in wce.Groups)
                {
                    go.Parents.Load();
                    var Parents = go.Parents.ToList();
                    foreach (Group gi in Parents)
                        go.Parents.Remove(gi);
                }
                wce.SaveChanges();

                foreach (Collection co in wce.Collections)
                {
                    co.Parents.Load();
                    var Parents = co.Parents.ToList();
                    foreach (Collection ci in Parents)
                        co.Parents.Remove(ci);
                }
                wce.SaveChanges();

                foreach (Asset ao in wce.Assets)
                {
                    ao.Collections.Load();
                    var Parents = ao.Collections.ToList();
                    foreach (Collection ci in Parents)
                        ao.Collections.Remove(ci);
                }
                wce.SaveChanges();

                foreach (Group go in wce.Groups)
                {
                    go.Users.Load();
                    var Parents = go.Users.ToList();
                    foreach (User ui in Parents)
                        go.Users.Remove(ui);
                }
                wce.SaveChanges();

                foreach (var a in deleteAssetTypes)
                    wce.DeleteObject(a);
                foreach (var c in deleteComments)
                    wce.DeleteObject(c);
                foreach (var c in deleteCreators)
                    wce.DeleteObject(c);
                foreach (var g in deleteGroups)
                    wce.DeleteObject(g);
                foreach (var d in deleteEnts)
                    wce.DeleteObject(d);
                foreach (var p in deletePerms)
                    wce.DeleteObject(p);
                foreach (var p in deletePols)
                    wce.DeleteObject(p);
                foreach (var v in deleteVers)
                    wce.DeleteObject(v);
                foreach (var a in deleteAssets)
                    wce.DeleteObject(a);
                foreach (var c in deleteColls)
                    wce.DeleteObject(c);

                wce.SaveChanges();
            }

            LoadTestDataButton.Enabled = true;
        }