protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value) { if (!(value is bool)) { string message = ServerStrings.ExInvalidValueForFlagsCalculatedProperty(this.flag); ExTraceGlobals.StorageTracer.TraceError((long)this.GetHashCode(), message); throw new ArgumentException(message); } object value2 = propertyBag.GetValue(this.nativeProperty); PropertyError propertyError = value2 as PropertyError; int num; if (propertyError == null) { num = (int)value2; } else { if (propertyError.PropertyErrorCode != PropertyErrorCode.NotFound) { throw PropertyError.ToException(new PropertyError[] { propertyError }); } num = 0; } if ((bool)value) { propertyBag.SetValueWithFixup(this.nativeProperty, num | this.flag); return; } propertyBag.SetValueWithFixup(this.nativeProperty, num & ~this.flag); }
private void CheckCanModify(StorePropertyDefinition propertyDefinition) { if (RecipientBase.ImmutableProperties.Contains(propertyDefinition)) { throw PropertyError.ToException(new PropertyError[] { new PropertyError(propertyDefinition, PropertyErrorCode.NotSupported) }); } }
private void CheckCanModify(StorePropertyDefinition propertyDefinition) { if (!(propertyDefinition is PropertyTagPropertyDefinition) || (this.coreRecipient.recipientState != CoreRecipient.RecipientState.Uninitialized && propertyDefinition == InternalSchema.RowId)) { throw PropertyError.ToException(new PropertyError[] { new PropertyError(propertyDefinition, PropertyErrorCode.NotSupported) }); } }
protected override void SetValidatedStoreProperty(StorePropertyDefinition propertyDefinition, object propertyValue) { SchemaConverter.Setter setter = this.schemaConverter.GetSetter(propertyDefinition); if (!this.isReadOnly && setter != null) { setter((IPropertyBag)this.underlyingPropertyBag, ExTimeZoneHelperForMigrationOnly.ToUtcIfDateTime(propertyValue)); return; } throw PropertyError.ToException(new PropertyError[] { new PropertyError(propertyDefinition, PropertyErrorCode.NotSupported) }); }
private static void ProcessCopyPropertyProblems(PropProblem[] problems, StoreSession sourceSession, MapiProp source) { if (problems != null) { for (int i = 0; i < problems.Length; i++) { int scode = problems[i].Scode; if (scode != -2147221233 && scode != -2147221222) { throw PropertyError.ToException(ServerStrings.MapiCopyFailedProperties, StoreObjectPropertyBag.MapiPropProblemsToPropertyErrors(sourceSession, source, problems)); } } } }
public PropValue(StorePropertyDefinition propDef, object value) { if (propDef == null) { throw new ArgumentNullException("propDef"); } if (value == null) { throw PropertyError.ToException(new PropertyError[] { new PropertyError(propDef, PropertyErrorCode.NullValue) }); } this.propDef = propDef; this.value = value; }
protected override void SetValidatedStoreProperty(StorePropertyDefinition propertyDefinition, object propertyValue) { if (propertyDefinition == null) { throw new ArgumentNullException(ServerStrings.ExNullParameter("propertyDefinition", 1)); } if (propertyValue == null) { throw PropertyError.ToException(new PropertyError[] { new PropertyError(propertyDefinition, PropertyErrorCode.NullValue) }); } ((IDirectPropertyBag)this.memoryPropertyBag).SetValue(propertyDefinition, propertyValue); this.TrackProperty(propertyDefinition, true); }
private static void ThrowIfPropertyError(StorePropertyDefinition propertyDefinition, object propertyValue) { if (propertyValue == null) { throw PropertyError.ToException(new PropertyError[] { new PropertyError(propertyDefinition, PropertyErrorCode.NullValue) }); } if (PropertyError.IsPropertyError(propertyValue)) { throw PropertyError.ToException(new PropertyError[] { (PropertyError)propertyValue }); } }
private OperationResult InternalLocalize(out Exception[] problems) { int num = 0; List <Exception> list = new List <Exception>(); foreach (DefaultFolder defaultFolder in this.defaultFolders) { try { PropertyError propertyError; if (defaultFolder.Localize(out propertyError) && propertyError != null) { list.Add(PropertyError.ToException(new PropertyError[] { propertyError })); num++; } } catch (StoragePermanentException item) { list.Add(item); } catch (StorageTransientException item2) { list.Add(item2); } } OperationResult result = OperationResult.Succeeded; if (list.Count > 0 && num > 0) { result = OperationResult.Failed; } else if (list.Count > 0) { result = OperationResult.PartiallySucceeded; } problems = list.ToArray(); return(result); }
protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value) { MessageItem messageItem = propertyBag.Context.StoreObject as MessageItem; if (messageItem != null) { try { ((Likers)messageItem.Likers).Blob = (byte[])value; return; } catch (CorruptDataException ex) { throw PropertyError.ToException(ex.LocalizedString, new PropertyError[] { new PropertyError(InternalSchema.LikersBlob, PropertyErrorCode.SetCalculatedPropertyError) }); } } propertyBag.SetValueWithFixup(InternalSchema.MapiLikersBlob, value); }
internal override void FlushChanges() { base.CheckDisposed("FlushChanges"); List <PropertyError> list = new List <PropertyError>(); this.BindToMapiPropertyBag(); this.MapiPropertyBag.SaveFlags = this.saveFlags; foreach (StoreObjectStream storeObjectStream in this.listOfStreams) { storeObjectStream.Flush(); } list.AddRange(this.FlushDeleteProperties()); list.AddRange(this.FlushSetProperties()); if ((this.saveFlags & PropertyBagSaveFlags.IgnoreMapiComputedErrors) == PropertyBagSaveFlags.IgnoreMapiComputedErrors) { for (int i = list.Count - 1; i >= 0; i--) { if (list[i].PropertyErrorCode == PropertyErrorCode.SetStoreComputedPropertyError) { list.RemoveAt(i); } } } if ((this.saveFlags & PropertyBagSaveFlags.IgnoreAccessDeniedErrors) == PropertyBagSaveFlags.IgnoreAccessDeniedErrors) { for (int j = list.Count - 1; j >= 0; j--) { if (list[j].PropertyErrorCode == PropertyErrorCode.AccessDenied) { list.RemoveAt(j); } } } if (list.Count > 0) { ExTraceGlobals.StorageTracer.TraceDebug <int>((long)this.GetHashCode(), "StoreObjectPropertyBag::FlushChanges. Property was not set or deleted successfully. Error Count = {0}.", list.Count); throw PropertyError.ToException(list.ToArray()); } this.memoryPropertyBag.ClearChangeInfo(); }
internal static T?CheckNullablePropertyValue <T>(StorePropertyDefinition propertyDefinition, object propertyValue) where T : struct { PropertyBag.EnsurePropertyIsNotStreamable(propertyDefinition); if (propertyValue == null) { return(null); } PropertyError propertyError = propertyValue as PropertyError; if (propertyError == null) { return(new T?((T)((object)propertyValue))); } if (propertyError.PropertyErrorCode == PropertyErrorCode.NotFound) { return(null); } throw PropertyError.ToException(new PropertyError[] { propertyError }); }
public static T CheckPropertyValue <T>(StorePropertyDefinition propertyDefinition, object propertyValue, T defaultPropertyValue) { PropertyBag.EnsurePropertyIsNotStreamable(propertyDefinition); if (propertyValue == null) { return(defaultPropertyValue); } PropertyError propertyError = propertyValue as PropertyError; if (propertyError == null) { return((T)((object)propertyValue)); } if (propertyError.PropertyErrorCode == PropertyErrorCode.NotFound) { return(defaultPropertyValue); } throw PropertyError.ToException(new PropertyError[] { propertyError }); }
public object this[PropertyDefinition propertyDefinition] { get { this.CheckDisposed("this::get[PropertyDefinition]"); object obj = this.TryGetProperty(propertyDefinition); PropertyError propertyError = obj as PropertyError; if (propertyError != null) { throw PropertyError.ToException(new PropertyError[] { propertyError }); } return(obj); } set { this.CheckDisposed("this::set[PropertyDefinition]"); this.SetProperty(propertyDefinition, value); } }
private void CreateStream() { if ((this.property.PropertyFlags & PropertyFlags.Streamable) == PropertyFlags.None) { ExTraceGlobals.PropertyBagTracer.TraceDebug <NativeStorePropertyDefinition>(0L, "StoreObjectStream::CreateStream property {0} is not marked as streamable.", this.property); } if (this.property.MapiPropertyType == PropType.Object) { this.OpenMapiStream(false); return; } if (this.property.MapiPropertyType != PropType.String && this.property.MapiPropertyType != PropType.Binary) { throw new InvalidOperationException(ServerStrings.ExPropertyNotStreamable(this.property.ToString())); } switch (this.openMode) { case PropertyOpenMode.ReadOnly: case PropertyOpenMode.Modify: { if (!((IDirectPropertyBag)this.storePropertyBag.MemoryPropertyBag).IsLoaded(this.property)) { this.OpenMapiStream(false); return; } object obj = this.storePropertyBag.MemoryPropertyBag.TryGetProperty(this.property); PropertyError propertyError = obj as PropertyError; if (propertyError == null) { this.CreateCache(obj); return; } if (PropertyError.IsPropertyValueTooBig(obj)) { this.OpenMapiStream(false); return; } if (propertyError.PropertyErrorCode != PropertyErrorCode.NotFound) { throw PropertyError.ToException(new PropertyError[] { propertyError }); } if (Array.IndexOf <StorePropertyDefinition>(StoreObjectStream.bodyProperties, this.property) != -1) { this.OpenMapiStream(false); return; } if (this.openMode != PropertyOpenMode.Modify) { throw new ObjectNotFoundException(ServerStrings.ExUnableToGetStreamProperty(this.property.Name)); } break; } case PropertyOpenMode.Create: break; default: return; } this.CreateCache(null); this.dataChanged = true; }
private PropertyError[] InternalSetProperties(PropertyDefinition[] propertyDefinitions, object[] propertyValues, MapiPropertyBag.MapiSetProps mapiSetProps) { this.CheckDisposed("SetProperties"); if (propertyDefinitions == null) { throw new ArgumentNullException(ServerStrings.ExNullParameter("propertyDefinitions", 1)); } if (propertyValues == null) { throw new ArgumentNullException(ServerStrings.ExNullParameter("propertyValues", 2)); } if (propertyDefinitions.Length == 0) { return(MapiPropertyBag.EmptyPropertyErrorArray); } ICollection <PropTag> collection = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(this.MapiProp, this.storeSession, (this.saveFlags & PropertyBagSaveFlags.IgnoreUnresolvedHeaders) == PropertyBagSaveFlags.IgnoreUnresolvedHeaders, true, (this.saveFlags & PropertyBagSaveFlags.DisableNewXHeaderMapping) != PropertyBagSaveFlags.DisableNewXHeaderMapping, propertyDefinitions); List <PropValue> list = new List <PropValue>(propertyDefinitions.Length); int num = 0; foreach (PropTag propTag in collection) { if (propTag != PropTag.Unresolved) { InternalSchema.CheckPropertyValueType(propertyDefinitions[num], propertyValues[num]); list.Add(MapiPropertyBag.GetPropValueFromValue(this.storeSession, this.ExTimeZone, propTag, propertyValues[num])); } num++; } PropProblem[] array = null; StoreSession storeSession = this.StoreSession; bool flag = false; try { if (storeSession != null) { storeSession.BeginMapiCall(); storeSession.BeginServerHealthCall(); flag = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } try { array = mapiSetProps(list.ToArray()); } catch (MapiExceptionNotEnoughMemory mapiExceptionNotEnoughMemory) { ExTraceGlobals.StorageTracer.TraceError <MapiExceptionNotEnoughMemory>((long)this.GetHashCode(), "MapiPropertyBag::InternalSetProperties. Failed to SetProps due to MapiException {0}.", mapiExceptionNotEnoughMemory); string errorDescription = mapiExceptionNotEnoughMemory.ToString(); List <PropertyError> list2 = new List <PropertyError>(); foreach (PropertyDefinition propertyDefinition in propertyDefinitions) { list2.Add(new PropertyError(propertyDefinition, PropertyErrorCode.NotEnoughMemory, errorDescription)); } throw PropertyError.ToException(list2.ToArray()); } } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetProps, ex, storeSession, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiPropertyBag::InternalSetProperties.", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetProps, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiPropertyBag::InternalSetProperties.", new object[0]), ex2 }); } finally { try { if (storeSession != null) { storeSession.EndMapiCall(); if (flag) { storeSession.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } PropertyError[] array2 = MapiPropertyBag.EmptyPropertyErrorArray; if (array != null) { array2 = new PropertyError[array.Length]; for (int j = 0; j < array.Length; j++) { int scode = array[j].Scode; PropertyDefinition propertyDefinition2 = null; int num2 = 0; foreach (PropTag propTag2 in collection) { if (array[j].PropTag == propTag2) { propertyDefinition2 = propertyDefinitions[num2]; break; } num2++; } string errorDescription2; PropertyErrorCode error = MapiPropertyHelper.MapiErrorToXsoError(scode, out errorDescription2); array2[j] = new PropertyError(propertyDefinition2, error, errorDescription2); ExTraceGlobals.StorageTracer.TraceError <string, MapiProp, PropertyError>((long)this.GetHashCode(), "MapiPropertyBag::InternalSetProperties. Failed. PropDef display name= {0}, MapiProp = {1}, Error = {2}.", propertyDefinition2.Name, this.MapiProp, array2[j]); } } return(array2); }
public PersistablePropertyBag CreateAttachment(ICollection <PropertyDefinition> propertiesToLoad, CoreAttachment attachmentToClone, IItem itemToAttach, out int attachmentNumber) { MapiAttach mapiAttach = null; PersistablePropertyBag persistablePropertyBag = null; bool flag = false; int num = 0; try { StoreSession session = this.AttachmentCollection.ContainerItem.Session; bool flag2 = false; try { if (session != null) { session.BeginMapiCall(); session.BeginServerHealthCall(); flag2 = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } mapiAttach = this.AttachmentCollection.ContainerItem.MapiMessage.CreateAttach(out num); } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenAttachment, ex, session, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenAttachment, ex2, session, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex2 }); } finally { try { if (session != null) { session.EndMapiCall(); if (flag2) { session.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } attachmentNumber = num; if (attachmentToClone != null) { MapiAttachmentProvider.CopySavedMapiAttachment(true, this, this.AttachmentCollection.ContainerItem.Session, (MapiAttach)attachmentToClone.PropertyBag.MapiProp, mapiAttach); } else if (itemToAttach != null) { MapiMessage mapiMessage = itemToAttach.MapiMessage; MapiMessage mapiMessage2 = null; StoreSession session2 = this.AttachmentCollection.ContainerItem.Session; bool flag3 = false; try { if (session2 != null) { session2.BeginMapiCall(); session2.BeginServerHealthCall(); flag3 = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } mapiMessage2 = mapiAttach.OpenEmbeddedMessage(OpenPropertyFlags.Create); } catch (MapiPermanentException ex3) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenEmbeddedMessage, ex3, session2, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex3 }); } catch (MapiRetryableException ex4) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenEmbeddedMessage, ex4, session2, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex4 }); } finally { try { if (session2 != null) { session2.EndMapiCall(); if (flag3) { session2.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } using (mapiMessage2) { PropProblem[] array = null; StoreSession session3 = this.AttachmentCollection.ContainerItem.Session; bool flag4 = false; try { if (session3 != null) { session3.BeginMapiCall(); session3.BeginServerHealthCall(); flag4 = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } array = mapiMessage.CopyTo(mapiMessage2, new PropTag[] { (PropTag)InternalSchema.UrlCompName.PropertyTag }); } catch (MapiPermanentException ex5) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCopyFailedProperties, ex5, session3, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex5 }); } catch (MapiRetryableException ex6) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCopyFailedProperties, ex6, session3, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex6 }); } finally { try { if (session3 != null) { session3.EndMapiCall(); if (flag4) { session3.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } if (array != null) { int num2 = -1; for (int i = 0; i < array.Length; i++) { int scode = array[i].Scode; if (scode == -2147221233 || scode == -2147221222) { ExTraceGlobals.StorageTracer.TraceDebug <int>((long)this.GetHashCode(), "Storage.MapiAttachmentProvider.AddExisting Item: CopyTo returned ignorable scode = {0}", scode); } else { ExTraceGlobals.StorageTracer.TraceError <int>((long)this.GetHashCode(), "Storage.MapiAttachmentProvider.AddExisting Item: CopyTo returned fatal scode = {0}", scode); num2 = i; } if (num2 != -1) { throw PropertyError.ToException(ServerStrings.ExUnableToCopyAttachments, StoreObjectPropertyBag.MapiPropProblemsToPropertyErrors(null, mapiMessage, array)); } } } StoreSession session4 = this.AttachmentCollection.ContainerItem.Session; bool flag5 = false; try { if (session4 != null) { session4.BeginMapiCall(); session4.BeginServerHealthCall(); flag5 = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } mapiMessage2.SaveChanges(); } catch (MapiPermanentException ex7) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSaveChanges, ex7, session4, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex7 }); } catch (MapiRetryableException ex8) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSaveChanges, ex8, session4, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex8 }); } finally { try { if (session4 != null) { session4.EndMapiCall(); if (flag5) { session4.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } } } persistablePropertyBag = this.CreateStorePropertyBag(mapiAttach, propertiesToLoad); persistablePropertyBag.ExTimeZone = this.ExTimeZone; flag = true; } finally { if (!flag) { if (persistablePropertyBag != null) { persistablePropertyBag.Dispose(); } if (mapiAttach != null) { mapiAttach.Dispose(); } } } return(persistablePropertyBag); }
internal static void CopySavedMapiAttachment(bool failOnProblems, object thisObject, StoreSession session, MapiAttach source, MapiAttach destination) { PropProblem[] array = null; bool flag = false; try { if (session != null) { session.BeginMapiCall(); session.BeginServerHealthCall(); flag = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } array = source.CopyTo(destination, new PropTag[0]); } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenAttachment, ex, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CopySavedMapiAttachment", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenAttachment, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CopySavedMapiAttachment", new object[0]), ex2 }); } finally { try { if (session != null) { session.EndMapiCall(); if (flag) { session.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } if (array != null) { ExTraceGlobals.StorageTracer.TraceError <int>((long)((thisObject == null) ? 0 : thisObject.GetHashCode()), "MapiAttachmentProvider.CreateNewAttachment: MapiAttach.CopyTo returned scode = {0}", array[0].Scode); if (failOnProblems) { throw PropertyError.ToException(ServerStrings.ExUnableToCopyAttachments, StoreObjectPropertyBag.MapiPropProblemsToPropertyErrors(null, destination, array)); } } }
private void CreateMapiFolder() { string valueOrDefault = base.GetValueOrDefault <string>(FolderSchema.DisplayName); string valueOrDefault2 = base.GetValueOrDefault <string>(FolderSchema.Description, string.Empty); byte[] array = base.Session.IsMoveUser ? base.GetValueOrDefault <byte[]>(StoreObjectSchema.EntryId, null) : null; MapiProp mapiProp = null; MapiPropertyBag mapiPropertyBag = null; bool flag = false; try { using (Folder folder = Folder.Bind(base.Session, this.parentFolderId, new PropertyDefinition[] { StoreObjectSchema.EffectiveRights })) { if (folder is SearchFolder) { throw new InvalidParentFolderException(ServerStrings.ExCannotCreateSubfolderUnderSearchFolder); } bool flag2 = (this.createMode & CreateMode.OpenIfExists) == CreateMode.OpenIfExists; bool flag3 = (this.createMode & CreateMode.InstantSearch) == CreateMode.InstantSearch; bool flag4 = (this.createMode & CreateMode.OptimizedConversationSearch) == CreateMode.OptimizedConversationSearch; bool flag5 = (this.createMode & CreateMode.CreatePublicFolderDumpster) == CreateMode.CreatePublicFolderDumpster; if (flag2 && flag3) { throw new ArgumentException("Cannot use both openIfExists and instantSearch folder creation flags"); } if (this.isSecure && (flag3 || flag4 || flag5)) { throw new ArgumentException("Cannot use isSecure in conjunction with instantSearch, optimizedConversationSearch or createPublicFolderDumpster"); } StoreSession session = base.Session; bool flag6 = false; try { if (session != null) { session.BeginMapiCall(); session.BeginServerHealthCall(); flag6 = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } try { this.OnBeforeCreateFolder(folder); if (this.isSecure) { mapiProp = folder.MapiFolder.CreateSecureFolder(valueOrDefault, valueOrDefault2, flag2, array); } else { mapiProp = folder.MapiFolder.CreateFolder(valueOrDefault, valueOrDefault2, flag2, this.isSearchFolder, flag3, flag4, flag5, array); } } catch (MapiExceptionNotEnoughMemory mapiExceptionNotEnoughMemory) { ExTraceGlobals.StorageTracer.TraceError <MapiExceptionNotEnoughMemory>((long)this.GetHashCode(), "CreateFolderPropertyBag::CreateMapiPropertyBag. Failed to create MapiFolder due to MapiException {0}.", mapiExceptionNotEnoughMemory); bool flag7 = !string.IsNullOrEmpty(valueOrDefault2); string errorDescription = mapiExceptionNotEnoughMemory.ToString(); PropertyError[] array2 = new PropertyError[flag7 ? 2 : 1]; array2[0] = new PropertyError(FolderSchema.DisplayName, PropertyErrorCode.NotEnoughMemory, errorDescription); if (flag7) { array2[1] = new PropertyError(FolderSchema.Description, PropertyErrorCode.NotEnoughMemory, errorDescription); } throw PropertyError.ToException(array2); } } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateFolder(valueOrDefault), ex, session, this, "{0}. MapiException = {1}.", new object[] { string.Format("CreateFolderPropertyBag::CreateMapiPropertyBag.", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateFolder(valueOrDefault), ex2, session, this, "{0}. MapiException = {1}.", new object[] { string.Format("CreateFolderPropertyBag::CreateMapiPropertyBag.", new object[0]), ex2 }); } finally { try { if (session != null) { session.EndMapiCall(); if (flag6) { session.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } } this.Context.CoreState.Origin = Origin.Existing; base.MemoryPropertyBag.ClearChangeInfo(FolderSchema.DisplayName); if (array != null) { base.MemoryPropertyBag.ClearChangeInfo(StoreObjectSchema.EntryId); } if (this.createMode == CreateMode.CreateNew) { base.MemoryPropertyBag.ClearChangeInfo(FolderSchema.Description); } mapiPropertyBag = new MapiPropertyBag(base.Session, mapiProp); base.MapiPropertyBag = mapiPropertyBag; flag = true; } finally { if (!flag) { Util.DisposeIfPresent(mapiPropertyBag); Util.DisposeIfPresent(mapiProp); } } }
private void PopulateExceptionOccurrence(object[] occurrence, PropertyDefinition[] columns, ExceptionInfo exception, ref AttachmentCollection attachments, ref Item master, VersionedId versionedId) { object[] array = null; for (int i = 0; i < columns.Length; i++) { if (!columns[i].Equals(InternalSchema.ItemId) && !columns[i].Equals(InternalSchema.IsRecurring) && !columns[i].Equals(InternalSchema.IsException) && !columns[i].Equals(InternalSchema.AppointmentRecurring) && !columns[i].Equals(InternalSchema.MapiStartTime) && !columns[i].Equals(InternalSchema.MapiPRStartDate) && !columns[i].Equals(InternalSchema.MapiEndTime) && !columns[i].Equals(InternalSchema.MapiPREndDate) && !columns[i].Equals(InternalSchema.CalendarItemType) && !columns[i].Equals(InternalSchema.GlobalObjectId) && !columns[i].Equals(InternalSchema.TimeZoneDefinitionStart) && !columns[i].Equals(InternalSchema.TimeZoneDefinitionEnd) && !columns[i].Equals(InternalSchema.Codepage) && !RecurrenceManager.MasterOnlyProperties.Contains(columns[i])) { if (RecurrenceManager.CanPropertyBeInExceptionData(columns[i])) { object obj = exception.PropertyBag.TryGetProperty(columns[i]); PropertyError propertyError = obj as PropertyError; if (propertyError != null) { if (propertyError.PropertyErrorCode != PropertyErrorCode.NotFound) { throw PropertyError.ToException(new PropertyError[] { propertyError }); } } else { occurrence[i] = obj; } } else { ExTraceGlobals.RecurrenceTracer.Information <PropertyDefinition>((long)this.recurrence.GetHashCode(), "RecurrenceManager::Expand, Opening embedded message for {0} property", columns[i]); if (array == null) { if (attachments == null) { if (master == null) { ExTraceGlobals.RecurrenceTracer.Information((long)this.recurrence.GetHashCode(), "RecurrenceManager::Expand. Fetching master message when constructing view"); StoreObjectId masterId = versionedId.ObjectId; bool flag = false; try { master = ItemBuilder.ConstructItem <Item>(this.storeSession, masterId, null, CalendarItemBaseSchema.Instance.AutoloadProperties, () => new StoreObjectPropertyBag(this.storeSession, this.storeSession.GetMapiProp(masterId), CalendarItemBaseSchema.Instance.AutoloadProperties), ItemCreateInfo.GenericItemInfo.Creator, Origin.Existing, ItemLevel.TopLevel); flag = true; } finally { if (!flag && master != null) { master.Dispose(); master = null; } } } attachments = master.AttachmentCollection; ExTraceGlobals.RecurrenceTracer.Information((long)this.recurrence.GetHashCode(), "RecurrenceManager::Expand, Fetching attachments"); } ItemAttachment itemAttachment = null; using (Item item = RecurrenceManager.OpenEmbeddedMessageAndAttachment(attachments, TimeZoneHelper.GetRecurringTimeZoneFromPropertyBag(attachments.ContainerItem.PropertyBag), exception.StartTime, exception.EndTime, out itemAttachment, columns)) { ExTraceGlobals.RecurrenceTracer.Information <ExDateTime>((long)this.recurrence.GetHashCode(), "RecurrenceManager::Expand, Fetching Embedded Message for exception occurence dateId: {0}", exception.OccurrenceDateId); if (item != null) { array = item.GetProperties(columns); itemAttachment.Dispose(); } else { array = new object[columns.Length]; } } } if (array[i] != null && !(array[i] is PropertyError)) { occurrence[i] = array[i]; } } } } }
public static Exception ToException(params PropertyError[] propertyErrors) { return(PropertyError.ToException(LocalizedString.Empty, propertyErrors)); }