コード例 #1
0
        public bool Execute(IProgressMessenger progressMessenger)
        {
            _progressMessenger = progressMessenger;
            try
            {
                _progressMessenger.AddProgressMessageText("Importing assets...", false, 0);
                ImportAssets(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\B2BProductAssets.episerverdata"));
                ImportAssets(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\Hero.episerverdata"));
                _progressMessenger.AddProgressMessageText("Running EPiServer Find Content Indexing Job...", false, 0);
                var job = ScheduledJobRepository.Service.List().FirstOrDefault(x => x.Name.Equals("EPiServer Find Content Indexing Job"));
                if (job != null)
                {
                    var result = ScheduledJobExecutor.Service.StartAsync(job).Result;
                    if (result.Status == ScheduledJobExecutionStatus.Failed)
                    {
                        _progressMessenger.AddProgressMessageText("Quicksilver B2B Media failed: " + result.Message, true, 0);
                        LogManager.GetLogger(GetType()).Error(result.Message);
                    }
                }
                _progressMessenger.AddProgressMessageText("Done running EPiServer Find Content Indexing Job", false, 0);

                return(true);
            }
            catch (Exception ex)
            {
                _progressMessenger.AddProgressMessageText("Quicksilver B2B Media failed failed: " + ex.Message + "Stack trace:" + ex.StackTrace, true, 0);
                LogManager.GetLogger(GetType()).Error(ex.Message, ex.StackTrace);
                return(false);
            }
        }
        public bool Execute(IProgressMessenger progressMessenger)
        {
            _progressMessenger = progressMessenger;
            try
            {
                _progressMessenger.AddProgressMessageText("Installing PayPal", false, 0);
                InstallPayPalPaymentProvider();

                return(true);
            }
            catch (Exception ex)
            {
                _progressMessenger.AddProgressMessageText("Setting up failed: " + ex.Message + "Stack trace:" + ex.StackTrace, true, 0);
                LogManager.GetLogger(GetType()).Error(ex.Message, ex.StackTrace);
                return(false);
            }
        }
コード例 #3
0
        public bool Execute(IProgressMessenger progressMessenger)
        {
            _progressMessenger = progressMessenger;

            try
            {
                _progressMessenger.AddProgressMessageText("Creating customers and orders...", false, 0);

                CreateContactsAndOrders();

                return(true);
            }
            catch (Exception ex)
            {
                _progressMessenger.AddProgressMessageText($"CreateCustomers failed: {ex.Message} Stack trace: {ex.StackTrace}", true, 0);
                LogManager.GetLogger(GetType()).Error(ex.Message, ex);
                return(false);
            }
        }
コード例 #4
0
        public bool Execute(IProgressMessenger progressMessenger)
        {
            progressMessenger.AddProgressMessageText($"{DateTime.Now.ToString(CultureInfo.InvariantCulture)} - Started step {GetType().Name}", false, 0);
            var name = GetType().Name;

            try
            {
                ExecuteInternal(progressMessenger);
            }
            catch (Exception ex)
            {
                progressMessenger.AddProgressMessageText($"Error executing step {name} with message\n {ex.Message}.\nPlease see log for more details.", true, 0);
                Logger.Error($"Error executing step {name}", ex);
                throw;
            }

            progressMessenger.AddProgressMessageText($"{DateTime.Now.ToString(CultureInfo.InvariantCulture)} - Ended {GetType().Name}", false, 0);
            progressMessenger.AddProgressMessageText("Step completed successfully", false, 0);
            return(true);
        }
コード例 #5
0
        private void ImportCatalog(string path)
        {
            var importJob = new ImportJob(AppContext.Current.ApplicationId, path, "Catalog.xml", true);

            Action importCatalog = () =>
            {
                _progressMessenger.AddProgressMessageText("Importing Catalog content...", false, 20);
                Action <IBackgroundTaskMessage> addMessage = msg =>
                {
                    var isError = msg.MessageType == BackgroundTaskMessageType.Error;
                    var percent = (int)Math.Round(msg.GetOverallProgress() * 100);
                    var message = msg.Exception == null
                        ? msg.Message
                        : string.Format("{0} {1}", msg.Message, msg.ExceptionMessage);
                    _progressMessenger.AddProgressMessageText(message, isError, percent);
                };
                importJob.Execute(addMessage, CancellationToken.None);
                _progressMessenger.AddProgressMessageText("Done importing Catalog content", false, 60);
            };

            importCatalog();

            //We are running in front-end site context, the metafield update events are ignored, we need to sync manually
            _progressMessenger.AddProgressMessageText("Syncing metaclasses with content types", false, 60);
            SyncMetaClassesToContentTypeModels();
            _progressMessenger.AddProgressMessageText("Done syncing metaclasses with content types", false, 70);
        }
コード例 #6
0
        public bool Execute(IProgressMessenger progressMessenger)
        {
            _progressMessenger = progressMessenger;
            try
            {
                _progressMessenger.AddProgressMessageText("Importing product assets...", false, 0);
                ImportAssets(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\ProductAssets.episerverdata"));

                _progressMessenger.AddProgressMessageText("Enabling currencies...", false, 0);
                EnableCurrencies();

                _progressMessenger.AddProgressMessageText("Importing catalog...", false, 0);
                ImportCatalog(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\Catalog_Fashion.zip"));

                _progressMessenger.AddProgressMessageText("Disabling default market...", false, 0);
                DisableDefaultMarket();

                _progressMessenger.AddProgressMessageText("Configuring payment methods", false, 0);
                ConfigurePaymentMethods();

                _progressMessenger.AddProgressMessageText("Configuring shipment methods", false, 0);
                ConfigureShippingMethods();

                _progressMessenger.AddProgressMessageText("Creating marketing campaigns and Promotions", false, 0);
                ConfigureMarketing();

                _progressMessenger.AddProgressMessageText("Rebuilding index...", false, 0);
                BuildIndex(_progressMessenger, AppContext.Current.ApplicationId, AppContext.Current.ApplicationName, true);
                _progressMessenger.AddProgressMessageText("Done rebuilding index", false, 0);

                return(true);
            }
            catch (Exception ex)
            {
                _progressMessenger.AddProgressMessageText("ImportSiteContent failed: " + ex.Message + "Stack trace:" + ex.StackTrace, true, 0);
                LogManager.GetLogger(GetType()).Error(ex.Message, ex.StackTrace);
                return(false);
            }
        }
コード例 #7
0
        private void DisableDefaultMarket()
        {
            var marketService = ServiceLocator.Current.GetInstance <IMarketService>();

            // Disable default market
            _progressMessenger.AddProgressMessageText("Disabling default market...", false, 0);
            var defaultMarket = new MarketImpl(marketService.GetMarket(MarketId.Default))
            {
                IsEnabled = false
            };

            marketService.UpdateMarket(defaultMarket);
        }
コード例 #8
0
        public bool Execute(IProgressMessenger progressMessenger)
        {
            _progressMessenger = progressMessenger;
            try
            {
                _progressMessenger.AddProgressMessageText("Importing product assets...", false, 0);
                ImportAssets(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\B2BProductAssets.episerverdata"));

                _progressMessenger.AddProgressMessageText("Importing catalog...", false, 0);
                ImportCatalog(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\CatalogExport_QuicksilverB2B_20161212-183053.zip"));

                _progressMessenger.AddProgressMessageText("Rebuilding index...", false, 0);
                BuildIndex(_progressMessenger, AppContext.Current.ApplicationId, AppContext.Current.ApplicationName, true);
                _progressMessenger.AddProgressMessageText("Done rebuilding index", false, 0);

                return(true);
            }
            catch (Exception ex)
            {
                _progressMessenger.AddProgressMessageText("ImportSiteB2BContent failed: " + ex.Message + "Stack trace:" + ex.StackTrace, true, 0);
                LogManager.GetLogger(GetType()).Error(ex.Message, ex.StackTrace);
                return(false);
            }
        }
コード例 #9
0
        public bool Execute(IProgressMessenger progressMessenger)
        {
            _progressMessenger = progressMessenger;
            try
            {
                _progressMessenger.AddProgressMessageText("Importing product assets...", false, 0);
                ImportAssets(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\ProductAssets.episerverdata"));

                _progressMessenger.AddProgressMessageText("Enabling currencies...", false, 0);
                EnableCurrencies();

                _progressMessenger.AddProgressMessageText("Importing catalog...", false, 0);
                ImportCatalog(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\Catalog_Fashion.zip"));

                _progressMessenger.AddProgressMessageText("Disabling default market...", false, 0);
                DisableDefaultMarket();

                _progressMessenger.AddProgressMessageText("Configuring payment methods", false, 0);
                ConfigurePaymentMethods();

                _progressMessenger.AddProgressMessageText("Configuring shipment methods", false, 0);
                ConfigureShippingMethods();

                _progressMessenger.AddProgressMessageText("Creating marketing campaigns and Promotions", false, 0);
                ConfigureMarketing();

                _progressMessenger.AddProgressMessageText("Rebuilding index...", false, 0);
                BuildIndex(_progressMessenger, AppContext.Current.ApplicationId, AppContext.Current.ApplicationName, true);
                _progressMessenger.AddProgressMessageText("Done rebuilding index", false, 0);

                return true;
            }
            catch (Exception ex)
            {
                _progressMessenger.AddProgressMessageText("ImportSiteContent failed: " + ex.Message + "Stack trace:" + ex.StackTrace, true, 0);
                LogManager.GetLogger(GetType()).Error(ex.Message, ex.StackTrace);
                return false;
            }
        }
コード例 #10
0
        protected override void ExecuteInternal(IProgressMessenger progressMessenger)
        {
            progressMessenger.AddProgressMessageText("Creating markets...", false, 0);
            using (var stream = new FileStream(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\markets.xml"), FileMode.Open))
            {
                foreach (var xMarket in GetXElements(stream, "Market"))
                {
                    var market = new MarketImpl(xMarket.Get("MarketId"))
                    {
                        IsEnabled         = xMarket.GetBool("IsEnabled"),
                        MarketName        = xMarket.Get("MarketName"),
                        MarketDescription = xMarket.Get("MarketDescription") ?? xMarket.Get("MarketName"),
                        DefaultCurrency   = new Currency(xMarket.Get("DefaultCurrency")),
                        DefaultLanguage   = new CultureInfo(xMarket.Get("DefaultLanguage")),
                        PricesIncludeTax  = xMarket.GetBoolOrDefault("PricesIncludeTax")
                    };

                    foreach (var xCurrency in xMarket.Element("Currencies").Elements("Currency").Distinct())
                    {
                        market.CurrenciesCollection.Add(new Currency((string)xCurrency));
                    }

                    foreach (var xLanguage in xMarket.Element("Languages").Elements("Language").Distinct())
                    {
                        market.LanguagesCollection.Add(new CultureInfo((string)xLanguage));
                    }

                    foreach (var xCountry in xMarket.Element("Countries").Elements("Country").Distinct())
                    {
                        market.CountriesCollection.Add((string)xCountry);
                    }

                    var existingMarket = MarketService.GetMarket(market.MarketId);
                    if (existingMarket == null)
                    {
                        MarketService.CreateMarket(market);
                    }
                    else
                    {
                        foreach (var currency in existingMarket.Currencies.Where(x => !market.CurrenciesCollection.Contains(x)))
                        {
                            market.CurrenciesCollection.Add(currency);
                        }

                        foreach (var language in existingMarket.Languages
                                 .Where(el => !market.Languages.Any(nl => string.Equals(el.Name, nl.Name, StringComparison.OrdinalIgnoreCase))))
                        {
                            market.LanguagesCollection.Add(language);
                        }

                        foreach (var country in existingMarket.Countries
                                 .Where(ec => !market.Countries.Any(nc => string.Equals(ec, nc, StringComparison.OrdinalIgnoreCase))))
                        {
                            market.CountriesCollection.Add(country);
                        }

                        MarketService.UpdateMarket(market);
                    }
                }
            }
        }