Beispiel #1
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());
            }
        }
Beispiel #2
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());
            }
        }