private static object GetMapiValueFromValue(StoreSession session, ExTimeZone timeZone, object value) { Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(timeZone, "timeZone"); if (value is PropertyError) { throw new ArgumentException(string.Format("We should never need to translate a PropertyError into mapi.net, because it makes no sense to set an error. PropertyError found = {0}.", value)); } QueryFilter queryFilter = value as QueryFilter; if (queryFilter != null) { return(FilterRestrictionConverter.CreateRestriction(session, timeZone, session.Mailbox.MapiStore, queryFilter)); } RuleAction[] array = value as RuleAction[]; if (array != null) { RuleAction[] array2 = new RuleAction[array.Length]; for (int i = 0; i < array2.Length; i++) { array2[i] = RuleActionConverter.ConvertRuleAction(session, timeZone, array[i]); } return(array2); } return(ExTimeZoneHelperForMigrationOnly.ToLegacyUtcIfDateTime(timeZone, value)); }
private void WriteTnefWriterPropertyValue(TnefPropertyTag propertyTag, object propertyValue) { TnefPropertyType tnefType = propertyTag.TnefType; if (tnefType == TnefPropertyType.AppTime || tnefType == (TnefPropertyType)4103) { DateTime dateTime = (DateTime)Util.Date1601Utc.ToUtc(); try { dateTime = ConvertUtils.GetDateTimeFromOADate((double)propertyValue); } catch (ArgumentException arg) { StorageGlobals.ContextTraceError <double, ArgumentException>(ExTraceGlobals.CcOutboundTnefTracer, "TnefContentWriter::WriteTnefWriterPropertyValue: ArgumentException processing date {0}, {1}.", (double)propertyValue, arg); } propertyValue = dateTime; } propertyValue = ExTimeZoneHelperForMigrationOnly.ToLegacyUtcIfDateTime(propertyValue); if (propertyValue is DateTime) { DateTime dateTime2 = (DateTime)propertyValue; if ((ExDateTime)dateTime2 < Util.Date1601Utc) { propertyValue = (DateTime)Util.Date1601Utc; } } this.tnefWriter.WritePropertyValue(propertyValue); }
private long WriteAttachmentProperties(Attachment attachment) { long result = 0L; this.tnefWriter.StartAttribute(TnefAttributeTag.Attachment, TnefAttributeLevel.Attachment); foreach (NativeStorePropertyDefinition nativeStorePropertyDefinition in attachment.AllNativeProperties) { if (nativeStorePropertyDefinition.Equals(InternalSchema.AttachDataObj)) { result = this.WriteAttachDataObj(attachment); } else if (!nativeStorePropertyDefinition.Equals(InternalSchema.AttachDataBin) && this.propertyChecker.IsAttachmentPropertyWritable(nativeStorePropertyDefinition)) { object obj = attachment.TryGetProperty(nativeStorePropertyDefinition); PropertyError propertyError = obj as PropertyError; if (propertyError != null && PropertyError.IsPropertyValueTooBig(propertyError)) { this.WritePropertyStreamData(attachment.PropertyBag, nativeStorePropertyDefinition); } else if (propertyError == null) { obj = ExTimeZoneHelperForMigrationOnly.ToLegacyUtcIfDateTime(obj); this.tnefWriter.WriteProperty(nativeStorePropertyDefinition, obj); } } } ItemAttachment itemAttachment = attachment as ItemAttachment; if (itemAttachment != null) { result = this.WriteAttachedItem(itemAttachment); } return(result); }
private void WriteProperty(NativeStorePropertyDefinition property, object value) { value = ExTimeZoneHelperForMigrationOnly.ToLegacyUtcIfDateTime(value); switch (property.SpecifiedWith) { case PropertyTypeSpecifier.PropertyTag: { PropertyTagPropertyDefinition propertyTagPropertyDefinition = (PropertyTagPropertyDefinition)property; TnefPropertyTag propertyTag = (int)propertyTagPropertyDefinition.PropertyTag; this.PropertyWriter.WriteProperty(propertyTag, value); return; } case PropertyTypeSpecifier.GuidString: { GuidNamePropertyDefinition guidNamePropertyDefinition = (GuidNamePropertyDefinition)property; TnefPropertyType propertyType = (TnefPropertyType)guidNamePropertyDefinition.MapiPropertyType; this.PropertyWriter.WriteProperty(guidNamePropertyDefinition.Guid, guidNamePropertyDefinition.PropertyName, propertyType, value); return; } case PropertyTypeSpecifier.GuidId: { GuidIdPropertyDefinition guidIdPropertyDefinition = (GuidIdPropertyDefinition)property; TnefPropertyType propertyType2 = (TnefPropertyType)guidIdPropertyDefinition.MapiPropertyType; this.PropertyWriter.WriteProperty(guidIdPropertyDefinition.Guid, guidIdPropertyDefinition.Id, propertyType2, value); return; } default: throw new InvalidOperationException(string.Format("Invalid native property specifier: {0}", property.SpecifiedWith)); } }
private bool WriteRecipientProperty(ConversionRecipientEntry recipient, NativeStorePropertyDefinition property) { object obj = recipient.TryGetProperty(property); if (!PropertyError.IsPropertyError(obj)) { obj = ExTimeZoneHelperForMigrationOnly.ToLegacyUtcIfDateTime(obj); this.tnefWriter.WriteProperty(property, obj); return(true); } return(false); }