protected override void Execute() { if (OutlookSession.OutlookProcessor.ShuttingDown) { return; } IEFolder folder = OutlookSession.OpenFolder(_ntf.ParentID, _storeID); if (folder != null) { using ( folder ) { FolderDescriptor folderDescriptor = FolderDescriptor.Get(folder); if (folderDescriptor == null) { return; } IResource resFolder = Folder.Find(folderDescriptor.FolderIDs.EntryId); if (resFolder == null) { return; } bool ignoredFolder = Folder.IsIgnored(resFolder); IEMessage message = OutlookSession.OpenMessage(_ntf.EntryID, _storeID); if (message == null) { return; } using ( message ) { string entryId = OutlookSession.GetMessageID(message); IResource mail = Core.ResourceStore.FindUniqueResource("Email", PROP.EntryID, _ntf.EntryID); if (mail == null && _ntf.OldEntryID != null) { mail = Core.ResourceStore.FindUniqueResource("Email", PROP.EntryID, _ntf.OldEntryID); } if (ignoredFolder && mail != null) { Trace.WriteLine("Moved mail ID=" + mail.Id + " to ignored folder"); Mail.ForceDelete(mail); return; } if (mail == null) { ProcessMailAddNtf.DoJob(_ntf, _storeID); return; } mail.SetProp(PROP.EntryID, entryId); Folder.LinkMail(resFolder, mail); } } } }
private static void LinkMail(IResource folder, IResource mail) { if (mail.IsDeleting) { return; } if (folder.IsDeleting) { return; } Folder.LinkMail(folder, mail); }
private void LinkToFolder(IResource resMail) { IResource resFolder = null; if (_folder != null) { resFolder = Folder.Find(_folder.FolderIDs.EntryId); } if (resFolder != null) { Folder.LinkMail(resFolder, resMail); IResource msgStore = Folder.GetMAPIStorage(resFolder); if (msgStore.GetDateProp(PROP.LastReceiveDate) < _receivedTime) { msgStore.SetProp(PROP.LastReceiveDate, _receivedTime); } } else { _tracer.Trace("Can't link mail to folder"); } }
public static void Delete(IResource mail) { if (mail == null || mail.Id == -1) { return; } if (!Mail.CanBeDeleted(mail)) { return; } IResource folder = mail.GetLinkProp(PROP.MAPIFolder); if (folder != null && Folder.IsIMAPFolder(folder) && !Settings.IgnoreDeletedIMAPMessages) { mail.SetProp(PROP.DeletedInIMAP, true); Folder.LinkMail(folder, mail); } else { ForceDelete(mail); } }
protected override void Execute() { IResource task = GetTaskResource(); if (task == null) { Tracer._Trace("TASK IMPORT task not found"); } if (task != null) { if (_folder.ContainerClass != FolderType.Task) { Tracer._Trace("Delete task: id = " + task.Id); task.Delete(); return; } } IResource resFolder = Folder.Find(_folder.FolderIDs.EntryId); bool folderIgnored = (resFolder != null && Folder.IsIgnored(resFolder)) || OutlookSession.IsDeletedItemsFolder(_folder.FolderIDs.EntryId); if (folderIgnored) { if (task != null) { task.Delete(); } return; } bool import = resFolder != null && !Folder.IsIgnoreImport(resFolder); if (!import && task == null) { return; } if (task == null) { task = Core.ResourceStore.BeginNewResource(STR.Task); } else { task.BeginUpdate(); } string oldEntryID = task.GetStringProp(PROP.EntryID); if (oldEntryID == null) { task.SetProp(PROP.EntryID, _entryID); } else if (oldEntryID != _entryID) { throw new ApplicationException("Try to change entryID for task"); } if (resFolder != null) { Folder.LinkMail(resFolder, task); } if (!import) { task.EndUpdate(); if (Settings.TraceTaskChanges) { _tracer.Trace(task); } return; } task.SetProp(Core.Props.Subject, _subject); SetDateProp(task, Core.Props.Date, _dueDate); SetDateProp(task, PROP.StartDate, _startDate); if (_reminderActive == 0) { SetDateProp(task, PROP.RemindDate, DateTime.MinValue); } else { SetDateProp(task, PROP.RemindDate, _remindDate); } task.SetProp(PROP.Status, _status); task.SetProp(PROP.Priority, _priority); task.SetProp(PROP.Description, _description); task.AddLink(PROP.Target, Core.ResourceTreeManager.GetRootForType(STR.Task)); if (!task.HasProp(PROP.SuperTaskLink)) { task.SetProp(PROP.SuperTaskLink, Core.ResourceTreeManager.GetRootForType(STR.Task)); } if (Settings.SyncTaskCategory) { CategorySetter.DoJob(_outlookCategories, task); } bool wereChanges = task.IsChanged(); task.EndUpdate(); if (wereChanges && Core.TextIndexManager != null) { Guard.QueryIndexingWithCheckId(task); } if (Settings.TraceTaskChanges) { _tracer.Trace(task); } }