Ejemplo n.º 1
0
        public void UpdateHistory(CallbackContext callbackContext)
        {
            if (this.ShouldSkipAudit)
            {
                return;
            }
            MailboxSession mailboxSession = (MailboxSession)this.currentFolder.Session;
            CoreFolder     coreFolder     = null;
            StoreObjectId  objectId       = this.currentFolder.Id.ObjectId;

            if (mailboxSession.LogonType == LogonType.Delegated || mailboxSession.LogonType == LogonType.DelegatedAdmin)
            {
                Exception ex = null;
                try
                {
                    coreFolder         = CoreFolder.Bind(callbackContext.SessionWithBestAccess, objectId);
                    this.currentFolder = coreFolder;
                }
                catch (StoragePermanentException ex2)
                {
                    ex = ex2;
                }
                catch (StorageTransientException ex3)
                {
                    ex = ex3;
                }
                if (ex != null)
                {
                    ExTraceGlobals.SessionTracer.TraceWarning <StoreObjectId, Exception>((long)this.currentFolder.Session.GetHashCode(), "Failed to rebind folder {0} with Admin logon. The cached RecentBindingHistory data will not be updated. Error: {1}", objectId, ex);
                    ProcessInfoEventLogger.Log(StorageEventLogConstants.Tuple_ErrorBindingFolderForFolderBindHistory, objectId.ToString(), new object[]
                    {
                        objectId,
                        mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(),
                        mailboxSession.MailboxGuid,
                        mailboxSession.LogonType,
                        IdentityHelper.SidFromLogonIdentity(mailboxSession.Identity),
                        COWTriggerAction.FolderBind,
                        ex
                    });
                    this.currentFolder = null;
                }
            }
            if (this.currentFolder != null)
            {
                try
                {
                    this.currentFolder.PropertyBag.SetProperty(FolderSchema.RecentBindingHistory, this.bindingHistory.ToArray());
                    FolderSaveResult folderSaveResult = this.currentFolder.Save(SaveMode.NoConflictResolutionForceSave);
                    if (coreFolder == null)
                    {
                        this.currentFolder.PropertyBag.Load(null);
                    }
                    if (folderSaveResult.OperationResult != OperationResult.Succeeded)
                    {
                        ExTraceGlobals.SessionTracer.TraceWarning <StoreObjectId, LocalizedException>((long)this.currentFolder.Session.GetHashCode(), "Failed to save RecentBindingHistory on folder {0}. Error: {1}.", objectId, folderSaveResult.Exception);
                        ProcessInfoEventLogger.Log(StorageEventLogConstants.Tuple_ErrorSavingFolderBindHistory, objectId.ToString(), new object[]
                        {
                            objectId,
                            mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(),
                            mailboxSession.MailboxGuid,
                            mailboxSession.LogonType,
                            IdentityHelper.SidFromLogonIdentity(mailboxSession.Identity),
                            COWTriggerAction.FolderBind,
                            folderSaveResult.Exception
                        });
                    }
                }
                finally
                {
                    if (coreFolder != null)
                    {
                        coreFolder.Dispose();
                    }
                }
            }
        }