コード例 #1
0
ファイル: FolderEnumerator.cs プロジェクト: mo5h/omeo
        private void EnumerateInternal(IEFolder folder, FolderDescriptor parentTag)
        {
            IEFolders folders = OutlookSession.GetFolders(folder);

            if (folders == null)
            {
                return;
            }
            using ( folders )
            {
                for (int i = 0; i < folders.GetCount(); ++i)
                {
                    OutlookSession.ProcessJobs();
                    IEFolder subFolder = OutlookSession.OpenFolder(folders, i);
                    if (subFolder == null)
                    {
                        continue;
                    }
                    using ( subFolder )
                    {
                        FolderDescriptor tag = null;
                        FolderDescriptor folderDescriptor  = FolderDescriptor.Get(_storeID, subFolder);
                        bool             continueEnumerate = _enumListener.FolderFetched(parentTag, folderDescriptor, out tag);
                        if (continueEnumerate)
                        {
                            EnumerateInternal(subFolder, tag);
                        }
                    }
                }
            }
        }
コード例 #2
0
 public FolderEnumeratorJob(IEFolder folder)
 {
     _folder = folder;
     if (_folder == null)
     {
         return;
     }
     _folders = OutlookSession.GetFolders(_folder);
     if (_folders != null)
     {
         _count = _folders.GetCount();
     }
 }
コード例 #3
0
 private void SynchronizeFolderRecursive(IEFolder folder, string name, string storeID, FolderDescriptor parentDescriptor)
 {
     if (folder == null)
     {
         return;
     }
     using ( folder )
     {
         FolderDescriptor folderDescriptor = FolderDescriptor.Get(folder);
         if (name != null)
         {
             folderDescriptor.Name = name;
             _tracer.Trace("Folder name = " + name);
         }
         else
         {
             _tracer.Trace("Folder name is unknown");
         }
         _folders.Remove(folderDescriptor.FolderIDs.EntryId);
         FolderStructureDescriptor folderStruct =
             new FolderStructureDescriptor(parentDescriptor, folderDescriptor);
         Core.ResourceAP.QueueJob(folderStruct);
         IEFolders folders = OutlookSession.GetFolders(folder, folderDescriptor);
         if (folders == null)
         {
             return;
         }
         using ( folders )
         {
             for (int i = 0; i < folders.GetCount(); ++i)
             {
                 try
                 {
                     SynchronizeFolderRecursive(folders.OpenFolder(i), null, storeID, folderDescriptor);
                 }
                 catch (COMException exception)
                 {
                     _tracer.TraceException(exception);
                     OutlookSession.ProblemWithOpeningFolder(folderDescriptor.FolderIDs.EntryId);
                     break;
                 }
             }
         }
     }
 }
コード例 #4
0
        public static bool IsStorageSupported(IEMsgStore msgStore)
        {
            if (Settings.SupportIMAP)
            {
                return(true);
            }

            IEFolder root = msgStore.GetRootFolder();

            if (root == null)
            {
                return(true);
            }
            using ( root )
            {
                IEFolders folders = OutlookSession.GetFolders(root);
                if (folders == null)
                {
                    return(true);
                }
                using ( folders )
                {
                    int count = folders.GetCount();
                    for (int i = 0; i < count; ++i)
                    {
                        IEFolder folder = OpenFolder(folders, i);
                        if (folder == null)
                        {
                            continue;
                        }
                        using ( folder )
                        {
                            string containerClass = folder.GetStringProp(MAPIConst.PR_CONTAINER_CLASS);
                            if (FolderType.IMAP == containerClass)
                            {
                                return(false);
                            }
                        }
                    }
                }
            }
            return(true);
        }
コード例 #5
0
ファイル: MAPIDescriptors.cs プロジェクト: mo5h/omeo
        public FolderDeletedDescriptor(MAPINtf ntf, string storeID)
        {
            Guard.NullArgument(ntf, "ntf");
            Guard.EmptyStringArgument(storeID, "storeID");
            _ntf     = ntf;
            _storeID = storeID;

            // The notification contains only the short-term entry ID, and since the
            // folder has already been deleted, it is no longer possible to get the
            // long-term entry ID. Thus, we need to scan the children of the parent of
            // the deleted folder and check if all of them still exist.
            IResource resFolder = Folder.Find(ntf.EntryID);

            if (resFolder == null)
            {
                IEFolder parentFolder =
                    OutlookSession.OpenFolder(ntf.ParentID, storeID);
                if (parentFolder != null)
                {
                    using ( parentFolder )
                    {
                        string    parentId         = OutlookSession.GetFolderID(parentFolder);
                        IResource parentMAPIFolder = Folder.Find(parentId);
                        if (parentMAPIFolder == null)
                        {
                            parentMAPIFolder = Folder.Find(ntf.ParentID);
                        }

                        if (parentMAPIFolder != null)
                        {
                            IResourceList childFolders = parentMAPIFolder.GetLinksTo("MAPIFolder", "Parent");
                            foreach (IResource childFolderRes in childFolders)
                            {
                                IEFolder childFolder = OutlookSession.OpenFolder(childFolderRes.GetStringProp("EntryID"),
                                                                                 storeID);
                                if (childFolder != null)
                                {
                                    childFolder.Dispose();
                                }
                                else
                                {
                                    _entryId = childFolderRes.GetStringProp("EntryID");
                                }
                            }

                            if (_entryId == null)
                            {
                                HashSet set = new HashSet(childFolders.Count);
                                foreach (IResource childFolderRes in childFolders)
                                {
                                    set.Add(childFolderRes.GetStringProp("EntryID"));
                                }

                                IEFolders folders = OutlookSession.GetFolders(parentFolder);
                                if (folders != null)
                                {
                                    using ( folders )
                                    {
                                        for (int i = 0; i < folders.GetCount(); ++i)
                                        {
                                            IEFolder folder = OutlookSession.OpenFolder(folders, i);
                                            if (folder != null)
                                            {
                                                using ( folder )
                                                {
                                                    string entryId = folder.GetBinProp(MAPIConst.PR_ENTRYID);
                                                    if (entryId != null)
                                                    {
                                                        set.Remove(entryId);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                foreach (HashSet.Entry entry in set)
                                {
                                    _entryId = (string)entry.Key;
                                    break;
                                }

                                if (_entryId == null && Retry)
                                {
                                    OutlookSession.OutlookProcessor.QueueJobAt(DateTime.Now.AddMinutes(2), "Delete folder",
                                                                               new MethodInvoker(CreateFolderDeletedDescriptor));
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                _entryId = ntf.EntryID;
            }
        }