示例#1
0
        public DragDropEffects DragOver(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState)
        {
            if (data.GetDataPresent(typeof(IResourceList)))                // Dragging resources over
            {
                // The resources we're dragging
                IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList));

                if (ListOfMailsOrLinkedAttachments(dragResources))
                {
                    return(DragDropEffects.Move);
                }
                if (!dragResources.AllResourcesOfType(STR.MAPIFolder))
                {
                    return(DragDropEffects.None);
                }
                foreach (IResource folder in dragResources.ValidResources)
                {
                    //  A default folder cannot be moved, so it can be dropped
                    //  only to its own parent for the sake of reordering
                    if ((Folder.IsDefault(folder)) && (Folder.GetParent(folder) != targetResource))
                    {
                        return(DragDropEffects.None);
                    }

                    // Don't allow dropping to self and own children
                    if ((folder == targetResource) || (Folder.IsAncestor(targetResource, folder)))
                    {
                        return(DragDropEffects.None);
                    }
                }
                return(DragDropEffects.Move);
            }
            return(DragDropEffects.None);
        }
示例#2
0
        private HashNode AddLocalAddressBook(IResource mapiFolder)
        {
            if (Folder.IsDeletedItems(mapiFolder))
            {
                Folder.SetIgnoreImportAsync(mapiFolder, _folderType, true);
                return(null);
            }
            IResource parentFolder = Folder.GetParent(mapiFolder);

            if (parentFolder == null)
            {
                ResourceProxy proxy = new ResourceProxy(mapiFolder);
                proxy.DeleteAsync();
                return(null);
            }
            if (Folder.IsRoot(parentFolder))
            {
                return(_rootNode.InsertResource(mapiFolder));
            }
            else
            {
                HashNode hasNode =
                    AddLocalAddressBook(parentFolder);
                if (hasNode == null)
                {
                    Folder.SetIgnoreImportAsync(mapiFolder, _folderType, true);
                    return(null);
                }
                return(hasNode.InsertResource(mapiFolder));
            }
        }
示例#3
0
文件: MAPIFolder.cs 项目: mo5h/omeo
        public static bool IsAncestor(IResource folder, IResource possibleAncestor)
        {
            IResource current = Folder.GetParent(folder);

            while (!Folder.IsRoot(current))
            {
                if (current == possibleAncestor)
                {
                    return(true);
                }
                current = Folder.GetParent(current);
            }
            return(false);
        }
示例#4
0
文件: MAPIFolder.cs 项目: mo5h/omeo
        public static bool HasDeletedItemsAsAncestor(IResource folder)
        {
            IResource current = Folder.GetParent(folder);

            while (!Folder.IsRoot(current))
            {
                if (Folder.IsDeletedItems(current))
                {
                    return(true);
                }
                current = Folder.GetParent(current);
            }
            return(false);
        }
示例#5
0
        protected void ExecuteActionImpl(IResourceList selectedResources)
        {
            Tracer._Trace("Execute action: MoveFolderToFolderAction");
            if (_selectedFolder == null || _targetFolder == null)
            {
                return;
            }

            IEFolder destFolder =
                OutlookSession.OpenFolder(_selectedFolder.EntryId, _selectedFolder.StoreId);

            if (destFolder == null)
            {
                return;
            }

            using ( destFolder )
            {
                for (int i = 0; i < selectedResources.Count; i++)
                {
                    PairIDs folderIDs = PairIDs.Get(selectedResources[i]);
                    if (folderIDs == null)
                    {
                        continue;
                    }
                    IResource parentFolder    = Folder.GetParent(selectedResources[i]);
                    PairIDs   parentFolderIDs = PairIDs.Get(parentFolder);
                    if (parentFolderIDs == null)
                    {
                        continue;
                    }

                    IEFolder ieFolder =
                        OutlookSession.OpenFolder(parentFolderIDs.EntryId, parentFolderIDs.StoreId);
                    if (ieFolder == null)
                    {
                        continue;
                    }
                    using ( ieFolder )
                    {
                        Tracer._Trace("Move folder: " + folderIDs.EntryId.GetHashCode() + "/" + folderIDs.EntryId);
                        try
                        {
                            ieFolder.MoveFolder(folderIDs.EntryId, destFolder);
                        }
                        catch (COMException exception)
                        {
                            Tracer._TraceException(exception);
                            if (exception.ErrorCode == (unchecked ((int)0x8004010F)))
                            {
                                StandartJobs.MessageBox("Folder is not found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else if (exception.ErrorCode == (unchecked ((int)0x80040604)))
                            {
                                StandartJobs.MessageBox("Collision. Probably target folder has subfolder with the same name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else if (exception.ErrorCode == (unchecked ((int)0x80040119)) || exception.ErrorCode == (unchecked ((int)0x8004dff2)))
                            {
                                StandartJobs.MessageBox("Unspecified error. Can't move or copt folder.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                StandartJobs.MessageBox(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
        }