Ejemplo n.º 1
0
        public void EmptyTrashcan(RecycleBin.RecycleBinType type)
        {
            //validate against the app type!
            switch (type)
            {
            case RecycleBin.RecycleBinType.Content:
                if (!AuthorizeRequest(DefaultApps.content.ToString()))
                {
                    return;
                }
                break;

            case RecycleBin.RecycleBinType.Media:
                if (!AuthorizeRequest(DefaultApps.media.ToString()))
                {
                    return;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException("type");
            }

            //TODO: This will never work in LB scenarios
            Application["trashcanEmptyLeft"] = RecycleBin.Count(type).ToString();
            emptyTrashCanDo(type);
        }
Ejemplo n.º 2
0
 public void EmptyTrashcan(cms.businesslogic.RecycleBin.RecycleBinType type)
 {
     if (BasePage.ValidateUserContextID(BasePage.umbracoUserContextID))
     {
         Application["trashcanEmptyLeft"] = RecycleBin.Count(type).ToString();
         emptyTrashCanDo(type);
     }
 }
Ejemplo n.º 3
0
        public void Media_Empty_Recycle_Bin()
        {
            //System.Diagnostics.Debugger.Break();

            var mediaList = new List <Media>();
            var total     = 20;
            var mt        = m_ExistingMediaType;

            //allow the doc type to be created underneath itself
            mt.AllowedChildContentTypeIDs = new int[] { mt.Id };
            mt.Save();

            //create 20 media nodes underneath each other, this will test deleting with heirarchy as well
            var lastParentId = -1;

            for (var i = 0; i < total; i++)
            {
                var newMedia = Media.MakeNew("R-" + i.ToString() + Guid.NewGuid().ToString("N"), mt, m_User, lastParentId);
                mediaList.Add(newMedia);
                Assert.IsTrue(mediaList[mediaList.Count - 1].Id > 0);
                Assert.AreEqual(lastParentId, newMedia.ParentId);
                lastParentId = newMedia.Id;
            }

            //now delete all of them, since they are nested, we only need to delete one
            mediaList.First().delete();

            //a callback action for each item removed from the recycle bin
            var totalDeleted = 0;

            var bin = new RecycleBin(RecycleBin.RecycleBinType.Media);
            var totalTrashedItems = bin.GetDescendants().Cast <object>().Count();

            bin.CallTheGarbageMan(x =>
            {
                Assert.AreEqual(totalTrashedItems - (++totalDeleted), x);
            });

            Assert.AreEqual(0, RecycleBin.Count(RecycleBin.RecycleBinType.Media));
        }
Ejemplo n.º 4
0
        public void Document_Empty_Recycle_Bin()
        {
            var docList = new List <Document>();
            var total   = 20;
            var dt      = m_ExistingDocType;

            //allow the doc type to be created underneath itself
            dt.AllowedChildContentTypeIDs = new int[] { dt.Id };
            dt.Save();

            //create 20 content nodes underneath each other, this will test deleting with heirarchy as well
            var lastParentId = -1;

            for (var i = 0; i < total; i++)
            {
                var newDoc = Document.MakeNew("R-" + i.ToString() + Guid.NewGuid().ToString("N"), dt, m_User, lastParentId);
                docList.Add(newDoc);
                Assert.IsTrue(docList[docList.Count - 1].Id > 0);
                Assert.AreEqual(lastParentId, newDoc.ParentId);
                lastParentId = newDoc.Id;
            }

            //now delete all of them, since they are nested, we only need to delete one
            docList.First().delete();

            //a callback action for each item removed from the recycle bin
            var totalDeleted = 0;

            var bin = new RecycleBin(RecycleBin.RecycleBinType.Content);
            var totalTrashedItems = bin.GetDescendants().Cast <object>().Count();

            bin.CallTheGarbageMan(x =>
            {
                Assert.AreEqual(totalTrashedItems - (++totalDeleted), x);
            });

            Assert.AreEqual(0, RecycleBin.Count(RecycleBin.RecycleBinType.Content));
        }