예제 #1
0
 internal static void TranslateXsoExceptions(IDiagnosticsSession tracer, LocalizedString errorString, XsoUtil.XsoExceptionHandlingFlags flags, Action xsoCall)
 {
     try
     {
         xsoCall();
     }
     catch (ConnectionFailedTransientException ex)
     {
         XsoUtil.TraceAndThrowTransientException(tracer, errorString, ex);
     }
     catch (ConnectionFailedPermanentException ex2)
     {
         XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex2);
     }
     catch (MailboxUnavailableException ex3)
     {
         XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex3);
     }
     catch (ObjectNotFoundException ex4)
     {
         if ((flags & XsoUtil.XsoExceptionHandlingFlags.DoNotExpectObjectNotFound) == XsoUtil.XsoExceptionHandlingFlags.DoNotExpectObjectNotFound)
         {
             tracer.SendInformationalWatsonReport(ex4, null);
             if ((flags & XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions) == XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions)
             {
                 XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex4);
             }
         }
         else
         {
             tracer.TraceDebug <LocalizedString, ObjectNotFoundException>("Error: {0}, exception: {1}", errorString, ex4);
         }
     }
     catch (CorruptDataException ex5)
     {
         if ((flags & XsoUtil.XsoExceptionHandlingFlags.DoNotExpectCorruptData) == XsoUtil.XsoExceptionHandlingFlags.DoNotExpectCorruptData)
         {
             tracer.SendInformationalWatsonReport(ex5, null);
             if ((flags & XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions) == XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions)
             {
                 XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex5);
             }
         }
         else
         {
             tracer.TraceDebug <LocalizedString, CorruptDataException>("Error: {0}, exception: {1}", errorString, ex5);
         }
     }
     catch (AccessDeniedException ex6)
     {
         tracer.SendWatsonReport(ex6);
         XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex6);
     }
     catch (StoragePermanentException ex7)
     {
         if (ex7.GetType() != typeof(StoragePermanentException))
         {
             tracer.SendInformationalWatsonReport(ex7, null);
         }
         if ((flags & XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions) == XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions)
         {
             XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex7);
         }
     }
     catch (StorageTransientException ex8)
     {
         if (ex8.GetType() != typeof(StorageTransientException))
         {
             tracer.SendInformationalWatsonReport(ex8, null);
         }
         if ((flags & XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions) == XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions)
         {
             XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex8);
         }
     }
 }
예제 #2
0
        internal static UserConfiguration ResetModel(string userConfigurationName, UserConfigurationTypes userConfigType, MailboxSession session, bool deleteOld, IDiagnosticsSession diagnosticSession)
        {
            StoreId         defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Inbox);
            OperationResult operationResult = OperationResult.Succeeded;
            Exception       ex = null;

            if (deleteOld)
            {
                try
                {
                    operationResult = session.UserConfigurationManager.DeleteFolderConfigurations(defaultFolderId, new string[]
                    {
                        userConfigurationName
                    });
                }
                catch (ObjectNotFoundException ex2)
                {
                    ex = ex2;
                    if (diagnosticSession != null)
                    {
                        diagnosticSession.TraceDebug <string, ObjectNotFoundException>("FAI message '{0}' is missing. Exception: {1}", userConfigurationName, ex2);
                    }
                }
                if (operationResult != OperationResult.Succeeded && ex == null)
                {
                    if (diagnosticSession != null)
                    {
                        diagnosticSession.TraceError(string.Format("Deletion of user configuration (userConfiguration Name = {0}) failed. OperationResult = {1}. ObjectNotFoundException = {2}", userConfigurationName, operationResult.ToString(), ex), new object[0]);
                    }
                    throw new DeleteItemsException(string.Format("Deletion of user configuration (userConfiguration Name = {0}) failed. OperationResult = {1}. ObjectNotFoundException = {2}", userConfigurationName, operationResult.ToString(), ex));
                }
            }
            UserConfiguration userConfiguration = null;

            try
            {
                userConfiguration = session.UserConfigurationManager.CreateFolderConfiguration(userConfigurationName, userConfigType, defaultFolderId);
                userConfiguration.Save();
            }
            catch (Exception ex3)
            {
                if (diagnosticSession != null && !(ex3 is QuotaExceededException))
                {
                    if (ex3 is StoragePermanentException)
                    {
                        diagnosticSession.SendInformationalWatsonReport(ex3, string.Format("Creation of user configuration failed (userConfiguration Name = {0}) deleteOld flag was {1}. Result of deletion of user configuration OperationResult = {2}. ObjectNotFoundException = {3}", new object[]
                        {
                            userConfigurationName,
                            deleteOld,
                            deleteOld ? operationResult.ToString() : "Not Applicable",
                            ex
                        }));
                    }
                    else
                    {
                        diagnosticSession.TraceError("Creation of user configuration failed (userConfiguration Name = {0}) deleteOld flag was {1}. Result of deletion of user configuration OperationResult = {2}. ObjectNotFoundException = {3}. Exception = {4}", new object[]
                        {
                            userConfigurationName,
                            deleteOld,
                            deleteOld ? operationResult.ToString() : "Not Applicable",
                            ex,
                            ex3.ToString()
                        });
                    }
                }
                if (userConfiguration != null)
                {
                    userConfiguration.Dispose();
                }
                throw;
            }
            return(userConfiguration);
        }