Esempio n. 1
0
        public static void DeleteFolder(IResource folder, bool deletedItems)
        {
            if (Folder.IsDefault(folder))
            {
                return;
            }
            IResourceList folders       = Folder.GetDefaultDeletedItemsFolder();
            HashSet       childrenNames = new HashSet();

            foreach (IResource resFolder in folders)
            {
                foreach (IResource child in Folder.GetSubFolders(resFolder))
                {
                    childrenNames.Add(child.GetPropText(Core.Props.Name));
                }
            }

            string name    = folder.GetPropText(Core.Props.Name);
            string oldName = name;
            bool   rename  = false;

            for (int j = 1;; j++)
            {
                if (!childrenNames.Contains(name))
                {
                    break;
                }
                name   = oldName + j.ToString();
                rename = true;
            }
            PairIDs pairIds = PairIDs.Get(folder);

            if (pairIds != null)
            {
                if (deletedItems && rename)
                {
                    OutlookSession.DeleteFolderWithRename(pairIds, name);
                }
                else
                {
                    OutlookSession.DeleteFolder(pairIds, deletedItems);
                }
            }

            if (!deletedItems)
            {
                Core.ResourceAP.QueueJob(JobPriority.AboveNormal,
                                         new ResourceDelegate(DeleteFolderResource), folder);
            }
        }