private static ConversationActionItem InternalCreate(MailboxSession session, ConversationId conversationId, string conversationTopic) { StoreId conversationActionsFolderId = ConversationActionItem.GetConversationActionsFolderId(session, true); if (conversationActionsFolderId == null) { throw new NotSupportedException("Failed to get conversation actions folder"); } ConversationActionItem conversationActionItem = ItemBuilder.CreateNewItem <ConversationActionItem>(session, conversationActionsFolderId, ItemCreateInfo.ConversationActionInfo, CreateMessageType.Associated); conversationActionItem[ItemSchema.ConversationTopic] = conversationTopic; conversationActionItem[ItemSchema.Subject] = conversationTopic; conversationActionItem[StoreObjectSchema.ItemClass] = "IPM.ConversationAction"; conversationActionItem[ItemSchema.ConversationId] = conversationId; conversationActionItem.SetExpiration(); conversationActionItem[ConversationActionItemSchema.ConversationActionVersion] = ConversationActionItem.MakeVersion(); return(conversationActionItem); }
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); }