internal ContactLinkingLogger(IExtensibleLogger logger, string activityName, MailboxInfoForLinking mailboxInfo) : base(logger)
 {
     ArgumentValidator.ThrowIfNull("activityName", activityName);
     ArgumentValidator.ThrowIfNull("mailboxInfo", mailboxInfo);
     this.mailboxInfo  = mailboxInfo;
     this.activityName = activityName;
 }
        public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(item, "item");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
            COWContactLinking.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWContactLinking.ItemOperation: processing contact linking for item {0}.", itemId);
            MailboxSession                   mailboxSession                = (MailboxSession)session;
            MailboxInfoForLinking            mailboxInfo                   = MailboxInfoForLinking.CreateFromMailboxSession(mailboxSession);
            ContactLinkingPerformanceTracker performanceTracker            = new ContactLinkingPerformanceTracker(mailboxSession);
            DirectoryPersonSearcher          directoryPersonSearcher       = new DirectoryPersonSearcher(mailboxSession.MailboxOwner);
            ContactStoreForContactLinking    contactStoreForContactLinking = new ContactStoreForCowContactLinking(mailboxSession, performanceTracker);
            ContactLinkingLogger             logger = new ContactLinkingLogger("COWContactLinking", mailboxInfo);
            AutomaticLink automaticLink             = new AutomaticLink(mailboxInfo, logger, performanceTracker, directoryPersonSearcher, contactStoreForContactLinking);

            automaticLink.LinkNewOrUpdatedContactBeforeSave(item, new Func <ContactInfoForLinking, IContactStoreForContactLinking, IEnumerable <ContactInfoForLinking> >(this.GetOtherContactsEnumeratorForCOW));
            if (!onBeforeNotification)
            {
                item.SaveFlags |= PropertyBagSaveFlags.ForceNotificationPublish;
                try
                {
                    item.Save(SaveMode.NoConflictResolution);
                }
                finally
                {
                    item.SaveFlags &= ~PropertyBagSaveFlags.ForceNotificationPublish;
                }
            }
            callbackContext.ContactLinkingProcessingState = ContactLinkingProcessingState.Processed;
        }
Beispiel #3
0
 public AutomaticLink(MailboxInfoForLinking mailboxInfo, IExtensibleLogger logger, IContactLinkingPerformanceTracker performanceTracker, IDirectoryPersonSearcher directoryPersonSearcher, IContactStoreForContactLinking contactStoreForContactLinking) : base(mailboxInfo, logger, performanceTracker)
 {
     Util.ThrowOnNullArgument(directoryPersonSearcher, "directoryPersonSearcher");
     Util.ThrowOnNullArgument(contactStoreForContactLinking, "contactStoreForContactLinking");
     Util.ThrowOnNullArgument(performanceTracker, "performanceTracker");
     this.directoryPersonSearcher       = directoryPersonSearcher;
     this.contactStoreForContactLinking = contactStoreForContactLinking;
 }
Beispiel #4
0
 protected ContactLink(MailboxInfoForLinking mailboxInfo, IExtensibleLogger logger, IContactLinkingPerformanceTracker performanceTracker)
 {
     Util.ThrowOnNullArgument(mailboxInfo, "mailboxInfo");
     Util.ThrowOnNullArgument(logger, "logger");
     Util.ThrowOnNullArgument(performanceTracker, "performanceTracker");
     this.mailboxInfo        = mailboxInfo;
     this.logger             = logger;
     this.performanceTracker = performanceTracker;
 }
        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);
        }
        public BulkAutomaticLink(MailboxSession session)
        {
            Util.ThrowOnNullArgument(session, "session");
            MailboxInfoForLinking mailboxInfo = MailboxInfoForLinking.CreateFromMailboxSession(session);

            this.logger             = new ContactLinkingLogger("BulkAutomaticLink", mailboxInfo);
            this.performanceTracker = new ContactLinkingPerformanceTracker(session);
            this.contactStore       = new ContactStoreForBulkContactLinking(session, this.performanceTracker);
            this.automaticLink      = new AutomaticLink(mailboxInfo, this.logger, this.performanceTracker, new DirectoryPersonSearcher(session.MailboxOwner), this.contactStore);
        }
 internal BulkAutomaticLink(MailboxInfoForLinking mailboxInfo, ContactLinkingLogger logger, IContactLinkingPerformanceTracker performanceTracker, IDirectoryPersonSearcher directoryPersonSearcher, ContactStoreForBulkContactLinking contactStoreForBulkContactLinking)
 {
     Util.ThrowOnNullArgument(mailboxInfo, "mailboxInfo");
     Util.ThrowOnNullArgument(logger, "logger");
     Util.ThrowOnNullArgument(performanceTracker, "performanceTracker");
     Util.ThrowOnNullArgument(directoryPersonSearcher, "directoryPersonSearcher");
     Util.ThrowOnNullArgument(contactStoreForBulkContactLinking, "contactStoreForBulkContactLinking");
     this.logger             = logger;
     this.performanceTracker = performanceTracker;
     this.contactStore       = contactStoreForBulkContactLinking;
     this.automaticLink      = new AutomaticLink(mailboxInfo, this.logger, this.performanceTracker, directoryPersonSearcher, this.contactStore);
 }
Beispiel #8
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
         }
     });
 }
Beispiel #9
0
 public ManualLink(MailboxInfoForLinking mailboxInfo, IExtensibleLogger logger, IContactLinkingPerformanceTracker performanceTracker) : base(mailboxInfo, logger, performanceTracker)
 {
 }
 public ContactLinkingLogger(string activityName, MailboxInfoForLinking mailboxInfo) : this(ContactLinkingLogger.Logger.Member, activityName, mailboxInfo)
 {
 }
Beispiel #11
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);
            }
        }