public void Apply(Operation operation, OperationFilterContext context)
        {
            trace.Record(Annotations.ServiceName("AuthorizationHeaderParameterOperationFilter:Apply"));
            trace.Record(Annotations.ServerRecv( ));

            var filterPipeline = context.ApiDescription.ActionDescriptor.FilterDescriptors;
            var isAuthorized   = filterPipeline.Select(filterInfo => filterInfo.Filter).Any(filter => filter is AuthorizeFilter);
            var allowAnonymous = filterPipeline.Select(filterInfo => filterInfo.Filter).Any(filter => filter is IAllowAnonymousFilter);

            if (isAuthorized && !allowAnonymous)
            {
                if (operation.Parameters == null)
                {
                    operation.Parameters = new List <IParameter>();
                }

                operation.Parameters.Add(new NonBodyParameter
                {
                    Name        = "Authorization",
                    In          = "header",
                    Description = "access token",
                    Required    = true,
                    Type        = "string"
                });
            }
            trace.Record(Annotations.ServerSend( ));
        }
コード例 #2
0
        protected ITransmissionResponse SendHttpRequest(HttpPost httpPost)
        {
            Trace span = this.root.Child();

            span.Record(Annotations.ServiceName("execute"));

            try
            {
                var httpClient = new HttpClient();
                var response   = httpClient.Execute(httpPost);


                var result = this.HandleResponse(response);
                span.Record(Annotations.ClientRecv());
                return(result);
            }
            catch (Exception e)
            {
                span.Record(Annotations.Tag("exception", e.Message));
                throw new HyperwayTransmissionException(this.transmissionRequest.GetEndpoint().Address, e);
            }
            finally
            {
                span.Record(Annotations.ClientRecv());
            }
        }
コード例 #3
0
        public void Apply(Operation operation, OperationFilterContext context)
        {
            trace.Record(Annotations.ServiceName("AuthorizeCheckOperationFilter:Apply"));
            trace.Record(Annotations.ServerRecv());
            // Check for authorize attribute
            var hasAuthorize = context.ApiDescription.ControllerAttributes().OfType <AuthorizeAttribute>().Any() ||
                               context.ApiDescription.ActionAttributes().OfType <AuthorizeAttribute>().Any();

            if (hasAuthorize)
            {
                operation.Responses.Add("401", new Response {
                    Description = "Unauthorized"
                });
                operation.Responses.Add("403", new Response {
                    Description = "Forbidden"
                });

                operation.Security = new List <IDictionary <string, IEnumerable <string> > >();
                operation.Security.Add(new Dictionary <string, IEnumerable <string> >
                {
                    { "oauth2", new [] { "basketapi" } }
                });
            }
            trace.Record(Annotations.ServerSend());
        }
コード例 #4
0
 public TracingTimer(Trace trace, string tracingServiceName, string methodName)
 {
     _trace = trace;
     _trace.Record(Annotations.ServiceName(tracingServiceName));
     _trace.Record(Annotations.ClientSend());
     _trace.Record(Annotations.Rpc($"{tracingServiceName}_{methodName}"));
 }
コード例 #5
0
        public TransmissionResult Call()
        {
            Trace span = Trace.Create();

            span.Record(Annotations.ServiceName("standalone"));
            span.Record(Annotations.ClientSend());

            try
            {
                ITransmissionResponse transmissionResponse;
                long duration = 0;

                if (this.parameters.UseFactory)
                {
                    using (Stream inputStream = File.Open(this.xmlPayloadFile.FullName, FileMode.Open, FileAccess.Read))
                    {
                        transmissionResponse = this.parameters.HyperwayOutboundComponent.GetTransmissionService()
                                               .Send(inputStream, span);
                    }
                }
                else
                {
                    ITransmissionRequest transmissionRequest = this.CreateTransmissionRequest(span);

                    ITransmitter transmitter;
                    Trace        span1 = span.Child();
                    span1.Record(Annotations.ServiceName("get transmitter"));
                    span1.Record(Annotations.ClientSend());
                    try
                    {
                        transmitter = this.parameters.HyperwayOutboundComponent.GetTransmitter();
                    }
                    finally
                    {
                        span1.Record(Annotations.ClientRecv());
                    }

                    // Performs the transmission
                    var watch = new Stopwatch();
                    watch.Start();
                    transmissionResponse = this.PerformTransmission(
                        this.parameters.EvidencePath, transmitter, transmissionRequest, span);
                    watch.Stop();

                    return(new TransmissionResult(watch.ElapsedMilliseconds, transmissionResponse.GetTransmissionIdentifier()));
                }

                return(new TransmissionResult(duration, transmissionResponse.GetTransmissionIdentifier()));
            }
            finally
            {
                span.Record(Annotations.ClientRecv());
            }
        }
コード例 #6
0
        // GET: /<controller>/
        public IActionResult Index()
        {
            trace.Record(Annotations.ServerRecv());
            trace.Record(Annotations.ServiceName("HomeController:Index"));
            trace.Record(Annotations.Rpc("GET"));

            var tmp = new RedirectResult("~/swagger");

            trace.Record(Annotations.ServerSend());
            return(tmp);
        }
コード例 #7
0
        public IActionResult Index(string returnUrl)
        {
            trace.Record(Annotations.ServerRecv());
            trace.Record(Annotations.ServiceName("HomeController:Index"));
            trace.Record(Annotations.Rpc("GET"));
            trace.Record(Annotations.ServerSend());

            return(View());
        }
コード例 #8
0
        /// <summary>
        /// Конструктор таймера метрик, который трейсит обращения к сервиса к внешним ресурсам
        /// </summary>
        /// <param name="trace"></param>
        /// <param name="tracingServiceName"></param>
        /// <param name="methodName"></param>
        /// <param name="getTracingTagsCallback"></param>
        public TracingTimer(Trace trace, string tracingServiceName, string methodName, Dictionary <string, string> getTracingTagsCallback)
        {
            if ((_trace = trace?.Child()) != null)
            {
                _trace.Record(Annotations.ServiceName(tracingServiceName));
                _trace.Record(Annotations.ClientSend());
                _trace.Record(Annotations.Rpc($"{tracingServiceName}_{methodName}"));

                foreach (var tag in getTracingTagsCallback)
                {
                    _trace.Record(Annotations.Tag(tag.Key, tag.Value));
                }
            }
        }
コード例 #9
0
        public async Task <bool> AddOrUpdateUserLocation(string userId, LocationRequest currentPosition)
        {
            trace.Record(Annotations.LocalOperationStart("LocationsService:AddOrUpdateUserLocation"));
            // Get the list of ordered regions the user currently is within
            var currentUserAreaLocationList = await _locationsRepository.GetCurrentUserRegionsListAsync(currentPosition);

            if (currentUserAreaLocationList is null)
            {
                trace.Record(Annotations.LocalOperationStop());
                throw new LocationDomainException("User current area not found");
            }

            // If current area found, then update user location
            var locationAncestors = new List <string>();
            var userLocation      = await _locationsRepository.GetUserLocationAsync(userId);

            userLocation            = userLocation ?? new UserLocation();
            userLocation.UserId     = userId;
            userLocation.LocationId = currentUserAreaLocationList[0].LocationId;
            userLocation.UpdateDate = DateTime.UtcNow;
            await _locationsRepository.UpdateUserLocationAsync(userLocation);

            // Publish integration event to update marketing read data model
            // with the new locations updated
            PublishNewUserLocationPositionIntegrationEvent(userId, currentUserAreaLocationList);

            trace.Record(Annotations.LocalOperationStop());
            return(true);
        }
コード例 #10
0
        // GET: /<controller>/
        public async Task <IActionResult> GetImage(int catalogItemId)
        {
            trace.Record(Annotations.ServiceName("PicController:GetImage"));
            trace.Record(Annotations.ServerRecv());

            if (catalogItemId <= 0)
            {
                trace.Record(Annotations.ServerSend());
                return(BadRequest());
            }

            var item = await _catalogContext.CatalogItems
                       .SingleOrDefaultAsync(ci => ci.Id == catalogItemId);

            if (item != null)
            {
                var webRoot = _env.WebRootPath;
                var path    = Path.Combine(webRoot, item.PictureFileName);

                string imageFileExtension = Path.GetExtension(item.PictureFileName);
                string mimetype           = GetImageMimeTypeFromImageFileExtension(imageFileExtension);

                var buffer = System.IO.File.ReadAllBytes(path);

                trace.Record(Annotations.ServerSend());
                return(File(buffer, mimetype));
            }

            trace.Record(Annotations.ServerSend());
            return(NotFound());
        }
コード例 #11
0
        public async Task <PhotoInfo> GetPhotoInfoAsync(string photoId)
        {
            _trace.Record(Annotations.ServerRecv());
            _trace.Record(Annotations.ServiceName("FlickrSearchService:GetPhotoInfoAsync"), DateTime.UtcNow);
            _trace.Record(Annotations.Rpc("get"));
            var photoInfo = await _flickr.PhotosGetInfoAsync(photoId);

            _trace.Record(Annotations.ServerSend());

            return(photoInfo);
        }
コード例 #12
0
        public ProducerTrace(string serviceName, string rpc)
        {
            if (Trace.Current != null)
            {
                Trace = Trace.Current.Child();
            }

            Trace.Record(Annotations.ProducerStart());
            Trace.Record(Annotations.ServiceName(serviceName));
            Trace.Record(Annotations.Rpc(rpc));
        }
コード例 #13
0
        public ClientTrace(string serviceName, string rpc)
        {
            if (Trace.Current != null)
            {
                Trace = Trace.Current.Child();
            }

            Trace.Record(Annotations.ClientSend());
            Trace.Record(Annotations.ServiceName(serviceName));
            Trace.Record(Annotations.Rpc(rpc));
        }
コード例 #14
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());
            }
        }
コード例 #15
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());
            }
        }
コード例 #16
0
        public static IEnumerable <ApiResource> GetApis()
        {
            trace.Record(Annotations.LocalOperationStart("Config:GetApis"));
            var tmp = new List <ApiResource>
            {
                new ApiResource("orders", "Orders Service"),
                new ApiResource("basket", "Basket Service"),
                new ApiResource("marketing", "Marketing Service"),
                new ApiResource("locations", "Locations Service")
            };

            trace.Record(Annotations.LocalOperationStop());
            return(tmp);
        }
コード例 #17
0
        public ConsumerTrace(string serviceName, string rpc, string encodedTraceId, string encodedSpanId,
                             string encodedParentSpanId, string sampledStr, string flagsStr)
        {
            var spanState = ExtractorHelper.TryParseTrace(encodedTraceId, encodedSpanId, encodedParentSpanId,
                                                          sampledStr, flagsStr);

            if (spanState != default(SpanState))
            {
                Trace = Trace.CreateFromId(spanState).Child();
            }
            else
            {
                Trace = Trace.Create();
            }

            Trace.Current = Trace;

            Trace.Record(Annotations.ConsumerStart());
            Trace.Record(Annotations.ServiceName(serviceName));
            Trace.Record(Annotations.Rpc(rpc));
        }
コード例 #18
0
 public void Dispose()
 {
     _trace?.Record(_trace.CurrentSpan.ParentSpanId == null ? Annotations.ServerSend() : Annotations.ClientRecv());
 }
コード例 #19
0
 public void Dispose()
 {
     Trace.Record(Annotations.ProducerStop());
 }
コード例 #20
0
        public async Task <IActionResult> Items([FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0)

        {
            trace.Record(Annotations.ServiceName("CatalogController:Items"));
            trace.Record(Annotations.ServerRecv());

            var totalItems = await _catalogContext.CatalogItems
                             .LongCountAsync();

            var itemsOnPage = await _catalogContext.CatalogItems
                              .OrderBy(c => c.Name)
                              .Skip(pageSize * pageIndex)
                              .Take(pageSize)
                              .ToListAsync();

            itemsOnPage = ChangeUriPlaceholder(itemsOnPage);

            var model = new PaginatedItemsViewModel <CatalogItem>(
                pageIndex, pageSize, totalItems, itemsOnPage);

            trace.Record(Annotations.ServerSend());

            return(Ok(model));
        }
コード例 #21
0
        protected ITransmissionResponse HandleResponse(HttpResponse httpResponse)
        {
            Trace span = this.root.Child();

            // tracer.newChild(root.context()).name("response").start();
            span.Record(Annotations.ServiceName("response"));
            span.Record(Annotations.ClientSend());

            try
            {
                HttpResponse response = httpResponse;
                span.Record(Annotations.Tag("code", response.StatusCode.ToString()));

                // span.tag("code", String.valueOf(response.getStatusLine().getStatusCode()));

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    Logger.ErrorFormat(
                        "AS2 HTTP POST expected HTTP OK, but got : {0} from {1}",
                        response.StatusCode,
                        this.transmissionRequest.GetEndpoint().Address);

                    // Throws exception
                    this.HandleFailedRequest(response);
                }

                // handle normal HTTP OK response
                Logger.DebugFormat(
                    "AS2 transmission to {0} returned HTTP OK, verify MDN response",
                    this.transmissionRequest.GetEndpoint().Address);

                string contentTypeHeader = response.Headers["Content-Type"];
                if (string.IsNullOrWhiteSpace(contentTypeHeader))
                {
                    throw new HyperwayTransmissionException(
                              "No Content-Type header in response, probably a server error.");
                }

                // Read MIME Message
                MimeMessage mimeMessage;
                using (var m = new MemoryStream())
                {
                    // Add headers to MIME Message
                    foreach (var headerName in response.Headers.AllKeys)
                    {
                        var headerText = $"{headerName}: {response.Headers[headerName]}";
                        var headerData = Encoding.ASCII.GetBytes(headerText);
                        m.Write(headerData, 0, headerData.Length);
                        m.Write(new byte[] { 13, 10 }, 0, 2);
                    }
                    m.Write(new byte[] { 13, 10 }, 0, 2);

                    var messageData = response.Entity.Content;
                    m.Write(messageData, 0, messageData.Length);


                    m.Seek(0, SeekOrigin.Begin);
                    mimeMessage = MimeMessage.Load(m);
                    mimeMessage.Headers[HeaderId.ContentType] = response.Headers["Content-Type"];
                }

                SMimeReader sMimeReader = new SMimeReader(mimeMessage);

                // Timestamp of reception of MDN
                Timestamp t3 = this.timestampProvider.Generate(sMimeReader.GetSignature(), Direction.OUT);

                MultipartSigned signedMessage = mimeMessage.Body as MultipartSigned;
                using (this.secureMimeContext())
                {
                    Debug.Assert(signedMessage != null, nameof(signedMessage) + " != null");

                    var signatures      = signedMessage.Verify();
                    var signature       = signatures.First();
                    var mimeCertificate = signature.SignerCertificate as SecureMimeDigitalCertificate;


                    // Verify if the certificate used by the receiving Access Point in
                    // the response message does not match its certificate published by the SMP
                    Debug.Assert(mimeCertificate != null, nameof(mimeCertificate) + " != null");
                    X509Certificate certificate = mimeCertificate.Certificate;
                    if (!this.transmissionRequest.GetEndpoint().Certificate.Equals(certificate))
                    {
                        throw new HyperwayTransmissionException(
                                  String.Format(
                                      "Certificate in MDN ('{0}') does not match certificate from SMP ('{1}').",
                                      certificate.SubjectDN,                                          // .getSubjectX500Principal().getName(),
                                      this.transmissionRequest.GetEndpoint().Certificate.SubjectDN)); // .getSubjectX500Principal().getName()));
                    }

                    Logger.Debug("MDN signature was verified for : " + certificate.SubjectDN);
                }


                // Verifies the actual MDN
                MdnMimeMessageInspector mdnMimeMessageInspector = new MdnMimeMessageInspector(mimeMessage);
                String msg = mdnMimeMessageInspector.GetPlainTextPartAsText();

                if (!mdnMimeMessageInspector.IsOkOrWarning(new Mic(this.outboundMic)))
                {
                    Logger.ErrorFormat("AS2 transmission failed with some error message '{0}'.", msg);
                    throw new HyperwayTransmissionException(String.Format("AS2 transmission failed : {0}", msg));
                }

                // Read structured content
                MimeEntity mimeBodyPart    = mdnMimeMessageInspector.GetMessageDispositionNotificationPart();
                var        internetHeaders = mimeBodyPart.Headers;
                // InternetHeaders internetHeaders = new InternetHeaders((InputStream)mimeBodyPart.getContent());

                // Fetch timestamp if set
                DateTime date = t3.GetDate();
                if (internetHeaders.Any(x => x.Field == MdnHeader.Date))
                {
                    var dateText = internetHeaders.First(x => x.Field == MdnHeader.Date).Value;
                    date = As2DateUtil.Rfc822.Parse(dateText);
                }


                // Return TransmissionResponse
                return(new As2TransmissionResponse(
                           this.transmissionIdentifier,
                           this.transmissionRequest,
                           this.outboundMic,
                           MimeMessageHelper.ToBytes(mimeMessage),
                           t3,
                           date));
            }
            catch (TimestampException e)
            {
                throw new HyperwayTransmissionException(e.Message, e);
            }
            catch (Exception e)
            {
                throw new HyperwayTransmissionException("Unable to parse received content.", e);
            }
            finally
            {
                span.Record(Annotations.ClientRecv());
            }
        }
コード例 #22
0
        public async Task SeedAsync(CatalogContext context, IHostingEnvironment env, IOptions <CatalogSettings> settings, ILogger <CatalogContextSeed> logger)
        {
            trace.Record(Annotations.LocalOperationStart("SeedSync"));
            var policy = CreatePolicy(logger, nameof(CatalogContextSeed));

            await policy.ExecuteAsync(async() =>
            {
                var useCustomizationData = settings.Value.UseCustomizationData;
                var contentRootPath      = env.ContentRootPath;
                var picturePath          = env.WebRootPath;

                if (!context.CatalogBrands.Any())
                {
                    await context.CatalogBrands.AddRangeAsync(useCustomizationData
                        ? GetCatalogBrandsFromFile(contentRootPath, logger)
                        : GetPreconfiguredCatalogBrands());

                    await context.SaveChangesAsync();
                }

                if (!context.CatalogTypes.Any())
                {
                    await context.CatalogTypes.AddRangeAsync(useCustomizationData
                        ? GetCatalogTypesFromFile(contentRootPath, logger)
                        : GetPreconfiguredCatalogTypes());

                    await context.SaveChangesAsync();
                }

                if (!context.CatalogItems.Any())
                {
                    await context.CatalogItems.AddRangeAsync(useCustomizationData
                        ? GetCatalogItemsFromFile(contentRootPath, context, logger)
                        : GetPreconfiguredItems());

                    await context.SaveChangesAsync();

                    GetCatalogItemPictures(contentRootPath, picturePath);
                }
            });

            trace.Record(Annotations.LocalOperationStop());
        }
コード例 #23
0
        protected HttpPost PrepareHttpRequest()
        {
            Trace span = this.root.Child();

            span.Record(Annotations.ServiceName("request"));
            span.Record(Annotations.ClientSend());
            try
            {
                HttpPost httpPost;

                // Create the body part of the MIME message containing our content to be transmitted.
                MimeEntity mimeBodyPart = MimeMessageHelper.CreateMimeBodyPart(
                    this.transmissionRequest.GetPayload(),
                    "application/xml");

                // Digest method to use.
                SMimeDigestMethod digestMethod =
                    SMimeDigestMethod.FindByTransportProfile(
                        this.transmissionRequest.GetEndpoint().TransportProfile);



                // Create a complete S/MIME message using the body part containing our content as the
                // signed part of the S/MIME message.
                MimeMessage signedMimeMessage =
                    this.sMimeMessageFactory.CreateSignedMimeMessage(mimeBodyPart, digestMethod);

                var signedMultipart = (signedMimeMessage.Body as MultipartSigned);
                Debug.Assert(signedMultipart != null, nameof(signedMultipart) + " != null");
                this.outboundMic = MimeMessageHelper.CalculateMic(signedMultipart[0], digestMethod);
                span.Record(Annotations.Tag("mic", this.outboundMic.ToString()));
                span.Record(Annotations.Tag("endpoint url", this.transmissionRequest.GetEndpoint().Address.ToString()));

                // Initiate POST request
                httpPost = new HttpPost(this.transmissionRequest.GetEndpoint().Address);

                foreach (var header in signedMimeMessage.Headers)
                {
                    span.Record(Annotations.Tag(header.Field, header.Value));
                    httpPost.AddHeader(header.Field, header.Value.Replace("\r\n\t", string.Empty));
                }
                signedMimeMessage.Headers.Clear();

                this.transmissionIdentifier = TransmissionIdentifier.FromHeader(httpPost.Headers[As2Header.MessageId]);

                // Write content to OutputStream without headers.
                using (var m = new MemoryStream())
                {
                    signedMultipart.WriteTo(m);
                    httpPost.Entity = m.ToBuffer();
                }

                var contentType = signedMultipart.Headers[HeaderId.ContentType];

                // Set all headers specific to AS2 (not MIME).
                httpPost.Host = "skynet.sediva.it";
                httpPost.Headers.Add("Content-Type", this.NormalizeHeaderValue(contentType));
                httpPost.Headers.Add(As2Header.As2From, this.fromIdentifier);
                httpPost.Headers.Add(
                    As2Header.As2To,
                    CertificateUtils.ExtractCommonName(this.transmissionRequest.GetEndpoint().Certificate));
                httpPost.Headers.Add(As2Header.DispositionNotificationTo, "*****@*****.**");
                httpPost.Headers.Add(
                    As2Header.DispositionNotificationOptions,
                    As2DispositionNotificationOptions.GetDefault(digestMethod).ToString());
                httpPost.Headers.Add(As2Header.As2Version, As2Header.Version);
                httpPost.Headers.Add(As2Header.Subject, "AS2 message from HYPERWAY");
                httpPost.Headers.Add(As2Header.Date, As2DateUtil.Rfc822.GetFormat(DateTime.Now));
                return(httpPost);
            }
            catch (Exception)
            {
                throw new HyperwayTransmissionException(
                          "Unable to stream S/MIME message into byte array output stream");
            }
            finally
            {
                span.Record(Annotations.ClientRecv());
            }
        }
コード例 #24
0
        protected ITransmissionRequest CreateTransmissionRequest(Trace root)
        {
            Trace span = root.Child();

            span.Record(Annotations.ServiceName("create transmission request"));
            span.Record(Annotations.ClientSend());

            try
            {
                // creates a transmission request builder and enables trace
                TransmissionRequestBuilder requestBuilder =
                    this.parameters.HyperwayOutboundComponent.GetTransmissionRequestBuilder();

                requestBuilder.SetTransmissionBuilderOverride(true);

                // add receiver participant
                if (this.parameters.Receiver != null)
                {
                    requestBuilder.Receiver(this.parameters.Receiver);
                }

                // add sender participant
                if (this.parameters.Sender != null)
                {
                    requestBuilder.Sender(this.parameters.Sender);
                }

                if (this.parameters.DocType != null)
                {
                    requestBuilder.DocumentType(this.parameters.DocType);
                }

                if (this.parameters.ProcessIdentifier != null)
                {
                    requestBuilder.ProcessType(this.parameters.ProcessIdentifier);
                }

                // Supplies the payload
                using (Stream inputStream = File.Open(this.xmlPayloadFile.FullName, FileMode.Open, FileAccess.Read))
                {
                    requestBuilder.PayLoad(inputStream);
                }

                // Overrides the destination URL if so requested
                if (this.parameters.Endpoint != null)
                {
                    Endpoint endpoint = this.parameters.Endpoint;
                    requestBuilder.OverrideAs2Endpoint(endpoint);
                }

                // Specifying the details completed, creates the transmission request
                return(requestBuilder.Build(span));
            }
            catch (Exception e)
            {
                span.Record(Annotations.Tag("exception", e.Message));
                Console.WriteLine("Message failed : " + e.Message + e.StackTrace);
                return(null);
            }
            finally
            {
                span.Record(Annotations.ClientRecv());
            }
        }
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
            modelBuilder
            .HasAnnotation("ProductVersion", "1.1.1")
            .HasAnnotation("SqlServer:Sequence:.catalog_brand_hilo", "'catalog_brand_hilo', '', '1', '10', '', '', 'Int64', 'False'")
            .HasAnnotation("SqlServer:Sequence:.catalog_hilo", "'catalog_hilo', '', '1', '10', '', '', 'Int64', 'False'")
            .HasAnnotation("SqlServer:Sequence:.catalog_type_hilo", "'catalog_type_hilo', '', '1', '10', '', '', 'Int64', 'False'")
            .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

            modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Model.CatalogBrand", b =>
            {
                b.Property <int>("Id")
                .ValueGeneratedOnAdd()
                .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_brand_hilo")
                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);

                b.Property <string>("Brand")
                .IsRequired()
                .HasMaxLength(100);

                b.HasKey("Id");

                b.ToTable("CatalogBrand");
            });

            modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Model.CatalogItem", b =>
            {
                b.Property <int>("Id")
                .ValueGeneratedOnAdd()
                .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_hilo")
                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);

                b.Property <int>("CatalogBrandId");

                b.Property <int>("CatalogTypeId");

                b.Property <string>("Description");

                b.Property <string>("Name")
                .IsRequired()
                .HasMaxLength(50);

                b.Property <string>("PictureFileName");

                b.Property <decimal>("Price");

                b.HasKey("Id");

                b.HasIndex("CatalogBrandId");

                b.HasIndex("CatalogTypeId");

                b.ToTable("Catalog");
                trace.Record(Annotations.ServerSend());
            });

            modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Model.CatalogType", b =>
            {
                b.Property <int>("Id")
                .ValueGeneratedOnAdd()
                .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_type_hilo")
                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);

                b.Property <string>("Type")
                .IsRequired()
                .HasMaxLength(100);

                b.HasKey("Id");

                b.ToTable("CatalogType");
            });

            modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Model.CatalogItem", b =>
            {
                b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Model.CatalogBrand", "CatalogBrand")
                .WithMany()
                .HasForeignKey("CatalogBrandId")
                .OnDelete(DeleteBehavior.Cascade);

                b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Model.CatalogType", "CatalogType")
                .WithMany()
                .HasForeignKey("CatalogTypeId")
                .OnDelete(DeleteBehavior.Cascade);
            });
        }
コード例 #26
0
        public async Task <IActionResult> Login(string returnUrl)
        {
            trace.Record(Annotations.ServerRecv());
            trace.Record(Annotations.ServiceName("AccountController:Login"));
            trace.Record(Annotations.Rpc("GET"));
            var context = await _interaction.GetAuthorizationContextAsync(returnUrl);

            if (context?.IdP != null)
            {
                trace.Record(Annotations.ServerSend());
                // if IdP is passed, then bypass showing the login screen
                return(ExternalLogin(context.IdP, returnUrl));
            }

            var vm = await BuildLoginViewModelAsync(returnUrl, context);

            ViewData["ReturnUrl"] = returnUrl;

            trace.Record(Annotations.ServerSend());
            return(View(vm));
        }
コード例 #27
0
 // GET: /<controller>/
 public IActionResult Index()
 {
     trace.Record(Annotations.ServiceName("HomeController:Index"));
     return(new RedirectResult("~/swagger"));
 }
コード例 #28
0
 public void Dispose()
 {
     Trace.Record(Annotations.ClientRecv());
 }
コード例 #29
0
 public void Dispose()
 {
     Trace.Record(Annotations.ConsumerStop());
 }
コード例 #30
0
        public async Task <IActionResult> Get(string id)
        {
            trace.Record(Annotations.ServiceName("BasketController:Get"));
            trace.Record(Annotations.ServerRecv());
            var basket = await _repository.GetBasketAsync(id);

            trace.Record(Annotations.ServerSend());

            return(Ok(basket));
        }