Esempio n. 1
0
        private static void GenerateDsnBody(MessageItem message, Stream outputStream, DsnHumanReadableWriter dsnWriter, HeaderList headerList, out CultureInfo cultureInfo, out Charset charset)
        {
            message.Load(ReportMessageSchema.Instance.AutoloadProperties);
            MailboxSession          mailboxSession = message.Session as MailboxSession;
            List <DsnRecipientInfo> list           = new List <DsnRecipientInfo>(message.Recipients.Count);
            HashSet <string>        hashSet        = new HashSet <string>();

            foreach (Recipient recipient in message.Recipients)
            {
                list.Add(new DsnRecipientInfo(recipient.Participant.DisplayName, recipient.Participant.EmailAddress, recipient.Participant.RoutingType, DsnMdnUtil.GetMimeDsnRecipientStatusCode(recipient).Value, recipient.GetValueOrDefault <string>(InternalSchema.SupplementaryInfo)));
                string valueOrDefault = recipient.GetValueOrDefault <string>(InternalSchema.RemoteMta);
                if (!string.IsNullOrEmpty(valueOrDefault))
                {
                    hashSet.TryAdd(valueOrDefault);
                }
            }
            StringBuilder stringBuilder = new StringBuilder(hashSet.Count * 20);

            foreach (string value in hashSet)
            {
                stringBuilder.Append(value);
                stringBuilder.Append(", ");
            }
            dsnWriter.CreateDsnHumanReadableBody(outputStream, ReportMessage.GetDsnCultures(mailboxSession, headerList, dsnWriter), message.GetValueOrDefault <string>(InternalSchema.OriginalSubject), list, ReportMessage.GetDsnFlags(message.ClassName), message.GetValueOrDefault <string>(InternalSchema.ReportingMta, string.Empty), (stringBuilder.Length > 0) ? stringBuilder.ToString(0, stringBuilder.Length - ", ".Length) : null, null, headerList, out cultureInfo, out charset);
        }
        private Item BindToItemWithItemClass(StoreObjectId id, ICollection <PropertyDefinition> properties)
        {
            switch (id.ObjectType)
            {
            case StoreObjectType.Message:
                return(MessageItem.Bind(this.folder.Session, id, properties));

            case StoreObjectType.MeetingRequest:
                return(MeetingRequest.Bind(this.folder.Session, id, properties));

            case StoreObjectType.MeetingResponse:
                return(MeetingResponse.Bind(this.folder.Session, id, properties));

            case StoreObjectType.MeetingCancellation:
                return(MeetingCancellation.Bind(this.folder.Session, id, properties));

            case StoreObjectType.Contact:
                return(Contact.Bind(this.folder.Session, id, properties));

            case StoreObjectType.DistributionList:
                return(DistributionList.Bind(this.folder.Session, id, properties));

            case StoreObjectType.Task:
                return(Task.Bind(this.folder.Session, id, true, properties));

            case StoreObjectType.Post:
                return(PostItem.Bind(this.folder.Session, id, properties));

            case StoreObjectType.Report:
                return(ReportMessage.Bind(this.folder.Session, id, properties));
            }
            return(Item.Bind(this.folder.Session, id, properties));
        }
Esempio n. 3
0
 internal static void GenerateReportBody(MessageItem message, Stream outputStream, out CultureInfo cultureInfo, out Charset charset)
 {
     if (ObjectClass.IsDsn(message.ClassName))
     {
         ReportMessage.GenerateDsnBody(message, outputStream, DsnHumanReadableWriter.DefaultDsnHumanReadableWriter, null, out cultureInfo, out charset);
         return;
     }
     ReportMessage.GenerateOldFashionedReportBody(message, outputStream, out cultureInfo, out charset);
 }
Esempio n. 4
0
        public void GenerateReportBody(Stream outputStream, out Charset charset)
        {
            this.CheckDisposed("GenerateReportBody");
            if (outputStream == null)
            {
                throw new ArgumentNullException("outputStream");
            }
            CultureInfo cultureInfo;

            ReportMessage.GenerateReportBody(this, outputStream, out cultureInfo, out charset);
        }
Esempio n. 5
0
        private static LocalizedString GenerateOldFashionedReportBody(MessageItem message, out CultureInfo culture)
        {
            message.Load(ReportMessageSchema.Instance.AutoloadProperties);
            ExDateTime?  valueAsNullable = message.GetValueAsNullable <ExDateTime>(InternalSchema.ReportTime);
            ExTimeZone   exTimeZone      = ExTimeZone.CurrentTimeZone;
            StoreSession session         = message.Session;

            if (session != null)
            {
                exTimeZone = session.ExTimeZone;
            }
            byte[]     valueOrDefault = message.GetValueOrDefault <byte[]>(InternalSchema.TimeZoneDefinitionStart);
            ExTimeZone exTimeZone2;

            if (valueOrDefault != null && O12TimeZoneFormatter.TryParseTruncatedTimeZoneBlob(valueOrDefault, out exTimeZone2))
            {
                exTimeZone = (TimeZoneHelper.PromoteCustomizedTimeZone(exTimeZone2) ?? exTimeZone2);
            }
            culture = ReportMessage.GetMdnCulture(message.CoreItem);
            LocalizedString originalMessageInfo = ReportMessage.GetOriginalMessageInfo(message, exTimeZone, culture);
            LocalizedString result;

            if (ObjectClass.IsReport(message.ClassName, "IPNRN"))
            {
                if (valueAsNullable != null)
                {
                    result = ClientStrings.MdnRead(originalMessageInfo, exTimeZone.ConvertDateTime(valueAsNullable.Value), new LocalizedString(exTimeZone.LocalizableDisplayName.ToString(culture)));
                }
                else
                {
                    result = ClientStrings.MdnReadNoTime(originalMessageInfo);
                }
            }
            else
            {
                if (!ObjectClass.IsReport(message.ClassName, "IPNNRN"))
                {
                    ExTraceGlobals.StorageTracer.TraceDebug((long)message.GetHashCode(), ServerStrings.UnsupportedReportType(message.ClassName));
                    return(new LocalizedString(ServerStrings.UnsupportedReportType(message.ClassName)));
                }
                if (valueAsNullable != null)
                {
                    result = ClientStrings.MdnNotRead(originalMessageInfo, exTimeZone.ConvertDateTime(valueAsNullable.Value), new LocalizedString(exTimeZone.LocalizableDisplayName.ToString(culture)));
                }
                else
                {
                    result = ClientStrings.MdnNotReadNoTime(originalMessageInfo);
                }
            }
            return(result);
        }
Esempio n. 6
0
        internal static Stream GenerateReportBody(MessageItem message, DsnHumanReadableWriter dsnWriter, HeaderList headerList, out CultureInfo cultureInfo, out Charset charset)
        {
            MemoryStream memoryStream = new MemoryStream(ReportMessage.EstimateGeneratedBodySize(message));

            if (ObjectClass.IsDsn(message.ClassName))
            {
                ReportMessage.GenerateDsnBody(message, memoryStream, dsnWriter, headerList, out cultureInfo, out charset);
            }
            else
            {
                ReportMessage.GenerateReportBody(message, memoryStream, out cultureInfo, out charset);
            }
            return(memoryStream);
        }
Esempio n. 7
0
        private static void GenerateOldFashionedReportBody(MessageItem message, Stream outputStream, out CultureInfo cultureInfo, out Charset charset)
        {
            Encoding unicode = Encoding.Unicode;
            string   text    = ReportMessage.GenerateOldFashionedReportBody(message, out cultureInfo).ToString(cultureInfo);
            OutboundCodePageDetector outboundCodePageDetector = new OutboundCodePageDetector();

            outboundCodePageDetector.AddText(text);
            charset = Charset.GetCharset(outboundCodePageDetector.GetCodePage(Culture.GetCulture(cultureInfo.Name), false));
            using (MemoryStream memoryStream = new MemoryStream(unicode.GetBytes(text)))
            {
                new TextToHtml
                {
                    InputEncoding  = unicode,
                    OutputEncoding = charset.GetEncoding()
                }.Convert(memoryStream, outputStream);
            }
        }
Esempio n. 8
0
 internal static void CoreObjectUpdateSubjectPrefix(CoreItem coreItem)
 {
     if (coreItem.Session != null)
     {
         string          valueOrDefault = coreItem.PropertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass);
         LocalizedString localizedString;
         if (DsnMdnUtil.TryGetSubjectPrefix(valueOrDefault, out localizedString))
         {
             CultureInfo formatProvider = coreItem.Session.InternalPreferedCulture;
             if (ObjectClass.IsMdn(valueOrDefault))
             {
                 formatProvider = ReportMessage.GetMdnCulture(coreItem);
             }
             coreItem.PropertyBag[InternalSchema.SubjectPrefix] = localizedString.ToString(formatProvider);
         }
     }
 }
Esempio n. 9
0
        public static MessageItem CreateNotReadNotification(MessageItem originalItem)
        {
            ExDateTime  utcNow      = ExDateTime.UtcNow;
            MessageItem messageItem = MessageItem.CreateInMemory(StoreObjectSchema.ContentConversionProperties);

            messageItem.ClassName = ObjectClass.MakeReportClassName(originalItem.ClassName, "IPNNRN");
            messageItem.SafeSetProperty(InternalSchema.ReportTime, utcNow);
            Participant participant = originalItem.ReadReceiptAddressee;

            if (null == participant)
            {
                if (null != originalItem.Sender)
                {
                    participant = originalItem.Sender;
                }
                else
                {
                    participant = originalItem.From;
                }
            }
            messageItem.Recipients.Add(participant, RecipientItemType.To);
            foreach (KeyValuePair <PropertyDefinition, PropertyDefinition> keyValuePair in RuleMessageUtils.NrnPropertyMap)
            {
                messageItem.SafeSetProperty(keyValuePair.Key, originalItem.TryGetProperty(keyValuePair.Value));
            }
            BodyWriteConfiguration configuration = new BodyWriteConfiguration(BodyFormat.TextHtml, originalItem.Body.RawCharset.Name);
            CultureInfo            formatProvider;

            using (Stream stream = messageItem.Body.OpenWriteStream(configuration))
            {
                Charset charset;
                ReportMessage.GenerateReportBody(messageItem, stream, out formatProvider, out charset);
            }
            messageItem.SafeSetProperty(InternalSchema.Subject, ServerStrings.NotRead.ToString(formatProvider) + originalItem.TryGetProperty(InternalSchema.Subject));
            byte[] parentBytes = originalItem.TryGetProperty(InternalSchema.ConversationIndex) as byte[];
            messageItem.SafeSetProperty(InternalSchema.ConversationIndex, ConversationIndex.CreateFromParent(parentBytes).ToByteArray());
            messageItem.SafeSetProperty(InternalSchema.ConversationTopic, StoreObject.SafePropertyValue(originalItem.TryGetProperty(InternalSchema.ConversationTopic), typeof(string), StoreObject.SafePropertyValue(originalItem.TryGetProperty(InternalSchema.NormalizedSubjectInternal), typeof(string), null)));
            messageItem.SafeSetProperty(InternalSchema.IsReadReceiptRequested, false);
            messageItem.SafeSetProperty(InternalSchema.IsDeliveryReceiptRequested, false);
            messageItem.SafeSetProperty(InternalSchema.IsNonDeliveryReceiptRequested, false);
            messageItem.SafeSetProperty(InternalSchema.NonReceiptReason, 0);
            messageItem.SafeSetProperty(InternalSchema.DiscardReason, 1);
            messageItem.SafeSetProperty(InternalSchema.OriginalDeliveryTime, utcNow);
            return(messageItem);
        }
Esempio n. 10
0
 public new static ReportMessage Bind(StoreSession session, StoreId reportMessageId)
 {
     return(ReportMessage.Bind(session, reportMessageId, null));
 }
 internal override void CoreObjectUpdate(CoreItem coreItem, CoreItemOperation operation)
 {
     base.CoreObjectUpdate(coreItem, operation);
     ReportMessage.CoreObjectUpdateSubjectPrefix(coreItem);
 }