コード例 #1
0
        public override void WriteCookie(byte[] cookie, DateTime timestamp)
        {
            if (cookie == null || cookie.Length == 0)
            {
                throw new ArgumentException("cookie is empty");
            }
            MsoTenantCookieContainer msoTenantCookieContainer = this.configSession.GetMsoTenantCookieContainer(base.ContextId);

            if (msoTenantCookieContainer != null)
            {
                int cookieVersion = (base.LastCookie != null) ? base.LastCookie.Version : 1;
                MsoFullSyncCookie msoFullSyncCookie = new MsoFullSyncCookie(cookie, cookieVersion);
                msoFullSyncCookie.Timestamp = timestamp;
                if (base.LastCookie != null)
                {
                    msoFullSyncCookie.SyncType          = base.LastCookie.SyncType;
                    msoFullSyncCookie.SyncRequestor     = base.LastCookie.SyncRequestor;
                    msoFullSyncCookie.WhenSyncRequested = base.LastCookie.WhenSyncRequested;
                    msoFullSyncCookie.WhenSyncStarted   = ((base.LastCookie.WhenSyncStarted != DateTime.MinValue) ? base.LastCookie.WhenSyncStarted : timestamp);
                }
                byte[] item = msoFullSyncCookie.ToStorageCookie();
                MultiValuedProperty <byte[]> multiValuedProperty = this.RetrievePersistedPageTokens(msoTenantCookieContainer);
                multiValuedProperty.Clear();
                multiValuedProperty.Add(item);
                this.configSession.Save(msoTenantCookieContainer);
                this.LogPersistPageTokenEvent();
            }
        }
コード例 #2
0
        public static MsoFullSyncCookie FromStorageCookie(byte[] storageCookie)
        {
            MsoFullSyncCookie result;
            Exception         ex;

            if (!MsoFullSyncCookie.TryFromStorageCookie(storageCookie, out result, out ex))
            {
                throw ex;
            }
            return(result);
        }
コード例 #3
0
 private static void FillCookieWithVersion3Data(MsoFullSyncCookie cookie, string data)
 {
     byte[] buffer = Convert.FromBase64String(data);
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         using (BinaryReader binaryReader = new BinaryReader(memoryStream))
         {
             cookie.SyncRequestor = binaryReader.ReadString();
         }
     }
 }
コード例 #4
0
 private static bool TryFromStorageCookie(byte[] storageCookie, out MsoFullSyncCookie cookie, out Exception ex)
 {
     ex     = null;
     cookie = null;
     if (storageCookie == null || storageCookie.Length == 0)
     {
         ex = new ArgumentNullException("storageCookie");
         return(false);
     }
     try
     {
         string   @string = Encoding.UTF8.GetString(storageCookie);
         string[] array   = @string.Split(new string[]
         {
             "\n"
         }, StringSplitOptions.None);
         byte[] rawCookie = Convert.FromBase64String(array[0]);
         cookie = new MsoFullSyncCookie(rawCookie, 3);
         if (array.Length == 1)
         {
             MsoFullSyncCookie.FillCookieWithVersion1Data(cookie);
         }
         if (array.Length >= 2)
         {
             MsoFullSyncCookie.FillCookieWithVersion1And2Data(cookie, array[1]);
         }
         if (array.Length >= 3)
         {
             MsoFullSyncCookie.FillCookieWithVersion3Data(cookie, array[2]);
         }
     }
     catch (DecoderFallbackException innerException)
     {
         ex = new InvalidTenantFullSyncCookieException(innerException);
     }
     catch (ArgumentException innerException2)
     {
         ex = new InvalidTenantFullSyncCookieException(innerException2);
     }
     catch (FormatException innerException3)
     {
         ex = new InvalidTenantFullSyncCookieException(innerException3);
     }
     catch (OverflowException innerException4)
     {
         ex = new InvalidTenantFullSyncCookieException(innerException4);
     }
     return(null == ex);
 }
コード例 #5
0
 private static void FillCookieWithVersion1And2Data(MsoFullSyncCookie cookie, string data)
 {
     byte[] buffer = Convert.FromBase64String(data);
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         using (BinaryReader binaryReader = new BinaryReader(memoryStream))
         {
             cookie.Version           = binaryReader.ReadInt32();
             cookie.SyncType          = (TenantSyncType)binaryReader.ReadByte();
             cookie.WhenSyncRequested = DateTime.FromBinary(binaryReader.ReadInt64());
             cookie.WhenSyncStarted   = DateTime.FromBinary(binaryReader.ReadInt64());
             cookie.Timestamp         = DateTime.FromBinary(binaryReader.ReadInt64());
         }
     }
 }
コード例 #6
0
        public override byte[] ReadCookie()
        {
            MsoTenantCookieContainer msoTenantCookieContainer = this.configSession.GetMsoTenantCookieContainer(base.ContextId);

            if (msoTenantCookieContainer == null)
            {
                return(null);
            }
            MultiValuedProperty <byte[]> multiValuedProperty = this.RetrievePersistedPageTokens(msoTenantCookieContainer);

            if (multiValuedProperty.Count == 0)
            {
                return(null);
            }
            base.LastCookie = MsoFullSyncCookie.FromStorageCookie(multiValuedProperty[0]);
            return(base.LastCookie.RawCookie);
        }
コード例 #7
0
 private static void FillCookieWithVersion1Data(MsoFullSyncCookie cookie)
 {
     cookie.SyncType          = TenantSyncType.Full;
     cookie.Version           = 1;
     cookie.WhenSyncRequested = DateTime.UtcNow;
 }