コード例 #1
0
        internal static LocalizedException TranslateDirectoryException(LocalizedString exceptionMessage, LocalizedException exception, object thisObject, string traceMessage = "", params object[] traceMessageParameters)
        {
            LocalizedException ex;

            if (exception is ADNoSuchObjectException)
            {
                ex = new ObjectNotFoundException(exceptionMessage, exception);
            }
            else if (exception is DataValidationException || exception is DataConversionException || exception is NonUniqueRecipientException)
            {
                ex = new StoragePermanentException(exceptionMessage, exception);
            }
            else if (exception is ADTransientException || exception is ComputerNameNotCurrentlyAvailableException || exception is ADPossibleOperationException || exception is RusServerUnavailableException || exception is DataSourceTransientException)
            {
                ex = new StorageTransientException(exceptionMessage, exception);
            }
            else if (exception is ADOperationException || exception is ADObjectAlreadyExistsException || exception is ADFilterException || exception is ServerRoleOperationException || exception is RusOperationException || exception is NameConversionException || exception is GenerateUniqueLegacyDnException)
            {
                ex = new StoragePermanentException(exceptionMessage, exception);
            }
            else
            {
                if (!(exception is ADExternalException) && !(exception is CannotGetComputerNameException) && !(exception is CannotGetDomainInfoException) && !(exception is CannotGetSiteInfoException) && !(exception is CannotGetForestInfoException) && !(exception is LocalServerNotFoundException) && !(exception is DataSourceOperationException))
                {
                    throw new ArgumentException("exception is not a directory exception");
                }
                ex = new StoragePermanentException(exceptionMessage, exception);
            }
            if (ExTraceGlobals.StorageTracer.IsTraceEnabled(TraceType.ErrorTrace))
            {
                string arg = string.Format(CultureInfo.InvariantCulture, traceMessage, traceMessageParameters);
                ExTraceGlobals.StorageTracer.TraceError <string, LocalizedException>((long)((thisObject != null) ? thisObject.GetHashCode() : 0), "{0}. Throwing exception: {1}.", arg, ex);
            }
            return(ex);
        }
コード例 #2
0
        public static LocalizedException TranslateMapiException(LocalizedString exceptionMessage, LocalizedException exception, StoreSession session, object thisObject, string traceMessage, params object[] traceMessageParameters)
        {
            if (ExTraceGlobals.MapiConnectivityTracer.IsTraceEnabled(TraceType.ErrorTrace) && (exception is MapiExceptionBackupInProgress || exception is MapiExceptionNetworkError || exception is MapiExceptionEndOfSession || exception is MapiExceptionLogonFailed || exception is MapiExceptionExiting || exception is MapiExceptionRpcServerTooBusy || exception is MapiExceptionBusy))
            {
                Guid guid = (session == null) ? Guid.Empty : session.MdbGuid;
                ExTraceGlobals.MapiConnectivityTracer.TraceError((long)((thisObject != null) ? thisObject.GetHashCode() : 0), "MAPI exception: {0}\n\rClient: {1}\n\rServer: {2}\n\rMDB: {3}", new object[]
                {
                    exception.ToString(),
                    (session != null) ? session.ClientInfoString : null,
                    (session != null && !session.IsRemote) ? session.ServerFullyQualifiedDomainName : null,
                    guid
                });
            }
            LocalizedException ex = null;

            if (session != null && session.IsRemote)
            {
                if (exception is MapiExceptionBackupInProgress || exception is MapiExceptionNetworkError || exception is MapiExceptionEndOfSession || exception is MapiExceptionLogonFailed || exception is MapiExceptionExiting || exception is MapiExceptionRpcServerTooBusy || exception is MapiExceptionBusy || exception is MapiExceptionMailboxInTransit || exception is MapiExceptionNotEnoughDisk || exception is MapiExceptionNotEnoughResources || exception is MapiExceptionMdbOffline || exception is MapiExceptionServerPaused || exception is MapiExceptionMailboxDisabled || exception is MapiExceptionAccountDisabled || exception is MapiExceptionWrongMailbox || exception is MapiExceptionCorruptStore || exception is MapiExceptionNoAccess || exception is MapiExceptionNoSupport || exception is MapiExceptionNotAuthorized || exception is MapiExceptionPasswordChangeRequired || exception is MapiExceptionPasswordExpired || exception is MapiExceptionNoMoreConnections || exception is MapiExceptionWrongServer || exception is MapiExceptionSessionLimit || exception is MapiExceptionUnconfigured || exception is MapiExceptionUnknownUser || exception is MapiExceptionCallFailed)
                {
                    MailboxSession mailboxSession = session as MailboxSession;
                    string         text           = mailboxSession.MailboxOwner.MailboxInfo.RemoteIdentity.Value.ToString();
                    string         text2          = exception.ToString();
                    StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_XtcMapiError, text, new object[]
                    {
                        text,
                        text2
                    });
                    ExTraceGlobals.XtcTracer.TraceError <string, string>(0L, "The remote connection threw exception for user {0}. Exception: {1}", text, text2);
                }
            }
            else
            {
                ex = StorageGlobals.CheckHAState(exceptionMessage, exception, session);
            }
            if (ex == null)
            {
                if (exception is MapiExceptionBackupInProgress || exception is MapiExceptionNetworkError || exception is MapiExceptionEndOfSession || exception is MapiExceptionLogonFailed || exception is MapiExceptionExiting)
                {
                    ex = new ConnectionFailedTransientException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionMailboxInTransit)
                {
                    ex = new MailboxInTransitException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionNotEnoughDisk || exception is MapiExceptionNotEnoughResources || exception is MapiExceptionBusy)
                {
                    ex = new ResourcesException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionObjectChanged)
                {
                    ex = new SaveConflictException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionCanNotComplete)
                {
                    ex = new CannotCompleteOperationException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionJetErrorCheckpointDepthTooDeep)
                {
                    ex = new CheckpointTooDeepException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionMdbOffline)
                {
                    ex = new MailboxOfflineException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionVirusScanInProgress)
                {
                    ex = new VirusScanInProgressException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionServerPaused)
                {
                    ex = new ServerPausedException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionSearchEvaluationInProgress)
                {
                    ex = new QueryInProgressException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionGlobalCounterRangeExceeded)
                {
                    ex = new GlobalCounterRangeExceededException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionCorruptMidsetDeleted)
                {
                    ex = new CorruptMidsetDeletedException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionMailboxDisabled || exception is MapiExceptionAccountDisabled || exception is MapiExceptionMailboxSoftDeleted)
                {
                    ex = new AccountDisabledException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionWrongMailbox || exception is MapiExceptionCorruptStore)
                {
                    ex = new ConnectionFailedPermanentException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionNoAccess || exception is MapiExceptionNotAuthorized || exception is MapiExceptionPasswordChangeRequired || exception is MapiExceptionPasswordExpired || exception is MapiExceptionNoCreateRight || exception is MapiExceptionNoCreateSubfolderRight)
                {
                    ex = new AccessDeniedException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionCorruptData)
                {
                    ex = new CorruptDataException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionQuotaExceeded || exception is MapiExceptionNamedPropsQuotaExceeded || exception is MapiExceptionShutoffQuotaExceeded)
                {
                    ex = new QuotaExceededException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionCollision)
                {
                    ex = new ObjectExistedException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionNotFound || exception is MapiExceptionInvalidEntryId || exception is MapiExceptionJetErrorRecordDeleted || exception is MapiExceptionObjectDeleted)
                {
                    ex = new ObjectNotFoundException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionNoMoreConnections)
                {
                    ex = new NoMoreConnectionsException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionPartialCompletion)
                {
                    ex = new PartialCompletionException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionFolderCycle)
                {
                    ex = new FolderCycleException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionWrongServer)
                {
                    ex = new WrongServerException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionIllegalCrossServerConnection)
                {
                    ex = new IllegalCrossServerConnectionException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionInvalidRecipients)
                {
                    ex = new InvalidRecipientsException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionMessageTooBig)
                {
                    ex = new MessageTooBigException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionMaxSubmissionExceeded)
                {
                    ex = new MessageSubmissionExceededException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionMaxAttachmentExceeded)
                {
                    ex = new AttachmentExceededException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionVirusDetected)
                {
                    ex = new VirusDetectedException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionVirusMessageDeleted)
                {
                    ex = new VirusMessageDeletedException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionNotInitialized)
                {
                    ex = new ObjectNotInitializedException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionSendAsDenied)
                {
                    ex = new SendAsDeniedException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionSessionLimit)
                {
                    ex = new TooManyObjectsOpenedException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionJetErrorTooManyOpenTablesAndCleanupTimedOut)
                {
                    ex = new ServerCleanupTimedOutException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionJetErrorInvalidLanguageId)
                {
                    ex = new InvalidFolderLanguageIdException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionEventsDeleted)
                {
                    ex = new EventNotFoundException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionUnconfigured)
                {
                    ex = new MailboxUnavailableException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionUnknownUser)
                {
                    ex = new MailboxUnavailableException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionNoReplicaHere)
                {
                    ex = new NoReplicaHereException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionNoReplicaAvailable)
                {
                    ex = new NoReplicaException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionConditionViolation)
                {
                    ex = new FolderSaveConditionViolationException(exceptionMessage, exception);
                }
                else if (exception is MapiExceptionNoSupport)
                {
                    ex = new NoSupportException(exceptionMessage, exception);
                }
                else if (exception is MapiPermanentException)
                {
                    ex = new StoragePermanentException(exceptionMessage, exception);
                }
                else if (exception is MapiRetryableException)
                {
                    ex = new StorageTransientException(exceptionMessage, exception);
                }
                else
                {
                    if (!(exception is MapiExceptionCallFailed))
                    {
                        throw new ArgumentException("Exception is not of type MapiException");
                    }
                    ex = new StoragePermanentException(exceptionMessage, exception);
                }
            }
            if (ExTraceGlobals.StorageTracer.IsTraceEnabled(TraceType.ErrorTrace))
            {
                string arg = string.Format(traceMessage, traceMessageParameters);
                ExTraceGlobals.StorageTracer.TraceError <string, LocalizedException>((long)((thisObject != null) ? thisObject.GetHashCode() : 0), "{0}. Throwing exception: {1}.", arg, ex);
            }
            return(ex);
        }
コード例 #3
0
        public void GroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId destinationFolderId, StoreObjectId[] itemIds, GroupOperationResult result, bool onBeforeNotification, CallbackContext callbackContext)
        {
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags");
            Util.ThrowOnNullArgument(dumpster, "dumpster");
            if (itemIds == null)
            {
                return;
            }
            if (dumpster.IsDumpsterOverCalendarLoggingQuota(callbackContext.SessionWithBestAccess, settings))
            {
                ExTraceGlobals.CalendarLoggingTracer.Information <string, string>((long)sourceSession.GetHashCode(), "User {0} has exceeded the calendar logging quota of {1}", sourceSession.UserLegacyDN, settings.CalendarLoggingQuota.Value.ToString("A"));
                StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_COWCalendarLoggingStopped, sourceSession.UserLegacyDN, new object[]
                {
                    sourceSession.UserLegacyDN
                });
                return;
            }
            if (dumpster.IsDumpsterOverWarningQuota(settings))
            {
                ExTraceGlobals.CalendarLoggingTracer.Information <string, string>((long)sourceSession.GetHashCode(), "Disabling calendar logging for user {0}, since it has exceeded the dumpster warning quota of {1}", sourceSession.UserLegacyDN, settings.DumpsterWarningQuota.Value.ToString("A"));
                dumpster.DisableCalendarLogging();
                return;
            }
            foreach (StoreObjectId storeObjectId in itemIds)
            {
                ICoreItem coreItem           = null;
                StoragePermanentException ex = null;
                try
                {
                    if (CalendarLoggingHelper.ShouldBeCopiedOnWrite(storeObjectId))
                    {
                        if (CalendarLoggingHelper.ShouldLogInitialCheck(storeObjectId, operation))
                        {
                            try
                            {
                                coreItem = CoreItem.Bind(callbackContext.SessionWithBestAccess, storeObjectId, CalendarLoggingHelper.RequiredOriginalProperties);
                                if (!CalendarLoggingHelper.ShouldLog(coreItem, operation))
                                {
                                    goto IL_25A;
                                }
                                if (coreItem.PropertyBag.GetValueOrDefault <bool>(InternalSchema.HasBeenSubmitted))
                                {
                                    ExTraceGlobals.CalendarLoggingTracer.TraceWarning <ICoreItem, COWTriggerAction>((long)callbackContext.SessionWithBestAccess.GetHashCode(), "Save Item for Calendar Logging skipped as the item.HasBeenSubmitted is true (item {0}, operation {1}.", coreItem, operation);
                                    goto IL_25A;
                                }
                                switch (operation)
                                {
                                case COWTriggerAction.Move:
                                case COWTriggerAction.MoveToDeletedItems:
                                case COWTriggerAction.SoftDelete:
                                    if (!this.PerformFolderCopyOnWrite(settings, dumpster, coreItem, callbackContext.SessionWithBestAccess, operation, flags, false))
                                    {
                                        goto IL_25A;
                                    }
                                    break;

                                case COWTriggerAction.HardDelete:
                                {
                                    StoreObjectId parentIdFromMessageId = IdConverter.GetParentIdFromMessageId(storeObjectId);
                                    if (DumpsterFolderHelper.IsAuditFolder(callbackContext.SessionWithBestAccess, parentIdFromMessageId))
                                    {
                                        goto IL_25A;
                                    }
                                    if (DumpsterFolderHelper.IsDumpsterFolder(callbackContext.SessionWithBestAccess, parentIdFromMessageId))
                                    {
                                        this.PerformCopyOnWrite(callbackContext.SessionWithBestAccess, dumpster, storeObjectId);
                                        goto IL_25A;
                                    }
                                    if (!this.PerformFolderCopyOnWrite(settings, dumpster, coreItem, callbackContext.SessionWithBestAccess, operation, flags, !settings.HoldEnabled()))
                                    {
                                        goto IL_25A;
                                    }
                                    break;
                                }
                                }
                            }
                            catch (ObjectNotFoundException ex2)
                            {
                                ex = ex2;
                            }
                            catch (VirusDetectedException ex3)
                            {
                                ex = ex3;
                            }
                            catch (VirusMessageDeletedException ex4)
                            {
                                ex = ex4;
                            }
                            catch (VirusException ex5)
                            {
                                ex = ex5;
                            }
                            if (ex != null)
                            {
                                ExTraceGlobals.CalendarLoggingTracer.TraceWarning <StoreObjectId, StoragePermanentException, COWTriggerAction>((long)callbackContext.SessionWithBestAccess.GetHashCode(), "Item ({0}) processing for Calendar Logging failure {1} (operation {2}).", storeObjectId, ex, operation);
                            }
                        }
                    }
                }
                finally
                {
                    if (coreItem != null)
                    {
                        coreItem.Dispose();
                    }
                }
                IL_25A :;
            }
        }