Пример #1
0
        private MasterCategoryList MergeCopies(SaveMode saveMode, UserConfiguration mclConfigurationItem, Stream mclXmlStream)
        {
            MasterCategoryList masterCategoryList = new MasterCategoryList();

            switch (saveMode)
            {
            case SaveMode.ResolveConflicts:
                try
                {
                    using (Stream stream = new BoundedStream(mclXmlStream, false, 0L, 524288L))
                    {
                        using (XmlReader xmlReader = XmlReader.Create(stream))
                        {
                            new MasterCategoryListSerializer(xmlReader).Deserialize(masterCategoryList);
                        }
                    }
                }
                catch (CorruptDataException ex)
                {
                    Exception ex2 = new SaveConflictException(ServerStrings.ExMclCannotBeResolved, ex);
                    ExTraceGlobals.StorageTracer.TraceDebug <SaveMode, string>((long)this.GetHashCode(), "Failed to load the Server copy of MCL for conflict resolution (SaveMode={0}): {1}", saveMode, ex.Message);
                    throw ex2;
                }
                return(MasterCategoryList.Resolve(this, masterCategoryList, this.originalMcl));

            case SaveMode.FailOnAnyConflict:
                throw new SaveConflictException(ServerStrings.ExSaveFailedBecauseOfConflicts(mclConfigurationItem.Id), null);

            case SaveMode.NoConflictResolution:
                return(this);

            default:
                throw new ArgumentOutOfRangeException("saveMode");
            }
        }
Пример #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);
        }