コード例 #1
0
        public async Task Invoke(HttpContext context)
        {
            //Do not process for exist exception
            var exceptionFeature = context.Features.Get <IExceptionHandlerFeature>();

            if (exceptionFeature != null)
            {
                await _next(context);

                return;
            }

            var builder     = new WorkContextBuilder(context, _options);
            var workContext = builder.WorkContext;

            workContext.ApplicationSettings = _applicationSettings;
            //The important to preserve the order of initialization
            await builder.WithCountriesAsync();

            await builder.WithStoresAsync(_options.DefaultStore);

            await builder.WithCurrentUserAsync();

            await builder.WithCurrenciesAsync(workContext.CurrentLanguage, workContext.CurrentStore);

            await builder.WithCatalogsAsync();

            await builder.WithDefaultShoppingCartAsync("default", workContext.CurrentStore, workContext.CurrentUser, workContext.CurrentCurrency, workContext.CurrentLanguage);

            await builder.WithMenuLinksAsync(workContext.CurrentStore, workContext.CurrentLanguage);

            await builder.WithPagesAsync(workContext.CurrentStore, workContext.CurrentLanguage);

            await builder.WithBlogsAsync(workContext.CurrentStore, workContext.CurrentLanguage);

            await builder.WithPricelistsAsync();

            if (workContext.CurrentStore.QuotesEnabled)
            {
                await builder.WithQuotesAsync(workContext.CurrentStore, workContext.CurrentUser, workContext.CurrentCurrency, workContext.CurrentLanguage);

                await builder.WithUserQuotesAsync();
            }
            await builder.WithUserOrdersAsync();

            await builder.WithUserSubscriptionsAsync();

            await builder.WithVendorsAsync(workContext.CurrentStore, workContext.CurrentLanguage);

            await builder.WithFulfillmentCentersAsync();

            workContext.AvailableRoles       = SecurityConstants.Roles.AllRoles;
            _workContextAccessor.WorkContext = workContext;


            await _next(context);
        }
コード例 #2
0
        public async Task Invoke(HttpContext context)
        {
            //Do not process for exist exception
            var exceptionFeature = context.Features.Get <IExceptionHandlerFeature>();

            if (exceptionFeature != null)
            {
                await _next(context);

                return;
            }

            var builder     = new WorkContextBuilder(context, _options);
            var workContext = builder.WorkContext;

            workContext.IsDevelopment       = _hostingEnvironment.IsDevelopment();
            workContext.ApplicationSettings = _applicationSettings;
            //The important to preserve the order of initialization
            await builder.WithCountriesAsync();

            await builder.WithStoresAsync(_options.DefaultStore);

            await builder.WithCurrentUserAsync();

            await builder.WithCurrenciesAsync(workContext.CurrentLanguage, workContext.CurrentStore);

            await builder.WithCatalogsAsync();

            await builder.WithDefaultShoppingCartAsync("default", workContext.CurrentStore, workContext.CurrentUser, workContext.CurrentCurrency, workContext.CurrentLanguage);

            await builder.WithMenuLinksAsync(workContext.CurrentStore, workContext.CurrentLanguage);

            await builder.WithPagesAsync(workContext.CurrentStore, workContext.CurrentLanguage);

            await builder.WithBlogsAsync(workContext.CurrentStore, workContext.CurrentLanguage);

            await builder.WithPricelistsAsync();

            if (workContext.CurrentStore.QuotesEnabled)
            {
                await builder.WithQuotesAsync(workContext.CurrentStore, workContext.CurrentUser, workContext.CurrentCurrency, workContext.CurrentLanguage);

                await builder.WithUserQuotesAsync();
            }
            await builder.WithUserOrdersAsync();

            if (workContext.CurrentStore.SubscriptionEnabled)
            {
                await builder.WithUserSubscriptionsAsync();
            }
            await builder.WithVendorsAsync(workContext.CurrentStore, workContext.CurrentLanguage);

            await builder.WithFulfillmentCentersAsync();

            //EU General Data Protection Regulation (GDPR) support
            var consentFeature = context.Features.Get <ITrackingConsentFeature>();

            if (consentFeature != null)
            {
                workContext.CanTrack      = !consentFeature?.CanTrack ?? false;
                workContext.ConsentCookie = consentFeature?.CreateConsentCookie();
            }
            workContext.AvailableRoles          = SecurityConstants.Roles.AllRoles;
            workContext.BusinessToBusinessRoles = SecurityConstants.Roles.B2BRoles;
            _workContextAccessor.WorkContext    = workContext;


            await _next(context);
        }