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 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);
        }