Ejemplo n.º 1
0
        public ContactDescriptor(IERowSet rowSet, int rowNum, string entryID, OutlookAddressBook addressBook)
        {
            _entryID       = entryID;
            _searchEntryID = _entryID;
            _addressBook   = addressBook;

            _emailAddresses = GetEmailAddresses( );
            if (_emailAddresses == null || _emailAddresses.Count == 0)
            {
                _contactNames.EmailAddress = rowSet.GetStringProp(2, rowNum);  //row.FindStringProp( MAPIConst.PR_EMAIL_ADDRESS );
            }
            else
            {
                _contactNames.EmailAddress = _emailAddresses[0] as string;
            }

            string fullName = rowSet.GetStringProp(1, rowNum);  //row.FindStringProp( MAPIConst.PR_DISPLAY_NAME );

            if (fullName != null)
            {
                fullName = fullName.Trim();
            }
            _contactNames.FullName = fullName;
            //_phones = contactProperties.GetPhones();
            //_birthday = contactProperties.BirthDay;
        }
Ejemplo n.º 2
0
        private void ProcessContactFolder(PairIDs folderIDs, string abName)
        {
            IEFolder folder = null;

            try
            {
                folder = OutlookSession.OpenFolder(folderIDs.EntryId, folderIDs.StoreId);
            }
            catch (System.Threading.ThreadAbortException)
            {
            }
            catch (Exception exception)
            {
                if (exception is COMException &&
                    ((COMException)exception).ErrorCode != (unchecked ((int)0x80040111)))       //ClassFactory cannot supply requested class
                {
                    return;
                }
                Core.ReportException(exception, ExceptionReportFlags.AttachLog);
                return;
            }
            if (folder == null)
            {
                return;
            }
            using ( folder )
            {
                OutlookAddressBook AB = new OutlookAddressBook(abName, folderIDs, true);
                AB.RunAB();
                IEMessages messages = folder.GetMessages();
                if (messages == null)
                {
                    return;
                }
                using ( messages )
                {
                    int mesCount = messages.GetCount();
                    for (int i = 0; i < mesCount; i++)
                    {
                        if (ShuttingDown)
                        {
                            break;
                        }
                        OutlookSession.ProcessJobs();
                        IEMessage message = messages.OpenMessage(i);
                        if (message == null)
                        {
                            continue;
                        }
                        using ( message )
                        {
                            string mesEntryID = OutlookSession.GetMessageID(message);
                            Core.ResourceAP.QueueJob(new ContactDescriptor(message, mesEntryID, mesEntryID, AB));
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public ContactDescriptor(IEMessage message, string entryID, string searchEntryID, OutlookAddressBook addressBook)
        {
            _searchEntryID = searchEntryID;
            _entryID       = entryID;
            _addressBook   = addressBook;
            SetFullName(message);

            _emailAddresses = GetEmailAddresses();

            if (_emailAddresses == null || _emailAddresses.Count == 0)
            {
                string tempString = message.GetStringProp(MAPIConst.PR_EMAIL_ADDRESS);
                if (tempString != null)
                {
                    _contactNames.EmailAddress = tempString;
                }
                else
                {
                    int tag = message.GetIDsFromNames(ref GUID.set3, lID.contactEmail, PropType.PT_STRING8);
                    tempString = message.GetStringProp(tag);
                    if (tempString != null)
                    {
                        _contactNames.EmailAddress = tempString;
                    }
                }
            }
            else
            {
                _contactNames.EmailAddress = _emailAddresses[0] as string;
            }

            _birthday = message.GetDateTimeProp(MAPIConst.PR_BIRTHDAY);
            foreach (Phone phone in Phone.GetPhones())
            {
                _phones.Add(new Pair(phone, message.GetStringProp(phone.MAPIPhoneAsInt)));
            }
            LoadProp(ref _companyName, message, MAPIConst.PR_COMPANY_NAME);
            LoadProp(ref _jobTitle, message, MAPIConst.PR_TITLE);
            LoadProp(ref _streetAddress, message, MAPIConst.PR_POSTAL_ADDRESS);
            LoadProp(ref _businessHomePage, message, MAPIConst.PR_BUSINESS_HOME_PAGE);

            string suffix = string.Empty;

            LoadProp(ref suffix, message, MAPIConst.PR_GENERATION);
            _contactNames.Suffix = suffix;
            string middleName = string.Empty;

            LoadProp(ref middleName, message, MAPIConst.PR_MIDDLE_NAME);
            _contactNames.MiddleName = middleName;
            string namePrefix = string.Empty;

            LoadProp(ref namePrefix, message, MAPIConst.PR_DISPLAY_NAME_PREFIX);
            _contactNames.NamePrefix = namePrefix;
            LoadStreamProp(ref _description, message);
            _outlookCategories = OutlookSession.GetCategories(message);
        }
Ejemplo n.º 4
0
 public static void UpdateContactFolder(FolderDescriptor folder)
 {
     if (folder.ContainerClass == FolderType.Contact)
     {
         IResource resAB = Core.ResourceStore.FindUniqueResource("AddressBook", PROP.EntryID, folder.FolderIDs.EntryId);
         if (resAB != null)
         {
             OutlookAddressBook.SetName(resAB, OutlookAddressBook.GetProposedName(folder.Name, folder.FolderIDs.EntryId));
         }
     }
 }
Ejemplo n.º 5
0
        private void ProcessGlobalAddressBook(IEABContainer abContainer)
        {
            IERowSet rowSet = abContainer.GetRowSet();

            if (rowSet == null)
            {
                return;
            }
            using ( rowSet )
            {
                string    entryID   = abContainer.GetBinProp(MAPIConst.PR_ENTRYID);
                IResource outlookAB = Core.ResourceStore.FindUniqueResource(STR.OutlookABDescriptor, PROP.EntryID, entryID);
                if (outlookAB == null)
                {
                    return;
                }
                if (!Folder.IsIgnoreImport(outlookAB))
                {
                    string             curName = abContainer.GetStringProp(MAPIConst.PR_DISPLAY_NAME);
                    string             abName  = OutlookAddressBook.GetProposedName(curName, entryID);
                    OutlookAddressBook AB      = new OutlookAddressBook(abName, entryID, false);
                    AB.RunAB();
                    int count = rowSet.GetRowCount();
                    for (int i = 0; i < count; i++)
                    {
                        if (ShuttingDown)
                        {
                            return;
                        }
                        OutlookSession.ProcessJobs();

                        string ABentryID = rowSet.GetBinProp(0, i /*MAPIConst.PR_ENTRYID*/);
                        if (ABentryID == null)
                        {
                            continue;
                        }
                        Core.ResourceAP.QueueJob(new ContactDescriptor(rowSet, i, ABentryID, AB));
                    }
                }
                else
                {
                    IResource AB = Core.ResourceStore.FindUniqueResource(STR.AddressBook, PROP.EntryID, entryID);
                    if (AB != null)
                    {
                        new ResourceProxy(AB).DeleteAsync();
                    }
                }
            }
        }
Ejemplo n.º 6
0
        protected override void Execute()
        {
            IResource resource =
                Core.ResourceStore.FindUniqueResource(STR.OutlookABDescriptor, PROP.EntryID, _entryID);

            if (resource == null)
            {
                resource = Core.ResourceStore.BeginNewResource(STR.OutlookABDescriptor);
                resource.SetProp(PROP.EntryID, _entryID);
                resource.SetProp(Core.Props.Name, _name);
                resource.EndUpdate();
            }
            else
            {
                resource.SetProp(Core.Props.Name, _name);
                _name = OutlookAddressBook.GetProposedName(_name, _entryID);
                OutlookAddressBook.SetName(_entryID, _name);
            }
        }
Ejemplo n.º 7
0
 protected override void Execute()
 {
     if (IsDataCorrect(_folder))
     {
         PairIDs   folderIDs = _folder.FolderIDs;
         IEMessage message   = OutlookSession.OpenMessage(_entryID, folderIDs.StoreId);
         if (message == null)
         {
             return;
         }
         using ( message )
         {
             OutlookAddressBook AB = new OutlookAddressBook(_folder.Name, _folder.FolderIDs, true);
             ContactDescriptor  contactDescriptor =
                 new ContactDescriptor(message, _entryID, _searchEntryID, AB);
             Core.ResourceAP.QueueJob(contactDescriptor);
         }
     }
 }
Ejemplo n.º 8
0
        private void ProcessContactFolders(int processedABs, int totalABs)
        {
            ArrayList toDeleteFolders = new ArrayList();

            foreach (IResource contactFolder in Folder.GetFolders(FolderType.Contact).ValidResources)
            {
                if (ShuttingDown)
                {
                    break;
                }
                OutlookSession.ProcessJobs();
                processedABs++;
                int percentage = (processedABs * 100) / totalABs;
                Settings.UpdateProgress(percentage, "Indexing Address Books", processedABs.ToString());

                PairIDs folderIDs = PairIDs.Get(contactFolder);
                if (folderIDs == null)
                {
                    toDeleteFolders.Add(contactFolder);
                    continue;
                }
                string abName = OutlookAddressBook.GetProposedName(contactFolder.GetPropText(Core.Props.Name), folderIDs.EntryId);
                Core.ResourceAP.QueueJob(new OutlookAddressBookReName(folderIDs.EntryId, abName));

                if (!Folder.IsIgnoreImport(contactFolder))
                {
                    ProcessContactFolder(folderIDs, abName);
                }
                else
                {
                    IResource AB = Core.ResourceStore.FindUniqueResource(STR.AddressBook, PROP.EntryID, folderIDs.EntryId);
                    if (AB != null)
                    {
                        new ResourceProxy(AB).DeleteAsync();
                    }
                }
            }
            foreach (IResource contactFolder in toDeleteFolders)   // delete corrupted 'MAPIFolder' resources
            {
                new ResourceProxy(contactFolder).DeleteAsync();
            }
        }
Ejemplo n.º 9
0
 protected override void Execute()
 {
     OutlookAddressBook.SetName(_entryID, _abName);
 }