示例#1
0
        private StoreObjectId ResolveSearchFolderIdForFilteredView(StoreId inboxFolderId, OwaViewFilter viewFilter)
        {
            StoreObjectId storeObjectId = null;

            ExTraceGlobals.NotificationsCallTracer.TraceDebug <string>((long)this.GetHashCode(), "HierarchyNotificationHandler.ResolveSearchFolderIdForFilteredView Start. SubscriptionId: {0}", base.SubscriptionId);
            OwaSearchContext owaSearchContext = new OwaSearchContext();

            owaSearchContext.ViewFilter       = viewFilter;
            owaSearchContext.FolderIdToSearch = inboxFolderId;
            StoreObjectId defaultFolderId = base.UserContext.MailboxSession.GetDefaultFolderId(DefaultFolderType.SearchFolders);

            using (SearchFolder owaViewFilterSearchFolder = SearchUtil.GetOwaViewFilterSearchFolder(owaSearchContext, base.UserContext.MailboxSession, defaultFolderId, null, CallContext.Current))
            {
                if (owaViewFilterSearchFolder == null)
                {
                    throw new ArgumentNullException(string.Format("HierarchyNotificationHandler.ResolveSearchFolderIdForFilteredView null searchFolder returned for subscriptionId: {0}. ViewFilter: {1}; Source folder id: {2}", base.SubscriptionId, viewFilter, inboxFolderId.ToString()));
                }
                storeObjectId = owaViewFilterSearchFolder.StoreObjectId;
                ExTraceGlobals.NotificationsCallTracer.TraceDebug((long)this.GetHashCode(), "HierarchyNotificationHandler.ResolveSearchFolderIdForFilteredView found filtered-view search folder subscriptionId: {0} . ViewFilter: {1}; Source folder id: {2}, Search folder id: {3}", new object[]
                {
                    base.SubscriptionId,
                    viewFilter,
                    inboxFolderId.ToString(),
                    storeObjectId.ToString()
                });
            }
            return(storeObjectId);
        }
        /// <summary>
        /// Creates a search folder that finds items in the Inbox that contain the word "extended" in the subject line.
        /// </summary>
        /// <param name="service">An ExchangeService object with credentials and the EWS URL.</param>
        private static void CreateASearchFolder(ExchangeService service)
        {
            // Create a new search folder.
            SearchFolder searchFolder = new SearchFolder(service);

            // Use the following search filter to get all mail in the Inbox with the word "extended" in the subject line.
            SearchFilter.ContainsSubstring searchCriteria = new SearchFilter.ContainsSubstring(ItemSchema.Subject, "extended");

            searchFolder.SearchParameters.RootFolderIds.Add(WellKnownFolderName.Inbox);
            searchFolder.SearchParameters.Traversal    = SearchFolderTraversal.Shallow;
            searchFolder.SearchParameters.SearchFilter = searchCriteria;
            searchFolder.DisplayName = "Extended";

            try
            {
                // This call results in a CreateFolder operation call to EWS. The search folder should be added
                // to the WellKnownFolderName.SearchFolders folder so that it is visible to clients like Outlook.
                searchFolder.Save(WellKnownFolderName.SearchFolders);
                Console.WriteLine("Added: {0}", searchFolder.DisplayName);
            }
            catch (ServiceResponseException e)
            {
                if (e.Response.ErrorCode == ServiceError.ErrorFolderExists)
                {
                    Console.WriteLine("Rename your search folder or delete the existing search folder of the same name.");
                }
                else
                {
                    Console.WriteLine("Error - " + e.Message);
                }
            }
        }
示例#3
0
        public virtual bool GetDidLastSearchFail()
        {
            if (!this.IsInSearch)
            {
                return(false);
            }
            if (this.didLastSearchFail != null)
            {
                return(this.didLastSearchFail.Value);
            }
            SearchFolder searchFolder = this.DataFolder as SearchFolder;

            if (searchFolder != null && this.UserContext.IsPushNotificationsEnabled)
            {
                bool flag2;
                bool flag = this.UserContext.MapiNotificationManager.HasCurrentSearchCompleted((MailboxSession)searchFolder.Session, searchFolder.StoreObjectId, out flag2);
                if (flag && flag2)
                {
                    this.didLastSearchFail = new bool?((searchFolder.GetSearchCriteria().SearchState & SearchState.Failed) != SearchState.None);
                }
                if (this.didLastSearchFail != null && this.didLastSearchFail == true)
                {
                    SearchPerformanceData searchPerformanceData = this.UserContext.MapiNotificationManager.GetSearchPerformanceData((MailboxSession)searchFolder.Session);
                    searchPerformanceData.SearchFailed();
                }
            }
            return(this.didLastSearchFail != null && this.didLastSearchFail.Value);
        }
示例#4
0
        private static void Main(string[] args)
        {
            //declare vars
            List <ExtractFile> rarFiles = new List <ExtractFile>();
            List <ExtractFile> mkvFiles = new List <ExtractFile>();

            string[] subDirectories = Directory.GetDirectories(globalVar.searchFolder);

            //searching through folders to determine what files need extracting
            SearchFolder.searchFolder(subDirectories, rarFiles, mkvFiles);
            // loop through created items to assign destination before extracting / moving.
            foreach (var item in rarFiles)
            {
                //TODO: add regex in this function to properly sort all media.
                //item.fileDestination = destination.finalFolder(item.fileName);
                item.fileDestination = globalVar.destinationFolder;
            }
            foreach (var item in mkvFiles)
            {
                //TODO: add regex in this function to properly sort all media.
                //item.fileDestination = destination.finalFolder(item.fileName);
                item.fileDestination = globalVar.destinationFolder;
            }

            //extract files
            //Unrar.rarFunction(rarFiles);

            //copying mkv files
            // foreach (var item in mkvFiles)
            // {
            //     FileHandler.CopyFiles(item.fileName, item.fileDestination);
            // }

            // temp print function
            logger.Info($"rar files found: { rarFiles.Count}");
            logger.Info($"mkv files found: { mkvFiles.Count}");
            foreach (var item in rarFiles)
            {
                logger.Info($"fileName: { item.fileName}");
                logger.Info($"filePath: { item.filePath}");
                logger.Info($"fileDestination: {item.fileDestination}");
            }
            foreach (var item in mkvFiles)
            {
                logger.Info($"fileName: { item.fileName}");
                logger.Info($"filePath: { item.filePath}");
                logger.Info($"fileDestination: {item.fileDestination}");
            }

            //TODO: publish as executable
            //unstaged comment
            //v2:
            //TODO: add database connection for storing shows added, shows seeding, shows ready for delete.
            //TODO: handling of moving shows between statuses
            //TODO: add extracted / moved tvShows or movies to separate list "ready for delete"
            //so that torrent download folder can be deleteted
            //TODO: add config file for filepaths.
            //TODO: create config file function, low pri
            //TODO: determine download type and add correct filedestination, tvshow + name / movie.
        }
示例#5
0
        private bool IsSearchFolderPopulated(SearchFolder folder, out SearchState state)
        {
            SearchFolderCriteria searchCriteria = folder.GetSearchCriteria();

            state = searchCriteria.SearchState;
            return((searchCriteria.SearchState & SearchState.Rebuild) != SearchState.Rebuild);
        }
示例#6
0
        // Token: 0x06001359 RID: 4953 RVA: 0x00077AAC File Offset: 0x00075CAC
        private static bool GetSearchFolderData(UserContext userContext, out int searchFolderItemCount, out SearchState searchState, out bool isRemoteSession)
        {
            searchFolderItemCount = -1;
            searchState           = SearchState.None;
            isRemoteSession       = false;
            bool result = false;

            if (userContext.SearchFolderId != null)
            {
                try
                {
                    using (SearchFolder searchFolder = SearchFolder.Bind(userContext.SearchFolderId.GetSession(userContext), userContext.SearchFolderId.StoreObjectId, SearchPerformanceData.searchFolderProperties))
                    {
                        object obj = searchFolder.TryGetProperty(FolderSchema.SearchFolderItemCount);
                        if (obj is int)
                        {
                            searchFolderItemCount = (int)obj;
                        }
                        searchState     = searchFolder.GetSearchCriteria().SearchState;
                        isRemoteSession = searchFolder.Session.IsRemote;
                    }
                    result = true;
                }
                catch (ObjectNotFoundException)
                {
                }
            }
            return(result);
        }
        protected override object GetModel()
        {
            if (ContextNode == null)
            {
                return(null);
            }

            var content = Content.Create(ContextNode);

            var qs = new QuerySettings();

            if (EnableAutofilters != FilterStatus.Default)
            {
                qs.EnableAutofilters = (EnableAutofilters == FilterStatus.Enabled);
            }
            if (EnableLifespanFilter != FilterStatus.Default)
            {
                qs.EnableLifespanFilter = (EnableLifespanFilter == FilterStatus.Enabled);
            }

            if (Top > 0)
            {
                qs.Top = Top;
            }
            if (State.Skip > 0)
            {
                qs.Skip = State.Skip;
            }

            if (!string.IsNullOrEmpty(State.SortColumn))
            {
                qs.Sort = new[] { new SortInfo {
                                      FieldName = State.SortColumn, Reverse = State.SortDescending
                                  } };
            }

            content.ChildrenQuerySettings = qs;
            content.ChildrenQueryFilter   = GetQueryFilter();

            content.XmlWriterExtender = writer => { };

            switch (CollectionAxis)
            {
            case CollectionAxisMode.Children:
                return(content);

            case CollectionAxisMode.VersionHistory:
                var versionRoot = SearchFolder.Create(content.Versions);

                return(versionRoot);

            case CollectionAxisMode.ReferenceProperty:
                return(content);

            case CollectionAxisMode.External:
                return(SearchFolder.Create(RequestNodeList));
            }

            return(null);
        }
示例#8
0
        // Token: 0x06000F5F RID: 3935 RVA: 0x0003BBE0 File Offset: 0x00039DE0
        public static ItemType[] GetItemDataFromSearchFolder(OwaSearchContext searchContext, MailboxSession mailboxSession, out int totalRowCount)
        {
            List <ItemType> list = new List <ItemType>(50);

            totalRowCount = 0;
            StoreId searchFolderId = searchContext.SearchFolderId;

            SortBy[] searchSortBy = searchContext.SearchSortBy;
            using (SearchFolder searchFolder = SearchFolder.Bind(mailboxSession, searchFolderId))
            {
                int rowCount = 25;
                using (QueryResult queryResult = searchFolder.ItemQuery(ItemQueryType.None, null, searchSortBy, SearchFolderItemDataRetriever.itemSearchPropertyDefinitions))
                {
                    bool flag = true;
                    while (flag)
                    {
                        object[][] rows = queryResult.GetRows(rowCount, out flag);
                        if (rows == null || rows.Length == 0)
                        {
                            break;
                        }
                        for (int i = 0; i < rows.Length; i++)
                        {
                            if (totalRowCount < 50)
                            {
                                ItemType itemFromDataRow = SearchFolderItemDataRetriever.GetItemFromDataRow(searchContext, mailboxSession, rows[i], SearchFolderItemDataRetriever.itemSearchPropertyDefinitionsOrderDictionary);
                                list.Add(itemFromDataRow);
                            }
                            totalRowCount++;
                        }
                    }
                }
            }
            return(list.ToArray());
        }
示例#9
0
        internal Folder GetAutoTaggedMailSearchFolder()
        {
            SearchFolder searchFolder = this.CreateSearchFolder("AutoTaggedMailSearchFolder" + Guid.NewGuid().ToString());
            QueryFilter  queryFilter  = this.CreateAutoTaggedSearchFolderQuery();

            this.PopulateSearchFolder(searchFolder, queryFilter);
            return(searchFolder);
        }
示例#10
0
        private SearchFolder GetSearchFolder(MailboxSession session)
        {
            bool          flag          = false;
            StoreObjectId storeObjectId = this.GetCvsFolderIdIfPresent(session);
            SearchFolder  searchFolder  = null;

            try
            {
                if (storeObjectId == null)
                {
                    storeObjectId = session.CreateDefaultFolder(DefaultFolderType.CalendarVersionStore);
                }
                try
                {
                    searchFolder = SearchFolder.Bind(session, storeObjectId);
                }
                catch (ObjectNotFoundException innerException)
                {
                    ExTraceGlobals.DefaultFoldersTracer.TraceError <string, StoreObjectId>((long)this.GetHashCode(), "CalendarVersionStoreGateway::GetSearchFolder - No item is found with the CVS search folder ID (Session Display Name: {0}; Folder ID: {1}).", session.DisplayName, storeObjectId);
                    throw new CalendarVersionStoreNotPopulatedException(false, SearchState.None, TimeSpan.Zero, innerException);
                }
                catch (WrongObjectTypeException innerException2)
                {
                    ExTraceGlobals.DefaultFoldersTracer.TraceError <string, StoreObjectId>((long)this.GetHashCode(), "CalendarVersionStoreGateway::GetSearchFolder - The CVS search folder ID does not belong to a search folder (Session Display Name: {0}; Folder ID: {1}).", session.DisplayName, storeObjectId);
                    throw new CalendarVersionStoreNotPopulatedException(false, SearchState.None, TimeSpan.Zero, innerException2);
                }
                SearchState folderState;
                if (!this.IsSearchFolderPopulated(searchFolder, out folderState))
                {
                    if (this.Policy.WaitForPopulation)
                    {
                        using (SearchFolderAsyncSearch searchFolderAsyncSearch = new SearchFolderAsyncSearch(session, storeObjectId, null, null))
                        {
                            if (!this.IsSearchFolderPopulated(searchFolder, out folderState) && !searchFolderAsyncSearch.AsyncResult.AsyncWaitHandle.WaitOne(this.Policy.WaitTimeForPopulation))
                            {
                                ExTraceGlobals.DefaultFoldersTracer.TraceDebug <TimeSpan, string>((long)this.GetHashCode(), "CalendarVersionStoreGateway::GetSearchFolder - The CVS search folder is not populated, and timeout ({0}) is passed (Session Display Name: {1}).", this.Policy.WaitTimeForPopulation, session.DisplayName);
                                throw new CalendarVersionStoreNotPopulatedException(true, folderState, this.Policy.WaitTimeForPopulation);
                            }
                            goto IL_151;
                        }
                    }
                    ExTraceGlobals.DefaultFoldersTracer.TraceDebug <string>((long)this.GetHashCode(), "CalendarVersionStoreGateway::GetSearchFolder - The CVS search folder is not populated, and query policy has no wait time specified (Session Display Name: {0}).", session.DisplayName);
                    throw new CalendarVersionStoreNotPopulatedException(true, folderState, TimeSpan.Zero);
                }
IL_151:
                flag = true;
            }
            finally
            {
                if (!flag && searchFolder != null)
                {
                    searchFolder.Dispose();
                }
            }
            return(searchFolder);
        }
示例#11
0
        public void MessageCountTest()
        {
            IDBAccessor  context = null;                              // TODO: Initialize to an appropriate value
            NodeID       nodeID  = new NodeID();                      // TODO: Initialize to an appropriate value
            SearchFolder target  = new SearchFolder(context, nodeID); // TODO: Initialize to an appropriate value
            int          actual;

            actual = target.MessageCount;
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
 public PhotoFrameApplication(IKeywordRepository keywordRepository, IPhotoRepository photoRepository, IPhotoFileService photoFileService)
 {
     _registKeyword  = new RegistKeyword(keywordRepository);
     _detailSearch   = new DetailSearch();
     _searchFolder   = new SearchFolder(photoRepository, photoFileService);
     _toggleFavorite = new ToggleFavorite(photoRepository);
     _sortList       = new SortList();
     _changeKeyword  = new ChangeKeyword(keywordRepository, photoRepository);
     _getKeywordList = new GetKeywordList(keywordRepository);
 }
示例#13
0
 private void DirectQueryByGlobalObjectId(MailboxSession session, GlobalObjectId globalObjectId, string schemaKey, StorePropertyDefinition[] propertiesToFetch, Func <PropertyBag, bool> matchFoundAction, bool fetchResultsInReverseChronologicalOrder, bool useCleanGoid, bool useCachedPropertySetIfPresent, string[] itemClassFilter, ExDateTime?startDate = null, ExDateTime?endDate = null)
 {
     if (!CalendarVersionStoreGateway.ValidateDateRanges(ref startDate, ref endDate))
     {
         throw new ArgumentException("StartDate cannot be greater than EndDate", "startDate");
     }
     using (SearchFolder searchFolder = this.GetSearchFolder(session))
     {
         CalendarCorrelationMatch.QueryRelatedItems(searchFolder, globalObjectId, schemaKey, propertiesToFetch, useCachedPropertySetIfPresent, matchFoundAction, fetchResultsInReverseChronologicalOrder, !useCleanGoid, itemClassFilter, new ExDateTime?(startDate.Value), new ExDateTime?(endDate.Value));
     }
 }
示例#14
0
 public void QueryBySubjectContains(MailboxSession session, string subject, string schemaKey, StorePropertyDefinition[] propertiesToFetch, Action <PropertyBag> matchFoundAction, ExDateTime?startDate = null, ExDateTime?endDate = null)
 {
     if (!CalendarVersionStoreGateway.ValidateDateRanges(ref startDate, ref endDate))
     {
         throw new ArgumentException("StartDate cannot be greater than EndDate", "startDate");
     }
     using (SearchFolder searchFolder = this.GetSearchFolder(session))
     {
         CalendarCorrelationMatch.QuerySubjectContains(searchFolder, subject, schemaKey, propertiesToFetch, this.useCachedPropertySetIfPresent, matchFoundAction, startDate.Value, endDate.Value);
     }
 }
示例#15
0
        // Token: 0x06001F6C RID: 8044 RVA: 0x000B4D2C File Offset: 0x000B2F2C
        public bool IsSearchInProgress()
        {
            bool         result       = false;
            SearchFolder searchFolder = this.Folder as SearchFolder;

            if (searchFolder != null && this.userContext.IsPushNotificationsEnabled)
            {
                result = this.userContext.MapiNotificationManager.IsSearchInProgress((MailboxSession)searchFolder.Session, searchFolder.StoreObjectId);
            }
            return(result);
        }
示例#16
0
 // Token: 0x0600228C RID: 8844 RVA: 0x000C5B13 File Offset: 0x000C3D13
 public void UpgradeFilter(SearchFolder folder, PropertyDefinition[] propertiesToLoad)
 {
     if (this.IsCurrentVersion)
     {
         throw new OwaInvalidOperationException("Can't upgrade a filter in current version");
     }
     this.version = 3;
     folder[ViewStateProperties.FilteredViewLabel] = this.GetPropertyValueToSave();
     folder.Save();
     folder.Load(FolderList.FolderTreeQueryProperties);
 }
        public void ContentSerialization_1()
        {
            var query  = new NodeQuery(new IntExpression(IntAttribute.ParentId, ValueOperator.Equal, Repository.Root.Id));
            var folder = SearchFolder.Create(query);
            var xml0   = XDocument.Load(new StreamReader(folder.GetXml(true)));
            var s0     = xml0.Element(XName.Get("Content")).Element(XName.Get("Children")).ToString();

            var content = Content.Create(Repository.Root);
            var xml1    = XDocument.Load(new StreamReader(content.GetXml(true)));
            var s1      = xml1.Element(XName.Get("Content")).Element(XName.Get("Children")).ToString();

            Assert.IsTrue(s0 == s1);
        }
        static void Main(string[] args)
        {
            ServicePointManager.ServerCertificateValidationCallback =
                CallbackMethods.CertificateValidationCallBack;
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

            // Get the information of the account.
            UserInfo user = new UserInfo();

            service.Credentials = new WebCredentials(user.Account, user.Pwd);

            // Set the url of server.
            if (!AutodiscoverUrl(service, user))
            {
                return;
            }
            Console.WriteLine();

            String subjectString = InputSubjectString();

            // Use the EmailMessageSchema.Subject to filter the emails.
            Dictionary <PropertyDefinition, String> filters = new Dictionary <PropertyDefinition, string>();

            filters[EmailMessageSchema.Subject] = subjectString;

            String folderName = "Subject contains for export email";

            // Delete the duplicate folder.
            DeleteFolder(service, WellKnownFolderName.SearchFolders, folderName);

            // Create the search folder named "Subject contains" to get the emails that received in last 30 days
            CreateSearchFolder(service, filters, folderName);
            Console.WriteLine("Create the search folder.");
            Console.WriteLine();

            // Get the search folder.
            SearchFilter filter       = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, folderName);
            SearchFolder searchFolder = GetFolder(service, filter,
                                                  WellKnownFolderName.SearchFolders) as SearchFolder;

            Console.WriteLine("Get the specific search folder.");
            Console.WriteLine();

            // Export the email messages to the application directory.
            Console.WriteLine("Begin to export the emails:");
            ExportEmailMessages(searchFolder, Environment.CurrentDirectory);
            Console.WriteLine();

            Console.WriteLine("Press any key to exit......");
            Console.ReadKey();
        }
示例#19
0
        /// <summary>
        /// Searches an XML file with an XPath expression
        /// </summary>
        /// <param name="context"></param>
        protected override void Execute(CodeActivityContext context)
        {
            // get the value of the XPathExpression
            var fileNamePattern = FileNamePattern.Get(context);

            // get the value of the FilePath
            var searchFolder = SearchFolder.Get(context);

            var filePath = FindFile(fileNamePattern, searchFolder);

            context.WriteBuildMessage(string.Format("Path found: {0}", filePath), BuildMessageImportance.High);

            // return the value
            FullFilePath.Set(context, filePath);
        }
示例#20
0
            public IEnumerable <T> EndAuditLogQuery <T>(IAsyncResult asyncResult, IAuditQueryStrategy <T> queryStrategy)
            {
                SearchFolder searchFolder = this.folder as SearchFolder;

                if (searchFolder != null)
                {
                    SearchFolderCriteria searchCriteria = searchFolder.GetSearchCriteria();
                    if ((searchCriteria.SearchState & SearchState.FailNonContentIndexedSearch) == SearchState.FailNonContentIndexedSearch && (searchCriteria.SearchState & SearchState.Failed) == SearchState.Failed)
                    {
                        throw queryStrategy.GetQueryFailedException();
                    }
                }
                AuditLog.AuditLogQueryContext.QueryRecordStrategy <T> strategy = new AuditLog.AuditLogQueryContext.QueryRecordStrategy <T>(queryStrategy);
                return(AuditLog.InternalFindAuditRecords <T>(this.folder, strategy));
            }
示例#21
0
        private void PopulateDynamicSearchFolder(SearchFolder searchFolder, SearchFolderCriteria searchCriteria)
        {
            IAsyncResult asyncResult = searchFolder.BeginApplyContinuousSearch(searchCriteria, null, null);
            bool         flag        = asyncResult.AsyncWaitHandle.WaitOne(SearchFolderManager.MaximumSearchTime, false);

            if (flag)
            {
                searchFolder.EndApplyContinuousSearch(asyncResult);
            }
            else
            {
                SearchFolderManager.Tracer.TraceDebug <SearchFolderManager>((long)this.GetHashCode(), "{0}: ELC Non Archive Tag search timed out.", this);
            }
            searchFolder.Save();
            searchFolder.Load();
        }
        /// <summary>
        /// Export the eamil messges form the specific search folder.
        /// </summary>
        private static void ExportEmailMessages(SearchFolder searchFolder, String filePath)
        {
            if (searchFolder == null)
            {
                return;
            }

            String[] invalidStings = { "\\", ",", ":", "*", "?", "\"", "<", ">", "|" };

            PropertySet itemPorpertySet = new PropertySet(BasePropertySet.FirstClassProperties,
                                                          EmailMessageSchema.MimeContent);

            const Int32 pageSize = 50;
            ItemView    itemView = new ItemView(pageSize);

            FindItemsResults <Item> findResults = null;

            do
            {
                findResults = searchFolder.FindItems(itemView);

                foreach (Item item in findResults.Items)
                {
                    if (item is EmailMessage)
                    {
                        EmailMessage email = item as EmailMessage;
                        email.Load(itemPorpertySet);

                        Byte[] content  = email.MimeContent.Content;
                        String fileName = email.Subject;

                        // Replace all the invaild strings.
                        foreach (String str in invalidStings)
                        {
                            fileName = fileName.Replace(str, "");
                        }

                        // Export the emails to the .eml files.
                        fileName = Path.Combine(filePath, fileName + ".eml");
                        File.WriteAllBytes(fileName, content);
                        Console.WriteLine("Export the email:{0}", email.Subject);
                    }
                }

                itemView.Offset += pageSize;
            } while (findResults.MoreAvailable);
        }
示例#23
0
        public static SearchFolder CreateSearchFolderIfNeeded(ExchangeService exchService, Mailbox mailbox)
        {
            // Check if it exists already
            var          searchFoldersId     = new FolderId(WellKnownFolderName.SearchFolders, mailbox);
            var          searchFoldersFolder = Folder.Bind(exchService, searchFoldersId);
            var          searchFoldersView   = new FolderView(2);
            var          searchFoldersFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, SearchFolderName);
            var          searchFolderResults = searchFoldersFolder.FindFolders(searchFoldersFilter, searchFoldersView);
            SearchFolder mySearchFolder      = null;

            if (searchFolderResults.Folders.Count > 1)
            {
                Console.WriteLine("The expected folder name is ambiguous. How did we end up with multiple folders?");
                Console.WriteLine("Dunno, but I'm going to delete all but the first.");
                for (var x = 1; x < searchFolderResults.Folders.Count; x++)
                {
                    searchFolderResults.Folders[x].Delete(DeleteMode.HardDelete);
                }
            }

            if (searchFolderResults.Folders.Count > 0)
            {
                Console.WriteLine("Found existing search folder.");
                mySearchFolder = searchFolderResults.Folders[0] as SearchFolder;
                if (mySearchFolder == null)
                {
                    Console.WriteLine("Somehow this folder isn't a search folder. Deleting it.");
                    searchFolderResults.Folders[0].Delete(DeleteMode.HardDelete);
                }
            }

            if (mySearchFolder == null)
            {
                Console.WriteLine("Creating a new search folder.");
                mySearchFolder             = new SearchFolder(exchService);
                mySearchFolder.DisplayName = SearchFolderName;
                mySearchFolder.SearchParameters.SearchFilter =
                    new SearchFilter.Exists(MyNamedProp);
                var inboxId = new FolderId(WellKnownFolderName.Inbox, mailbox);
                mySearchFolder.SearchParameters.RootFolderIds.Add(inboxId);
                mySearchFolder.SearchParameters.Traversal = SearchFolderTraversal.Shallow;
                mySearchFolder.Save(searchFoldersId);
            }

            return(mySearchFolder);
        }
示例#24
0
 private void InitReminderTableSubscription()
 {
     if (this.reminderSub == null)
     {
         using (SearchFolder searchFolder = SearchFolder.Bind(this.mailboxSession, DefaultFolderType.Reminders))
         {
             SortBy[] sortColumns = new SortBy[]
             {
                 new SortBy(ItemSchema.ReminderIsSet, SortOrder.Descending),
                 new SortBy(ItemSchema.ReminderNextTime, SortOrder.Descending)
             };
             this.queryResultReminder = searchFolder.ItemQuery(ItemQueryType.None, null, sortColumns, RemindersRenderingUtilities.QueryProperties);
             this.queryResultReminder.GetRows(1);
             this.reminderSub = Subscription.Create(this.queryResultReminder, new NotificationHandler(this.HandleReminderNotification));
         }
     }
 }
示例#25
0
        // Token: 0x0600228D RID: 8845 RVA: 0x000C5B54 File Offset: 0x000C3D54
        public void ApplyFilter(SearchFolder folder, PropertyDefinition[] propertiesToLoad)
        {
            if (!this.IsCurrentVersion)
            {
                throw new OwaInvalidOperationException("Can't apply a filter in different version");
            }
            int num = 0;
            SearchFolderCriteria searchFolderCriteria = new SearchFolderCriteria(this.GetQueryFilter(), new StoreId[]
            {
                this.SourceFolderId.StoreObjectId
            });

            searchFolderCriteria.DeepTraversal = false;
            SearchPerformanceData searchPerformanceData = new SearchPerformanceData();
            string text = this.ToDescription();

            searchPerformanceData.StartSearch(string.IsNullOrEmpty(text) ? "No Search String" : text);
            IAsyncResult asyncResult = folder.BeginApplyContinuousSearch(searchFolderCriteria, null, null);
            Stopwatch    watch       = Utilities.StartWatch();
            bool         flag        = asyncResult.AsyncWaitHandle.WaitOne(5000, false);

            searchPerformanceData.Complete(!flag, true);
            if (flag)
            {
                folder.EndApplyContinuousSearch(asyncResult);
            }
            else
            {
                ExTraceGlobals.MailTracer.TraceDebug((long)this.GetHashCode(), "FolderVirtualListViewEventHandler.GetFilteredView. Search for filtered view timed out.");
                if (Globals.ArePerfCountersEnabled)
                {
                    OwaSingleCounters.SearchesTimedOut.Increment();
                }
            }
            OwaContext.Current.SearchPerformanceData = searchPerformanceData;
            Utilities.StopWatch(watch, "FolderVirtualListViewEventHandler.GetFilteredView (Wait for filter to complete)");
            object obj = folder.TryGetProperty(FolderSchema.ExtendedFolderFlags);

            if (!(obj is PropertyError))
            {
                num = (int)obj;
            }
            folder[FolderSchema.ExtendedFolderFlags] = (num | 4194304);
            folder.Save();
            folder.Load(propertiesToLoad);
        }
        public static List <object[]> QueryReminders(ExDateTime actualizationTime, UserContext userContext)
        {
            List <object[]> list = new List <object[]>();

            object[][]       array            = null;
            ComparisonFilter comparisonFilter = new ComparisonFilter(ComparisonOperator.LessThan, ItemSchema.ReminderNextTime, actualizationTime.AddHours(24.0));

            if (userContext.IsPushNotificationsEnabled)
            {
                array = userContext.MapiNotificationManager.GetReminderRows(comparisonFilter, 100);
            }
            else
            {
                using (SearchFolder searchFolder = SearchFolder.Bind(userContext.MailboxSession, DefaultFolderType.Reminders))
                {
                    SortBy[] sortColumns = new SortBy[]
                    {
                        new SortBy(ItemSchema.ReminderIsSet, SortOrder.Descending),
                        new SortBy(ItemSchema.ReminderNextTime, SortOrder.Descending)
                    };
                    using (QueryResult queryResult = searchFolder.ItemQuery(ItemQueryType.None, null, sortColumns, RemindersRenderingUtilities.QueryProperties))
                    {
                        queryResult.SeekToCondition(SeekReference.OriginBeginning, comparisonFilter);
                        array = queryResult.GetRows(100);
                    }
                }
            }
            if (array == null)
            {
                return(list);
            }
            for (int i = 0; i < array.Length; i++)
            {
                bool itemProperty = RemindersRenderingUtilities.GetItemProperty <bool>(array[i], ItemSchema.ReminderIsSet, false);
                if (!itemProperty)
                {
                    break;
                }
                list.Add(array[i]);
                if (list.Count == 100)
                {
                    break;
                }
            }
            return(list);
        }
示例#27
0
        // Token: 0x060005CF RID: 1487 RVA: 0x0002BFD8 File Offset: 0x0002A1D8
        private void DeleteObjectsInFolder(SearchFolder searchFolder)
        {
            GroupOperationResult groupOperationResult = searchFolder.DeleteAllObjects(DeleteItemFlags.HardDelete | DeleteItemFlags.SuppressReadReceipt, true);
            OperationResult      operationResult      = groupOperationResult.OperationResult;
            Exception            exception            = groupOperationResult.Exception;

            if (operationResult == OperationResult.Failed || operationResult == OperationResult.PartiallySucceeded)
            {
                DiscoveryHoldEnforcer.Tracer.TraceError <DiscoveryHoldEnforcer, string, OperationResult>((long)this.GetHashCode(), "{0}: An error occured when trying to hard delete all messages in {1}. Operation Result: {2}", this, searchFolder.Id.ToString(), operationResult);
                Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_ExpirationOfMsgsInDiscoveryHoldsFolderFailed, null, new object[]
                {
                    base.MailboxDataForTags.MailboxSession.MailboxOwner,
                    DeleteItemFlags.HardDelete.ToString(),
                    (searchFolder.Id == null) ? string.Empty : searchFolder.Id.ToString(),
                    (exception == null) ? string.Empty : exception.ToString()
                });
            }
        }
        public PhotoFrameApplication()
        {
            this.ServiceFactory = new ServiceFactory();

            this.repositoryMaster = new RepositoryMaster();
            this.photoFileService = ServiceFactory.PhotoFileService;

            this.searchFolder       = new SearchFolder(repositoryMaster, photoFileService);
            this.filter             = new Filter(repositoryMaster);
            this.addKeyword         = new AddKeyword(repositoryMaster);
            this.deleteKeyword      = new DeleteKeyword(repositoryMaster);
            this.toggleIsFavorite   = new ToggleIsFavorite(repositoryMaster);
            this.addAlbum           = new AddAlbum(repositoryMaster);
            this.searchAlbum        = new SearchAlbum(repositoryMaster);
            this.sortDateAscending  = new SortDateAscending();
            this.sortDateDescending = new SortDateDescending();
            this.getAllAlbums       = new GetAllAlbums(repositoryMaster);
        }
示例#29
0
            public IAsyncResult BeginAuditLogQuery(QueryFilter queryFilter, int maximumResultsCount)
            {
                if (this.pendingAsyncResult != null)
                {
                    throw new InvalidOperationException("Asynchronous query is already pending.");
                }
                StoreId      storeId = null;
                IAsyncResult result;

                using (DisposeGuard disposeGuard = default(DisposeGuard))
                {
                    Folder disposable;
                    if (queryFilter != null)
                    {
                        SearchFolder searchFolder = SearchFolder.Create(this.auditLog.Session, this.auditLog.Session.GetDefaultFolderId(DefaultFolderType.SearchFolders), "SearchAuditMailboxFolder" + Guid.NewGuid().ToString(), CreateMode.OpenIfExists);
                        disposeGuard.Add <SearchFolder>(searchFolder);
                        searchFolder.Save();
                        searchFolder.Load();
                        storeId = searchFolder.Id;
                        result  = searchFolder.BeginApplyOneTimeSearch(new SearchFolderCriteria(queryFilter, new StoreId[]
                        {
                            this.auditLog.LogFolderId
                        })
                        {
                            DeepTraversal               = false,
                            UseCiForComplexQueries      = true,
                            FailNonContentIndexedSearch = true,
                            MaximumResultsCount         = new int?(maximumResultsCount)
                        }, null, null);
                        disposable = searchFolder;
                    }
                    else
                    {
                        disposable = Folder.Bind(this.auditLog.Session, this.auditLog.LogFolderId);
                        disposeGuard.Add <Folder>(disposable);
                        result = new CompletedAsyncResult();
                    }
                    disposeGuard.Success();
                    this.pendingAsyncResult = result;
                    this.folder             = disposable;
                    this.folderIdToDelete   = storeId;
                }
                return(result);
            }
示例#30
0
 public void SubscribeForSearchPageNotify(StoreObjectId searchFolderId, SearchFolder searchFolder, SearchFolderCriteria searchCriteria, string searchString)
 {
     if (!this.userContext.LockedByCurrentThread())
     {
         throw new InvalidOperationException("UserContext lock should be acquired before calling this method");
     }
     lock (this)
     {
         this.ResetSearchFolderReferences(true);
         this.InitSubscriptions(ClientSubscriptionFlags.StaticSearch);
         this.hasCurrentSearchCompleted             = false;
         this.wasFailNonContentIndexedSearchFlagSet = searchCriteria.FailNonContentIndexedSearch;
         this.searchFolderIdCurrent = OwaStoreObjectId.CreateFromSessionFolderId(this.userContext, this.mailboxSession, searchFolderId);
         this.searchSub             = Subscription.Create(this.mailboxSession, new NotificationHandler(this.HandleFullSearchComplete), NotificationType.SearchComplete, searchFolderId);
         searchFolder.ApplyOneTimeSearch(searchCriteria);
         this.searchPerformanceData = new SearchPerformanceData();
         this.searchPerformanceData.StartSearch(searchString);
     }
 }