Beispiel #1
0
        protected void Application_Start()
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            //Initialize your application
            WebSettingsConfig.Instance.SetDeferredSettings(webSettingsConfig => {
                ISalesSettings salesSettings = webSettingsConfig.GetSalesSettings(SectionId.VisualDictionary);
                if (salesSettings == null)
                {
                    return;
                }

                long languageId          = WebSettingsConfig.Instance.GetLanguageFromId();
                var representationsQuery = new RepresentationsQuery(languageId);

                List <SalesItemForUser> allSalesItems =
                    representationsQuery.GetForSales(WebSettingsConfig.Instance.DefaultUserLanguages,
                                                     salesSettings);
                var salesCalculator             = new SalesCalculator(allSalesItems, allSalesItems, salesSettings.Discount);
                salesSettings.SummDiscountPrice = salesCalculator.SummDiscountPrice;
            }, webSettingsConfig => {
                //кладем в кэш файл sitemap.xml
                SitemapFileGenerator.Generate(false);
            }, webSettingsConfig => {
                //подчистить старые файлы js/css
                Minimizer.DeleteOldFiles(webSettingsConfig.WebPath);
            });
        }
        private static IEnumerable <SalesItemForUser> GetSalesItems(ISalesSettings salesSettings)
        {
            if (salesSettings == null)
            {
                return(new List <SalesItemForUser>(0));
            }
            var representationsQuery           = new RepresentationsQuery(WebSettingsConfig.Instance.GetLanguageFromId());
            List <SalesItemForUser> salesItems =
                representationsQuery.GetForSales(WebSettingsConfig.Instance.DefaultUserLanguages, salesSettings);

            return(salesItems);
        }