コード例 #1
0
ファイル: ContactDescriptor.cs プロジェクト: mo5h/omeo
        protected override void Execute()
        {
            if (!_contactNames.CheckIfNamesValid())
            {
                return;
            }
            ImportedContactsChangeWatcher.ProcessingImportFromOutlook = true;

            if (_searchEntryID == null)
            {
                _searchEntryID = _entryID;
            }

            IContact contactBO = _contactNames.FindOrCreateContact(_searchEntryID);

            contactBO.BeginUpdate();

            if (_emailAddresses != null && _emailAddresses.Count > 1)
            {
                for (int i = 1; i < _emailAddresses.Count; ++i)
                {
                    contactBO.AddAccount((string)_emailAddresses[i]);
                }
            }

            IResource person = contactBO.Resource;

            _addressBook.AB().AddContact(person);
            person.SetProp(PROP.Imported, 1);
            person.DeleteProp("UserCreated");
            if (person.HasProp(PROP.EntryID) && person.GetStringProp(PROP.EntryID) != _entryID)
            {
                person.SetProp(PROP.EntryID, _entryID);
            }
            else
            {
                person.SetProp(PROP.EntryID, _entryID);
            }

            Pair otherPhone = null;

            foreach (Pair pair in _phones)
            {
                string phoneNumber = (string)pair.Second;
                if (phoneNumber != null && phoneNumber.Length > 0)
                {
                    Phone phone = (Phone)pair.First;
                    if (phone.Name == Phone.Other.Name)
                    {
                        otherPhone = pair;
                    }
                    else
                    {
                        contactBO.SetPhoneNumber(phone.Name, phoneNumber);
                    }
                }
            }
            if (otherPhone != null && !contactBO.PhoneNumberExists((string)otherPhone.Second))
            {
                contactBO.SetPhoneNumber(Phone.Other.Name, (string)otherPhone.Second);
            }

            contactBO.Company     = _companyName;
            contactBO.JobTitle    = _jobTitle;
            contactBO.Address     = _streetAddress;
            contactBO.HomePage    = _businessHomePage;
            contactBO.Suffix      = _contactNames.Suffix;
            contactBO.MiddleName  = _contactNames.MiddleName;
            contactBO.Title       = _contactNames.NamePrefix;
            contactBO.Description = _description;
            if (Settings.SyncContactCategory)
            {
                CategorySetter.DoJob(_outlookCategories, person);
            }

            if (_birthday > DateTime.MinValue || contactBO.Birthday.CompareTo(_birthday) != 0)
            {
                contactBO.Birthday = _birthday;
            }

            contactBO.EndUpdate();
            ImportedContactsChangeWatcher.ProcessingImportFromOutlook = false;
            if (Settings.TraceContactChanges)
            {
                _tracer.Trace(contactBO.Resource);
            }
        }
コード例 #2
0
ファイル: MailDescriptor.cs プロジェクト: mo5h/omeo
        protected IResource ExecuteImpl()
        {
            IResource resMail = GetEmailResource();

            if (resMail == null)
            {
                Trace("GetEmailResource returned null");
                return(null);
            }
            resMail.SetProp(Core.Props.Subject, _subject);
            resMail.SetProp(Core.Props.Date, _receivedTime);
            resMail.SetProp(PROP.SentOn, _sentOn);
            resMail.SetProp(PROP.ContainerClass, _messageClass);

            if (_contactCreated)
            {
                CreateSenderContact(resMail);
            }
            _state.EndOfExecuteImpl(this, resMail);
            bool isChanged = resMail.IsChanged();

            SetDisplayName(resMail);
            LinkToFolder(resMail);

            AddReplyLinks(resMail);
            AddConversationReplyLinks(resMail);

            SetFlag(resMail);
            if (Settings.SyncMailCategory)
            {
                CategorySetter.DoJob(_outlookCategories, resMail);
            }
            resMail.SetProp(PROP.LastModifiedTime, _lastModifiedDate);
            resMail.SetProp(Core.Props.Size, _messageSize);
            resMail.SetProp(PROP.PR_ICON_INDEX, _iconIndex);
            resMail.SetProp(PROP.EntryID, _entryID);
            resMail.SetProp(PROP.RecordKey, _recordKey);
            resMail.SetProp(Core.Props.IsUnread, _unread);
            resMail.SetProp(PROP.Priority, _priority);
            if (_longBody != null)
            {
                if (_longBody.Length == _longBodyMaxSize)
                {
                    _longBody += "...";
                }
                resMail.SetProp(Core.Props.LongBody, _longBody);
            }

            bool deletedInIMAP = resMail.HasProp(PROP.DeletedInIMAP);

            resMail.SetProp(PROP.DeletedInIMAP, _deletedInIMAP);
            if (deletedInIMAP != _deletedInIMAP)
            {
                Mail.SetIsDeleted(resMail, _deletedInIMAP);
            }

            if (!(resMail.GetIntProp(PROP.Importance) == 0 && _importance == 0))
            {
                resMail.SetProp(PROP.Importance, _importance);
            }

            if (Settings.CreateAnnotationFromFollowup)
            {
                if (_flag == null || _flag.Length == 0)
                {
                    resMail.DeleteProp(Core.Props.Annotation);
                }
                else
                {
                    resMail.SetProp(Core.Props.Annotation, _flag);
                }
            }

            resMail.EndUpdate();
            if (isChanged)
            {
                QueryIndexing(resMail);
            }
            return(resMail);
        }
コード例 #3
0
ファイル: TaskDescriptor.cs プロジェクト: mo5h/omeo
        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);
            }
        }