コード例 #1
0
        protected sealed override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
        {
            ConversationId conversationId = value as ConversationId;

            if (conversationId == null)
            {
                throw new ArgumentException("value", "Must be a non-null ConversationId instance");
            }
            ConversationIndex conversationIndex;

            if (!ConversationIndex.TryCreate(propertyBag.GetValueOrDefault <byte[]>(InternalSchema.ConversationIndex), out conversationIndex))
            {
                conversationIndex = ConversationIndex.Create(conversationId);
            }
            else
            {
                conversationIndex = conversationIndex.UpdateGuid(new Guid(conversationId.GetBytes()));
            }
            byte[] array          = conversationIndex.ToByteArray();
            string valueOrDefault = propertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass);

            if (valueOrDefault != null && ObjectClass.IsOfClass(valueOrDefault, "IPM.ConversationAction"))
            {
                array[0] = 1;
                array[1] = (array[2] = (array[3] = (array[4] = (array[5] = 0))));
            }
            propertyBag.SetValueWithFixup(InternalSchema.ConversationIndex, array);
        }
コード例 #2
0
 public void UpdateManifestFromPropertyBag(IReadOnlyPropertyBag propertyBag)
 {
     this.messageClass = (propertyBag[InternalSchema.ItemClass] as string);
     try
     {
         object obj = propertyBag[ItemSchema.ReceivedTime];
         if (obj is ExDateTime)
         {
             this.filterDate = new ExDateTime?((ExDateTime)obj);
         }
     }
     catch (PropertyErrorException)
     {
         this.filterDate = null;
     }
     try
     {
         object obj = propertyBag[ItemSchema.ConversationId];
         if (obj is ConversationId)
         {
             this.conversationId = (ConversationId)obj;
         }
         obj = propertyBag[ItemSchema.ConversationIndex];
         ConversationIndex index;
         if (obj is byte[] && ConversationIndex.TryCreate((byte[])obj, out index) && index != ConversationIndex.Empty && index.Components != null && index.Components.Count == 1)
         {
             this.firstMessageInConversation = true;
         }
     }
     catch (PropertyErrorException)
     {
         this.conversationId             = null;
         this.firstMessageInConversation = false;
     }
     try
     {
         object obj = propertyBag[MessageItemSchema.IsRead];
         if (obj is bool)
         {
             this.itemRead = (((bool)obj) ? ServerManifestEntry.ReadFlagState.Read : ServerManifestEntry.ReadFlagState.UnRead);
         }
     }
     catch (PropertyErrorException)
     {
         this.itemRead = ServerManifestEntry.ReadFlagState.Unknown;
     }
 }
コード例 #3
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            byte[] valueOrDefault  = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.MapiConversationFamilyId, null);
            byte[] valueOrDefault2 = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.ConversationIndex);
            if (valueOrDefault2 == null || valueOrDefault == null)
            {
                return(null);
            }
            ConversationIndex conversationIndex;
            bool           flag           = ConversationIndex.TryCreate(valueOrDefault2, out conversationIndex);
            ConversationId conversationId = ConversationId.Create(valueOrDefault);

            if (!flag)
            {
                return(null);
            }
            return(conversationIndex.UpdateGuid(conversationId).ToByteArray());
        }
コード例 #4
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            propertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass);
            byte[] valueOrDefault = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.ConversationIndex);
            if (valueOrDefault == null)
            {
                return(null);
            }
            ConversationIndex conversationIndex;

            if (!ConversationIndex.TryCreate(valueOrDefault, out conversationIndex))
            {
                return(null);
            }
            bool?valueAsNullable = propertyBag.GetValueAsNullable <bool>(InternalSchema.ConversationIndexTracking);

            if (valueAsNullable == null || !valueAsNullable.Value)
            {
                string topic = propertyBag.GetValueOrDefault <string>(InternalSchema.ConversationTopic) ?? string.Empty;
                byte[] bytes = this.ComputeHashTopic(topic);
                return(ConversationId.Create(bytes));
            }
            return(ConversationId.Create(conversationIndex.Guid));
        }
コード例 #5
0
        public static IList <StoreId> QueryConversationActionsFolder(MailboxSession session, ConversationId conversationId, int maxRowCount, out int totalActionItemCount)
        {
            totalActionItemCount = 0;
            StoreId conversationActionsFolderId = ConversationActionItem.GetConversationActionsFolderId(session, false);

            if (conversationActionsFolderId == null)
            {
                return(null);
            }
            IList <StoreId> result;

            try
            {
                using (Folder folder = Folder.Bind(session, conversationActionsFolderId))
                {
                    int?valueAsNullable = folder.GetValueAsNullable <int>(FolderSchema.AssociatedItemCount);
                    if (valueAsNullable != null && valueAsNullable <= 0)
                    {
                        result = null;
                    }
                    else
                    {
                        totalActionItemCount = ((valueAsNullable != null) ? valueAsNullable.Value : 0);
                        if (conversationId == null)
                        {
                            result = null;
                        }
                        else
                        {
                            SortBy[] sortColumns = new SortBy[]
                            {
                                new SortBy(ItemSchema.ConversationIndex, SortOrder.Ascending),
                                new SortBy(StoreObjectSchema.LastModifiedTime, SortOrder.Descending)
                            };
                            ConversationIndex conversationIndex = ConversationActionItem.GetConversationIndex(conversationId);
                            using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.Associated, null, sortColumns, new PropertyDefinition[]
                            {
                                ItemSchema.ConversationIndex,
                                ItemSchema.Id,
                                ConversationActionItemSchema.ConversationActionVersion
                            }))
                            {
                                if (queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.ConversationIndex, conversationIndex.ToByteArray())))
                                {
                                    IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(maxRowCount);
                                    if (propertyBags.Length >= 1)
                                    {
                                        List <StoreId> list = new List <StoreId>();
                                        for (int i = 0; i < propertyBags.Length; i++)
                                        {
                                            byte[] array = propertyBags[i][ItemSchema.ConversationIndex] as byte[];
                                            if (array != null)
                                            {
                                                ConversationIndex conversationIndex2;
                                                bool flag = ConversationIndex.TryCreate(array, out conversationIndex2);
                                                if (flag)
                                                {
                                                    if (!conversationIndex2.Equals(conversationIndex))
                                                    {
                                                        break;
                                                    }
                                                    if (!(propertyBags[i].TryGetProperty(ConversationActionItemSchema.ConversationActionVersion) is PropertyError))
                                                    {
                                                        int version = (int)propertyBags[i].TryGetProperty(ConversationActionItemSchema.ConversationActionVersion);
                                                        if (ConversationActionItem.GetMajorVersion(version) >= 4)
                                                        {
                                                            list.Add(propertyBags[i][ItemSchema.Id] as VersionedId);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        return((list.Count == 0) ? null : list);
                                    }
                                }
                                result = null;
                            }
                        }
                    }
                }
            }
            catch (ObjectNotFoundException)
            {
                result = null;
            }
            return(result);
        }
コード例 #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);
        }
コード例 #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());
        }