コード例 #1
0
        void GenerateMessageBody(
            MailMessage msg,
            WebBaseEventCollection events,
            DateTime lastNotificationUtc,
            int discardedSinceLastNotification,
            int eventsInBuffer,
            int notificationSequence,
            EventNotificationType notificationType,
            int eventsInNotification,
            int eventsRemaining,
            int messagesInNotification,
            int eventsLostDueToMessageLimit,
            int messageSequence,
            out bool fatalError)
        {
            StringWriter writer = new StringWriter(CultureInfo.InstalledUICulture);

            MailEventNotificationInfo info = new MailEventNotificationInfo(
                msg,
                events,
                lastNotificationUtc,
                discardedSinceLastNotification,
                eventsInBuffer,
                notificationSequence,
                notificationType,
                eventsInNotification,
                eventsRemaining,
                messagesInNotification,
                eventsLostDueToMessageLimit,
                messageSequence);

            CallContext.SetData(CurrentEventsName, info);

            try {
                TemplatedMailErrorFormatterGenerator gen = new TemplatedMailErrorFormatterGenerator(events.Count + eventsRemaining, _detailedTemplateErrors);
                HttpServerUtility.ExecuteLocalRequestAndCaptureResponse(_templateUrl, writer, gen);

                fatalError = gen.ErrorFormatterCalled;

                if (fatalError)
                {
                    msg.Subject = HttpUtility.HtmlEncode(SR.GetString(SR.WebEvent_event_email_subject_template_error,
                                                                      notificationSequence.ToString(CultureInfo.InstalledUICulture),
                                                                      messageSequence.ToString(CultureInfo.InstalledUICulture),
                                                                      SubjectPrefix));
                }

                msg.Body       = writer.ToString();
                msg.IsBodyHtml = true;
            }
            finally {
                CallContext.FreeNamedDataSlot(CurrentEventsName);
            }
        }
 private void GenerateMessageBody(MailMessage msg, WebBaseEventCollection events, DateTime lastNotificationUtc, int discardedSinceLastNotification, int eventsInBuffer, int notificationSequence, EventNotificationType notificationType, int eventsInNotification, int eventsRemaining, int messagesInNotification, int eventsLostDueToMessageLimit, int messageSequence, out bool fatalError)
 {
     StringWriter writer = new StringWriter(CultureInfo.InstalledUICulture);
     MailEventNotificationInfo data = new MailEventNotificationInfo(msg, events, lastNotificationUtc, discardedSinceLastNotification, eventsInBuffer, notificationSequence, notificationType, eventsInNotification, eventsRemaining, messagesInNotification, eventsLostDueToMessageLimit, messageSequence);
     CallContext.SetData("_TWCurEvt", data);
     try
     {
         TemplatedMailErrorFormatterGenerator errorFormatterGenerator = new TemplatedMailErrorFormatterGenerator(events.Count + eventsRemaining, this._detailedTemplateErrors);
         HttpServerUtility.ExecuteLocalRequestAndCaptureResponse(this._templateUrl, writer, errorFormatterGenerator);
         fatalError = errorFormatterGenerator.ErrorFormatterCalled;
         if (fatalError)
         {
             msg.Subject = HttpUtility.HtmlEncode(System.Web.SR.GetString("WebEvent_event_email_subject_template_error", new object[] { notificationSequence.ToString(CultureInfo.InstalledUICulture), messageSequence.ToString(CultureInfo.InstalledUICulture), base.SubjectPrefix }));
         }
         msg.Body = writer.ToString();
         msg.IsBodyHtml = true;
     }
     finally
     {
         CallContext.FreeNamedDataSlot("_TWCurEvt");
     }
 }