public ManifestCallbackStatus Change(byte[] entryId, byte[] sourceKey, byte[] changeKey, byte[] changeList, DateTime lastModificationTime, ManifestChangeType changeType, bool associated, PropValue[] props) { return(ManifestCallbackStatus.Stop); }
private void TraceChangeChangeCallbackProps(byte[] entryId, byte[] sourceKey, byte[] changeKey, byte[] changeList, DateTime lastModifiedTime, ManifestChangeType changeType, bool associated, PropValue[] properties) { StringBuilder stringBuilder = new StringBuilder(1024); stringBuilder.Append("ICS Change Callback: "); stringBuilder.Append("entryId="); stringBuilder.Append((entryId == null) ? "null" : Convert.ToBase64String(entryId)); stringBuilder.Append(" sourceKey="); stringBuilder.Append((sourceKey == null) ? "null" : Convert.ToBase64String(sourceKey)); stringBuilder.Append(" changeKey="); stringBuilder.Append((changeKey == null) ? "null" : Convert.ToBase64String(changeKey)); stringBuilder.Append(" changeList="); stringBuilder.Append((changeList == null) ? "null" : Convert.ToBase64String(changeList)); stringBuilder.Append(" lastModifiedTime="); stringBuilder.Append(lastModifiedTime.ToString()); stringBuilder.Append(" changeType="); stringBuilder.Append(changeType.ToString()); stringBuilder.Append(" associated="); stringBuilder.Append(associated.ToString()); stringBuilder.Append(" properties.Length="); stringBuilder.Append((properties == null) ? "null" : properties.Length.ToString()); stringBuilder.Append("{"); if (properties != null) { for (int i = 0; i < properties.Length; i++) { stringBuilder.Append("{"); if (properties[i].IsError()) { stringBuilder.Append("Error: " + properties[i].GetErrorValue().ToString()); } else { stringBuilder.Append(properties[i].PropTag.ToString() + ", "); stringBuilder.Append(properties[i].PropType.ToString() + ", "); stringBuilder.Append((properties[i].Value == null) ? "null" : properties[i].Value); } stringBuilder.Append("}"); } } stringBuilder.Append("}"); ExTraceGlobals.SyncTracer.Information <StringBuilder>((long)this.GetHashCode(), "{0}", stringBuilder); }
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()); }
ManifestCallbackStatus IMapiManifestCallback.Change(byte[] entryId, byte[] sourceKey, byte[] changeKey, byte[] changeList, DateTime lastModificationTime, ManifestChangeType changeType, bool associated, PropValue[] props) { int messageSize = 0; if (props != null) { foreach (PropValue propValue in props) { PropTag propTag = propValue.PropTag; if (propTag == PropTag.MessageSize) { messageSize = propValue.GetInt(); } } } MsgRecFlags msgRecFlags = associated ? MsgRecFlags.Associated : MsgRecFlags.None; if (changeType.Equals(ManifestChangeType.Add)) { msgRecFlags |= MsgRecFlags.New; } MessageRec item = new MessageRec(entryId, this.folderId, DateTime.MinValue, messageSize, msgRecFlags, null); this.changes.ChangedMessages.Add(item); this.countEnumeratedChanges++; if (this.isPagedEnumeration && this.countEnumeratedChanges == this.maxChanges) { this.changes.HasMoreChanges = true; return(ManifestCallbackStatus.Yield); } return(ManifestCallbackStatus.Continue); }