public PropertyError(PropertyDefinition propertyDefinition, PropertyErrorCode error, string errorDescription) { EnumValidator.ThrowIfInvalid <PropertyErrorCode>(error, "error"); this.propertyDefinition = propertyDefinition; this.error = error; this.errorDescription = errorDescription; }
private static PropertyError CreatePropertyError(int mapiErrorCode, StorePropertyDefinition propertyDefinition) { string errorDescription; PropertyErrorCode propertyErrorCode = MapiPropertyHelper.MapiErrorToXsoError(mapiErrorCode, out errorDescription); if (propertyErrorCode == PropertyErrorCode.NotEnoughMemory && propertyDefinition.Type != typeof(string) && propertyDefinition.Type != typeof(byte[])) { propertyErrorCode = PropertyErrorCode.CorruptedData; } PropertyError propertyError; if (propertyErrorCode == PropertyErrorCode.NotFound) { propertyError = propertyDefinition.GetNotFoundError(); } else if (propertyErrorCode == PropertyErrorCode.NotEnoughMemory) { propertyError = propertyDefinition.GetNotEnoughMemoryError(); } else { propertyError = new PropertyError(propertyDefinition, propertyErrorCode, errorDescription); ExTraceGlobals.StorageTracer.TraceError <PropertyError>(0L, "MapiPropertyBag::GetValueFromPropValue. Error = {0}.", propertyError); } return(propertyError); }
internal static PropertyError[] MapiPropProblemsToPropertyErrors(PropertyDefinition[] propertyDefinitions, PropProblem[] problems) { PropertyError[] array = new PropertyError[problems.Length]; for (int i = 0; i < problems.Length; i++) { string errorDescription; PropertyErrorCode error = MapiPropertyHelper.MapiErrorToXsoError(problems[i].Scode, out errorDescription); array[i] = new PropertyError(propertyDefinitions[problems[i].Index], error, errorDescription); } return(array); }
private IList <PropertyError> ConvertSetPropsToErrors(PropertyErrorCode errorCode, string errorMessage) { List <PropertyError> list = new List <PropertyError>(); foreach (PropertyDefinition propertyDefinition in base.MemoryPropertyBag.ChangeList) { object obj = base.MemoryPropertyBag.TryGetProperty(propertyDefinition); if (!(obj is PropertyError)) { list.Add(new PropertyError(propertyDefinition, errorCode, errorMessage)); } } return(list); }
private static PropertyError[] ToXsoPropertyErrors(StoreSession session, MapiProp destMapiProp, PropProblem[] problems) { if (problems == null || problems.Length == 0) { return(MapiPropertyBag.EmptyPropertyErrorArray); } PropTag[] array = new PropTag[problems.Length]; int[] array2 = new int[problems.Length]; for (int i = 0; i < problems.Length; i++) { array2[i] = problems[i].Scode; array[i] = problems[i].PropTag; } NativeStorePropertyDefinition[] array3 = PropertyTagCache.Cache.PropertyDefinitionsFromPropTags(NativeStorePropertyDefinition.TypeCheckingFlag.DisableTypeCheck, destMapiProp, session, array); PropertyError[] array4 = new PropertyError[problems.Length]; for (int j = 0; j < problems.Length; j++) { string errorDescription; PropertyErrorCode error = MapiPropertyHelper.MapiErrorToXsoError(array2[j], out errorDescription); array4[j] = new PropertyError(array3[j], error, errorDescription); } return(array4); }
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); }
internal PropertyError[] DeleteProperties(ICollection <PropertyDefinition> propertyDefinitions) { this.CheckDisposed("DeleteProperties"); if (propertyDefinitions == null) { throw new ArgumentNullException(ServerStrings.ExNullParameter("propertyDefinitions", 1)); } if (propertyDefinitions.Count == 0) { ExTraceGlobals.StorageTracer.TraceError <string>((long)this.GetHashCode(), "MapiPropertyBag::DeleteProperties. {0} contain zero elements.", "propertyDefinitions"); throw new ArgumentException(ServerStrings.ExEmptyCollection("propertyDefinitions"), "propertyDefinitions"); } IList <PropertyDefinition> list = new List <PropertyDefinition>(); IList <PropertyDefinition> list2 = new List <PropertyDefinition>(); foreach (PropertyDefinition propertyDefinition in propertyDefinitions) { StorePropertyDefinition storePropertyDefinition = InternalSchema.ToStorePropertyDefinition(propertyDefinition); NativeStorePropertyDefinition nativeStorePropertyDefinition = storePropertyDefinition as NativeStorePropertyDefinition; if (nativeStorePropertyDefinition != null) { list.Add(storePropertyDefinition); } else { list2.Add(storePropertyDefinition); } } ICollection <PropTag> tags = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(this.MapiProp, this.storeSession, false, list); 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()); } array = this.MapiProp.DeleteProps(tags, (this.SaveFlags & PropertyBagSaveFlags.NoChangeTracking) != PropertyBagSaveFlags.NoChangeTracking); } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotDeleteProperties, ex, storeSession, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiPropertyBag::SetProperty. MapiProp = {0}.", this.MapiProp), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotDeleteProperties, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiPropertyBag::SetProperty. MapiProp = {0}.", this.MapiProp), ex2 }); } finally { try { if (storeSession != null) { storeSession.EndMapiCall(); if (flag) { storeSession.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } PropertyError[] array2; if (array != null || list2.Count > 0) { int num = list2.Count; if (array != null) { num += array.Length; } array2 = new PropertyError[num]; int num2 = 0; if (array != null) { int i = 0; while (i < array.Length) { int scode = array[i].Scode; string errorDescription; PropertyErrorCode error = MapiPropertyHelper.MapiErrorToXsoError(scode, out errorDescription); PropertyError propertyError = new PropertyError(list[array[i].Index], error, errorDescription); array2[num2] = propertyError; ExTraceGlobals.StorageTracer.TraceError <string, PropertyError>((long)this.GetHashCode(), "MapiPropertyBag::DeleteProperties. Failed. DisplayName = {0}, Error = {1}.", list[array[i].Index].Name, propertyError); i++; num2++; } } int count = list2.Count; int j = 0; while (j < count) { PropertyError propertyError2 = new PropertyError(list2[j], PropertyErrorCode.SetCalculatedPropertyError, ServerStrings.ExSetNotSupportedForCalculatedProperty(list2[j].Name)); array2[num2] = propertyError2; ExTraceGlobals.StorageTracer.TraceError <string, PropertyError>((long)this.GetHashCode(), "MapiPropertyBag::DeleteProperties. Failed. DisplayName = {0}, Error = {1}.", list2[j].Name, propertyError2); j++; num2++; } } else { array2 = MapiPropertyBag.EmptyPropertyErrorArray; } return(array2); }
private void CalculateRawFormat() { if (this.rawBodyFormat != -1) { return; } BodyFormat bodyFormat = BodyFormat.TextPlain; bool flag = false; bool flag2 = false; BodyFormat bodyFormat2 = BodyFormat.TextPlain; bool flag3 = false; bool flag4 = false; int num = 0; object obj = this.coreItem.PropertyBag.TryGetProperty(InternalSchema.TextBody); object obj2 = this.coreItem.PropertyBag.TryGetProperty(InternalSchema.HtmlBody); object obj3 = this.coreItem.PropertyBag.TryGetProperty(InternalSchema.RtfBody); object obj4 = this.coreItem.PropertyBag.TryGetProperty(InternalSchema.RtfInSync); PropertyErrorCode propertyErrorCode = (PropertyErrorCode)(-1); PropertyError propertyError; if ((propertyError = (obj as PropertyError)) != null) { propertyErrorCode = ((propertyError.PropertyErrorCode == PropertyErrorCode.RequireStreamed) ? PropertyErrorCode.NotEnoughMemory : propertyError.PropertyErrorCode); } PropertyErrorCode propertyErrorCode2 = (PropertyErrorCode)(-1); if ((propertyError = (obj2 as PropertyError)) != null) { propertyErrorCode2 = ((propertyError.PropertyErrorCode == PropertyErrorCode.RequireStreamed) ? PropertyErrorCode.NotEnoughMemory : propertyError.PropertyErrorCode); } PropertyErrorCode propertyErrorCode3 = (PropertyErrorCode)(-1); if ((propertyError = (obj3 as PropertyError)) != null) { propertyErrorCode3 = ((propertyError.PropertyErrorCode == PropertyErrorCode.RequireStreamed) ? PropertyErrorCode.NotEnoughMemory : propertyError.PropertyErrorCode); } bool flag5 = false; if (!(obj4 is PropertyError)) { flag5 = (bool)obj4; } if (!this.IsAnyBodyPropDirty()) { object obj5 = this.coreItem.PropertyBag.TryGetProperty(InternalSchema.NativeBodyInfo); if (!(obj5 is PropertyError)) { flag2 = true; switch ((int)obj5) { case 0: flag = true; bodyFormat = BodyFormat.TextPlain; num = 1; break; case 1: if (propertyErrorCode == PropertyErrorCode.NotFound) { flag2 = false; } else { bodyFormat = BodyFormat.TextPlain; num = 3; } break; case 2: if (propertyErrorCode3 == PropertyErrorCode.NotFound) { flag2 = false; } else { bodyFormat = BodyFormat.ApplicationRtf; num = 4; } break; case 3: if (propertyErrorCode2 == PropertyErrorCode.NotFound) { flag2 = false; } else { bodyFormat = BodyFormat.TextHtml; num = 2; } break; default: flag2 = false; break; } } } if (!flag2) { if (propertyErrorCode == PropertyErrorCode.NotFound && propertyErrorCode2 == PropertyErrorCode.NotFound && propertyErrorCode3 == PropertyErrorCode.NotFound) { flag3 = true; bodyFormat2 = BodyFormat.TextPlain; num = 11; flag4 = true; } else if (propertyErrorCode == PropertyErrorCode.NotEnoughMemory && propertyErrorCode2 == PropertyErrorCode.NotFound && propertyErrorCode3 == PropertyErrorCode.NotFound) { bodyFormat2 = BodyFormat.TextPlain; num = 12; flag4 = true; } else if ((propertyErrorCode == PropertyErrorCode.NotEnoughMemory && propertyErrorCode3 == PropertyErrorCode.NotEnoughMemory && propertyErrorCode2 == PropertyErrorCode.NotFound) || (propertyErrorCode == PropertyErrorCode.NotEnoughMemory && propertyErrorCode3 == PropertyErrorCode.NotEnoughMemory && propertyErrorCode2 == PropertyErrorCode.NotEnoughMemory && flag5)) { bodyFormat2 = BodyFormat.ApplicationRtf; num = 13; flag4 = true; } else if ((propertyErrorCode == PropertyErrorCode.NotEnoughMemory || propertyErrorCode == (PropertyErrorCode)(-1)) && propertyErrorCode3 == PropertyErrorCode.NotEnoughMemory && propertyErrorCode2 == PropertyErrorCode.NotEnoughMemory && !flag5) { bodyFormat2 = BodyFormat.TextHtml; num = 14; flag4 = true; } if (!flag4) { if (propertyErrorCode2 == (PropertyErrorCode)(-1) || propertyErrorCode2 == PropertyErrorCode.NotEnoughMemory) { if ((propertyErrorCode3 == (PropertyErrorCode)(-1) || propertyErrorCode3 == PropertyErrorCode.NotEnoughMemory) && flag5) { bodyFormat2 = BodyFormat.ApplicationRtf; num = 21; } else { bodyFormat2 = BodyFormat.TextHtml; num = 22; } flag4 = true; } else if (propertyErrorCode3 == (PropertyErrorCode)(-1) || propertyErrorCode3 == PropertyErrorCode.NotEnoughMemory) { if ((propertyErrorCode == (PropertyErrorCode)(-1) || propertyErrorCode == PropertyErrorCode.NotEnoughMemory) && !flag5) { bodyFormat2 = BodyFormat.TextPlain; num = 23; } else { bodyFormat2 = BodyFormat.ApplicationRtf; num = 24; } flag4 = true; } else { bodyFormat2 = BodyFormat.TextPlain; num = 25; flag4 = true; } } } this.bodyFormatDecision = num; if (!flag4) { this.noBody = flag; this.rawBodyFormat = (int)bodyFormat; } else { this.noBody = flag3; this.rawBodyFormat = (int)bodyFormat2; } ExTraceGlobals.CcBodyTracer.TraceDebug <int, bool, int>((long)this.GetHashCode(), "Body.CalculateRawFormat: BodyFormat={0}, missing={1}, decision point={2}", this.rawBodyFormat, this.noBody, this.bodyFormatDecision); }
public PropertyError(PropertyDefinition propertyDefinition, PropertyErrorCode error, string errorDescription) { this.propertyDefinition = propertyDefinition; this.error = error; this.errorDescription = errorDescription; }
public PropertyError(PropertyDefinition propertyDefinition, PropertyErrorCode error) : this(propertyDefinition, error, string.Empty) { }
public RegistrationPropertyError(PropertyDefinition propDef, PropertyErrorCode errorCode) { this.PropertyDefinition = propDef; this.ErrorCode = errorCode; this.Exception = null; }
public static bool Has(this IEnumerable <PropertyError> errors, PropertyErrorCode code) { return(errors.FirstOrDefault(e => e.Code == code) != null); }
public static bool Has(this IEnumerable<PropertyError> errors, PropertyErrorCode code) { return errors.FirstOrDefault(e => e.Code == code) != null; }
internal virtual FolderSaveResult SaveFolderPropertyBag(bool needVersionCheck) { base.CheckDisposed("SaveFolderPropertyBag"); base.BindToMapiPropertyBag(); LocalizedException ex = null; List <PropertyError> list = new List <PropertyError>(); try { if (needVersionCheck) { this.SaveFlags |= PropertyBagSaveFlags.SaveFolderPropertyBagConditional; } else { this.SaveFlags &= ~PropertyBagSaveFlags.SaveFolderPropertyBagConditional; } base.MapiPropertyBag.SaveFlags = this.SaveFlags; list.AddRange(base.FlushSetProperties()); } catch (FolderSaveConditionViolationException ex2) { list.AddRange(this.ConvertSetPropsToErrors(PropertyErrorCode.FolderHasChanged, ServerStrings.ExFolderSetPropsFailed(ex2.ToString()))); return(new FolderSaveResult(OperationResult.Failed, ex2, list.ToArray())); } catch (StoragePermanentException ex3) { ex = ex3; } catch (StorageTransientException ex4) { ex = ex4; } finally { if (ex != null) { ExTraceGlobals.StorageTracer.TraceDebug <LocalizedException>((long)this.GetHashCode(), "FolderPropertyBag::SaveFolderPropertyBag. Exception caught while setting properties. Exception = {0}.", ex); PropertyErrorCode errorCode = (ex is StorageTransientException) ? PropertyErrorCode.TransientMapiCallFailed : PropertyErrorCode.MapiCallFailed; if (ex is ObjectExistedException && base.MemoryPropertyBag.ChangeList.Contains(InternalSchema.DisplayName)) { errorCode = PropertyErrorCode.FolderNameConflict; } list.AddRange(this.ConvertSetPropsToErrors(errorCode, ServerStrings.ExFolderSetPropsFailed(ex.ToString()))); } } LocalizedException ex5 = null; try { list.AddRange(base.FlushDeleteProperties()); } catch (StoragePermanentException ex6) { ex5 = ex6; } catch (StorageTransientException ex7) { ex5 = ex7; } finally { if (ex5 != null) { ExTraceGlobals.StorageTracer.TraceDebug <LocalizedException>((long)this.GetHashCode(), "FolderPropertyBag::SaveFolderPropertyBag. Exception caught while deleting properties. Exception = {0}.", ex5); PropertyErrorCode error = (ex5 is StorageTransientException) ? PropertyErrorCode.TransientMapiCallFailed : PropertyErrorCode.MapiCallFailed; foreach (PropertyDefinition propertyDefinition in base.MemoryPropertyBag.DeleteList) { list.Add(new PropertyError(propertyDefinition, error, ServerStrings.ExFolderDeletePropsFailed(ex5.ToString()))); } } } try { base.MapiPropertyBag.SaveChanges(false); } catch (StoragePermanentException arg) { ExTraceGlobals.StorageTracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "FolderPropertyBag::SaveFolderPropertyBag. Exception caught when calling MapiFolder.SaveChanges. Exception = {0}.", arg); if (this.Session != null && this.Session.IsMoveUser) { throw; } } catch (StorageTransientException arg2) { ExTraceGlobals.StorageTracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "FolderPropertyBag::SaveFolderPropertyBag. Exception caught when calling MapiFolder.SaveChanges. Exception = {0}.", arg2); if (this.Session != null && this.Session.IsMoveUser) { throw; } } this.Clear(); if (list.Count == 0) { return(FolderPropertyBag.SuccessfulSave); } return(new FolderSaveResult(OperationResult.PartiallySucceeded, ex5 ?? ex, list.ToArray())); }