예제 #1
0
 private DateTime GetRestrictDate(IResource resFolder)
 {
     if (Refresh)
     {
         return(_indexStartDate);
     }
     if (resFolder != null)
     {
         bool seeAll = Folder.GetSeeAll(resFolder);
         if (seeAll)
         {
             return(DateTime.MinValue);
         }
         if (!seeAll && _indexStartDate == DateTime.MinValue)
         {
             Folder.SetSeeAllAsync(resFolder);
         }
     }
     return(_indexStartDate);
 }
예제 #2
0
        private void EnumerateMail(FolderDescriptor folder, IEFolder mapiFolder)
        {
            try
            {
                OnFolderFetched(folder.Name);
                int indexed = 0;

                IResource resFolder  = Folder.Find(folder.FolderIDs.EntryId);
                DateTime  dtRestrict = GetRestrictDate(resFolder);

                IETable table = null;
                try
                {
                    table = mapiFolder.GetEnumTable(dtRestrict);
                }
                catch (System.UnauthorizedAccessException exception)
                {
                    _tracer.TraceException(exception);
                }
                catch (OutOfMemoryException exception)
                {
                    _tracer.TraceException(exception);
                }
                if (table == null)
                {
                    return;
                }
                using ( table )
                {
                    int count = table.GetRowCount();
                    if (count > 0)
                    {
                        table.Sort(MAPIConst.PR_MESSAGE_DELIVERY_TIME, false);
                    }
                    for (uint i = 0; i < count; i++)
                    {
                        if (OutlookSession.OutlookProcessor.ShuttingDown)
                        {
                            break;
                        }
                        if (_idle && Settings.IdleModeManager.CheckInterruptIdle())
                        {
                            break;
                        }
                        IERowSet row = row = table.GetNextRow();
                        if (row == null)
                        {
                            continue;
                        }
                        using ( row )
                        {
                            if (row.GetLongProp(6) != 1)
                            {
                                ProcessRow(row, folder, mapiFolder, ref indexed);
                            }
                        }
                    }
                }
                if (Settings.IdleModeManager.CompletedIdle)
                {
                    Folder.SetSeeAllAsync(resFolder);
                }

                _tracer.Trace("Indexed " + indexed + " messages in folder " + folder.Name);
            }
            finally
            {
                OutlookSession.ProcessJobs();
            }
        }