private int MoveItems(IConversationTree conversationTree, List <GroupOperationResult> results, bool isUndo) { int num = 0; List <StoreId> list = new List <StoreId>(); StoreId defaultFolderId = ((MailboxSession)base.Session).GetDefaultFolderId(DefaultFolderType.Inbox); StoreId defaultFolderId2 = ((MailboxSession)base.Session).GetDefaultFolderId(DefaultFolderType.SentItems); StoreId defaultFolderId3 = ((MailboxSession)base.Session).GetDefaultFolderId(DefaultFolderType.DeletedItems); foreach (IConversationTreeNode conversationTreeNode in conversationTree) { for (int i = 0; i < conversationTreeNode.StorePropertyBags.Count; i++) { if (!this.CanSkipProcessing(conversationTreeNode.StorePropertyBags[i])) { StoreId item = conversationTreeNode.StorePropertyBags[i].TryGetProperty(ItemSchema.Id) as StoreId; StoreId storeId = conversationTreeNode.StorePropertyBags[i].TryGetProperty(StoreObjectSchema.ParentItemId) as StoreId; if (isUndo) { if (!storeId.Equals(defaultFolderId2) && !storeId.Equals(defaultFolderId)) { num++; list.Add(item); } } else if (!storeId.Equals(defaultFolderId2) && !storeId.Equals(this.TargetFolderId) && (this.ConversationActionLastMoveFolderId == null || (this.ConversationActionLastMoveFolderId.Length == 0 && !this.TargetFolderId.Equals(defaultFolderId3)) || ArrayComparer <byte> .Comparer.Equals(storeId.GetBytes(), this.ConversationActionLastMoveFolderId))) { num++; list.Add(item); } } } } if (list.Count > 0) { AggregateOperationResult aggregateOperationResult; if (isUndo) { aggregateOperationResult = base.Session.Move(defaultFolderId, list.ToArray()); } else { aggregateOperationResult = base.Session.Move(this.TargetFolderId, list.ToArray()); } if (aggregateOperationResult != null && aggregateOperationResult.GroupOperationResults != null && aggregateOperationResult.GroupOperationResults.Length > 0) { foreach (GroupOperationResult item2 in aggregateOperationResult.GroupOperationResults) { results.Add(item2); } } } if (isUndo) { base.Delete(ConversationActionItemSchema.ConversationActionLastMoveFolderId); } else if (this.AlwaysDeleteValue) { if (this.ConversationActionLastMoveFolderId == null || this.ConversationActionLastMoveFolderId.Length != 0) { this.ConversationActionLastMoveFolderId = Array <byte> .Empty; } } else if (!ArrayComparer <byte> .Comparer.Equals(this.ConversationActionLastMoveFolderId, this.TargetFolderId.GetBytes())) { this.ConversationActionLastMoveFolderId = this.TargetFolderId.GetBytes(); } return(num); }
private static bool IdsAreEqual(StoreId leftId, StoreId rightId) { return(leftId == null == (rightId == null) && (leftId == null || leftId.Equals(rightId))); }
private bool IsValidContactBeingSaved(ICoreItem contactBeingSaved) { Util.ThrowOnNullArgument(contactBeingSaved, "contactBeingSaved"); StoreId parentFolder = contactBeingSaved.PropertyBag.GetValueOrDefault <StoreId>(StoreObjectSchema.ParentItemId, null); if (parentFolder == null) { ContactLink.Tracer.TraceDebug <StoreId>((long)this.GetHashCode(), "AutomaticLinking.IsValidContactBeingSaved: ignoring item because we are unable to retrieve ParentItemId from the contact.", parentFolder); return(false); } if (!Array.Exists <StoreId>(this.contactStoreForContactLinking.FolderScope, (StoreId folderId) => parentFolder.Equals(folderId))) { ContactLink.Tracer.TraceDebug <StoreId>((long)this.GetHashCode(), "AutomaticLinking.IsValidContactBeingSaved: ignoring item because its folder is not under MyContactsExtended: {0}.", parentFolder); return(false); } return(true); }