internal void InvokeWithWrappedException(ParameterlessReturnlessDelegate invoke, LocalizedString message, MapiObjectId source, MapiSession.ErrorTranslatorDelegate translateError) { try { invoke(); } catch (MapiRetryableException ex) { LocalizedException ex2; if (translateError != null && (ex2 = translateError(ref message, ex)) != null) { throw ex2; } MapiSession.ThrowWrappedException(ex, message, source, this); } catch (MapiPermanentException ex3) { LocalizedException ex2; if (translateError != null && (ex2 = translateError(ref message, ex3)) != null) { throw ex2; } MapiSession.ThrowWrappedException(ex3, message, source, this); } catch (MapiInvalidOperationException ex4) { LocalizedException ex2; if (translateError != null && (ex2 = translateError(ref message, ex4)) != null) { throw ex2; } MapiSession.ThrowWrappedException(ex4, message, source, this); } }
internal MapiObject(MapiObjectId mapiObjectId, MapiSession mapiSession) : base(new MapiPropertyBag()) { this.SetIdentity(mapiObjectId); this.MapiSession = mapiSession; this.disposeTracker = null; this.disposed = false; }
internal static MapiEntryId GetAddressBookEntryIdFromLegacyDN(string userLegacyDN) { byte[] binaryEntryId = null; try { binaryEntryId = MapiStore.GetAddressBookEntryIdFromLegacyDN(userLegacyDN); } catch (MapiRetryableException exception) { MapiSession.ThrowWrappedException(exception, Strings.ErrorGetAddressBookEntryIdFromLegacyDN(userLegacyDN), null, null); } catch (MapiPermanentException exception2) { MapiSession.ThrowWrappedException(exception2, Strings.ErrorGetAddressBookEntryIdFromLegacyDN(userLegacyDN), null, null); } catch (MapiInvalidOperationException exception3) { MapiSession.ThrowWrappedException(exception3, Strings.ErrorGetAddressBookEntryIdFromLegacyDN(userLegacyDN), null, null); } return(new MapiEntryId(binaryEntryId)); }
internal static string GetLegacyDNFromAddressBookEntryId(MapiEntryId abbEntryId) { string result = null; try { result = MapiStore.GetLegacyDNFromAddressBookEntryId((byte[])abbEntryId); } catch (MapiRetryableException exception) { MapiSession.ThrowWrappedException(exception, Strings.ErrorGetGetLegacyDNFromAddressBookEntryId(abbEntryId.ToString()), null, null); } catch (MapiPermanentException exception2) { MapiSession.ThrowWrappedException(exception2, Strings.ErrorGetGetLegacyDNFromAddressBookEntryId(abbEntryId.ToString()), null, null); } catch (MapiInvalidOperationException exception3) { MapiSession.ThrowWrappedException(exception3, Strings.ErrorGetGetLegacyDNFromAddressBookEntryId(abbEntryId.ToString()), null, null); } return(result); }
internal MailboxEntry(MailboxId mapiObjectId, MapiSession mapiSession) : base(mapiObjectId, mapiSession) { }
internal static void ThrowWrappedException(LocalizedException exception, LocalizedString message, MapiObjectId source, MapiSession mapiSession) { if (exception is MapiExceptionNotFound) { if (source is PublicFolderId) { throw new PublicFolderNotFoundException(source.ToString(), exception); } if (source is MailboxId) { mapiSession.AnalyzeMailboxNotFoundAndThrow((MailboxId)source, exception); } throw new MapiObjectNotFoundException(message, exception); } else if (exception is MapiExceptionLogonFailed) { if (source is PublicFolderId) { throw new PublicStoreLogonFailedException(mapiSession.ServerName, exception); } if (source is MailboxId) { mapiSession.AnalyzeMailboxLogonFailedAndThrow((MailboxId)source, exception); } throw new MapiLogonFailedException(Strings.LogonFailedExceptionError(message, mapiSession.ServerName), exception); } else { if (exception is MapiExceptionSessionLimit) { throw new MapiLogonFailedException(Strings.SessionLimitExceptionError, exception); } if (exception is MapiExceptionUnknownMailbox) { if (source is MailboxId) { mapiSession.AnalyzeMailboxNotFoundAndThrow((MailboxId)source, exception); } throw new MapiObjectNotFoundException(message, exception); } if (exception is MapiExceptionMdbOffline) { if (mapiSession == null) { throw new DatabaseUnavailableException(Strings.DatabaseUnavailableExceptionErrorSimple, exception); } DatabaseId databaseId = null; if (source is MailboxId && null != ((MailboxId)source).MailboxDatabaseId) { databaseId = ((MailboxId)source).MailboxDatabaseId; } else if (source is DatabaseId) { databaseId = (DatabaseId)source; } if (null == databaseId) { throw new DatabaseUnavailableException(Strings.DatabaseUnavailableExceptionError(mapiSession.ServerName), exception); } throw new DatabaseUnavailableException(Strings.DatabaseUnavailableByIdentityExceptionError(mapiSession.GetDatabaseIdentityString(databaseId), mapiSession.ServerName), exception); } else { if (exception is MapiExceptionPartialCompletion) { throw new MapiPartialCompletionException(message, exception); } if (exception is MapiExceptionNetworkError) { if (mapiSession != null) { throw new MapiNetworkErrorException(Strings.MapiNetworkErrorExceptionError(mapiSession.ServerName), exception); } throw new MapiNetworkErrorException(Strings.MapiNetworkErrorExceptionErrorSimple, exception); } else if (exception is MapiExceptionNoAccess) { if (null != source) { throw new MapiAccessDeniedException(Strings.MapiAccessDeniedExceptionError(source.ToString()), exception); } throw new MapiAccessDeniedException(Strings.MapiAccessDeniedExceptionErrorSimple, exception); } else { if (exception is MapiRetryableException) { throw new MapiTransientException(message, exception); } if (exception is MapiPermanentException) { throw new MapiOperationException(message, exception); } if (exception is MapiInvalidOperationException) { throw new MapiOperationException(message, exception); } return; } } } }
internal override void Save(bool keepUnmanagedResources) { if (ObjectState.Unchanged == base.ObjectState) { return; } if (ObjectState.Deleted == base.ObjectState) { throw new MapiInvalidOperationException(Strings.ExceptionObjectStateInvalid(base.ObjectState.ToString())); } base.EnableDisposeTracking(); using (MapiStore messageStore = this.GetMessageStore()) { MapiFolder mapiFolder = null; MapiFolder parentFolder = null; bool isFolderRetrieved = false; try { MapiSession mapiSession = base.MapiSession; Folder.CheckRequirementsOnSessionToContinue(base.MapiSession); bool creating = false; if (base.ObjectState == ObjectState.New) { creating = true; string text = null; if (this.newFolderIdentity == null) { if (null == this.Identity) { throw new MapiInvalidOperationException(Strings.ExceptionIdentityNull); } if (null == this.Identity.MapiFolderPath) { throw new MapiInvalidOperationException(Strings.ExceptionIdentityInvalid); } MapiFolder mapiFolder2 = null; try { parentFolder = Folder.RetrieveParentMapiFolder(messageStore, this.Identity, ref mapiFolder2); } finally { if (mapiFolder2 != null) { mapiFolder2.Dispose(); } } if (parentFolder != null && !parentFolder.AllowWarnings) { parentFolder.AllowWarnings = true; } text = this.Identity.MapiFolderPath.Name; } else { this.Identity = this.ConstructIdentity(null, MapiFolderPath.GenerateFolderPath(this.newFolderIdentity.ParentIdentity.MapiFolderPath, this.newFolderIdentity.FolderName, false), null); parentFolder = Folder.RetrieveMapiFolder(messageStore, this.newFolderIdentity.ParentIdentity); if (parentFolder != null && !parentFolder.AllowWarnings) { parentFolder.AllowWarnings = true; } text = this.newFolderIdentity.FolderName; } ExTraceGlobals.FolderTracer.TraceDebug <FolderId, string>((long)this.GetHashCode(), "To Create Folder '{0}' on server '{1}'.", this.Identity, base.MapiSession.ServerName); try { mapiFolder = parentFolder.CreateFolder(text, string.Empty, false); if (mapiFolder != null && !mapiFolder.AllowWarnings) { mapiFolder.AllowWarnings = true; } isFolderRetrieved = true; } catch (MapiExceptionCollision innerException) { this.DetectFolderExistence(messageStore, parentFolder, text, innerException); throw; } this.UpdateIdentity(this.UpdateIdentityFlagsForCreating); } if (creating || ObjectState.Changed == base.ObjectState) { Folder.CheckRequirementsOnIdentityToContinue(this.Identity); this.DetectDisallowedModification(messageStore); if (ObjectState.Changed == base.ObjectState && base.IsChanged(MapiPropertyDefinitions.Name)) { string name = (string)this[MapiPropertyDefinitions.Name]; if (parentFolder == null) { MapiFolder mapiFolder3 = null; try { parentFolder = Folder.RetrieveParentMapiFolder(messageStore, this.Identity, ref mapiFolder3); } finally { if (mapiFolder3 != null) { mapiFolder3.Dispose(); } } } this.DetectFolderExistence(messageStore, parentFolder, name, null); } PropProblem[] array = null; PropProblem[] array2 = null; FolderId folderId = null; if (mapiFolder != null) { mapiFolder.Dispose(); mapiFolder = null; } mapiFolder = Folder.RetrieveMapiFolder(messageStore, this.Identity, ref parentFolder, new Folder.IdentityConstructor(this.ConstructIdentity), out folderId); ParameterlessReturnlessDelegate parameterlessReturnlessDelegate = delegate() { if (creating && isFolderRetrieved) { ExTraceGlobals.FolderTracer.TraceDebug <FolderId, string>((long)this.GetHashCode(), "To Remove Folder '{0}' for rolling back creating on server '{1}'.", this.Identity, this.MapiSession.ServerName); try { parentFolder.DeleteFolder((byte[])this.Identity.MapiEntryId); } catch (MapiRetryableException ex) { ExTraceGlobals.FolderTracer.TraceError <FolderId, string, string>((long)this.GetHashCode(), "Removing Folder '{0}' for rolling back caughting an exception on server '{1}': {2}", this.Identity, this.MapiSession.ServerName, ex.Message); } catch (MapiPermanentException ex2) { ExTraceGlobals.FolderTracer.TraceError <FolderId, string, string>((long)this.GetHashCode(), "Removing Folder '{0}' for rolling back caughting an exception on server '{1}': {2}", this.Identity, this.MapiSession.ServerName, ex2.Message); } } }; try { PropValue[] propertyValuesToUpdate = base.GetPropertyValuesToUpdate(); if (0 < propertyValuesToUpdate.Length) { ExTraceGlobals.FolderTracer.TraceDebug <FolderId, string>((long)this.GetHashCode(), "To Set PropValues against Folder '{0}' on server '{1}'.", this.Identity, base.MapiSession.ServerName); array = mapiFolder.SetProps(propertyValuesToUpdate); } PropTag[] propertyTagsToDelete = base.GetPropertyTagsToDelete(); if (0 < propertyTagsToDelete.Length) { ExTraceGlobals.FolderTracer.TraceDebug <FolderId, string>((long)this.GetHashCode(), "To Delete PropTags against Folder '{0}' on server '{1}'.", this.Identity, base.MapiSession.ServerName); array2 = mapiFolder.DeleteProps(propertyTagsToDelete); } } catch (DataValidationException) { parameterlessReturnlessDelegate(); throw; } catch (MapiRetryableException) { parameterlessReturnlessDelegate(); throw; } catch (MapiPermanentException) { parameterlessReturnlessDelegate(); throw; } base.ResetChangeTrackingAndObjectState(); StringBuilder stringBuilder = new StringBuilder(); if (array != null && 0 < array.Length) { stringBuilder.AppendLine(Strings.ErrorSetPropsProblem(this.Identity.ToString(), array.Length.ToString())); foreach (PropProblem propProblem in array) { stringBuilder.Append('\t'); stringBuilder.AppendLine(Strings.ErrorPropProblem(propProblem.PropTag.ToString(), propProblem.PropType.ToString(), propProblem.Scode.ToString())); } stringBuilder.AppendLine(); } if (array2 != null && 0 < array2.Length) { stringBuilder.AppendLine(Strings.ErrorDeletePropsProblem(this.Identity.ToString(), array2.Length.ToString())); foreach (PropProblem propProblem2 in array2) { stringBuilder.Append('\t'); stringBuilder.Append(Strings.ErrorPropProblem(propProblem2.PropTag.ToString(), propProblem2.PropType.ToString(), propProblem2.Scode.ToString())); stringBuilder.AppendLine(); } stringBuilder.AppendLine(); } if (0 < stringBuilder.Length) { string text2 = stringBuilder.ToString(); ExTraceGlobals.FolderTracer.TraceDebug <FolderId, string, string>((long)this.GetHashCode(), "Setting Folder '{0}' on server '{1}' returns error '{2}'.", this.Identity, base.MapiSession.ServerName, text2); parameterlessReturnlessDelegate(); throw new MapiInvalidOperationException(new LocalizedString(text2)); } } } finally { if (mapiFolder != null) { mapiFolder.Dispose(); } if (parentFolder != null) { parentFolder.Dispose(); } base.Dispose(); } } }
internal MailboxStatistics(MailboxId mapiObjectId, MapiSession mapiSession) : base(mapiObjectId, mapiSession) { }
internal MessageStore(MessageStoreId mapiObjectId, MapiSession mapiSession) : base(mapiObjectId, mapiSession) { }