Пример #1
0
        private void EnumerateTasks(FolderDescriptor folder, IEFolder mapiFolder)
        {
            OnFolderFetched(folder.Name);

            IEMessages messages = mapiFolder.GetMessages();

            if (messages != null)
            {
                using ( messages )
                {
                    int count = messages.GetCount();
                    for (int i = 0; i < count; i++)
                    {
                        IEMessage message = messages.OpenMessage(i);
                        if (message != null)
                        {
                            using ( message )
                            {
                                string entryID = OutlookSession.GetMessageID(message);
                                TaskDescriptor.Do(folder, message, entryID);
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        private void ProcessMailModifyImpl(MAPIFullNtf ntf, IEMessage message, FolderDescriptor folderDescriptor)
        {
            string messageClass = MessageType.GetMessageClass(message);

            if (MessageType.InterpretAsMail(messageClass))
            {
                string entryId = OutlookSession.GetMessageID(message);
                if (OutlookSession.IsMailExported(entryId))
                {
                    return;
                }
                new MailDescriptor(folderDescriptor, entryId, message, MailDescriptor.UpdateState).QueueJob(JobPriority.AboveNormal);
            }
            else if (MessageType.InterpretAsContact(messageClass))
            {
                string realEntryId = message.GetBinProp(MAPIConst.PR_ENTRYID);
                if (OutlookSession.IsMailExported(realEntryId))
                {
                    return;
                }
                ContactDescriptorWrapper.Do(folderDescriptor, realEntryId, realEntryId);
            }
            else if (MessageType.InterpretAsTask(messageClass))
            {
                _tracer.Trace("Task was modified");
                string realEntryId = message.GetBinProp(MAPIConst.PR_ENTRYID);
                if (OutlookSession.IsMailExported(realEntryId))
                {
                    return;
                }
                TaskDescriptor.Do(JobPriority.AboveNormal, folderDescriptor, message, realEntryId);
            }
            else
            {
                ntf = ntf;
//                _tracer.Trace( "Unknown item of class " + messageClass + " was modified" );
            }
        }
Пример #3
0
        public static void DoJobImpl(MAPINtf ntf, IEMessage message, FolderDescriptor folderDescriptor)
        {
            string entryId      = OutlookSession.GetMessageID(message);
            string messageClass = MessageType.GetMessageClass(message);

            if (MessageType.InterpretAsMail(messageClass))
            {
                new MailDescriptor(folderDescriptor, entryId, message).QueueJob(JobPriority.AboveNormal);
            }
            else if (MessageType.InterpretAsContact(messageClass))
            {
                ContactDescriptorWrapper.Do(JobPriority.AboveNormal, folderDescriptor, entryId, entryId);
            }
            else if (MessageType.InterpretAsTask(messageClass))
            {
                Tracer._Trace("Task was added");
                TaskDescriptor.Do(JobPriority.AboveNormal, folderDescriptor, message, entryId);
            }
            else
            {
                Tracer._Trace("Unknown item of class " + messageClass + " was added");
            }
        }
Пример #4
0
        private void OnMailMoveImpl(MAPIFullNtf ntf)
        {
            if (CheckStorageIgnored(_storeID))
            {
                return;
            }
            FolderDescriptor folderDescriptor = FolderDescriptor.Get(ntf.ParentID, _storeID);

            if (folderDescriptor == null)
            {
                return;
            }

            try
            {
                IEMessage message = OutlookSession.OpenMessage(ntf.EntryID, _storeID);
                if (message == null)
                {
                    return;
                }
                using ( message )
                {
                    string realID = message.GetBinProp(MAPIConst.PR_ENTRYID);
                    if (realID == null)
                    {
                        realID = ntf.EntryID;
                    }
                    else
                    {
                        if (OutlookSession.IsMailExported(realID))
                        {
                            return;
                        }
                    }
                    string messageClass = MessageType.GetMessageClass(message);
                    if (MessageType.InterpretAsMail(messageClass))
                    {
                        Core.ResourceAP.QueueJob(JobPriority.AboveNormal, new MailMovedDescriptor(ntf, _storeID));
                    }
                    else
                    if (MessageType.InterpretAsContact(messageClass))
                    {
                        if (folderDescriptor.ContainerClass != FolderType.Contact)
                        {
                            _tracer.Trace("Contact was moved to deleted items");
                            IResource contact = Core.ResourceStore.FindUniqueResource(STR.Contact, PROP.EntryID, realID);
                            string    entryID = realID;
                            if (contact == null && ntf.OldEntryID != null)
                            {
                                _tracer.Trace("contact not found");
                                contact = Core.ResourceStore.FindUniqueResource(STR.Contact, PROP.EntryID, ntf.OldEntryID);
                                entryID = ntf.EntryID;
                            }
                            if (contact != null)
                            {
                                _tracer.Trace("contact found");
                                _tracer.Trace("RemoveFromSync");
                                Contact.RemoveFromSync(contact, entryID);
                            }
                            else
                            {
                                _tracer.Trace("ClearInvalidEntryIDFromContacts");
                                _jobStrategy.QueueJob(new MethodInvoker(REGISTRY.ClearInvalidEntryIDFromContacts));
                            }
                        }
                        else
                        {
                            string searchEntryID = realID;
                            if (realID != ntf.OldEntryID)
                            {
                                searchEntryID = ntf.OldEntryID;
                            }

                            _tracer.Trace("ContactDescriptorWrapper process moving");
                            ContactDescriptorWrapper.Do(_jobStrategy.JobPriority, folderDescriptor, realID, searchEntryID);
                        }
                        //OutlookSession.OutlookProcessor.QueueJob( new ContactDescriptorWrapper( folderDescriptor, ntf.EntryID ) );
                    }
                    else if (MessageType.InterpretAsTask(messageClass))
                    {
                        _tracer.Trace("Task was moved");
                        if (Core.ResourceStore.FindUniqueResource(STR.Task, PROP.EntryID, realID) != null)
                        {
                            TaskDescriptor.Do(JobPriority.AboveNormal, folderDescriptor, message, realID);
                        }
                        else
                        {
                            RefreshTaskFolder(folderDescriptor);
                            FolderDescriptor oldFolderDescriptor = FolderDescriptor.Get(ntf.OldParentID, _storeID);
                            if (oldFolderDescriptor != null)
                            {
                                RefreshTaskFolder(oldFolderDescriptor);
                            }
                        }
                    }
                    else
                    {
                        _tracer.Trace("Unknown item of class " + messageClass + " was moved");
                    }
                }
            }
            catch (System.Threading.ThreadAbortException ex)
            {
                Tracer._TraceException(ex);
            }
            catch (Exception exception)
            {
                Core.ReportBackgroundException(exception);
            }
        }