public ActionResult Configure() { var model = new FeedFroogleModel(); model.ProductPictureSize = _froogleSettings.ProductPictureSize; model.PassShippingInfo = _froogleSettings.PassShippingInfo; //stores model.StoreId = _froogleSettings.StoreId; model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var s in _storeService.GetAllStores()) model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); //currencies model.CurrencyId = _froogleSettings.CurrencyId; foreach (var c in _currencyService.GetAllCurrencies()) model.AvailableCurrencies.Add(new SelectListItem { Text = c.Name, Value = c.Id.ToString() }); //Google categories model.DefaultGoogleCategory = _froogleSettings.DefaultGoogleCategory; 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 }); //file paths foreach (var store in _storeService.GetAllStores()) { var localFilePath = System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, "content\\files\\exportimport", store.Id + "-" + _froogleSettings.StaticFileName); if (System.IO.File.Exists(localFilePath)) model.GeneratedFiles.Add(new FeedFroogleModel.GeneratedFileModel { StoreName = store.Name, FileUrl = string.Format("{0}content/files/exportimport/{1}-{2}", _webHelper.GetStoreLocation(false), store.Id, _froogleSettings.StaticFileName) }); } return View("~/Plugins/Feed.Froogle/Views/FeedFroogle/Configure.cshtml", model); }
public ActionResult Configure() { var model = new FeedFroogleModel(); //Picture model.ProductPictureSize = _froogleSettings.ProductPictureSize; //Currency model.CurrencyId = _froogleSettings.CurrencyId; foreach (var c in _currencyService.GetAllCurrencies(false)) { model.AvailableCurrencies.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString() }); } //Google category model.DefaultGoogleCategory = _froogleSettings.DefaultGoogleCategory; 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 }); } //FTP settings model.FtpHostname = _froogleSettings.FtpHostname; model.FtpFilename = _froogleSettings.FtpFilename; model.FtpUsername = _froogleSettings.FtpUsername; model.FtpPassword = _froogleSettings.FtpPassword; //task ScheduleTask task = FindScheduledTask(); if (task != null) { model.GenerateStaticFileEachMinutes = task.Seconds / 60; model.TaskEnabled = task.Enabled; } //file path if (System.IO.File.Exists(System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, "content\\files\\exportimport", _froogleSettings.StaticFileName))) model.StaticFilePath = string.Format("{0}content/files/exportimport/{1}", _webHelper.GetStoreLocation(false), _froogleSettings.StaticFileName); return View("Nop.Plugin.Feed.Froogle.Views.FeedFroogle.Configure", model); }
public ActionResult Configure() { var model = new FeedFroogleModel(); //Picture model.ProductPictureSize = _froogleSettings.ProductPictureSize; //Currency model.CurrencyId = _froogleSettings.CurrencyId; foreach (var c in _currencyService.GetAllCurrencies(false)) { model.AvailableCurrencies.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString() }); } //Google category model.DefaultGoogleCategory = _froogleSettings.DefaultGoogleCategory; 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 }); } //FTP settings model.FtpHostname = _froogleSettings.FtpHostname; model.FtpFilename = _froogleSettings.FtpFilename; model.FtpUsername = _froogleSettings.FtpUsername; model.FtpPassword = _froogleSettings.FtpPassword; return View("Nop.Plugin.Feed.Froogle.Views.FeedFroogle.Configure", model); }
public ActionResult GenerateFeed(FeedFroogleModel model) { try { var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("PromotionFeed.Froogle"); if (pluginDescriptor == null) throw new Exception("Cannot load the plugin"); //plugin var plugin = pluginDescriptor.Instance() as FroogleService; if (plugin == null) throw new Exception("Cannot load the plugin"); var stores = new List<Store>(); var storeById = _storeService.GetStoreById(_froogleSettings.StoreId); if (storeById != null) stores.Add(storeById); else stores.AddRange(_storeService.GetAllStores()); foreach (var store in stores) plugin.GenerateStaticFile(store); SuccessNotification(_localizationService.GetResource("Plugins.Feed.Froogle.SuccessResult")); } catch (Exception exc) { ErrorNotification(exc.Message); _logger.Error(exc.Message, exc); } return Configure(); }
public ActionResult Configure(FeedFroogleModel model) { if (!ModelState.IsValid) { return Configure(); } //save settings _froogleSettings.ProductPictureSize = model.ProductPictureSize; _froogleSettings.PassShippingInfo = model.PassShippingInfo; _froogleSettings.CurrencyId = model.CurrencyId; _froogleSettings.StoreId = model.StoreId; _froogleSettings.DefaultGoogleCategory = model.DefaultGoogleCategory; _settingService.SaveSetting(_froogleSettings); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); //redisplay the form return Configure(); }
public ActionResult Configure(FeedFroogleModel model) { if (!ModelState.IsValid) { return Configure(); } //save settings _froogleSettings.ProductPictureSize = model.ProductPictureSize; _froogleSettings.CurrencyId = model.CurrencyId; _froogleSettings.StoreId = model.StoreId; _froogleSettings.DefaultGoogleCategory = model.DefaultGoogleCategory; _settingService.SaveSetting(_froogleSettings); //redisplay the form return Configure(); }
public ActionResult GenerateFeed(FeedFroogleModel model) { try { var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("PromotionFeed.Froogle"); if (pluginDescriptor == null) throw new Exception("Cannot load the plugin"); //plugin var plugin = pluginDescriptor.Instance() as FroogleService; if (plugin == null) throw new Exception("Cannot load the plugin"); var stores = new List<Store>(); var storeById = _storeService.GetStoreById(_froogleSettings.StoreId); if (storeById != null) stores.Add(storeById); else stores.AddRange(_storeService.GetAllStores()); foreach (var store in stores) plugin.GenerateStaticFile(store); model.GenerateFeedResult = _localizationService.GetResource("Plugins.Feed.Froogle.SuccessResult"); } catch (Exception exc) { model.GenerateFeedResult = exc.Message; _logger.Error(exc.Message, exc); } //stores model.AvailableStores.Add(new SelectListItem() { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var s in _storeService.GetAllStores()) model.AvailableStores.Add(new SelectListItem() { Text = s.Name, Value = s.Id.ToString() }); //currencies foreach (var c in _currencyService.GetAllCurrencies()) model.AvailableCurrencies.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString() }); //Google categories 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 }); //file paths foreach (var store in _storeService.GetAllStores()) { var localFilePath = System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, "content\\files\\exportimport", store.Id + "-" + _froogleSettings.StaticFileName); if (System.IO.File.Exists(localFilePath)) model.GeneratedFiles.Add(new FeedFroogleModel.GeneratedFileModel() { StoreName = store.Name, FileUrl = string.Format("{0}content/files/exportimport/{1}-{2}", _webHelper.GetStoreLocation(false), store.Id, _froogleSettings.StaticFileName) }); } return View("~/Plugins/Feed.Froogle/Views/FeedFroogle/Configure.cshtml", model); }
public ActionResult UploadFeed(FeedFroogleModel model) { if (!ModelState.IsValid) { return Configure(); } try { string uri = String.Format("{0}/{1}", _froogleSettings.FtpHostname, _froogleSettings.FtpFilename); FtpWebRequest req = WebRequest.Create(uri) as FtpWebRequest; req.Credentials = new NetworkCredential(_froogleSettings.FtpUsername, _froogleSettings.FtpPassword); req.KeepAlive = true; req.UseBinary = true; req.Method = WebRequestMethods.Ftp.UploadFile; using (Stream reqStream = req.GetRequestStream()) { var feed = _promotionFeedService.LoadPromotionFeedBySystemName("PromotionFeed.Froogle"); feed.GenerateFeed(reqStream); } var rsp = req.GetResponse() as FtpWebResponse; model.GenerateFeedResult = String.Format(_localizationService.GetResource("Plugins.Feed.Froogle.FtpUploadStatus"), rsp.StatusDescription); } 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); }
public ActionResult UploadFeed(FeedFroogleModel model) { if (!ModelState.IsValid) { return Configure(); } try { string uri = String.Format("{0}/{1}", _froogleSettings.FtpHostname, _froogleSettings.FtpFilename); var req = WebRequest.Create(uri) as FtpWebRequest; req.Credentials = new NetworkCredential(_froogleSettings.FtpUsername, _froogleSettings.FtpPassword); req.KeepAlive = true; req.UseBinary = true; req.Method = WebRequestMethods.Ftp.UploadFile; using (Stream reqStream = req.GetRequestStream()) { var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("PromotionFeed.Froogle"); if (pluginDescriptor == null) throw new Exception("Cannot load the plugin"); //plugin var plugin = pluginDescriptor.Instance() as FroogleService; if (plugin == null) throw new Exception("Cannot load the plugin"); plugin.GenerateFeed(reqStream); } var rsp = req.GetResponse() as FtpWebResponse; model.GenerateFeedResult = String.Format(_localizationService.GetResource("Plugins.Feed.Froogle.FtpUploadStatus"), rsp.StatusDescription); } 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 }); } //task ScheduleTask task = FindScheduledTask(); if (task != null) { model.GenerateStaticFileEachMinutes = task.Seconds / 60; model.TaskEnabled = task.Enabled; } //file path if (System.IO.File.Exists(System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, "content\\files\\exportimport", _froogleSettings.StaticFileName))) model.StaticFilePath = string.Format("{0}content/files/exportimport/{1}", _webHelper.GetStoreLocation(false), _froogleSettings.StaticFileName); return View("Nop.Plugin.Feed.Froogle.Views.FeedFroogle.Configure", model); }
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); }
public ActionResult Configure(FeedFroogleModel model) { if (!ModelState.IsValid) { return Configure(); } //save settings _froogleSettings.ProductPictureSize = model.ProductPictureSize; _froogleSettings.CurrencyId = model.CurrencyId; _froogleSettings.DefaultGoogleCategory = model.DefaultGoogleCategory; _froogleSettings.FtpHostname = model.FtpHostname; _froogleSettings.FtpFilename = model.FtpFilename; _froogleSettings.FtpUsername = model.FtpUsername; _froogleSettings.FtpPassword = model.FtpPassword; _settingService.SaveSetting(_froogleSettings); //redisplay the form 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); }
public ActionResult GoogleProductUpdate(GridCommand command, FeedFroogleModel.GoogleProductModel model) { var googleProduct = _googleService.GetByProductVariantId(model.ProductVariantId); if (googleProduct != null) { googleProduct.Taxonomy = model.GoogleCategory; googleProduct.Gender = model.Gender; googleProduct.AgeGroup = model.AgeGroup; googleProduct.Color = model.Color; googleProduct.Size = model.GoogleSize; _googleService.UpdateGoogleProductRecord(googleProduct); } else { //insert googleProduct = new GoogleProductRecord() { ProductVariantId = model.ProductVariantId, Taxonomy = model.GoogleCategory, Gender = model.Gender, AgeGroup = model.AgeGroup, Color = model.Color, Size = model.GoogleSize }; _googleService.InsertGoogleProductRecord(googleProduct); } return GoogleProductList(command); }
public ActionResult GenerateFeed(FeedFroogleModel model) { if (!ModelState.IsValid) { return Configure(); } try { var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("PromotionFeed.Froogle"); if (pluginDescriptor == null) throw new Exception("Cannot load the plugin"); //plugin var plugin = pluginDescriptor.Instance() as FroogleService; if (plugin == null) throw new Exception("Cannot load the plugin"); plugin.GenerateStaticFile(); string clickhereStr = string.Format("<a href=\"{0}content/files/exportimport/{1}\" target=\"_blank\">{2}</a>", _webHelper.GetStoreLocation(false), _froogleSettings.StaticFileName, _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 }); } //task ScheduleTask task = FindScheduledTask(); if (task != null) { model.GenerateStaticFileEachMinutes = task.Seconds / 60; model.TaskEnabled = task.Enabled; } //file path if (System.IO.File.Exists(System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, "content\\files\\exportimport", _froogleSettings.StaticFileName))) model.StaticFilePath = string.Format("{0}content/files/exportimport/{1}", _webHelper.GetStoreLocation(false), _froogleSettings.StaticFileName); return View("Nop.Plugin.Feed.Froogle.Views.FeedFroogle.Configure", model); }
public ActionResult Configure(FeedFroogleModel model) { if (!ModelState.IsValid) { return Configure(); } string saveResult = ""; //save settings _froogleSettings.ProductPictureSize = model.ProductPictureSize; _froogleSettings.CurrencyId = model.CurrencyId; _froogleSettings.DefaultGoogleCategory = model.DefaultGoogleCategory; _settingService.SaveSetting(_froogleSettings); // Update the task var task = FindScheduledTask(); if (task != null) { task.Enabled = model.TaskEnabled; task.Seconds = model.GenerateStaticFileEachMinutes * 60; _scheduleTaskService.UpdateTask(task); saveResult = _localizationService.GetResource("Plugins.Feed.Froogle.TaskRestart"); } //redisplay the form 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 }); } //file path if (System.IO.File.Exists(System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, "content\\files\\exportimport", _froogleSettings.StaticFileName))) model.StaticFilePath = string.Format("{0}content/files/exportimport/{1}", _webHelper.GetStoreLocation(false), _froogleSettings.StaticFileName); //set result text model.SaveResult = saveResult; return View("Nop.Plugin.Feed.Froogle.Views.FeedFroogle.Configure", model); }
public ActionResult GoogleProductUpdate(FeedFroogleModel.GoogleProductModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins)) return Content("Access denied"); var googleProduct = _googleService.GetByProductId(model.ProductId); if (googleProduct != null) { googleProduct.Taxonomy = model.GoogleCategory; googleProduct.Gender = model.Gender; googleProduct.AgeGroup = model.AgeGroup; googleProduct.Color = model.Color; googleProduct.Size = model.GoogleSize; _googleService.UpdateGoogleProductRecord(googleProduct); } else { //insert googleProduct = new GoogleProductRecord { ProductId = model.ProductId, Taxonomy = model.GoogleCategory, Gender = model.Gender, AgeGroup = model.AgeGroup, Color = model.Color, Size = model.GoogleSize }; _googleService.InsertGoogleProductRecord(googleProduct); } return new NullJsonResult(); }
public ActionResult GoogleProductUpdate(GridCommand command, FeedFroogleModel.GoogleProductModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePromotionFeeds)) throw new NopException("Not authorized"); var googleProduct = _googleService.GetByProductVariantId(model.ProductVariantId); if (googleProduct != null) { //update googleProduct.Taxonomy = model.GoogleCategory; _googleService.UpdateGoogleProductRecord(googleProduct); } else { //insert googleProduct = new GoogleProductRecord() { ProductVariantId = model.ProductVariantId, Taxonomy = model.GoogleCategory }; _googleService.InsertGoogleProductRecord(googleProduct); } return GoogleProductList(command); }
public ActionResult GoogleProductUpdate(GridCommand command, FeedFroogleModel.GoogleProductModel model) { var googleProduct = _googleService.GetByProductVariantId(model.ProductVariantId); if (googleProduct != null) { //update googleProduct.Taxonomy = model.GoogleCategory; _googleService.UpdateGoogleProductRecord(googleProduct); } else { //insert googleProduct = new GoogleProductRecord() { ProductVariantId = model.ProductVariantId, Taxonomy = model.GoogleCategory }; _googleService.InsertGoogleProductRecord(googleProduct); } return GoogleProductList(command); }