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 static void OnNewConverterCreatedCallback(IComWorker <IOleConverter> converterProcess, object requestParameters) { IOleConverter worker = converterProcess.Worker; uint num = 0U; string conversionsDirectory = OleConverter.GetConversionsDirectory(true); if (conversionsDirectory == null) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcOleTracer, "OleConverter::OnNewConverterCreatedCallback: conversions directory full or inaccessible."); throw new OleConversionFailedException(ServerStrings.OleConversionFailed); } int num2; worker.ConfigureConverter(out num2, 4194304U, 262144U, conversionsDirectory, out num); if (num2 != 0) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcOleTracer, "OleConverter::OnNewConverterCreatedCallback: failed to configure converter."); throw new OleConversionFailedException(ServerStrings.OleConversionFailed, new COMException("HRESULT =", num2)); } if (num != (uint)converterProcess.ProcessId) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcOleTracer, "OleConverter::OnNewConverterCreatedCallback: process id mismatch."); throw new OleConversionFailedException(ServerStrings.OleConversionInitError(Process.GetCurrentProcess().ProcessName, converterProcess.ProcessId, (int)num)); } }
protected override object ReadValue() { if (this.IsLargeValue()) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundTnefTracer, "InboundTnefConverter::ReadValue: large property value"); throw new ConversionFailedException(ConversionFailureReason.CorruptContent); } if (this.PropertyReader.IsMultiValuedProperty) { Type elementType = InternalSchema.ClrTypeFromPropTagType(ConvertUtils.GetPropertyBaseType(this.PropertyReader.PropertyTag)); List <object> list = new List <object>(); while (this.PropertyReader.ReadNextValue()) { if (this.PropertyReader.IsLargeValue) { throw new ConversionFailedException(ConversionFailureReason.CorruptContent, ServerStrings.LargeMultivaluedPropertiesNotSupportedInTNEF, null); } object obj = this.ReadSingleValue(); if (obj == null) { throw new ConversionFailedException(ConversionFailureReason.CorruptContent, ServerStrings.InvalidTnef, null); } list.Add(obj); } Array array = Array.CreateInstance(elementType, list.Count); for (int i = 0; i < array.Length; i++) { array.SetValue(list[i], i); } return(array); } return(this.ReadSingleValue()); }
protected override Stream OpenValueReadStream(out int skipTrailingNulls) { TnefPropertyType tnefType = this.PropertyReader.PropertyTag.TnefType; TnefPropertyType tnefPropertyType = tnefType; switch (tnefPropertyType) { case TnefPropertyType.String8: { skipTrailingNulls = 1; TextToText textToText = new TextToText(TextToTextConversionMode.ConvertCodePageOnly); textToText.InputEncoding = this.GetString8Encoding(); textToText.OutputEncoding = ConvertUtils.UnicodeEncoding; return(new ConverterStream(this.PropertyReader.GetRawValueReadStream(), textToText, ConverterStreamAccess.Read)); } case TnefPropertyType.Unicode: skipTrailingNulls = 2; return(this.PropertyReader.GetRawValueReadStream()); default: if (tnefPropertyType == TnefPropertyType.Binary) { skipTrailingNulls = 0; return(this.PropertyReader.GetRawValueReadStream()); } StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundTnefTracer, "InboundTnefConverter::StreamLargeProperty: only supports binary and string properties."); throw new ConversionFailedException(ConversionFailureReason.CorruptContent); } }
private static Stream CreateResultStream(object result) { string text = result as string; if (text != null) { try { return(new OleConverter.ConversionResultFileStream(text)); } catch (IOException arg) { OleConverter.DeleteTempFile(text); StorageGlobals.ContextTraceError <IOException>(ExTraceGlobals.CcOleTracer, "OleConverter::CreateResultStream: IOException caught. Exception:\n {0}", arg); throw new OleConversionFailedException(ServerStrings.OleConversionResultFailed); } } byte[] array = result as byte[]; if (array != null) { return(new MemoryStream(array)); } StorageGlobals.ContextTraceError <Type>(ExTraceGlobals.CcOleTracer, "OleConverter::CreateResultStream: result type is invalid, {0}.", result.GetType()); throw new OleConversionFailedException(ServerStrings.OleConversionInvalidResultType); }
private static string SaveStreamToTempFile(Stream stream) { StringBuilder stringBuilder = new StringBuilder(256); string conversionsDirectory = OleConverter.GetConversionsDirectory(true); if (NativeMethods.GetTempFileName(conversionsDirectory, "ole", 0U, stringBuilder) == 0) { StorageGlobals.ContextTraceError <string, int>(ExTraceGlobals.CcOleTracer, "OleConverter::SaveStreamToTempFile: failed to create temp file name, directory = {0}. Error {1}", conversionsDirectory, Marshal.GetLastWin32Error()); throw new OleConversionFailedException(ServerStrings.OleConversionPrepareFailed); } try { using (FileStream fileStream = new FileStream(stringBuilder.ToString(), FileMode.OpenOrCreate, FileAccess.Write)) { Util.StreamHandler.CopyStreamData(stream, fileStream); fileStream.Close(); } } catch (IOException arg) { OleConverter.DeleteTempFile(stringBuilder.ToString()); StorageGlobals.ContextTraceError <IOException>(ExTraceGlobals.CcOleTracer, "OleConverter::SaveStreamToTempFile: IOException caught. Exception:\n {0}", arg); throw new OleConversionFailedException(ServerStrings.OleConversionPrepareFailed); } return(stringBuilder.ToString()); }
internal void CountRecipient() { if (this.enforceLimits && this.recipientCount >= this.limits.MaxMimeRecipients) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcGenericTracer, "ConversionLimitsTracker::CountRecipient: maximum recipient count exceeded."); throw new ConversionFailedException(ConversionFailureReason.ExceedsLimit, ServerStrings.ConversionMaxRecipientExceeded(this.limits.MaxMimeRecipients), null); } this.recipientCount++; }
internal void StartEmbeddedMessage() { if (this.enforceLimits && this.depth >= this.limits.MaxEmbeddedMessageDepth) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcGenericTracer, "ConversionLimitsTracker::StartEmbeddedMessage: maximum depth exceeded."); throw new ConversionFailedException(ConversionFailureReason.ExceedsLimit, ServerStrings.ConversionMaxEmbeddedDepthExceeded(this.limits.MaxEmbeddedMessageDepth), null); } this.depth++; }
private void CountMessagePart() { if (this.enforceLimits && this.partCount >= this.limits.MaxBodyPartsTotal) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcGenericTracer, "ConversionLimitsTracker::CountBodyPart: maximum body part count exceeded."); throw new ConversionFailedException(ConversionFailureReason.ExceedsLimit, ServerStrings.ConversionMaxBodyPartsExceeded(this.limits.MaxBodyPartsTotal), null); } this.partCount++; }
protected override object ReadValue() { if (this.IsLargeValue()) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundTnefTracer, "InboundMsgConverter::ReadValue: large property value"); throw new ConversionFailedException(ConversionFailureReason.CorruptContent); } return(ExTimeZoneHelperForMigrationOnly.ToExDateTimeIfObjectIsDateTime(this.PropertyReader.ReadValue())); }
public ImapItemConverter(Item itemIn, OutboundConversionOptions options) { StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::ctor."); using (DisposeGuard disposeGuard = this.Guard()) { Util.ThrowOnNullArgument(itemIn, "itemIn"); Util.ThrowOnNullArgument(options, "options"); Util.ThrowOnNullOrEmptyArgument(options.ImceaEncapsulationDomain, "options.ImceaEncapsulationDomain"); if (!ItemConversion.IsItemClassConvertibleToMime(itemIn.ClassName)) { StorageGlobals.ContextTraceError <string>(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::CheckItemType: wrong item type, {0}", itemIn.ClassName); throw new WrongObjectTypeException(ServerStrings.ConversionInvalidItemType(itemIn.ClassName)); } this.itemIn = itemIn; this.options = options; using (StorageGlobals.SetTraceContext(this.options)) { using (StorageGlobals.SetTraceContext(this.itemIn)) { if (this.options.GenerateMimeSkeleton) { PropertyError propertyError = this.itemIn.TryGetProperty(InternalSchema.MimeSkeleton) as PropertyError; if (propertyError != null && propertyError.PropertyErrorCode == PropertyErrorCode.NotFound) { if (this.itemIn.IsReadOnly) { this.itemIn.OpenAsReadWrite(); } this.itemNeedsSave = true; using (Stream stream = this.itemIn.OpenPropertyStream(InternalSchema.MimeSkeleton, PropertyOpenMode.Create)) { using (Stream stream2 = new MimeStreamWriter.MimeTextStream(null)) { using (ItemToMimeConverter itemToMimeConverter = new ItemToMimeConverter(itemIn, options, ConverterFlags.GenerateSkeleton)) { using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter(stream2, stream, itemToMimeConverter.GetItemMimeEncodingOptions(this.options), MimeStreamWriter.Flags.ForceMime)) { ConversionLimitsTracker limits = new ConversionLimitsTracker(this.options.Limits); itemToMimeConverter.ConvertItemToMime(mimeStreamWriter, limits); } } } } } } ItemToMimeConverter itemToMimeConverter2 = new ItemToMimeConverter(itemIn, options, ConverterFlags.None); this.mimeProvider = IImapMimeProvider.CreateInstance(itemToMimeConverter2); this.itemEncodingOptions = itemToMimeConverter2.GetItemMimeEncodingOptions(this.options); } } disposeGuard.Success(); } }
internal void EndAttachment() { this.CheckDisposed("EndAttachment"); if (this.attachment == null) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundTnefTracer, "InboundMessageWriter::EndAttachment: the attachment is null."); throw new ConversionFailedException(ConversionFailureReason.CorruptContent, null); } this.attachment.SaveAttachment(); this.attachment.Dispose(); this.attachment = null; this.componentType = ConversionComponentType.Message; }
public void PromoteProperty(AbstractInboundConverter converter, NativeStorePropertyDefinition property) { if (converter.CurrentComponentType == this.expectedComponentType) { converter.PromoteProperty(this.substituteProperty, false); return; } StorageGlobals.ContextTraceError <NativeStorePropertyDefinition, ConversionComponentType>(ExTraceGlobals.CcInboundTnefTracer, "SmartPropertyPromotionRule.PromoteProperty {0}, wrong component type {1}", property, converter.CurrentComponentType); if (this.promoteForOtherComponentTypes) { converter.PromoteProperty(property, false); } }
private static void InitializeWriter(TnefWriter writer, Charset charset) { writer.WriteTnefVersion(); try { writer.WriteOemCodePage(charset.CodePage); } catch (ArgumentException innerException) { StorageGlobals.ContextTraceError <int>(ExTraceGlobals.CcOutboundTnefTracer, "TnefContentWriter::InitializeWriter: invalid codepage, {0}.", charset.CodePage); throw new ConversionFailedException(ConversionFailureReason.CorruptContent, innerException); } }
private void ConvertRecipient(int recipientIndex) { try { this.reader.OpenRecipient(recipientIndex); base.MessageWriter.StartNewRecipient(); this.PromotePropertyList(); base.MessageWriter.EndRecipient(); } catch (MsgStorageNotFoundException) { StorageGlobals.ContextTraceError <int>(ExTraceGlobals.CcInboundTnefTracer, "InboundMsgConverter::RecipientNotFound (index = {0})", recipientIndex); } }
private void ConvertAttachment(int attachmentIndex) { try { this.reader.OpenAttachment(attachmentIndex); base.MessageWriter.StartNewAttachment(this.reader.PropertyReader.AttachMethod); this.PromotePropertyList(); base.MessageWriter.EndAttachment(); } catch (MsgStorageNotFoundException) { StorageGlobals.ContextTraceError <int>(ExTraceGlobals.CcInboundTnefTracer, "InboundMsgConverter::AttachmentNotFound (index = {0})", attachmentIndex); } }
internal Stream OpenPropertyStream(StorePropertyDefinition property) { this.CheckDisposed("OpenPropertyStream"); switch (this.componentType) { case ConversionComponentType.Message: return(this.OpenMessagePropertyStream(property)); case ConversionComponentType.FileAttachment: return(this.OpenAttachmentPropertyStream(property)); } StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundTnefTracer, "MessageWriter.OpenPropertyStream: can't open stream on the component"); throw new ConversionFailedException(ConversionFailureReason.CorruptContent); }
private IImapMimeProvider GetAttachedItemConverter(ref MimePartInfo part, ref Item item, ref EncodingOptions itemEncodingOptions, List <IDisposable> disposeList) { if (part.ContentType != MimePartContentType.ItemAttachment) { return(null); } IImapMimeProvider imapMimeProvider; if (part.SmimePart == null) { Attachment attachment = item.AttachmentCollection.Open(part.AttachmentId, InternalSchema.ContentConversionProperties); disposeList.Add(attachment); ItemAttachment itemAttachment = attachment as ItemAttachment; if (itemAttachment == null) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::GetAttachedItemConverter: attachment is not an item."); ExAssert.RetailAssert(false, "ImapItemConverter::GetAttachedItemConverter: attachment is not an item."); return(null); } item = ConvertUtils.OpenAttachedItem(itemAttachment); if (item == null) { return(null); } disposeList.Add(item); ItemToMimeConverter itemToMimeConverter = new ItemToMimeConverter(item, this.options, ConverterFlags.IsEmbeddedMessage); imapMimeProvider = IImapMimeProvider.CreateInstance(itemToMimeConverter); disposeList.Add(imapMimeProvider); itemEncodingOptions = itemToMimeConverter.GetItemMimeEncodingOptions(this.options); if (part.AttachedItemStructure != null) { itemToMimeConverter.SetSkeletonAndSmimeDoc(part.AttachedItemStructure.Skeleton, part.AttachedItemStructure.SmimeDocument); } } else { imapMimeProvider = IImapMimeProvider.CreateInstance((MimePart)part.SmimePart.FirstChild, part.SmimeDocument); disposeList.Add(imapMimeProvider); itemEncodingOptions = this.itemEncodingOptions; } if (part.AttachedItemStructure == null) { part.AttachedItemStructure = imapMimeProvider.CalculateMimeStructure(Charset.GetCharset(itemEncodingOptions.CharsetName)); } part = part.AttachedItemStructure; return(imapMimeProvider); }
internal void EndRecipient() { this.CheckDisposed("EndRecipient"); if (this.currentRecipient != null) { if (this.currentRecipient.Participant != null && ConvertUtils.IsRecipientTransmittable(this.currentRecipient.RecipientItemType)) { this.conversionAddressCache.AddRecipient(this.currentRecipient); } else { StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundTnefTracer, "Tnef didn't have enough information to construct a Participant"); } this.currentRecipient = null; } this.componentType = ConversionComponentType.Message; }
private object ReadSingleValue() { TnefPropertyType tnefType = this.PropertyReader.PropertyTag.TnefType; if (tnefType == TnefPropertyType.AppTime || tnefType == (TnefPropertyType)4103) { double num = 0.0; DateTime dateTime = this.PropertyReader.ReadValueAsDateTime(); try { num = ConvertUtils.GetOADate(dateTime); } catch (OverflowException arg) { StorageGlobals.ContextTraceError <DateTime, OverflowException>(ExTraceGlobals.CcInboundTnefTracer, "InboundTnefConverter::ReadPropertyReaderValue: OverflowException processing date {0}, {1}.", dateTime, arg); } return(num); } return(ExTimeZoneHelperForMigrationOnly.ToExDateTimeIfObjectIsDateTime(this.PropertyReader.ReadValue())); }
internal static void CallCts(Trace tracer, string methodName, LocalizedString exceptionString, ConvertUtils.CtsCall ctsCall) { try { ctsCall(); } catch (ExchangeDataException ex) { StorageGlobals.ContextTraceError <string, ExchangeDataException>(tracer, "{0}: ExchangeDataException, {1}", methodName, ex); throw new ConversionFailedException(ConversionFailureReason.CorruptContent, exceptionString, ex); } catch (IOException ex2) { StorageGlobals.ContextTraceError <string, IOException>(tracer, "{0}: IOException, {1}", methodName, ex2); if (StorageGlobals.IsDiskFullException(ex2)) { throw new StorageTransientException(exceptionString, ex2); } throw new StoragePermanentException(exceptionString, ex2); } }
protected void SetResolvedParticipants(ConversionAddressCollection.ParticipantResolutionList participantList) { foreach (IConversionParticipantList conversionParticipantList in this.participantLists) { int count = conversionParticipantList.Count; for (int num = 0; num != count; num++) { Participant nextResolvedParticipant = participantList.GetNextResolvedParticipant(); if (nextResolvedParticipant != null) { if (nextResolvedParticipant.ValidationStatus == ParticipantValidationStatus.NoError) { conversionParticipantList[num] = nextResolvedParticipant; } else { StorageGlobals.ContextTraceError <Participant, Participant>(ExTraceGlobals.CcGenericTracer, "The resolved Participant is invalid. The source Participant will be used instead\r\n\tSource: {0}\r\n\tResolved: {1}", conversionParticipantList[num], nextResolvedParticipant); } } } } }
private void ResetAttachMethod(int newAttachMethod) { this.CheckDisposed("TransformAttachment"); if (this.attachMethod == newAttachMethod) { return; } if (this.attachMethod == 5 || (this.attachMethod != null && newAttachMethod == 5)) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundMimeTracer, "MessageAttachmentWriter::TransformAttachment: wrong attachment transformation."); throw new ConversionFailedException(ConversionFailureReason.CorruptContent, null); } IDirectPropertyBag propertyBag = this.coreAttachment.PropertyBag; this.attachMethod = new int?(newAttachMethod); propertyBag.SetValue(InternalSchema.AttachMethod, newAttachMethod); if (newAttachMethod == 1 && this.data != null) { propertyBag.SetValue(InternalSchema.AttachDataBin, this.data); this.data = null; } }
private static object CreateOleObjectData(Stream oleDataStream, bool canCacheInMemory) { if (canCacheInMemory && oleDataStream.CanSeek) { long length = oleDataStream.Length; if (length <= 262144L) { byte[] array = new byte[length]; int num; for (int i = 0; i < array.Length; i += num) { num = oleDataStream.Read(array, i, (int)length - i); if (num == 0) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcOleTracer, "OleConverter::CreateOleObjectData: unable to load full stream."); throw new OleConversionFailedException(ServerStrings.OleUnableToReadAttachment); } } return(array); } } return(OleConverter.SaveStreamToTempFile(oleDataStream)); }
protected ConversionAddressCollection.ParticipantResolutionList CreateResolutionList() { ConversionAddressCollection.ParticipantResolutionList participantResolutionList = new ConversionAddressCollection.ParticipantResolutionList(); foreach (IConversionParticipantList conversionParticipantList in this.participantLists) { int count = conversionParticipantList.Count; for (int num = 0; num != count; num++) { Participant participant = null; Participant participant2 = conversionParticipantList[num]; if (conversionParticipantList.IsConversionParticipantAlwaysResolvable(num) || this.CanResolveParticipant(participant2)) { participant = participant2; } if (!this.disableLengthValidation && participant2 != null && (participant2.ValidationStatus == ParticipantValidationStatus.EmailAddressTooBig || participant2.ValidationStatus == ParticipantValidationStatus.RoutingTypeTooBig)) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundMimeTracer, "ConversionAddressCollection::CreateResolutionList: participant validation failed."); throw new ConversionFailedException(ConversionFailureReason.ExceedsLimit); } participantResolutionList.AddParticipantForResolution(participant); } } return(participantResolutionList); }
public void ConvertToImage(Stream outStream, ImageFormat format) { EnumValidator.ThrowIfInvalid <ImageFormat>(format, "format"); using (Stream stream = this.ConvertToBitmap()) { try { using (Image image = Image.FromStream(stream)) { try { switch (format) { case ImageFormat.Jpeg: image.Save(outStream, ImageFormat.Jpeg); break; case ImageFormat.Png: image.Save(outStream, ImageFormat.Png); break; } } catch (ExternalException innerException) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcOleTracer, "OleAttachment::ConvertToImage: result stream is corrupt."); throw new OleConversionFailedException(ServerStrings.OleConversionFailed, innerException); } } } catch (ArgumentException innerException2) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcOleTracer, "OleAttachment::ConvertToImage: result stream is corrupt."); throw new OleConversionFailedException(ServerStrings.OleConversionFailed, innerException2); } } }
protected void PromoteLargeProperty(StorePropertyDefinition property) { NativeStorePropertyDefinition nativeStorePropertyDefinition = property as NativeStorePropertyDefinition; if (nativeStorePropertyDefinition == null) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundTnefTracer, "AbstractInboundConverter::ReadSmallPropertyValue: non-native property"); throw new ConversionFailedException(ConversionFailureReason.CorruptContent); } if (nativeStorePropertyDefinition.MapiPropertyType != PropType.String && nativeStorePropertyDefinition.MapiPropertyType != PropType.Binary) { StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundTnefTracer, "AbstractInboundConverter::ReadSmallPropertyValue: non-streamable property"); throw new ConversionFailedException(ConversionFailureReason.CorruptContent); } int trailingNulls = 0; using (Stream stream = this.OpenValueReadStream(out trailingNulls)) { using (Stream stream2 = this.OpenPropertyStream(property)) { Util.StreamHandler.CopyStreamData(stream, stream2, null, trailingNulls); } } }
private void WriteAttachmentAttributes(Attachment attachment) { this.tnefWriter.StartAttribute(TnefAttributeTag.AttachRenderData, TnefAttributeLevel.Attachment); object obj = attachment.TryGetProperty(InternalSchema.AttachMethod); if (obj is PropertyError) { StorageGlobals.ContextTraceError <string>(ExTraceGlobals.CcOutboundTnefTracer, "ItemToTnefConverter::WriteAttachmentAttributes: unable to get attach method, {0}.", ((PropertyError)obj).PropertyErrorDescription); throw new ConversionFailedException(ConversionFailureReason.CorruptContent); } this.tnefWriter.WriteProperty(TnefPropertyTag.AttachMethod, (int)obj); obj = attachment.TryGetProperty(InternalSchema.RenderingPosition); if (obj is PropertyError) { obj = -1; } this.tnefWriter.WriteProperty(TnefPropertyTag.RenderingPosition, (int)obj); obj = attachment.TryGetProperty(InternalSchema.AttachEncoding); if (!(obj is PropertyError)) { this.tnefWriter.WriteProperty(TnefPropertyTag.AttachEncoding, (byte[])obj); } this.tnefWriter.StartAttribute(TnefAttributeTag.AttachTitle, TnefAttributeLevel.Attachment); this.tnefWriter.WriteProperty(TnefPropertyTag.AttachFilenameA, attachment.DisplayName ?? string.Empty); this.tnefWriter.StartAttribute(TnefAttributeTag.AttachCreateDate, TnefAttributeLevel.Attachment); this.tnefWriter.WriteProperty(TnefPropertyTag.CreationTime, attachment.CreationTime); this.tnefWriter.StartAttribute(TnefAttributeTag.AttachModifyDate, TnefAttributeLevel.Attachment); this.tnefWriter.WriteProperty(TnefPropertyTag.LastModificationTime, attachment.LastModifiedTime); object obj2 = attachment.TryGetProperty(InternalSchema.AttachRendering); if (!(obj2 is PropertyError)) { this.tnefWriter.StartAttribute(TnefAttributeTag.AttachMetaFile, TnefAttributeLevel.Attachment); this.tnefWriter.WriteProperty(TnefPropertyTag.AttachRendering, obj2); } }
public static void GetMapiDsnRecipientStatusCode(string statusString, out MapiDiagnosticCode diagCode, out NdrReasonCode reasonCode, out int statusCode) { diagCode = MapiDiagnosticCode.NoDiagnostic; reasonCode = NdrReasonCode.TransferFailed; EnhancedStatusCode enhancedStatusCode; string[] array; int num; int num2; int num3; if (!EnhancedStatusCode.TryParse(statusString, out enhancedStatusCode) || (array = statusString.Split(new char[] { '.' })).Length != 3 || !int.TryParse(array[0], out num) || !int.TryParse(array[1], out num2) || !int.TryParse(array[2], out num3)) { StorageGlobals.ContextTraceError <string>(ExTraceGlobals.CcInboundMimeTracer, "DsnMdnUtil::GetMapiDsnRecipientStatusCode: incorrect status string, {0}", statusString); throw new ConversionFailedException(ConversionFailureReason.CorruptContent, null); } switch (num2) { case 1: switch (num3) { case 1: diagCode = MapiDiagnosticCode.MailRecipientUnknown; reasonCode = NdrReasonCode.TransferImpossible; goto IL_288; case 2: diagCode = MapiDiagnosticCode.BadDestinationSystemAddress; goto IL_288; case 3: diagCode = MapiDiagnosticCode.MailAddressIncorrect; goto IL_288; case 4: diagCode = MapiDiagnosticCode.OrNameAmbiguous; goto IL_288; case 6: diagCode = MapiDiagnosticCode.MailRecipientMoved; goto IL_288; } diagCode = MapiDiagnosticCode.OrNameUnrecognized; break; case 2: switch (num3) { case 1: diagCode = MapiDiagnosticCode.MailRefused; break; case 2: diagCode = MapiDiagnosticCode.LengthConstraintViolatd; break; case 3: diagCode = MapiDiagnosticCode.LengthConstraintViolatd; break; case 4: diagCode = MapiDiagnosticCode.ExpansionFailed; break; default: diagCode = MapiDiagnosticCode.MailRefused; break; } break; case 3: switch (num3) { case 1: diagCode = MapiDiagnosticCode.MailRefused; break; case 2: break; case 3: diagCode = MapiDiagnosticCode.CriticalFuncUnsupported; break; case 4: diagCode = MapiDiagnosticCode.LengthConstraintViolatd; break; case 5: diagCode = MapiDiagnosticCode.LoopDetected; break; default: diagCode = MapiDiagnosticCode.MailRefused; break; } break; case 4: switch (num3) { case 0: case 4: goto IL_288; case 3: reasonCode = NdrReasonCode.DirectoryOperatnFailed; goto IL_288; case 6: case 8: diagCode = MapiDiagnosticCode.LoopDetected; goto IL_288; case 7: diagCode = MapiDiagnosticCode.MaximumTimeExpired; goto IL_288; } diagCode = MapiDiagnosticCode.MtsCongested; break; case 5: switch (num3) { case 3: diagCode = MapiDiagnosticCode.TooManyRecipients; goto IL_288; case 4: diagCode = MapiDiagnosticCode.ParametersInvalid; goto IL_288; } diagCode = MapiDiagnosticCode.NoBilateralAgreement; break; case 6: switch (num3) { case 1: diagCode = MapiDiagnosticCode.ContentTypeUnsupported; break; case 2: diagCode = MapiDiagnosticCode.ProhibitedToConvert; break; case 3: diagCode = MapiDiagnosticCode.ImpracticalToConvert; break; case 4: diagCode = MapiDiagnosticCode.MultipleInfoLosses; break; case 5: reasonCode = NdrReasonCode.ConversionNotPerformed; break; default: diagCode = MapiDiagnosticCode.ContentTypeUnsupported; break; } break; case 7: switch (num3) { case 1: diagCode = MapiDiagnosticCode.SubmissionProhibited; break; case 2: diagCode = MapiDiagnosticCode.ExpansionProhibited; break; case 3: diagCode = MapiDiagnosticCode.ReassignmentProhibited; break; default: diagCode = MapiDiagnosticCode.SecureMessagingError; break; } break; } IL_288: if (num2 < 0 || num2 > 9) { num2 = 0; } if (num3 < 0 || num3 > 9) { num3 = 0; } statusCode = num * 100 + num2 * 10 + num3; }
internal Stream ConvertToBitmap(Stream oleDataStream) { object obj = null; int num = Interlocked.Increment(ref this.nQueueSize); Stream result; try { try { bool canCacheInMemory = num <= 30; obj = OleConverter.CreateOleObjectData(oleDataStream, canCacheInMemory); OleConverter.ConversionRequestParameters conversionRequestParameters = new OleConverter.ConversionRequestParameters(obj, null); base.ExecuteRequest(conversionRequestParameters); result = OleConverter.CreateResultStream(conversionRequestParameters.ResponseData); } catch (ComInterfaceInitializeException ex) { StorageGlobals.ContextTraceError <ComInterfaceInitializeException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex); throw new OleConversionServerBusyException(ServerStrings.OleConversionFailed, ex); } catch (ComProcessBusyException ex2) { StorageGlobals.ContextTraceError <ComProcessBusyException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex2); throw new OleConversionServerBusyException(ServerStrings.OleConversionFailed, ex2); } catch (ComProcessTimeoutException ex3) { StorageGlobals.ContextTraceError <ComProcessTimeoutException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex3); throw new OleConversionFailedException(ServerStrings.OleConversionFailed, ex3); } catch (ComProcessBeyondMemoryLimitException ex4) { StorageGlobals.ContextTraceError <ComProcessBeyondMemoryLimitException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex4); throw new OleConversionFailedException(ServerStrings.OleConversionFailed, ex4); } catch (COMException ex5) { StorageGlobals.ContextTraceError <COMException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex5); throw new OleConversionFailedException(ServerStrings.OleConversionFailed, ex5); } catch (InvalidComObjectException ex6) { StorageGlobals.ContextTraceError <InvalidComObjectException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex6); throw new OleConversionFailedException(ServerStrings.OleConversionFailed, ex6); } catch (InvalidCastException ex7) { StorageGlobals.ContextTraceError <InvalidCastException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex7); throw new OleConversionFailedException(ServerStrings.OleConversionFailed, ex7); } catch (NoSupportException ex8) { StorageGlobals.ContextTraceError <NoSupportException>(ExTraceGlobals.CcOleTracer, "OleConverter::ConvertToBitmap: ole conversion failed. Exception:\n {0}", ex8); throw new OleConversionFailedException(ServerStrings.OleConversionFailed, ex8); } } catch (StoragePermanentException exc) { OleConverter.SaveFailedConversionData(obj, exc, null); throw; } catch (StorageTransientException exc2) { OleConverter.SaveFailedConversionData(obj, exc2, null); throw; } finally { Interlocked.Decrement(ref this.nQueueSize); if (obj != null) { OleConverter.DestroyOleObjectData(obj); } } return(result); }