Ejemplo n.º 1
0
        void SaveEvidence(
            ITransmissionResponse transmissionResponse,
            String suffix,
            byte[] supplier,
            DirectoryInfo evidencePath)
        {
            String fileName = FileUtils.FilterString(transmissionResponse.GetTransmissionIdentifier().ToString())
                              + suffix;
            FileInfo evidenceFile = new FileInfo(Path.Combine(evidencePath.FullName, fileName));

            File.WriteAllBytes(evidenceFile.FullName, supplier);
            Log.InfoFormat("Evidence written to '{0}'.", evidenceFile.FullName);
        }
Ejemplo n.º 2
0
        public void Persist(
            ITransmissionRequest transmissionRequest,
            ITransmissionResponse transmissionResponse,
            Trace root)
        {
            Trace span = root.Child();

            span.Record(Annotations.ServiceName("persist statistics"));
            span.Record(Annotations.ClientSend());
            try
            {
                RawStatisticsBuilder builder = new RawStatisticsBuilder()
                                               .AccessPointIdentifier(this.ourAccessPointIdentifier).Direction(Direction.OUT)
                                               .DocumentType(transmissionResponse.GetHeader().DocumentType)
                                               .Sender(transmissionResponse.GetHeader().Sender)
                                               .Receiver(transmissionResponse.GetHeader().Receiver)
                                               .Profile(transmissionResponse.GetHeader().Process)
                                               .Date(transmissionResponse.GetTimestamp()); // Time stamp of reception of the receipt

                // If we know the CN name of the destination AP, supply that
                // as the channel id otherwise use the protocol name
                if (transmissionRequest.GetEndpoint().Certificate != null)
                {
                    String accessPointIdentifierValue =
                        CertificateUtils.ExtractCommonName(transmissionRequest.GetEndpoint().Certificate);
                    builder.Channel(new ChannelId(accessPointIdentifierValue));
                }
                else
                {
                    String protocolName = transmissionRequest.GetEndpoint().TransportProfile.Identifier;
                    builder.Channel(new ChannelId(protocolName));
                }

                DefaultRawStatistics rawStatistics = builder.Build();
                this.rawStatisticsRepository.Persist(rawStatistics);
            }
            catch (Exception ex)
            {
                span.Record(Annotations.Tag("exception", ex.Message));
                Logger.Error($"Persisting DefaultRawStatistics about oubound transmission failed : {ex.Message}", ex);
            }
            finally
            {
                span.Record(Annotations.ClientRecv());
            }
        }
Ejemplo n.º 3
0
        protected ITransmissionResponse PerformTransmission(
            DirectoryInfo evidencePath,
            ITransmitter transmitter,
            ITransmissionRequest transmissionRequest,
            Trace root)
        {
            Trace span = root.Child();

            span.Record(Annotations.ServiceName("transmission"));
            span.Record(Annotations.ClientSend());
            try
            {
                // ... and performs the transmission
                Stopwatch watch = new Stopwatch();
                watch.Start();
                // long start = System.DateTime.Now;
                ITransmissionResponse transmissionResponse = transmitter.Transmit(transmissionRequest, span);
                watch.Stop();

                long durationInMs = watch.ElapsedMilliseconds; // System.DateTime.Now - start;

                Log.Debug(
                    String.Format(
                        "Message using messageId {0} sent to {1} using {2} was assigned transmissionId {3} took {4}ms\n",
                        transmissionResponse.GetHeader().Identifier.Identifier,
                        transmissionResponse.GetEndpoint().Address,
                        transmissionResponse.GetProtocol().Identifier,
                        transmissionResponse.GetTransmissionIdentifier(),
                        durationInMs));

                this.SaveEvidence(transmissionResponse, evidencePath, span);

                return(transmissionResponse);
            }
            finally
            {
                span.Record(Annotations.ClientRecv());
            }
        }
Ejemplo n.º 4
0
        protected void SaveEvidence(
            ITransmissionResponse transmissionResponse,
            DirectoryInfo evidencePath,
            Trace root)
        {
            Trace span = Trace.Create();

            span.Record(Annotations.ServiceName("save evidence"));
            span.Record(Annotations.ClientSend());
            try
            {
                this.SaveEvidence(
                    transmissionResponse,
                    "-as2-mdn.txt",
#pragma warning disable 612
                    transmissionResponse.GetNativeEvidenceBytes(),
#pragma warning restore 612
                    evidencePath);
            }
            finally
            {
                span.Record(Annotations.ClientRecv());
            }
        }
Ejemplo n.º 5
0
 public void Persist(ITransmissionRequest transmissionRequest,
                     ITransmissionResponse transmissionResponse, Trace root)
 {
     // No action.
 }