Exemple #1
0
 public virtual void CopyFrom(FolderRecWrapper sourceRec)
 {
     this.FolderRec.CopyFrom(sourceRec.FolderRec);
     this.Rules                   = sourceRec.Rules;
     this.FolderNTSD              = sourceRec.FolderNTSD;
     this.FolderFreeBusyNTSD      = sourceRec.FolderFreeBusyNTSD;
     this.FolderACL               = sourceRec.FolderACL;
     this.FolderFreeBusyACL       = sourceRec.FolderFreeBusyACL;
     this.SearchFolderRestriction = sourceRec.SearchFolderRestriction;
     this.SearchFolderScopeIDs    = sourceRec.SearchFolderScopeIDs;
     this.SearchFolderState       = sourceRec.SearchFolderState;
     this.LoadedData              = sourceRec.LoadedData;
     this.MappedData              = sourceRec.MappedData;
 }
Exemple #2
0
 public void RemoveFolder(FolderRecWrapper rec)
 {
     if (rec == this.RootRec)
     {
         throw new UnexpectedErrorPermanentException(-2147467259);
     }
     this[rec.EntryId] = null;
     rec.Parent        = null;
     if (rec.Children != null)
     {
         while (rec.Children.Count > 0)
         {
             this.RemoveFolder(rec.Children[0]);
         }
     }
 }
Exemple #3
0
        protected static bool IsValidFolderType(EnumHierarchyFlags flags, FolderRecWrapper folderRec)
        {
            switch (folderRec.FolderType)
            {
            case FolderType.Root:
                return((flags & EnumHierarchyFlags.RootFolder) != EnumHierarchyFlags.None);

            case FolderType.Generic:
                return((flags & EnumHierarchyFlags.NormalFolders) != EnumHierarchyFlags.None);

            case FolderType.Search:
                return((flags & EnumHierarchyFlags.SearchFolders) != EnumHierarchyFlags.None);

            default:
                return(false);
            }
        }
Exemple #4
0
        private void MarkPublicFolderDumpster(FolderRecWrapper sourceFolder)
        {
            if (!base.IsPublicFolderMailbox)
            {
                return;
            }
            FolderMapping folderMapping = (FolderMapping)sourceFolder;

            if (!folderMapping.IsPublicFolderDumpster && ((folderMapping.Flags & FolderMappingFlags.Include) != FolderMappingFlags.None || (folderMapping.Flags & FolderMappingFlags.InheritedInclude) != FolderMappingFlags.None))
            {
                FolderMapping folderMapping2 = (FolderMapping)sourceFolder.PublicFolderDumpster;
                if (folderMapping2 != null)
                {
                    folderMapping2.Flags |= FolderMappingFlags.Include;
                }
            }
        }
Exemple #5
0
 public override void CopyFolderProperties(FolderRecWrapper sourceFolderRecWrapper, ISourceFolder sourceFolder, IDestinationFolder destFolder, FolderRecDataFlags dataToCopy, out bool wasPropertyCopyingSkipped)
 {
     wasPropertyCopyingSkipped = false;
     if (this.sessionSpecificEntryIds.ContainsKey(sourceFolderRecWrapper.EntryId) && destFolder != null)
     {
         if (base.SupportsPerUserReadUnreadDataTransfer)
         {
             using (IFxProxy fxProxy = destFolder.GetFxProxy(FastTransferFlags.PassThrough))
             {
                 using (IFxProxy fxProxy2 = base.CreateFxProxyTransmissionPipeline(fxProxy))
                 {
                     sourceFolder.CopyTo(fxProxy2, CopyPropertiesFlags.CopyFolderPerUserData, Array <PropTag> .Empty);
                 }
             }
         }
         base.CopyFolderProperties(sourceFolderRecWrapper, sourceFolder, destFolder, FolderRecDataFlags.Rules, out wasPropertyCopyingSkipped);
     }
 }
Exemple #6
0
        public override bool IsContentAvailableInTargetMailbox(FolderRecWrapper destinationFolderRec)
        {
            FolderMapping folderMapping = destinationFolderRec as FolderMapping;

            if (folderMapping.IsSystemPublicFolder || destinationFolderRec.IsPublicFolderDumpster)
            {
                return(false);
            }
            byte[] array = destinationFolderRec.FolderRec[PropTag.ReplicaList] as byte[];
            if (array != null)
            {
                StorePropertyDefinition replicaList = CoreFolderSchema.ReplicaList;
                string[] stringArrayFromBytes       = ReplicaListProperty.GetStringArrayFromBytes(array);
                Guid     a;
                return(stringArrayFromBytes.Length > 0 && GuidHelper.TryParseGuid(stringArrayFromBytes[0], out a) && a == base.TargetMailboxGuid);
            }
            return(true);
        }
Exemple #7
0
        public void UpdateFolder(FolderRec updatedFolderData)
        {
            FolderRecWrapper folderRecWrapper = this[updatedFolderData.EntryId];

            if (folderRecWrapper == null)
            {
                return;
            }
            if (!CommonUtils.IsSameEntryId(updatedFolderData.ParentId, folderRecWrapper.ParentId))
            {
                FolderRecWrapper folderRecWrapper2 = this[updatedFolderData.ParentId];
                if (folderRecWrapper2 == null || folderRecWrapper2.IsChildOf(folderRecWrapper))
                {
                    throw new UnableToApplyFolderHierarchyChangesTransientException();
                }
                folderRecWrapper.Parent = folderRecWrapper2;
            }
            folderRecWrapper.FolderRec.CopyFrom(updatedFolderData);
        }
Exemple #8
0
 public void Config(List <FolderRecWrapper> folders)
 {
     this.Clear();
     foreach (FolderRecWrapper folderRecWrapper in folders)
     {
         if (this.folders.ContainsKey(folderRecWrapper.EntryId))
         {
             FolderRecWrapper folderRecWrapper2 = this.folders[folderRecWrapper.EntryId];
             MrsTracer.Service.Error("Folder {0} is listed more than once in the input folder list", new object[]
             {
                 folderRecWrapper.FolderRec.ToString()
             });
             this.TraceFolders(folders, "Input folder list");
             throw new FolderHierarchyContainsDuplicatesPermanentException(folderRecWrapper.FolderRec.ToString(), folderRecWrapper2.FolderRec.ToString());
         }
         if (this.IsPublicFolderMailbox && folderRecWrapper.IsPublicFolderDumpster)
         {
             byte[] array = (byte[])folderRecWrapper.FolderRec[PropTag.LTID];
             if (array != null)
             {
                 this.publicFolderDumpsters.Add(array, folderRecWrapper);
             }
         }
         this.InsertFolderInternal(folderRecWrapper);
     }
     if (this.IsPublicFolderMailbox)
     {
         foreach (FolderRecWrapper folderRecWrapper3 in folders)
         {
             if (!folderRecWrapper3.IsPublicFolderDumpster)
             {
                 byte[]           array2 = (byte[])folderRecWrapper3.FolderRec[PropTag.IpmWasteBasketEntryId];
                 FolderRecWrapper publicFolderDumpster;
                 if (array2 != null && this.publicFolderDumpsters.TryGetValue(array2, out publicFolderDumpster))
                 {
                     folderRecWrapper3.PublicFolderDumpster = publicFolderDumpster;
                 }
             }
         }
     }
     this.ValidateMap();
 }
Exemple #9
0
        public override void CopyFolderProperties(FolderRecWrapper folderRec, ISourceFolder sourceFolder, IDestinationFolder destFolder, FolderRecDataFlags dataToCopy, out bool wasPropertyCopyingSkipped)
        {
            base.CopyFolderProperties(folderRec, sourceFolder, destFolder, dataToCopy, out wasPropertyCopyingSkipped);
            MrsTracer.Service.Debug("Stamping additional properties on the target folder", new object[0]);
            List <PropValueData> list = new List <PropValueData>(3);

            list.Add(new PropValueData(this.DestHierarchy.SourceEntryIDPtag, folderRec.EntryId));
            list.Add(new PropValueData(this.DestHierarchy.SourceLastModifiedTimestampPtag, folderRec.FolderRec.LastModifyTimestamp));
            WellKnownFolderType wellKnownFolderType = WellKnownFolderType.None;

            if (this.SourceHierarchy != null)
            {
                wellKnownFolderType = this.SourceHierarchy.GetWellKnownFolderType(folderRec.EntryId);
            }
            if (wellKnownFolderType != WellKnownFolderType.None)
            {
                list.Add(new PropValueData(this.DestHierarchy.SourceWKFTypePtag, (int)wellKnownFolderType));
            }
            destFolder.SetProps(list.ToArray());
        }
Exemple #10
0
        protected virtual void InsertFolderInternal(FolderRecWrapper rec)
        {
            FolderRecWrapper folderRecWrapper;

            if (rec.ParentId != null)
            {
                folderRecWrapper = this[rec.ParentId];
            }
            else
            {
                folderRecWrapper = null;
            }
            for (FolderRecWrapper folderRecWrapper2 = folderRecWrapper; folderRecWrapper2 != null; folderRecWrapper2 = folderRecWrapper2.Parent)
            {
                if (CommonUtils.IsSameEntryId(folderRecWrapper2.ParentId, rec.EntryId))
                {
                    MrsTracer.Service.Error("Loop in the parent chain detected, folder {0}", new object[]
                    {
                        rec.FolderRec.ToString()
                    });
                    this.TraceFolders(this.folders.Values, "Folders");
                    throw new FolderHierarchyContainsParentChainLoopPermanentException(rec.FolderRec.ToString());
                }
            }
            this[rec.EntryId] = rec;
            rec.Parent        = folderRecWrapper;
            for (int i = this.roots.Count - 1; i >= 0; i--)
            {
                FolderRecWrapper folderRecWrapper3 = this.roots[i];
                if (CommonUtils.IsSameEntryId(folderRecWrapper3.ParentId, rec.EntryId))
                {
                    folderRecWrapper3.Parent = rec;
                    this.roots.RemoveAt(i);
                }
            }
            if (folderRecWrapper == null)
            {
                this.roots.Add(rec);
            }
        }
Exemple #11
0
        protected override FolderRecWrapper CreateDestinationFolder(SyncContext syncContext, FolderRecWrapper srcFolderRec, FolderRecWrapper destParentRec)
        {
            CreateFolderFlags createFolderFlags = CreateFolderFlags.None;

            if (base.IsRoot && base.IsPublicFolderMigration && base.DestMailbox.IsCapabilitySupported(MRSProxyCapabilities.CanStoreCreatePFDumpster))
            {
                createFolderFlags = CreateFolderFlags.CreatePublicFolderDumpster;
            }
            byte[] entryId;
            this.CreateFolder(PublicFolderMigrator.dummyEnumFolderContext, srcFolderRec, createFolderFlags, out entryId);
            FolderRecWrapper folderRecWrapper = syncContext.CreateTargetFolderRec(srcFolderRec);

            folderRecWrapper.FolderRec.EntryId  = entryId;
            folderRecWrapper.FolderRec.ParentId = destParentRec.EntryId;
            List <PropValueData> list = new List <PropValueData>(folderRecWrapper.FolderRec.AdditionalProps);

            list.Add(new PropValueData(PropTag.ReplicaList, ReplicaListProperty.GetBytesFromStringArray(new string[]
            {
                this.GetContentMailboxGuid(srcFolderRec).ToString()
            })));
            folderRecWrapper.FolderRec.AdditionalProps = list.ToArray();
            return(folderRecWrapper);
        }
Exemple #12
0
 private Guid GetContentMailboxGuid(FolderRecWrapper sourceFolderRec)
 {
     return(sourceFolderRec.GetContentMailboxGuid(delegate(string fullFolderName)
     {
         fullFolderName = PublicFolderMigrator.NormalizeFolderPath(sourceFolderRec.FullFolderName);
         if (string.IsNullOrWhiteSpace(fullFolderName))
         {
             return this.publicFolderConfiguration.GetHierarchyMailboxInformation().HierarchyMailboxGuid;
         }
         Guid result = this.publicFolderConfiguration.GetHierarchyMailboxInformation().HierarchyMailboxGuid;
         int num = 0;
         foreach (FolderToMailboxMapping folderToMailboxMapping in this.folderToMailboxMap)
         {
             string text = folderToMailboxMapping.FolderName;
             text = ((text.IndexOf('ÿ') > -1) ? text.Replace('ÿ', "\\"[0]) : text);
             if (fullFolderName.StartsWith(text, StringComparison.OrdinalIgnoreCase) && text.Length >= num)
             {
                 num = text.Length;
                 result = folderToMailboxMapping.MailboxGuid;
             }
         }
         return result;
     }));
 }
Exemple #13
0
 public FolderRecWrapper(FolderRecWrapper folderRecWrapper)
 {
     this.FolderRec = new FolderRec();
     this.CopyFrom(folderRecWrapper);
 }
Exemple #14
0
        public override void CopyFolderProperties(FolderRecWrapper sourceFolderRecWrapper, ISourceFolder sourceFolder, IDestinationFolder destFolder, FolderRecDataFlags dataToCopy, out bool wasPropertyCopyingSkipped)
        {
            Guid empty  = Guid.Empty;
            bool isRoot = base.IsRoot;
            bool flag   = false;

            wasPropertyCopyingSkipped = false;
            FolderMapping folderMapping = sourceFolderRecWrapper as FolderMapping;

            while (folderMapping.WKFType != WellKnownFolderType.Root)
            {
                if (folderMapping.IsLegacyPublicFolder)
                {
                    return;
                }
                folderMapping = (folderMapping.Parent as FolderMapping);
            }
            if (destFolder == null)
            {
                if (!isRoot || ((FolderMapping)sourceFolderRecWrapper).IsSystemPublicFolder)
                {
                    MrsTracer.Service.Debug("Skipping final property copying for \"{0}\" folder since it's contents don't reside in this mailbox", new object[]
                    {
                        sourceFolderRecWrapper.FullFolderName
                    });
                    return;
                }
                throw new FolderCopyFailedPermanentException(sourceFolderRecWrapper.FullFolderName);
            }
            else
            {
                PropValueData[] props = destFolder.GetProps(new PropTag[]
                {
                    PropTag.ReplicaList,
                    PropTag.IpmWasteBasketEntryId
                });
                IDataConverter <PropValue, PropValueData> dataConverter = new PropValueConverter();
                PropValue nativeRepresentation = dataConverter.GetNativeRepresentation(props[0]);
                byte[]    array = nativeRepresentation.Value as byte[];
                if (!nativeRepresentation.IsNull() && !nativeRepresentation.IsError() && array != null)
                {
                    StorePropertyDefinition replicaList = CoreFolderSchema.ReplicaList;
                    string[] stringArrayFromBytes       = ReplicaListProperty.GetStringArrayFromBytes(array);
                    if (stringArrayFromBytes.Length > 0 && GuidHelper.TryParseGuid(stringArrayFromBytes[0], out empty))
                    {
                        flag = (empty == base.TargetMailboxGuid);
                    }
                }
                FolderStateSnapshot folderStateSnapshot = base.ICSSyncState[sourceFolderRecWrapper.EntryId];
                FolderState         state = folderStateSnapshot.State;
                if (sourceFolder.GetFolderRec(this.GetAdditionalFolderPtags(), GetFolderRecFlags.None).IsGhosted)
                {
                    folderStateSnapshot.State |= FolderState.IsGhosted;
                }
                else
                {
                    folderStateSnapshot.State &= ~FolderState.IsGhosted;
                }
                if (state != folderStateSnapshot.State)
                {
                    base.SaveICSSyncState(false);
                }
                if (!isRoot && !flag)
                {
                    return;
                }
                List <PropValueData> list = new List <PropValueData>(2);
                bool flag2 = false;
                if (flag)
                {
                    PropValue nativeRepresentation2 = dataConverter.GetNativeRepresentation(sourceFolder.GetProps(new PropTag[]
                    {
                        PropTag.PfProxy
                    })[0]);
                    if (!nativeRepresentation2.IsNull() && !nativeRepresentation2.IsError())
                    {
                        byte[] array2 = nativeRepresentation2.Value as byte[];
                        if (array2 != null && array2.Length == 16 && new Guid(array2) != Guid.Empty)
                        {
                            Guid a     = Guid.Empty;
                            bool flag3 = base.Flags.HasFlag(MailboxCopierFlags.CrossOrg);
                            if (flag3)
                            {
                                a = destFolder.LinkMailPublicFolder(LinkMailPublicFolderFlags.EntryId, sourceFolderRecWrapper.EntryId);
                            }
                            else
                            {
                                a = destFolder.LinkMailPublicFolder(LinkMailPublicFolderFlags.ObjectGuid, array2);
                            }
                            if (a != Guid.Empty)
                            {
                                list.Add(new PropValueData(PropTag.PfProxy, a.ToByteArray()));
                                list.Add(new PropValueData(PropTag.PfProxyRequired, true));
                                flag2 = true;
                            }
                            else
                            {
                                base.Report.Append(new ReportEntry(MrsStrings.ReportFailedToLinkADPublicFolder(sourceFolderRecWrapper.FullFolderName, BitConverter.ToString(array2), BitConverter.ToString(sourceFolderRecWrapper.EntryId)), ReportEntryType.Warning));
                            }
                        }
                    }
                }
                if (!flag2)
                {
                    list.Add(new PropValueData(PropTag.PfProxy, Guid.Empty.ToByteArray()));
                    list.Add(new PropValueData(PropTag.PfProxyRequired, false));
                }
                List <PropValueData> list2 = new List <PropValueData>(9);
                if (isRoot)
                {
                    if (!flag)
                    {
                        dataToCopy &= (FolderRecDataFlags.SecurityDescriptors | FolderRecDataFlags.FolderAcls | FolderRecDataFlags.ExtendedAclInformation);
                    }
                    list2.AddRange(list);
                }
                else
                {
                    byte[] sessionSpecificEntryId = this.hierarchyMailbox.GetSessionSpecificEntryId(sourceFolderRecWrapper.EntryId);
                    using (IDestinationFolder folder = this.hierarchyMailbox.GetFolder(sessionSpecificEntryId))
                    {
                        if (folder == null)
                        {
                            MrsTracer.Service.Error("Something deleted destination hierarchy folder from under us", new object[0]);
                            throw new UnexpectedErrorPermanentException(-2147221238);
                        }
                        if (list.Count > 0)
                        {
                            folder.SetProps(list.ToArray());
                        }
                    }
                }
                base.CopyFolderProperties(sourceFolderRecWrapper, sourceFolder, destFolder, dataToCopy, out wasPropertyCopyingSkipped);
                PropTag[] pta = new PropTag[]
                {
                    PropTag.DisablePeruserRead,
                    PropTag.OverallAgeLimit,
                    PropTag.RetentionAgeLimit,
                    PropTag.PfQuotaStyle,
                    PropTag.PfOverHardQuotaLimit,
                    PropTag.PfStorageQuota,
                    PropTag.PfMsgSizeLimit
                };
                foreach (PropValueData propValueData in sourceFolder.GetProps(pta))
                {
                    PropValue nativeRepresentation3 = dataConverter.GetNativeRepresentation(propValueData);
                    if (!nativeRepresentation3.IsNull() && !nativeRepresentation3.IsError())
                    {
                        if (propValueData.PropTag == 1721303043 && (int)propValueData.Value > 0)
                        {
                            propValueData.Value = (int)EnhancedTimeSpan.FromDays((double)((int)propValueData.Value)).TotalSeconds;
                        }
                        list2.Add(propValueData);
                    }
                }
                if (list2.Count > 0)
                {
                    destFolder.SetProps(list2.ToArray());
                }
                return;
            }
        }
Exemple #15
0
 public override byte[] GetSourceFolderEntryId(FolderRecWrapper destinationFolderRec)
 {
     return(base.SourceMailbox.GetSessionSpecificEntryId(destinationFolderRec.EntryId));
 }
Exemple #16
0
        public override void CreateFolder(FolderMap.EnumFolderContext context, FolderRecWrapper sourceFolderRecWrapper, CreateFolderFlags createFolderFlags, out byte[] newFolderEntryId)
        {
            if (sourceFolderRecWrapper.IsInternalAccess)
            {
                throw new InternalAccessFolderCreationIsNotSupportedException();
            }
            newFolderEntryId = null;
            FolderMapping   folderMapping   = sourceFolderRecWrapper as FolderMapping;
            FolderHierarchy folderHierarchy = base.DestMailboxWrapper.FolderMap as FolderHierarchy;

            byte[]        sessionSpecificEntryId = base.DestMailbox.GetSessionSpecificEntryId(folderMapping.EntryId);
            FolderMapping folderMapping2         = folderMapping.Parent as FolderMapping;
            bool          isRoot = base.IsRoot;

            byte[] parentId;
            switch (folderMapping2.WKFType)
            {
            case WellKnownFolderType.Root:
            case WellKnownFolderType.NonIpmSubtree:
            case WellKnownFolderType.IpmSubtree:
            case WellKnownFolderType.EFormsRegistry:
                parentId = folderHierarchy.GetWellKnownFolder(folderMapping2.WKFType).EntryId;
                break;

            default:
                if (isRoot || this.ShouldCreateUnderParentInSecondary())
                {
                    parentId = base.DestMailbox.GetSessionSpecificEntryId(folderMapping.ParentId);
                }
                else
                {
                    parentId = folderHierarchy.GetWellKnownFolder(WellKnownFolderType.IpmSubtree).EntryId;
                }
                break;
            }
            byte[] entryId   = folderMapping.FolderRec.EntryId;
            byte[] parentId2 = folderMapping.FolderRec.ParentId;
            folderMapping.FolderRec.EntryId  = sessionSpecificEntryId;
            folderMapping.FolderRec.ParentId = parentId;
            base.DestMailbox.CreateFolder(folderMapping.FolderRec, createFolderFlags, out newFolderEntryId);
            folderMapping.FolderRec.EntryId  = entryId;
            folderMapping.FolderRec.ParentId = parentId2;
            List <PropValueData> list           = new List <PropValueData>(2);
            Guid contentMailboxGuid             = this.GetContentMailboxGuid(sourceFolderRecWrapper);
            StorePropertyDefinition replicaList = CoreFolderSchema.ReplicaList;

            byte[] bytesFromStringArray = ReplicaListProperty.GetBytesFromStringArray(new string[]
            {
                contentMailboxGuid.ToString()
            });
            list.Add(new PropValueData(PropTag.ReplicaList, bytesFromStringArray));
            using (IDestinationFolder folder = base.DestMailbox.GetFolder(sessionSpecificEntryId))
            {
                if (folder == null)
                {
                    MrsTracer.Service.Error("Something deleted destination folder from under us", new object[0]);
                    throw new UnexpectedErrorPermanentException(-2147221238);
                }
                if (isRoot && !this.AssociatedDumpsterExists(folder))
                {
                    byte[] value = this.CreateAssociatedDumpsterFolder(folderMapping.FolderName, bytesFromStringArray, sessionSpecificEntryId);
                    list.Add(new PropValueData(PropTag.IpmWasteBasketEntryId, value));
                }
                folder.SetProps(list.ToArray());
            }
        }
Exemple #17
0
 protected virtual void AfterParentChange(FolderRecWrapper previousParent)
 {
 }
Exemple #18
0
 protected override bool ShouldCopyFolderProperties(FolderRecWrapper sourceFolderRec)
 {
     return(this.IsHierarchyMailboxCopier() || this.HasSourceFolderContents(sourceFolderRec));
 }
Exemple #19
0
 public override byte[] GetSourceEntryIdFromTargetFolder(FolderRecWrapper targetFolder)
 {
     return(this.Merger.GetSourceFolderEntryId(targetFolder));
 }
 protected override void VerifyFolderContents(MailboxCopierBase mbxCtx, FolderRecWrapper folderRecWrapper, List <FolderSizeRec> verificationResults)
 {
     throw new NotImplementedException();
 }
Exemple #21
0
 protected override void AfterParentChange(FolderRecWrapper previousParent)
 {
     this.ApplyInheritanceFlags();
 }
 public List <FolderRecWrapper> LoadFolders <TFolderRec>(EnumerateFolderHierarchyFlags enumerateFolderHierarchyFlags, PropTag[] additionalPtags) where TFolderRec : FolderRecWrapper, new()
 {
     return(FolderRecWrapper.WrapList <TFolderRec>(this.Mailbox.EnumerateFolderHierarchy(enumerateFolderHierarchyFlags, additionalPtags)));
 }
        protected override void CatchupFolderHierarchy()
        {
            if (!this.PrimaryHierarchyMbxWrapper.Mailbox.IsConnected())
            {
                this.PrimaryHierarchyMbxWrapper.Mailbox.Connect(MailboxConnectFlags.None);
            }
            FolderRecDataFlags folderRecDataFlags = FolderRecDataFlags.SearchCriteria;

            if (!base.CachedRequestJob.SkipFolderPromotedProperties)
            {
                folderRecDataFlags |= FolderRecDataFlags.PromotedProperties;
            }
            if (!base.CachedRequestJob.SkipFolderViews)
            {
                folderRecDataFlags |= FolderRecDataFlags.Views;
            }
            if (!base.CachedRequestJob.SkipFolderRestrictions)
            {
                folderRecDataFlags |= FolderRecDataFlags.Restrictions;
            }
            List <WellKnownFolder> list = this.folderMover.SourceMailbox.DiscoverWellKnownFolders(0);
            List <WellKnownFolder> destinationWellKnownFolders = this.folderMover.DestMailbox.DiscoverWellKnownFolders(0);

            foreach (byte[] array in this.foldersToMove)
            {
                using (IFolder folder = ((ISourceMailbox)this.PrimaryHierarchyMbxWrapper.Mailbox).GetFolder(array))
                {
                    using (IDestinationFolder folder2 = this.folderMover.DestMailbox.GetFolder(this.folderMover.DestMailbox.GetSessionSpecificEntryId(array)))
                    {
                        if (folder2 == null)
                        {
                            if (folder == null)
                            {
                                MrsTracer.Service.Debug("Folder {0} unavailable at both source and destination mailbox during catchup", new object[]
                                {
                                    HexConverter.ByteArrayToHexString(array)
                                });
                            }
                            else
                            {
                                List <FolderRecWrapper> list2 = new List <FolderRecWrapper>();
                                byte[] entryId = array;
                                for (;;)
                                {
                                    using (ISourceFolder folder3 = this.folderMover.SourceMailbox.GetFolder(entryId))
                                    {
                                        if (folder3 != null)
                                        {
                                            FolderRecWrapper folderRecWrapper = new FolderRecWrapper(folder3.GetFolderRec(null, GetFolderRecFlags.None));
                                            if (folderRecWrapper.ParentId != null)
                                            {
                                                list2.Insert(0, folderRecWrapper);
                                                bool flag = false;
                                                foreach (WellKnownFolder wellKnownFolder in list)
                                                {
                                                    if (CommonUtils.IsSameEntryId(wellKnownFolder.EntryId, folderRecWrapper.ParentId))
                                                    {
                                                        flag = true;
                                                        break;
                                                    }
                                                }
                                                if (!flag)
                                                {
                                                    entryId = folderRecWrapper.ParentId;
                                                    continue;
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                                foreach (FolderRecWrapper folderRecWrapper2 in list2)
                                {
                                    byte[] entryId2 = folderRecWrapper2.FolderRec.EntryId;
                                    byte[] parentId = folderRecWrapper2.FolderRec.ParentId;
                                    byte[] sessionSpecificEntryId = this.folderMover.DestMailbox.GetSessionSpecificEntryId(entryId2);
                                    bool   flag2 = false;
                                    byte[] destinationFolderIdFromSourceFolderId = AuxFolderMoveJob.GetDestinationFolderIdFromSourceFolderId(list, destinationWellKnownFolders, this.folderMover.DestMailbox, parentId, out flag2);
                                    using (IDestinationFolder folder4 = this.folderMover.DestMailbox.GetFolder(sessionSpecificEntryId))
                                    {
                                        if (folder4 == null)
                                        {
                                            using (ISourceFolder folder5 = this.folderMover.SourceMailbox.GetFolder(entryId2))
                                            {
                                                if (folder5 == null)
                                                {
                                                    MrsTracer.Service.Warning("Source folder '{0}' {1} disappeared, skipping", new object[]
                                                    {
                                                        folderRecWrapper2.FolderName,
                                                        folderRecWrapper2.EntryId
                                                    });
                                                    break;
                                                }
                                                folderRecWrapper2.EnsureDataLoaded(folder5, folderRecDataFlags, this.folderMover);
                                                this.folderMover.TranslateFolderData(folderRecWrapper2);
                                                CreateFolderFlags createFolderFlags = CreateFolderFlags.None;
                                                folderRecWrapper2.FolderRec.EntryId  = sessionSpecificEntryId;
                                                folderRecWrapper2.FolderRec.ParentId = destinationFolderIdFromSourceFolderId;
                                                byte[] array2;
                                                this.folderMover.CreateFolder(null, folderRecWrapper2, createFolderFlags, out array2);
                                                folderRecWrapper2.FolderRec.EntryId  = entryId2;
                                                folderRecWrapper2.FolderRec.ParentId = parentId;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            base.SyncStage                = SyncStage.CreatingInitialSyncCheckpoint;
            base.OverallProgress          = 15;
            base.TimeTracker.CurrentState = RequestState.CreatingInitialSyncCheckpoint;
            base.SaveState(SaveStateFlags.Regular, delegate(TransactionalRequestJob moveRequest)
            {
                moveRequest.RestartFromScratch = false;
            });
            base.ScheduleWorkItem(new Action(base.CatchupFolders), WorkloadType.Unknown);
        }
Exemple #24
0
 private bool DoesAnySubFolderResideInTargetMailbox(FolderRecWrapper folderRec)
 {
     return(PublicFolderMigrator.DoesAnySubFolderResideInTargetMailbox(folderRec, base.TargetMailboxGuid, this.folderToMailboxMap));
 }
 public FolderRecWrapperDataContext(FolderRecWrapper folderRecWrapper)
 {
     this.folderRecWrapper = folderRecWrapper;
 }
Exemple #26
0
 protected override bool ShouldCopyFolderProperties(FolderRecWrapper sourceFolderRec)
 {
     return(base.IsRoot || this.HasSourceFolderContents(sourceFolderRec));
 }
		public override byte[] GetSourceEntryIdFromTargetFolder(FolderRecWrapper targetFolder)
		{
			return this.sourceDatabase.GetSessionSpecificEntryId(targetFolder.EntryId);
		}
Exemple #28
0
 protected override bool HasSourceFolderContents(FolderRecWrapper sourceFolderRec)
 {
     return(this.GetContentMailboxGuid(sourceFolderRec) == base.TargetMailboxGuid);
 }
Exemple #29
0
 protected override IEnumerable <FolderRecWrapper> GetFolderList(EnumHierarchyFlags flags, FolderRecWrapper folderRec)
 {
     foreach (KeyValuePair <byte[], FolderRecWrapper> kvp in this.folders)
     {
         KeyValuePair <byte[], FolderRecWrapper> keyValuePair = kvp;
         yield return(keyValuePair.Value);
     }
     yield break;
 }
		public override FolderRecWrapper CreateTargetFolderRec(FolderRecWrapper sourceFolderRec)
		{
			return new FolderMapping(((FolderMapping)sourceFolderRec).FolderRec);
		}