public ActionResult GenerateFeed(FeedFroogleModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }


            try
            {
                string fileName = string.Format("froogle_{0}_{1}.xml", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"), CommonHelper.GenerateRandomDigitCode(4));
                string filePath = string.Format("{0}content\\files\\exportimport\\{1}", Request.PhysicalApplicationPath, fileName);
                using (var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
                {
                    var feed = _promotionFeedService.LoadPromotionFeedBySystemName("PromotionFeed.Froogle");
                    feed.GenerateFeed(fs);
                }

                string clickhereStr = string.Format("<a href=\"{0}content/files/exportimport/{1}\" target=\"_blank\">{2}</a>", _webHelper.GetStoreLocation(false), fileName, _localizationService.GetResource("Plugins.Feed.Froogle.ClickHere"));
                string result       = string.Format(_localizationService.GetResource("Plugins.Feed.Froogle.SuccessResult"), clickhereStr);
                model.GenerateFeedResult = result;
            }
            catch (Exception exc)
            {
                model.GenerateFeedResult = exc.Message;
                _logger.Error(exc.Message, exc);
            }


            foreach (var c in _currencyService.GetAllCurrencies(false))
            {
                model.AvailableCurrencies.Add(new SelectListItem()
                {
                    Text  = c.Name,
                    Value = c.Id.ToString()
                });
            }
            model.AvailableGoogleCategories.Add(new SelectListItem()
            {
                Text  = "Select a category",
                Value = ""
            });
            foreach (var gc in _googleService.GetTaxonomyList())
            {
                model.AvailableGoogleCategories.Add(new SelectListItem()
                {
                    Text  = gc,
                    Value = gc
                });
            }
            return(View("Nop.Plugin.Feed.Froogle.Views.FeedFroogle.Configure", model));
        }
示例#2
0
        public ActionResult ConfigureMethod(string systemName)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePromotionFeeds))
            {
                return(AccessDeniedView());
            }

            var feed = _promotionFeedService.LoadPromotionFeedBySystemName(systemName);

            if (feed == null)
            {
                //No feed found with the specified id
                return(RedirectToAction("List"));
            }

            var    model = feed.ToModel();
            string actionName, controllerName;
            RouteValueDictionary routeValues;

            feed.GetConfigurationRoute(out actionName, out controllerName, out routeValues);
            model.ConfigurationActionName     = actionName;
            model.ConfigurationControllerName = controllerName;
            model.ConfigurationRouteValues    = routeValues;
            return(View(model));
        }