private void FindItemInAllItems() { this.allItemsItemId = null; AllItemsFolderHelper.CheckAndCreateDefaultFolders(this.parent.MailboxSession); using (Folder folder = Folder.Bind(this.parent.MailboxSession, this.key.FolderToSearch())) { PropertyDefinition[] dataColumns = new PropertyDefinition[] { ItemSchema.Id }; using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, this.key.Filter, null, dataColumns)) { object[][] rows = queryResult.GetRows(1); if (rows == null) { ExTraceGlobals.SessionTracer.TraceWarning <string, string>((long)this.parent.MailboxSession.GetHashCode(), "AnalysisGroupData.FindItemInAllItems found NO items in folder {0} for the key {1}", this.key.FolderToSearch().ToString(), this.key.ToString()); this.allItemsItemId = null; } else if (rows.Length != 1) { ExTraceGlobals.SessionTracer.TraceWarning <string, string, int>((long)this.parent.MailboxSession.GetHashCode(), "AnalysisGroupData.FindItemInAllItems found {2} items in folder {0} for the key {1}", this.key.FolderToSearch().ToString(), this.key.ToString(), rows.Length); this.allItemsItemId = null; } else { this.allItemsItemId = StoreId.GetStoreObjectId(rows[0][0] as StoreId); } } } }
public static object[] FindItemBySharePointId(MailboxSession session, Guid sharepointId) { Util.ThrowOnNullArgument(session, "session"); if (sharepointId == Guid.Empty) { throw new ArgumentNullException("sharepointId"); } object[] array = AllItemsFolderHelper.RunQueryOnAllItemsFolder <object[]>(session, AllItemsFolderHelper.SupportedSortBy.SharePointId, sharepointId, null, delegate(QueryResult queryResult) { object[][] rows = queryResult.GetRows(1); if (rows == null || rows.Length <= 0) { return(null); } object[] array2 = new object[AllItemsFolderHelper.findItemBySharePointIdProps.Count]; array2[0] = ((VersionedId)rows[0][0]).ObjectId; array2[1] = (StoreObjectId)rows[0][1]; string text = (string)rows[0][2]; if (!string.IsNullOrEmpty(text)) { array2[2] = new Uri(text); } else { array2[2] = null; } return(array2); }, AllItemsFolderHelper.findItemBySharePointIdProps); return(array ?? null); }
protected override void SetPropertiesInternal(DefaultFolderContext context, Folder folder) { base.SetPropertiesInternal(context, folder); SearchFolder searchFolder = (SearchFolder)folder; searchFolder.Save(); searchFolder.Load(null); AllItemsFolderHelper.InitializeTransportIndexes(folder); AllItemsFolderValidation.TryApplyContinuousSearch(searchFolder, AllItemsFolderValidation.CreateSearchCriteria(context)); }
public static G RunQueryOnAllItemsFolder <G>(MailboxSession session, AllItemsFolderHelper.SupportedSortBy supportedSortBy, object seekToValue, G defaultValue, AllItemsFolderHelper.DoQueryProcessing <G> queryProcessor, ICollection <PropertyDefinition> properties, ItemQueryType itemQueryType) { return(AllItemsFolderHelper.RunQueryOnAllItemsFolder <G>(session, supportedSortBy, delegate(QueryResult queryResult) { if (queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, AllItemsFolderHelper.sortOrderMap[supportedSortBy][0].ColumnDefinition, seekToValue))) { return queryProcessor(queryResult); } return defaultValue; }, properties, itemQueryType)); }
public static G RunQueryOnAllItemsFolder <G>(MailboxSession session, AllItemsFolderHelper.SupportedSortBy supportedSortBy, AllItemsFolderHelper.DoQueryProcessing <G> queryProcessor, ICollection <PropertyDefinition> properties, ItemQueryType itemQueryType) { AllItemsFolderHelper.CheckAndCreateDefaultFolders(session); G result; using (SearchFolder searchFolder = SearchFolder.Bind(session, DefaultFolderType.AllItems)) { using (QueryResult queryResult = searchFolder.ItemQuery(itemQueryType, null, AllItemsFolderHelper.sortOrderMap[supportedSortBy], properties)) { result = queryProcessor(queryResult); } } return(result); }
public static IStorePropertyBag[] FindItemsFromInternetId(MailboxSession session, string internetMessageId, ItemQueryType itemQueryType, params PropertyDefinition[] propertyDefinitions) { Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullOrEmptyArgument(internetMessageId, "internetMessageId"); Util.ThrowOnNullOrEmptyArgument(propertyDefinitions, "propertyDefinitions"); ICollection <PropertyDefinition> properties = InternalSchema.Combine <PropertyDefinition>(propertyDefinitions, new PropertyDefinition[] { ItemSchema.InternetMessageId, ItemSchema.InternetMessageIdHash }); int internetMessageIdHash = (int)AllItemsFolderHelper.GetHashValue(internetMessageId); IStorePropertyBag[] array = AllItemsFolderHelper.RunQueryOnAllItemsFolder <IStorePropertyBag[]>(session, AllItemsFolderHelper.SupportedSortBy.InternetMessageIdHash, internetMessageIdHash, null, (QueryResult queryResult) => AllItemsFolderHelper.ProcessQueryResult(queryResult, internetMessageId, internetMessageIdHash), properties, itemQueryType); return(array ?? Array <IStorePropertyBag> .Empty); }
private bool IsDuplicateMessageBySiteMailboxDrop(MailboxSession session, CoreItem item) { if (item.Origin != Origin.New) { return(false); } item.PropertyBag.Load(COWSiteMailboxMessageDedup.PropItemClass); if (item.ClassName() != "IPM.Note") { return(false); } byte[] array = item.PropertyBag.TryGetProperty(StoreObjectSchema.ParentEntryId) as byte[]; string text = item.PropertyBag.TryGetProperty(ItemSchema.InternetMessageId) as string; string text2 = item.PropertyBag.TryGetProperty(MessageItemSchema.SenderSmtpAddress) as string; ExDateTime?exDateTime = item.PropertyBag.TryGetProperty(ItemSchema.SentTime) as ExDateTime?; string a = item.PropertyBag.TryGetProperty(ItemSchema.Subject) as string; if (array == null || string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text2) || exDateTime == null) { COWSiteMailboxMessageDedup.Tracer.TraceError((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.IsDuplicateMessageBySiteMailboxDrop: required poperties are not complete, rawId: {0}, internetMessageId: {1}, senderSmtpAddress: {2}, sentTime: {3}", new object[] { array, text, text2, exDateTime }); return(false); } int hashValue = (int)AllItemsFolderHelper.GetHashValue(text); StoreObjectId folderId = StoreObjectId.FromProviderSpecificId(array, StoreObjectType.Message); using (Folder folder = Folder.Bind(session, folderId)) { using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, null, COWSiteMailboxMessageDedup.DedupSortBy, COWSiteMailboxMessageDedup.DedupProperties)) { if (!queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.InternetMessageIdHash, hashValue))) { return(false); } IStorePropertyBag[] array2 = AllItemsFolderHelper.ProcessQueryResult(queryResult, text, hashValue); if (array2 == null) { COWSiteMailboxMessageDedup.Tracer.TraceDebug((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.IsDuplicateMessageBySiteMailboxDrop: propertyBags is null for ProcessQueryResult."); return(false); } foreach (IStorePropertyBag storePropertyBag in array2) { string text3 = storePropertyBag.TryGetProperty(ItemSchema.InternetMessageId) as string; string text4 = storePropertyBag.TryGetProperty(MessageItemSchema.SenderSmtpAddress) as string; string b = storePropertyBag.TryGetProperty(ItemSchema.Subject) as string; ExDateTime? exDateTime2 = storePropertyBag.TryGetProperty(ItemSchema.SentTime) as ExDateTime?; VersionedId versionedId = storePropertyBag.TryGetProperty(ItemSchema.Id) as VersionedId; if (!string.IsNullOrEmpty(text3) && string.Equals(text, text3, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(text4) && string.Equals(text2, text4, StringComparison.OrdinalIgnoreCase) && string.Equals(a, b) && exDateTime2 != null && exDateTime2 == exDateTime) { if (item.Id == null || item.Id.ObjectId == null || versionedId == null || versionedId.ObjectId == null) { COWSiteMailboxMessageDedup.Tracer.TraceError((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.IsDuplicateMessageBySiteMailboxDrop: some following values are unavailable: item.Id, item.Id.ObjectId, matchedId, matchedId.ObjectId"); } else { COWSiteMailboxMessageDedup.Tracer.TraceDebug <StoreObjectId, StoreObjectId, string>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.IsDuplicateMessageBySiteMailboxDrop: found duplicate {0} of message {1} in site mailbox {2}.", versionedId.ObjectId, item.Id.ObjectId, session.DisplayName); } return(true); } } } } return(false); }
public G RunQueryOnAllItemsFolder <G>(IMailboxSession session, AllItemsFolderHelper.SupportedSortBy supportedSortBy, AllItemsFolderHelper.DoQueryProcessing <G> queryProcessor, ICollection <PropertyDefinition> properties) { return(AllItemsFolderHelper.RunQueryOnAllItemsFolder <G>((MailboxSession)session, supportedSortBy, queryProcessor, properties)); }
public T RunQueryOnAllItemsFolder <T>(IMailboxSession session, AllItemsFolderHelper.SupportedSortBy supportedSortBy, object seekToValue, T defaultValue, AllItemsFolderHelper.DoQueryProcessing <T> queryProcessor, ICollection <PropertyDefinition> properties) { return(AllItemsFolderHelper.RunQueryOnAllItemsFolder <T>((MailboxSession)session, supportedSortBy, seekToValue, defaultValue, queryProcessor, properties)); }
public static G RunQueryOnAllItemsFolder <G>(MailboxSession session, AllItemsFolderHelper.SupportedSortBy supportedSortBy, object seekToValue, G defaultValue, AllItemsFolderHelper.DoQueryProcessing <G> queryProcessor, ICollection <PropertyDefinition> properties) { return(AllItemsFolderHelper.RunQueryOnAllItemsFolder <G>(session, supportedSortBy, seekToValue, defaultValue, queryProcessor, properties, ItemQueryType.None)); }
public static IStorePropertyBag[] FindItemsFromInternetId(MailboxSession session, string internetMessageId, params PropertyDefinition[] propertyDefinitions) { return(AllItemsFolderHelper.FindItemsFromInternetId(session, internetMessageId, ItemQueryType.None, propertyDefinitions)); }
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++; } }