protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag) { object value = propertyBag.GetValue(this.conversationIdPropertyDefinition); byte[] array = value as byte[]; if (array != null) { object result; try { result = ConversationId.Create(array); } catch (CorruptDataException) { result = new PropertyError(this, PropertyErrorCode.CorruptedData); } return(result); } PropertyError propertyError = (PropertyError)value; if (propertyError.PropertyErrorCode == PropertyErrorCode.NotEnoughMemory) { return(new PropertyError(this, PropertyErrorCode.CorruptedData)); } return(new PropertyError(this, propertyError.PropertyErrorCode)); }
public void LogAggregationResultData(ConversationAggregationResult aggregationResult) { this.LogEvent(new SchemaBasedLogEvent <ConversationAggregationLogSchema.AggregationResult> { { ConversationAggregationLogSchema.AggregationResult.ConversationFamilyId, aggregationResult.ConversationFamilyId }, { ConversationAggregationLogSchema.AggregationResult.ConversationId, ConversationId.Create(aggregationResult.ConversationIndex) }, { ConversationAggregationLogSchema.AggregationResult.IsOutOfOrderDelivery, ConversationIndex.IsFixupAddingOutOfOrderMessageToConversation(aggregationResult.Stage) }, { ConversationAggregationLogSchema.AggregationResult.NewConversationCreated, ConversationIndex.IsFixUpCreatingNewConversation(aggregationResult.Stage) }, { ConversationAggregationLogSchema.AggregationResult.SupportsSideConversation, aggregationResult.SupportsSideConversation }, { ConversationAggregationLogSchema.AggregationResult.FixupStage, aggregationResult.Stage } }); }
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()); }
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)); }
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()); }
public static void ChunkSmsConversation(IXSOFactory xsoFactory, IMailboxSession session, ConversationIndex conversationIndex, ConversationIndexTrackingEx conversationIndexTrackingEx) { Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(conversationIndex, "conversationIndex"); byte[] conversationIdBytes = ConversationId.Create(conversationIndex.Guid).GetBytes(); int conversationIdHash = (int)AllItemsFolderHelper.GetHashValue(conversationIdBytes); Stopwatch stopwatch = Stopwatch.StartNew(); List <IStorePropertyBag> list = xsoFactory.RunQueryOnAllItemsFolder <List <IStorePropertyBag> >(session, AllItemsFolderHelper.SupportedSortBy.ConversationIdHash, conversationIdHash, null, delegate(QueryResult queryResult) { List <IStorePropertyBag> list2 = null; bool flag = false; while (!flag) { IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(10); if (propertyBags == null || propertyBags.Length <= 0) { break; } for (int i = 0; i < propertyBags.Length; i++) { int?num2 = propertyBags[i].TryGetProperty(ItemSchema.ConversationIdHash) as int?; if (num2 == null) { break; } if (num2.Value != conversationIdHash) { flag = true; break; } byte[] array = propertyBags[i].TryGetProperty(InternalSchema.MapiConversationId) as byte[]; if (array != null && Util.CompareByteArray(conversationIdBytes, array)) { if (list2 == null) { list2 = new List <IStorePropertyBag>(10); } list2.Add(propertyBags[i]); } } } return(list2); }, new StorePropertyDefinition[] { ItemSchema.Id, ItemSchema.ConversationIdHash, ItemSchema.ReceivedTime, InternalSchema.MapiConversationId }); stopwatch.Stop(); if (conversationIndexTrackingEx != null) { conversationIndexTrackingEx.Trace("SBSMSCID", stopwatch.ElapsedMilliseconds.ToString()); } if (list == null || list.Count < 79) { return; } list.Sort(delegate(IStorePropertyBag x, IStorePropertyBag y) { ExDateTime?exDateTime = x.TryGetProperty(ItemSchema.ReceivedTime) as ExDateTime?; ExDateTime?exDateTime2 = y.TryGetProperty(ItemSchema.ReceivedTime) as ExDateTime?; if (exDateTime == null && exDateTime2 == null) { return(0); } if (exDateTime == null) { return(1); } if (exDateTime2 == null) { return(-1); } return(exDateTime.Value.CompareTo(exDateTime2.Value)); }); string str = conversationIndex.Guid.ToString("D").Substring("472e2878-19b1-4ac1-a21a-".Length); string text; do { text = Guid.NewGuid().ToString("D").Substring(0, "472e2878-19b1-4ac1-a21a-".Length); }while (string.Equals(text, "472e2878-19b1-4ac1-a21a-")); ConversationIndex conversationIndex2 = ConversationIndex.Create(new Guid(text + str)); int num = 0; while (num < list.Count && num < 50) { VersionedId versionedId = (VersionedId)list[num].TryGetProperty(ItemSchema.Id); if (versionedId != null) { StoreObjectId objectId = versionedId.ObjectId; if (objectId != null) { using (IMessageItem messageItem = xsoFactory.BindToMessage(session, objectId, null)) { messageItem.OpenAsReadWrite(); messageItem[ItemSchema.ConversationIndex] = conversationIndex2.ToByteArray(); messageItem[ItemSchema.ConversationIndexTracking] = true; messageItem.Save(SaveMode.ResolveConflicts); } } } num++; } }
public static ConversationId RetrieveConversationId(IList <byte> conversationIndexInBytes) { return(ConversationId.Create(ConversationIndex.Create(conversationIndexInBytes))); }
internal static QueryFilter NativeFilterToConversationIdBasedSmartFilter(this SmartPropertyDefinition conversationIdSmartPropertyDefinition, QueryFilter filter, PropertyDefinition conversationIdNativePropertyDefinition) { SinglePropertyFilter singlePropertyFilter = filter as SinglePropertyFilter; if (singlePropertyFilter != null && singlePropertyFilter.Property.Equals(conversationIdNativePropertyDefinition)) { ComparisonFilter comparisonFilter = filter as ComparisonFilter; if (comparisonFilter != null) { return(new ComparisonFilter(comparisonFilter.ComparisonOperator, conversationIdSmartPropertyDefinition, ConversationId.Create((byte[])comparisonFilter.PropertyValue))); } ExistsFilter existsFilter = filter as ExistsFilter; if (existsFilter != null) { return(new ExistsFilter(conversationIdSmartPropertyDefinition)); } } return(null); }