Ejemplo n.º 1
0
 internal void Bind(FolderSync folderSync, ServerManifestEntry manifestEntry, bool cacheItem)
 {
     this.cacheItem     = cacheItem;
     this.manifestEntry = manifestEntry;
     this.item          = null;
     this.folderSync    = folderSync;
 }
Ejemplo n.º 2
0
 internal void Bind(ISyncItem item, ServerManifestEntry manifestEntry)
 {
     this.cacheItem     = true;
     this.manifestEntry = manifestEntry;
     this.item          = item;
     this.folderSync    = null;
 }
Ejemplo n.º 3
0
 public SyncOperations(FolderSync folderSync, IDictionary changes, bool moreAvailable)
 {
     this.moreAvailable = moreAvailable;
     this.changes       = new List <SyncOperation>(changes.Keys.Count);
     foreach (object obj in changes.Values)
     {
         ServerManifestEntry serverManifestEntry = (ServerManifestEntry)obj;
         if (serverManifestEntry.ChangeType != ChangeType.OutOfFilter)
         {
             SyncOperation syncOperation = new SyncOperation();
             syncOperation.Bind(folderSync, serverManifestEntry, false);
             this.changes.Add(syncOperation);
         }
     }
 }
Ejemplo n.º 4
0
        public ManifestCallbackStatus ReadUnread(byte[] entryId, bool read)
        {
            ManifestCallbackStatus result     = ManifestCallbackStatus.Continue;
            StoreObjectId          id         = StoreObjectId.FromProviderSpecificId(entryId, StoreObjectType.Unknown);
            ISyncItemId            syncItemId = MailboxSyncItemId.CreateForExistingItem(this.mailboxSyncProvider.FolderSync, id);

            if (syncItemId == null)
            {
                return(result);
            }
            ServerManifestEntry serverManifestEntry = this.mailboxSyncProvider.CreateReadFlagChangeManifestEntry(syncItemId, read);

            if (serverManifestEntry != null)
            {
                this.lastServerManifestEntry = serverManifestEntry;
            }
            return(this.CheckYieldOrStop());
        }
Ejemplo n.º 5
0
 public virtual void UpdateFilterState(SyncOperation syncOperation)
 {
     if (syncOperation.ChangeType == ChangeType.Delete)
     {
         this.entriesInFilter.Remove(syncOperation.Id);
         return;
     }
     try
     {
         try
         {
             bool flag = EvaluatableFilter.Evaluate(this.filter, syncOperation, true);
             if (flag)
             {
                 ServerManifestEntry serverManifestEntry = new ServerManifestEntry(syncOperation.Id);
                 serverManifestEntry.UpdateManifestFromPropertyBag(syncOperation);
                 serverManifestEntry.FirstMessageInConversation = syncOperation.FirstMessageInConversation;
                 this.entriesInFilter[syncOperation.Id]         = serverManifestEntry;
             }
         }
         catch (PropertyErrorException)
         {
             ISyncItem item = syncOperation.GetItem(MailboxSyncProvider.QueryColumns);
             bool      flag = item.IsItemInFilter(this.filter);
             if (flag)
             {
                 ServerManifestEntry serverManifestEntry2 = new ServerManifestEntry(syncOperation.Id);
                 serverManifestEntry2.UpdateManifestFromItem(item);
                 this.entriesInFilter[syncOperation.Id] = serverManifestEntry2;
             }
         }
     }
     catch (ObjectNotFoundException)
     {
     }
 }
Ejemplo n.º 6
0
        private bool GetNewOperationsWithFilter(MailboxSyncWatermark minWatermark, MailboxSyncWatermark maxWatermark, int numOperations, QueryFilter filter, Dictionary <ISyncItemId, ServerManifestEntry> newServerManifest)
        {
            this.SyncLogger.Information(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider.GetNewOperationsWithFilter. numOperations {0}, newServerManifest count {1}, minWatermark is New? {2}. Starting change number {3}", new object[]
            {
                numOperations,
                newServerManifest.Count,
                minWatermark.IsNew,
                minWatermark.ChangeNumber
            });
            bool             result           = false;
            ComparisonFilter comparisonFilter = null;

            if (!minWatermark.IsNew)
            {
                comparisonFilter = new ComparisonFilter(ComparisonOperator.GreaterThan, InternalSchema.ArticleId, minWatermark.RawChangeNumber);
            }
            if (this.syncQueryResult == null)
            {
                this.syncQueryResult = MailboxSyncQueryProcessor.ItemQuery(this.folder, ItemQueryType.None, filter, this.itemQueryOptimizationFilter, MailboxSyncProvider.sortByArticleIdAscending, MailboxSyncProvider.queryColumns, this.allowTableRestrict, this.UseSortOrder);
            }
            else if (comparisonFilter == null)
            {
                this.syncQueryResult.SeekToOffset(SeekReference.OriginBeginning, 0);
            }
            if (comparisonFilter != null)
            {
                this.syncQueryResult.SeekToCondition(SeekReference.OriginBeginning, comparisonFilter);
            }
            bool flag = false;

            while (!flag)
            {
                int num;
                if (numOperations == -1)
                {
                    num = 10000;
                }
                else
                {
                    int num2 = numOperations - newServerManifest.Count;
                    num = num2 + 1;
                }
                if (num < 0)
                {
                    throw new InvalidOperationException(ServerStrings.ExNumberOfRowsToFetchInvalid(num.ToString()));
                }
                object[][] rows = this.syncQueryResult.GetRows(num);
                flag = (this.syncQueryResult.CurrentRow == this.syncQueryResult.EstimatedRowCount);
                this.SyncLogger.Information <int, int, bool>(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider.GetNewOperationsWithFilter. Requested {0} rows, Received {1} rows, All fetched? {2}", num, rows.Length, flag);
                for (int i = 0; i < rows.Length; i++)
                {
                    try
                    {
                        StoreObjectId        objectId             = ((VersionedId)rows[i][1]).ObjectId;
                        int                  changeNumber         = (int)rows[i][0];
                        MailboxSyncWatermark mailboxSyncWatermark = (MailboxSyncWatermark)this.CreateNewWatermark();
                        mailboxSyncWatermark.UpdateWithChangeNumber(changeNumber, (bool)rows[i][2]);
                        if (maxWatermark == null || maxWatermark.CompareTo(mailboxSyncWatermark) >= 0)
                        {
                            ISyncItemId         syncItemId          = this.CreateISyncItemIdForNewItem(objectId);
                            ServerManifestEntry serverManifestEntry = this.CreateItemChangeManifestEntry(syncItemId, mailboxSyncWatermark);
                            serverManifestEntry.ConversationId = (rows[i][3] as ConversationId);
                            byte[]            bytes = rows[i][4] as byte[];
                            ConversationIndex index;
                            if (ConversationIndex.TryCreate(bytes, out index) && index != ConversationIndex.Empty && index.Components != null && index.Components.Count == 1)
                            {
                                serverManifestEntry.FirstMessageInConversation = true;
                            }
                            if (rows[i][5] is ExDateTime)
                            {
                                serverManifestEntry.FilterDate = new ExDateTime?((ExDateTime)rows[i][5]);
                            }
                            serverManifestEntry.MessageClass = (rows[i][6] as string);
                            if (numOperations != -1 && newServerManifest.Count >= numOperations)
                            {
                                result = true;
                                goto IL_2B9;
                            }
                            newServerManifest[serverManifestEntry.Id] = serverManifestEntry;
                            minWatermark.ChangeNumber = changeNumber;
                        }
                    }
                    catch
                    {
                        throw;
                    }
                }
            }
IL_2B9:
            this.SyncLogger.Information <int>(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider.GetNewOperationsWithFilter. Ending change number {0}", minWatermark.ChangeNumber);
            return(result);
        }
Ejemplo n.º 7
0
        public ManifestCallbackStatus Change(byte[] entryId, byte[] sourceKey, byte[] changeKey, byte[] changeList, DateTime lastModifiedTime, ManifestChangeType changeType, bool associated, PropValue[] properties)
        {
            EnumValidator.ThrowIfInvalid <ManifestChangeType>(changeType, "changeType");
            if (ExTraceGlobals.SyncTracer.IsTraceEnabled(TraceType.InfoTrace))
            {
                this.TraceChangeChangeCallbackProps(entryId, sourceKey, changeKey, changeList, lastModifiedTime, changeType, associated, properties);
            }
            int?           num                        = null;
            string         text                       = null;
            bool           read                       = false;
            ConversationId conversationId             = null;
            bool           firstMessageInConversation = false;
            ExDateTime?    filterDate                 = null;

            foreach (PropValue propValue in properties)
            {
                if (!propValue.IsError())
                {
                    PropTag propTag = propValue.PropTag;
                    if (propTag <= PropTag.MessageDeliveryTime)
                    {
                        if (propTag != PropTag.MessageClass)
                        {
                            ConversationIndex index;
                            if (propTag != PropTag.ConversationIndex)
                            {
                                if (propTag == PropTag.MessageDeliveryTime)
                                {
                                    if (propValue.PropType == PropType.SysTime)
                                    {
                                        filterDate = new ExDateTime?((ExDateTime)propValue.GetDateTime());
                                    }
                                }
                            }
                            else if (propValue.PropType == PropType.Binary && ConversationIndex.TryCreate(propValue.GetBytes(), out index) && index != ConversationIndex.Empty && index.Components != null && index.Components.Count == 1)
                            {
                                firstMessageInConversation = true;
                            }
                        }
                        else if (propValue.PropType == PropType.String)
                        {
                            text = propValue.GetString();
                        }
                    }
                    else if (propTag != PropTag.MessageFlags)
                    {
                        if (propTag != PropTag.InternetArticleNumber)
                        {
                            if (propTag == PropTag.ConversationId)
                            {
                                if (propValue.PropType == PropType.Binary)
                                {
                                    conversationId = ConversationId.Create(propValue.GetBytes());
                                }
                            }
                        }
                        else
                        {
                            if (propValue.PropType != PropType.Int)
                            {
                                return(ManifestCallbackStatus.Continue);
                            }
                            num = new int?(propValue.GetInt());
                        }
                    }
                    else if (propValue.PropType == PropType.Int)
                    {
                        MessageFlags @int = (MessageFlags)propValue.GetInt();
                        read = ((@int & MessageFlags.IsRead) == MessageFlags.IsRead);
                    }
                }
            }
            if (changeType == ManifestChangeType.Add || changeType == ManifestChangeType.Change)
            {
                if (num == null)
                {
                    return(ManifestCallbackStatus.Continue);
                }
                StoreObjectId        id = StoreObjectId.FromProviderSpecificId(entryId, (text == null) ? StoreObjectType.Unknown : ObjectClass.GetObjectType(text));
                MailboxSyncItemId    mailboxSyncItemId    = MailboxSyncItemId.CreateForNewItem(id);
                MailboxSyncWatermark mailboxSyncWatermark = MailboxSyncWatermark.CreateForSingleItem();
                mailboxSyncWatermark.UpdateWithChangeNumber(num.Value, read);
                ServerManifestEntry serverManifestEntry = this.mailboxSyncProvider.CreateItemChangeManifestEntry(mailboxSyncItemId, mailboxSyncWatermark);
                serverManifestEntry.IsNew                      = (changeType == ManifestChangeType.Add);
                serverManifestEntry.MessageClass               = text;
                serverManifestEntry.ConversationId             = conversationId;
                serverManifestEntry.FirstMessageInConversation = firstMessageInConversation;
                serverManifestEntry.FilterDate                 = filterDate;
                mailboxSyncItemId.ChangeKey                    = changeKey;
                this.lastServerManifestEntry                   = serverManifestEntry;
            }
            else
            {
                StoreObjectId     id2 = StoreObjectId.FromProviderSpecificId(entryId, StoreObjectType.Unknown);
                MailboxSyncItemId mailboxSyncItemId2 = MailboxSyncItemId.CreateForExistingItem(this.mailboxSyncProvider.FolderSync, id2);
                if (mailboxSyncItemId2 == null)
                {
                    return(ManifestCallbackStatus.Continue);
                }
                this.lastServerManifestEntry = MailboxSyncProvider.CreateItemDeleteManifestEntry(mailboxSyncItemId2);
                this.lastServerManifestEntry.ConversationId = conversationId;
            }
            return(this.CheckYieldOrStop());
        }
Ejemplo n.º 8
0
        public override void UpdateFilterState(SyncOperation syncOperation)
        {
            ServerManifestEntry value = new ServerManifestEntry(syncOperation.Id);

            base.EntriesInFilter[syncOperation.Id] = value;
        }