示例#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);
        }
示例#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());
            }
        }