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 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); }