Exemple #1
0
        protected override void Execute()
        {
            if (Settings.TraceContactChanges)
            {
                Trace("Try to export contact");
                _resTracer.Trace(_contact);
            }
            IEMAPIProp message = OpenMessage(_contact, _createNew, true, true);

            if (message == null)
            {
                if (_newCreated)
                {
                    _tracer.Trace("Cannot Export NEW contact for resource id = " + _contact.Id);
                }
                _tracer.Trace("Cannot Export contact for resource id = " + _contact.Id);
                return;
            }
            using ( message )
            {
                IContact contactBO = Core.ContactManager.GetContact(_contact);
                ExportProperties(message, contactBO);
                ExportPhones(contactBO, message);
                SetEmailAddress(message);
                if (Settings.SyncContactCategory)
                {
                    SetCategories(message);
                }
                _lastContact = _contact;
                OutlookSession.SaveChanges(_newCreated, "Export contact for resource id = " + _contact.Id, message, message.GetBinProp(MAPIConst.PR_ENTRYID));
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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);
            }
        }