/// <summary>
        /// Empties the trash can
        /// </summary>
        /// <param name="itemDeletedCallback">a function to call whenever an item is removed from the bin</param>
        public void CallTheGarbageMan(Action <int> itemDeletedCallback)
        {
            lock (m_Locker)
            {
                //first, move all nodes underneath the recycle bin directly under the recycle bin node (flatten heirarchy)
                //then delete them all.

                SqlHelper.ExecuteNonQuery("UPDATE umbracoNode SET parentID=@parentID, level=1 WHERE path LIKE '%," + ((int)m_BinType).ToString() + ",%'",
                                          SqlHelper.CreateParameter("@parentID", (int)m_BinType));

                foreach (var c in Children.ToList())
                {
                    switch (m_BinType)
                    {
                    case RecycleBinType.Content:
                        new Document(c.Id).delete(true);
                        itemDeletedCallback(RecycleBin.Count(m_BinType));
                        break;

                    case RecycleBinType.Media:
                        new Media(c.Id).delete(true);
                        itemDeletedCallback(RecycleBin.Count(m_BinType));
                        break;
                    }
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// If I smell, I'm not empty
 /// </summary>
 public bool Smells()
 {
     return(RecycleBin.Count(m_BinType) > 0);
 }