예제 #1
0
        public static void ConvertE14MVtoE15MV(SyncServiceInstance serviceInstance, int maxCookieHistoryCount, TimeSpan cookieHistoryInterval)
        {
            ITopologyConfigurationSession ridmasterSession = MsoCookieConverter.GetRIDMasterSession();

            ridmasterSession.UseConfigNC = true;
            ADObjectId orgContainerId = ridmasterSession.GetOrgContainerId();
            ADRawEntry adrawEntry     = ridmasterSession.ReadADRawEntry(orgContainerId.Parent, MsoCookieConverter.E14MsoMainStreamCookieContainerSchema.CookieProperties);

            ridmasterSession.UseConfigNC = false;
            List <MsoMainStreamCookie>          ordredCookieList  = MsoCookieConverter.GetOrdredCookieList(serviceInstance.Name, adrawEntry.propertyBag[MsoCookieConverter.E14MsoMainStreamCookieContainerSchema.MsoForwardSyncNonRecipientCookie] as IEnumerable <byte[]>);
            List <MsoMainStreamCookie>          ordredCookieList2 = MsoCookieConverter.GetOrdredCookieList(serviceInstance.Name, adrawEntry.propertyBag[MsoCookieConverter.E14MsoMainStreamCookieContainerSchema.MsoForwardSyncRecipientCookie] as IEnumerable <byte[]>);
            MsoCompanyMainStreamCookieManager   msoCompanyMainStreamCookieManager   = new MsoCompanyMainStreamCookieManager(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval);
            MsoRecipientMainStreamCookieManager msoRecipientMainStreamCookieManager = new MsoRecipientMainStreamCookieManager(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval);

            if (ordredCookieList.Count > 0)
            {
                MsoMainStreamCookie msoMainStreamCookie = ordredCookieList.Last <MsoMainStreamCookie>();
                msoCompanyMainStreamCookieManager.WriteCookie(msoMainStreamCookie.RawCookie, null, msoMainStreamCookie.TimeStamp, msoMainStreamCookie.IsSyncPropertySetUpgrading, msoMainStreamCookie.SyncPropertySetVersion, true);
            }
            if (ordredCookieList2.Count > 0)
            {
                MsoMainStreamCookie msoMainStreamCookie2 = ordredCookieList2.Last <MsoMainStreamCookie>();
                msoRecipientMainStreamCookieManager.WriteCookie(msoMainStreamCookie2.RawCookie, null, msoMainStreamCookie2.TimeStamp, msoMainStreamCookie2.IsSyncPropertySetUpgrading, msoMainStreamCookie2.SyncPropertySetVersion, true);
            }
        }
예제 #2
0
        public static void ConvertE15toE14MV(SyncServiceInstance serviceInstance, int maxCookieHistoryCount, TimeSpan cookieHistoryInterval)
        {
            ITopologyConfigurationSession ridmasterSession = MsoCookieConverter.GetRIDMasterSession();
            MsoMainStreamCookie           cookieToAdd      = null;
            MsoMainStreamCookie           cookieToAdd2     = null;

            if (serviceInstance.IsMultiObjectCookieEnabled)
            {
                MsoMultiObjectCookieManager msoMultiObjectCookieManager  = new MsoMultiObjectCookieManager(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval, ForwardSyncCookieType.CompanyIncremental);
                MsoMultiObjectCookieManager msoMultiObjectCookieManager2 = new MsoMultiObjectCookieManager(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval, ForwardSyncCookieType.RecipientIncremental);
                ForwardSyncCookie           forwardSyncCookie            = msoMultiObjectCookieManager.ReadMostRecentCookie();
                ForwardSyncCookie           forwardSyncCookie2           = msoMultiObjectCookieManager2.ReadMostRecentCookie();
                if (forwardSyncCookie != null)
                {
                    cookieToAdd = new MsoMainStreamCookie(serviceInstance.Name, forwardSyncCookie.Data, forwardSyncCookie.Timestamp, new ServerVersion(forwardSyncCookie.SyncPropertySetVersion), forwardSyncCookie.IsUpgradingSyncPropertySet);
                }
                if (forwardSyncCookie2 != null)
                {
                    cookieToAdd2 = new MsoMainStreamCookie(serviceInstance.Name, forwardSyncCookie2.Data, forwardSyncCookie2.Timestamp, new ServerVersion(forwardSyncCookie2.SyncPropertySetVersion), forwardSyncCookie2.IsUpgradingSyncPropertySet);
                }
            }
            else
            {
                MsoCompanyMainStreamCookieManager   msoCompanyMainStreamCookieManager   = new MsoCompanyMainStreamCookieManager(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval);
                MsoRecipientMainStreamCookieManager msoRecipientMainStreamCookieManager = new MsoRecipientMainStreamCookieManager(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval);
                cookieToAdd  = msoCompanyMainStreamCookieManager.ReadMostRecentCookie();
                cookieToAdd2 = msoRecipientMainStreamCookieManager.ReadMostRecentCookie();
            }
            ridmasterSession.UseConfigNC = true;
            MsoCookieConverter.E14MsoMainStreamCookieContainer[] array = ridmasterSession.Find <MsoCookieConverter.E14MsoMainStreamCookieContainer>(ridmasterSession.GetOrgContainerId().Parent, QueryScope.SubTree, null, null, 1);
            if (array == null || array.Length == 0)
            {
                throw new ExchangeConfigurationContainerNotFoundException();
            }
            List <MsoMainStreamCookie> list  = MsoCookieConverter.GetOrderedE14CookieList(array[0].MsoForwardSyncNonRecipientCookie);
            List <MsoMainStreamCookie> list2 = MsoCookieConverter.GetOrderedE14CookieList(array[0].MsoForwardSyncRecipientCookie);

            list  = MsoCookieConverter.AddCookieToE14MVList(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval, cookieToAdd, list);
            list2 = MsoCookieConverter.AddCookieToE14MVList(serviceInstance.Name, maxCookieHistoryCount, cookieHistoryInterval, cookieToAdd2, list2);
            array[0].MsoForwardSyncNonRecipientCookie.Clear();
            foreach (MsoMainStreamCookie msoMainStreamCookie in list)
            {
                array[0].MsoForwardSyncNonRecipientCookie.Add(msoMainStreamCookie.ToStorageCookie());
            }
            array[0].MsoForwardSyncRecipientCookie.Clear();
            foreach (MsoMainStreamCookie msoMainStreamCookie2 in list2)
            {
                array[0].MsoForwardSyncRecipientCookie.Add(msoMainStreamCookie2.ToStorageCookie());
            }
            ridmasterSession.Save(array[0]);
        }