Ejemplo n.º 1
0
        private bool TryEnumerateContactsAndApplyUpdates(Action <ContactInfoForLinking> updateOperation, string sessionName, ILogEvent operationIntentionEvent)
        {
            List <ContactInfoForLinkingFromPropertyBag> list = new List <ContactInfoForLinkingFromPropertyBag>(this.contacts.Count);
            bool flag = false;

            foreach (IStorePropertyBag propertyBag in this.contacts)
            {
                ContactInfoForLinkingWithPropertyBagUpdater contactInfoForLinkingWithPropertyBagUpdater = ContactInfoForLinkingWithPropertyBagUpdater.Create(this.mailboxSession, propertyBag, this.contactProperties);
                updateOperation(contactInfoForLinkingWithPropertyBagUpdater);
                list.Add(contactInfoForLinkingWithPropertyBagUpdater);
                if (contactInfoForLinkingWithPropertyBagUpdater.IsDirty)
                {
                    flag = true;
                }
            }
            if (!flag)
            {
                GALLinkingFixer.Tracer.TraceDebug((long)this.personId.GetHashCode(), "GALLinkingFixer::Contact properties are up to date, no need to update contact in store or in memory.");
                return(true);
            }
            GALLinkingFixer.Tracer.TraceDebug((long)this.personId.GetHashCode(), "GALLinkingFixer::Contact properties are NOT up to date, update contact in store and in memory.");
            bool result;

            try
            {
                List <IStorePropertyBag>         list2                            = new List <IStorePropertyBag>(this.contacts.Count);
                MailboxInfoForLinking            mailboxInfo                      = MailboxInfoForLinking.CreateFromMailboxSession(this.mailboxSession);
                ContactLinkingLogger             contactLinkingLogger             = new ContactLinkingLogger(sessionName, mailboxInfo);
                ContactLinkingPerformanceTracker contactLinkingPerformanceTracker = new ContactLinkingPerformanceTracker(this.mailboxSession);
                contactLinkingPerformanceTracker.Start();
                contactLinkingLogger.LogEvent(operationIntentionEvent);
                foreach (ContactInfoForLinkingFromPropertyBag contactInfoForLinkingFromPropertyBag in list)
                {
                    ContactInfoForLinkingWithPropertyBagUpdater contactInfoForLinkingWithPropertyBagUpdater2 = (ContactInfoForLinkingWithPropertyBagUpdater)contactInfoForLinkingFromPropertyBag;
                    contactInfoForLinkingWithPropertyBagUpdater2.Commit(contactLinkingLogger, contactLinkingPerformanceTracker);
                    list2.Add(contactInfoForLinkingWithPropertyBagUpdater2.PropertyBag);
                }
                contactLinkingPerformanceTracker.Stop();
                contactLinkingLogger.LogEvent(contactLinkingPerformanceTracker.GetLogEvent());
                this.contacts.Clear();
                this.contacts.AddRange(list2);
                GALLinkingFixer.Tracer.TraceDebug((long)this.personId.GetHashCode(), "GALLinkingFixer::Contacts successfully updated in store and in memory.");
                result = true;
            }
            catch (StorageTransientException arg)
            {
                GALLinkingFixer.Tracer.TraceError <StorageTransientException>((long)this.personId.GetHashCode(), "Failed while fixing GAL Linking properties on the contact, exception: {0}.", arg);
                result = false;
            }
            catch (StoragePermanentException arg2)
            {
                GALLinkingFixer.Tracer.TraceError <StoragePermanentException>((long)this.personId.GetHashCode(), "Failed while fixing GAL Linking properties on the contact, exception: {0}.", arg2);
                result = false;
            }
            return(result);
        }
Ejemplo n.º 2
0
 private static void TraceAndLogExceptionDuringLinkingPostMigration(MailboxInfoForLinking mailbox, ContactLinkingLogger logger, Exception e)
 {
     ContactLink.Tracer.TraceError <MailboxInfoForLinking, Exception>(0L, "AutomaticLink::PerformContactLinkingAfterMigration:  failed to link contacts post-migration of mailbox {0}.  Exception: {1}", mailbox, e);
     logger.LogEvent(new SchemaBasedLogEvent <ContactLinkingLogSchema.Error>
     {
         {
             ContactLinkingLogSchema.Error.Context,
             "Failed to link contacts post-migration"
         },
         {
             ContactLinkingLogSchema.Error.Exception,
             e
         }
     });
 }
Ejemplo n.º 3
0
        internal static void PerformContactLinkingAfterMigration(StoreSession storeSession)
        {
            MailboxSession mailboxSession = storeSession as MailboxSession;

            if (mailboxSession == null)
            {
                ContactLink.Tracer.TraceDebug(0L, "AutomaticLink::PerformContactLinkingAfterMigration. Skiping session as it is not a MailboxSession.");
                return;
            }
            ContactLink.Tracer.TraceDebug <MailboxSession>(0L, "StoreSession::PerformContactLinking. Starting linking for {0}.", mailboxSession);
            ExDateTime                        exDateTime                        = ExDateTime.Now.Add(AutomaticLink.AllocatedTimeSlotForLinkingOnMigration.Value);
            MailboxInfoForLinking             mailboxInfoForLinking             = MailboxInfoForLinking.CreateFromMailboxSession(mailboxSession);
            ContactLinkingPerformanceTracker  performanceTracker                = new ContactLinkingPerformanceTracker(mailboxSession);
            DirectoryPersonSearcher           directoryPersonSearcher           = new DirectoryPersonSearcher(mailboxSession.MailboxOwner);
            ContactStoreForBulkContactLinking contactStoreForBulkContactLinking = new ContactStoreForBulkContactLinking(mailboxSession, performanceTracker);
            ContactLinkingLogger              contactLinkingLogger              = new ContactLinkingLogger("PerformContactLinkingAfterMigration", mailboxInfoForLinking);
            bool flag = false;

            contactLinkingLogger.LogEvent(new SchemaBasedLogEvent <ContactLinkingLogSchema.MigrationStart>
            {
                {
                    ContactLinkingLogSchema.MigrationStart.DueTime,
                    (DateTime)exDateTime
                }
            });
            try
            {
                AutomaticLink.RefreshContactLinkingDefaultFolderIds(mailboxSession);
                AutomaticLink automaticLink = new AutomaticLink(mailboxInfoForLinking, contactLinkingLogger, performanceTracker, directoryPersonSearcher, contactStoreForBulkContactLinking);
                automaticLink.LinkAllExistingContactsTimeBound(exDateTime);
                flag = true;
            }
            catch (DefaultFolderNameClashException e)
            {
                AutomaticLink.TraceAndLogExceptionDuringLinkingPostMigration(mailboxInfoForLinking, contactLinkingLogger, e);
            }
            catch (AccessDeniedException e2)
            {
                AutomaticLink.TraceAndLogExceptionDuringLinkingPostMigration(mailboxInfoForLinking, contactLinkingLogger, e2);
            }
            catch (ConnectionFailedTransientException e3)
            {
                AutomaticLink.TraceAndLogExceptionDuringLinkingPostMigration(mailboxInfoForLinking, contactLinkingLogger, e3);
            }
            catch (FolderSaveTransientException e4)
            {
                AutomaticLink.TraceAndLogExceptionDuringLinkingPostMigration(mailboxInfoForLinking, contactLinkingLogger, e4);
            }
            catch (MailboxUnavailableException e5)
            {
                AutomaticLink.TraceAndLogExceptionDuringLinkingPostMigration(mailboxInfoForLinking, contactLinkingLogger, e5);
            }
            catch (ObjectNotFoundException e6)
            {
                AutomaticLink.TraceAndLogExceptionDuringLinkingPostMigration(mailboxInfoForLinking, contactLinkingLogger, e6);
            }
            catch (StorageTransientException e7)
            {
                AutomaticLink.TraceAndLogExceptionDuringLinkingPostMigration(mailboxInfoForLinking, contactLinkingLogger, e7);
            }
            catch (StoragePermanentException e8)
            {
                AutomaticLink.TraceAndLogExceptionDuringLinkingPostMigration(mailboxInfoForLinking, contactLinkingLogger, e8);
            }
            catch (Exception e9)
            {
                AutomaticLink.TraceAndLogExceptionDuringLinkingPostMigration(mailboxInfoForLinking, contactLinkingLogger, e9);
                throw;
            }
            finally
            {
                contactLinkingLogger.LogEvent(new SchemaBasedLogEvent <ContactLinkingLogSchema.MigrationEnd>
                {
                    {
                        ContactLinkingLogSchema.MigrationEnd.Success,
                        flag
                    }
                });
                ContactLink.Tracer.TraceDebug <MailboxInfoForLinking, bool>(0L, "AutomaticLink::PerformContactLinkingAfterMigration. Done processing {0}. Contact linking completed successfully: {1}", mailboxInfoForLinking, flag);
            }
        }