Ejemplo n.º 1
0
        public bool CompareRootFolders()
        {
            ISourceFolder folder = base.SourceMailbox.GetFolder(null);

            if (folder == null)
            {
                throw new RootFolderNotFoundPermananentException();
            }
            FolderRec folderRec;

            using (folder)
            {
                folderRec = folder.GetFolderRec(null, GetFolderRecFlags.None);
            }
            IDestinationFolder folder2 = base.DestMailbox.GetFolder(null);

            if (folder2 == null)
            {
                throw new RootFolderNotFoundPermananentException();
            }
            FolderRec folderRec2;

            using (folder2)
            {
                folderRec2 = folder2.GetFolderRec(null, GetFolderRecFlags.None);
            }
            if (!CommonUtils.IsSameEntryId(folderRec.EntryId, folderRec2.EntryId))
            {
                MrsTracer.Service.Warning("Root folder IDs don't match on source and destination mailboxes. Restarting the move.", new object[0]);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
 public override FolderMap GetDestinationFolderMap(GetFolderMapFlags flags)
 {
     base.DestMailboxWrapper.LoadFolderMap(flags, delegate
     {
         List <FolderRecWrapper> list = new List <FolderRecWrapper>(this.hierarchyFolderEntryIds.Count);
         foreach (byte[] entryId in this.hierarchyFolderEntryIds)
         {
             byte[] sessionSpecificEntryId = base.DestMailbox.GetSessionSpecificEntryId(entryId);
             using (IDestinationFolder folder = base.DestMailbox.GetFolder(sessionSpecificEntryId))
             {
                 list.Add(new FolderRecWrapper(folder.GetFolderRec(null, GetFolderRecFlags.None)));
             }
         }
         return(new PublicFolderMap(list));
     });
     return(base.DestMailboxWrapper.FolderMap);
 }
        private IFolderProxy CreateFolder(FolderRec folder)
        {
            IFolderProxy result = null;
            bool         flag;

            folder.EntryId  = this.syncContext.MapSourceToDestinationFolderId(folder.EntryId, out flag);
            folder.ParentId = this.syncContext.MapSourceToDestinationFolderId(folder.ParentId, out flag);
            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                IDestinationFolder folder2 = this.destinationMailbox.GetFolder(folder.EntryId);
                if (folder2 != null)
                {
                    disposeGuard.Add <IDestinationFolder>(folder2);
                    folder2.SetProps(CommonUtils.PropertiesToDelete);
                    FolderRec folderRec = folder2.GetFolderRec(null, GetFolderRecFlags.None);
                    if (!CommonUtils.IsSameEntryId(folderRec.ParentId, folder.ParentId))
                    {
                        try
                        {
                            this.destinationMailbox.MoveFolder(folderRec.EntryId, folderRec.ParentId, folder.ParentId);
                        }
                        catch (ObjectNotFoundException arg)
                        {
                            PublicFolderHierarchyProxyPool.Tracer.TraceWarning <FolderRec, FolderRec, ObjectNotFoundException>((long)this.GetHashCode(), "ObjectNotFoundException caught during MoveFolder. Calling to FixParentChain before reattempting the folder move. SourceFolder={0}. DestinationFolder={1}. Exception={2}", folder, folderRec, arg);
                            this.FixParentChain(folder);
                            this.destinationMailbox.MoveFolder(folderRec.EntryId, folderRec.ParentId, folder.ParentId);
                        }
                    }
                    result = base.WrappedObject.GetFolderProxy(folder.EntryId);
                    PublicFolderHierarchyProxyPool.Tracer.TraceDebug <FolderRec>((long)this.GetHashCode(), "Folder updated: {0}", folder);
                    this.syncContext.Logger.LogFolderUpdated(folder.EntryId);
                }
                else
                {
                    try
                    {
                        result = base.WrappedObject.CreateFolder(folder);
                    }
                    catch (ObjectNotFoundException arg2)
                    {
                        PublicFolderHierarchyProxyPool.Tracer.TraceWarning <FolderRec, ObjectNotFoundException>((long)this.GetHashCode(), "ObjectNotFoundException caught during CreateFolder. Calling to FixParentChain before reattempting the folder creation. Folder={0}. Exception={1}", folder, arg2);
                        this.FixParentChain(folder);
                        result = base.WrappedObject.CreateFolder(folder);
                    }
                    folder2 = this.destinationMailbox.GetFolder(folder.EntryId);
                    disposeGuard.Add <IDestinationFolder>(folder2);
                    PublicFolderHierarchyProxyPool.Tracer.TraceDebug <FolderRec>((long)this.GetHashCode(), "Folder created: {0}", folder);
                    this.syncContext.Logger.LogFolderCreated(folder.EntryId);
                }
                byte[] dumpsterEntryIdFromFolderRec = PublicFolderHierarchyProxyPool.GetDumpsterEntryIdFromFolderRec(folder);
                if (dumpsterEntryIdFromFolderRec != null)
                {
                    bool   flag2;
                    byte[] value = this.syncContext.MapSourceToDestinationFolderId(dumpsterEntryIdFromFolderRec, out flag2);
                    folder2.SetProps(new PropValueData[]
                    {
                        new PropValueData(PropTag.IpmWasteBasketEntryId, value)
                    });
                }
            }
            return(result);
        }