Пример #1
0
        /**
         * Constructs the attachment from a string containing the serialised XML of an intact
         * distribution envelope.
         */
        public ITKDistributionEnvelopeAttachment(string a)
        {
            string d = stripMimeHeaders(a);
            DistributionEnvelopeHelper deh = DistributionEnvelopeHelper.getInstance();

            distributionEnvelope = deh.getDistributionEnvelope(d);
        }
Пример #2
0
        /**
         * Implementation of the interface' "handle()" method. Determines the
         * file name and tries to write it. Note that this doesn't return any
         * ITK response because formally such a response requires a router. Providing
         * an ITK router here would put a dependency on the ITK code, in the TMS
         * adapter. An implementation that does do ITK responses will be found in
         * the router package.
         */
        public void handle(DistributionEnvelope d)
        {
            StringBuilder sb = new StringBuilder(spoolDirectory);

            sb.Append("\\");
            sb.Append(getLastServiceURIElement(d.getService()));
            sb.Append("_");
            sb.Append(getFileSafeMessageID(d.getTrackingId()));
            sb.Append(".message");
            string filename = sb.ToString();

            try
            {
                using (FileStream fs = new FileStream(filename, FileMode.Create))
                {
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        d.parsePayloads();
                        sw.Write(d.getEnvelope());
                        sw.Flush();
                        sw.Close();
                    }
                }
            }
            catch (Exception e)
            {
                EventLog ev = new EventLog("Application");
                ev.Source = LOGSOURCE;
                StringBuilder sbe = new StringBuilder("Failed to save DistributionEnvelope ");
                sbe.Append(d.getTrackingId());
                sbe.Append(" service ");
                sbe.Append(d.getService());
                sbe.Append(" from ");
                sbe.Append(d.getSender().getUri());
                sbe.Append(". Reason: ");
                sbe.Append(e.ToString());
                ev.WriteEntry(sbe.ToString(), EventLogEntryType.Error);
            }
        }
Пример #3
0
        public void handle(Sendable s)
        {
            EbXmlMessage ebxml = (EbXmlMessage)s;
            ITKDistributionEnvelopeAttachment a = (ITKDistributionEnvelopeAttachment)ebxml.Attachments[ITKATTACHMENT];
            DistributionEnvelope         d      = a.DistributionEnvelope;
            IDistributionEnvelopeHandler h      = null;

            try
            {
                h = handlers[d.getService()];
            }
            catch (KeyNotFoundException)
            {
                EventLog logger = new EventLog("Application");
                logger.Source = LOGSOURCE;
                StringBuilder sb = new StringBuilder("No explicit handler found for ");
                sb.Append(d.getService());
                sb.Append(" using default DefaultFileSaveDistributionEnvelopeHandler instead");
                logger.WriteEntry(sb.ToString(), EventLogEntryType.Warning);
                h = new DefaultFileSaveDistributionEnvelopeHandler();
            }
            h.handle(d);
        }
Пример #4
0
 /**
  * Constructs the attachment from an existing DistributionEnvelope instance.
  */
 public ITKDistributionEnvelopeAttachment(DistributionEnvelope d)
 {
     description          = DEFAULT_DESCRIPTION;
     distributionEnvelope = d;
     mimetype             = MIME_TYPE;
 }