public Image DoProcessPhoto(Image photo) { string fileName = ModuleSettingsProvider.GetAbsolutePath() + "Modules/" + ModuleStringId + "/" + ModuleSettingsProvider.GetSettingValue <string>("WatermarkImage", ModuleStringId); if (!File.Exists(fileName)) { return(photo); } using (Stream streamOpen = new FileStream(fileName, FileMode.Open)) { using (Image watermarkImage = Image.FromStream(streamOpen)) { using (var graphics = Graphics.FromImage(photo)) { graphics.DrawImage(watermarkImage, Convert.ToInt32((photo.Width * ModuleSettingsProvider.GetSettingValue <decimal>("WatermarkPositionX", ModuleStringId) / 100) - (watermarkImage.Width * ModuleSettingsProvider.GetSettingValue <decimal>("WatermarkPositionX", ModuleStringId) / 100)), Convert.ToInt32((photo.Height * ModuleSettingsProvider.GetSettingValue <decimal>("WatermarkPositionY", ModuleStringId) / 100) - (watermarkImage.Height * ModuleSettingsProvider.GetSettingValue <decimal>("WatermarkPositionY", ModuleStringId) / 100)), watermarkImage.Width, watermarkImage.Height); } } streamOpen.Close(); } return(photo); }
public string DoRenderIntoFinalStep(IOrder order) { var listid = ModuleSettingsProvider.GetSettingValue <string>("PriceListID", ModuleID); var offers = order.OrderItems.Select(item => OfferService.GetOffer(item.ArtNo)); return(string.Format("<script type='text/javascript'>var _tmr = _tmr || [];_tmr.push({{type: 'itemView', productid: [{0}], pagetype: 'purchase', totalvalue: '{1}', list: '{2}' }});</script>", offers.Select(o => "'" + o.OfferId + "'").AggregateString(","), order.OrderItems.Sum(item => item.Price * item.Amount), listid)); }
public static void AddStoreReview(StoreReview storeReview) { ModulesRepository.ModuleExecuteNonQuery( "INSERT INTO [Module].[StoreReview] ([ParentID],[Rate],[Review],[ReviewerEmail],[ReviewerName],[DateAdded],[Moderated]) VALUES (@ParentID,@Rate,@Review,@ReviewerEmail,@ReviewerName,GETDATE(),@Moderated)", CommandType.Text, new SqlParameter("@ParentID", storeReview.ParentId == 0 ? DBNull.Value : (object)storeReview.ParentId), new SqlParameter("@Rate", storeReview.Rate), new SqlParameter("@Review", storeReview.Review), new SqlParameter("@ReviewerEmail", storeReview.ReviewerEmail), new SqlParameter("@ReviewerName", storeReview.ReviewerName), new SqlParameter("@Moderated", storeReview.Moderated)); if (ModuleSettingsProvider.GetSettingValue <bool>("EnableSendMails", "StoreReviews")) { var message = ModuleSettingsProvider.GetSettingValue <string>("Format", "StoreReviews"); message = message.Replace("#NAME#", storeReview.ReviewerName); message = message.Replace("#EMAIL#", storeReview.ReviewerEmail); message = message.Replace("#REVIEW#", storeReview.Review); ModulesService.SendModuleMail( ModuleSettingsProvider.GetSettingValue <string>("Subject", "StoreReviews"), message, ModuleSettingsProvider.GetSettingValue <string>("Email", "StoreReviews"), true); } }
public string RenderToRightColumn() { if (!ModuleSettingsProvider.GetSettingValue <bool>("EnableQrcode", ModuleStringId)) { return(string.Empty); } return("<img src =\"Modules/AdvQrCode/GetQrCodeByUrl.ashx\"/ alt=\"qrcode\">"); }
public string DoRenderAfterBodyStart() { var counter = ModuleSettingsProvider.GetSettingValue <string>("COUNTER", ModuleID); if (string.IsNullOrEmpty(counter)) { return(string.Empty); } return("<div style='display:none !important;'>" + counter + "</div>"); }
public string DoRenderBeforeBodyEnd() { return (String.Format("<link rel='stylesheet' href='{0}' /><script src='{1}' data-callback-options data-callback-title='{2}' data-callback-text='{3}'></script>" + "<script src='{4}'></script>", "Modules/Callback/callback.css", "Modules/Callback/callback.js", ModuleSettingsProvider.GetSettingValue <string>("windowTitle", ModuleStringId), ModuleSettingsProvider.GetSettingValue <string>("windowText", ModuleStringId), "Modules/Callback/localization/" + CultureInfo.CurrentCulture.ToString() + "/lang.js" )); }
public static void SendEmail(CallbackCustomer callbackCustomer) { string email = ModuleSettingsProvider.GetSettingValue <string>("email4notify", _moduleName); string subject = ModuleSettingsProvider.GetSettingValue <string>("emailSubject", _moduleName); string format = ModuleSettingsProvider.GetSettingValue <string>("emailFormat", _moduleName); format = format.Replace("#NAME#", callbackCustomer.Name) .Replace("#PHONE#", callbackCustomer.Phone) .Replace("#COMMENT#", callbackCustomer.Comment); Mails.SendMail.SendMailNow(email, subject, format, true); }
public string DoRenderAfterBodyStart() { var counterId = ModuleSettingsProvider.GetSettingValue <string>("COUNTER_ID", ModuleID); var counter = ModuleSettingsProvider.GetSettingValue <string>("COUNTER", ModuleID); if (string.IsNullOrEmpty(counterId) || string.IsNullOrEmpty(counter)) { return(string.Empty); } return("<div style='display:none !important;'>" + counter + "</div>" + string.Format("<script type=\"text/javascript\" src=\"{0}\"></script> " + "<div class=\"yacounterid\" data-counterId=\"{1}\"></div>", "modules/yametrika/js/tracking.js", counterId)); }
public string RenderToProductInformation(int productId) { var discountModel = BuyInTimeService.GetByProduct(productId, DateTime.Now); if (discountModel == null) { return(string.Empty); } var actionTitle = ModuleSettingsProvider.GetSettingValue <string>("BuyInTimeActionTitle", ModuleStringId); var countdown = discountModel.DateExpired != null ? string.Format(BuyInTimeService.CountdownScript, ((DateTime)discountModel.DateExpired).ToString("dd.MM.yyyy HH:mm:ss")) : string.Empty; return(string.Format("<div class=\"buy-in-time-product\"><div class=\"buy-in-time-action-b\">{0}</div> {1}</div>", actionTitle, countdown)); }
public string DoRenderBeforeBodyEnd() { string res; var listid = ModuleSettingsProvider.GetSettingValue <string>("PriceListID", ModuleID); string url = HttpContext.Current.Request.Url.ToString().ToLower(); if (url.Contains("default.aspx")) { res = string.Format("<script type='text/javascript'>var _tmr = _tmr || [];_tmr.push({{type: 'itemView', productid: '', pagetype: 'home',totalvalue: '', list: '{0}' }});</script>", listid); } else if (url.Contains("catalog.aspx")) { res = string.Format("<script type='text/javascript'>var _tmr = _tmr || [];_tmr.push({{type: 'itemView', productid: '', pagetype: 'category', totalvalue:'', list: '{0}' }});</script>", listid); } else if (url.Contains("details.aspx")) { Offer mainOffer; var product = ProductService.GetProduct(HttpContext.Current.Request["ProductID"].TryParseInt()); if (product != null && (mainOffer = OfferService.GetMainOffer(product.Offers, product.AllowPreOrder, HttpContext.Current.Request["color"].TryParseInt(true), HttpContext.Current.Request["size"].TryParseInt(true))) != null) { res = string.Format("<script type='text/javascript'>var _tmr = _tmr || [];_tmr.push({{type: 'itemView',productid: '{0}',pagetype: 'product', totalvalue:'{1}',list: '{2}' }});</script>", mainOffer.OfferId, mainOffer.Price.ToString("F2").Replace(",", "."), listid); } else { res = string.Empty; } } else if (url.Contains("shoppingcart.aspx")) { var cart = ShoppingCartService.CurrentShoppingCart; res = string.Format("<script type='text/javascript'>var _tmr = _tmr || [];_tmr.push({{type: 'itemView',productid: [{0}], pagetype: 'cart', totalvalue:'{1}', list: '{2}' }});</script>", cart.Select(o => "'" + o.OfferId + "'").AggregateString(","), cart.TotalPrice.ToString("F2").Replace(",", "."), listid); } else { res = string.Format("<script type='text/javascript'>var _tmr = _tmr || [];_tmr.push({{type: 'itemView', productid: '', pagetype: 'other', totalvalue: '', list: '{0}' }});</script>", listid); } return(res); }
public ProductLabel GetLabel() { var labelCode = ModuleSettingsProvider.GetSettingValue <string>("BuyInTimeLabel", ModuleStringId); if (labelCode.IsNullOrEmpty()) { return(null); } var productDiscounts = BuyInTimeService.GetProductDiscountsList(DateTime.Now); if (productDiscounts == null || productDiscounts.Count == 0) { return(null); } return(new ProductLabel() { LabelCode = labelCode, ProductIds = productDiscounts.Select(p => p.ProductId).ToList() }); }
public string DoRenderIntoFinalStep(IOrder order) { var counterId = ModuleSettingsProvider.GetSettingValue <string>("COUNTER_ID", ModuleID); if (string.IsNullOrEmpty(counterId)) { return(string.Empty); } return(string.Format( "<script type=\"text/javascript\">\r\n" + "$(setTimeout(function () {{\r\n" + "var yaParams = {{ order_id:\"{0}\", order_price: {1}, currency: \"{2}\", exchange_rate: 1, goods: [{3}]}};\r\n" + "yaCounter{4}.reachGoal('Order', yaParams);\r\n" + "}},3000));\r\n" + "</script>\r\n", order.OrderID, order.Sum.ToString().Replace(",", "."), order.OrderCurrency.CurrencyCode, string.Join(", ", order.OrderItems.Select(orderItem => string.Format("{{ id: '{0}', name: '{1}', price: {2}, quantity: {3} }}", HttpUtility.HtmlEncode(orderItem.ArtNo), HttpUtility.HtmlEncode(orderItem.Name), orderItem.Price.ToString().Replace(",", "."), orderItem.Amount.ToString().Replace(",", ".")))), counterId)); }
public string RenderMainPageAfterCarousel() { var cacheKey = BuyInTimeService.CacheKey + BuyInTimeService.eShowMode.Vertical; if (CacheManager.Contains(cacheKey)) { return(CacheManager.Get <string>(cacheKey)); } var action = BuyInTimeService.GetByShowMode((int)BuyInTimeService.eShowMode.Vertical, DateTime.Now); var actionHorizontal = BuyInTimeService.GetByShowMode((int)BuyInTimeService.eShowMode.Horizontal, DateTime.Now); if (actionHorizontal != null && action != null && action.Id < actionHorizontal.Id) { CacheManager.Insert(cacheKey, ""); return(string.Empty); } if (action != null) { if (action.IsRepeat && action.DateExpired < DateTime.Now) { action.DateExpired = BuyInTimeService.GetExpireDateTime(action.DateExpired, action.DaysRepeat); } var actionTitle = ModuleSettingsProvider.GetSettingValue <string>("BuyInTimeActionTitle", ModuleStringId); var countdown = string.Format(BuyInTimeService.CountdownScript, action.DateExpired.ToString("dd.MM.yyyy HH:mm:ss")); var actionText = action.ActionText.Replace("#ActionTitle#", actionTitle) .Replace("#Countdown#", countdown); var product = ProductService.GetProduct(action.ProductId); if (product == null) { return(actionText); } var offer = product.Offers.FirstOrDefault(o => o.Main) ?? product.Offers.FirstOrDefault(); if (offer == null) { return(actionText); } actionText = actionText.Replace("#ProductPicture#", action.Picture.IsNotEmpty() ? string.Format("<img src=\"modules/{0}/pictures/{1}\" />", ModuleStringId.ToLower(), action.Picture) : string.Empty) .Replace("#ProductLink#", UrlService.GetLink(ParamType.Product, product.UrlPath, product.ProductId)) .Replace("#ProductName#", product.Name) .Replace("#OldPrice#", CatalogService.GetStringPrice(offer.Price).Replace("руб", "р")) .Replace("#NewPrice#", CatalogService.GetStringPrice(offer.Price, action.DiscountInTime).Replace("руб", "р")) .Replace("#DiscountPrice#", CatalogService.GetStringPrice(offer.Price * action.DiscountInTime / 100).Replace("руб", "р")) .Replace("#DiscountPercent#", action.DiscountInTime.ToString("0.##")); CacheManager.Insert(cacheKey, actionText); return(actionText); } return(string.Empty); }
public string GetShoppingCartPopupJson(Offer offer, float amount, bool isSocialTemplate) { var product = offer.Product; var shpCart = ShoppingCartService.CurrentShoppingCart; var totalItems = shpCart.TotalItems; var totalDiscount = shpCart.TotalDiscount; var totalPrice = shpCart.TotalPrice; var totalCounts = string.Format("{0} {1}", totalItems == 0 ? "" : totalItems.ToString(CultureInfo.InvariantCulture), Strings.Numerals(totalItems, Resource.Client_UserControls_ShoppingCart_Empty, Resource.Client_UserControls_ShoppingCart_1Product, Resource.Client_UserControls_ShoppingCart_2Products, Resource.Client_UserControls_ShoppingCart_5Products)); var customerGroup = CustomerContext.CurrentCustomer.CustomerGroup; var showMode = ModuleSettingsProvider.GetSettingValue <string>("showmode", ModuleID); var relatedProducts = new List <RelatedProductsModel>(); if (showMode != "none") { relatedProducts = ProductService.GetRelatedProducts(product.ProductId, showMode == "related" ? RelatedType.Related : RelatedType.Alternative) .Select(item => new RelatedProductsModel { ProductId = item.ProductId, Name = item.Name, ArtNo = item.ArtNo, Link = UrlService.GetLink(ParamType.Product, item.UrlPath, item.ProductId), Price = CatalogService.RenderPrice(item.MainPrice, item.Discount, true, customerGroup), Photo = item.Photo != null ? String.Format("<img src='{0}' alt='{1}' class='img-cart' />", FoldersHelper.GetImageProductPath(ProductImageType.Small, item.Photo, false), item.PhotoDesc) : "<img src='images/nophoto_xsmall.jpg' alt='' class='img-cart' />", Buttons = GetItemButtons(item) }).ToList(); } var obj = new { status = "success", showCart = true, tpl = "Modules/ShoppingCartPopup/cartpopup.tpl", product.Name, Sku = offer.ArtNo, TotalItems = totalItems, Price = CatalogService.RenderPrice(offer.Price, product.CalculableDiscount, true, customerGroup), Photo = offer.Photo != null ? String.Format("<img src='{0}' alt='{1}' class='img-cart' />", FoldersHelper.GetImageProductPath(ProductImageType.Small, offer.Photo.PhotoName, false), offer.Product.Name) : "<img src='images/nophoto_xsmall.jpg' alt='' class='img-cart' />", Link = isSocialTemplate ? "social/detailssocial.aspx?productid=" + product.ProductId : UrlService.GetLink(ParamType.Product, product.UrlPath, product.ProductId), ColorHeader = SettingsCatalog.ColorsHeader, ColorName = offer.Color != null ? offer.Color.ColorName : null, SizeHeader = SettingsCatalog.SizesHeader, SizeName = offer.Size != null ? offer.Size.SizeName : null, TotalCount = totalCounts, TotalPrice = CatalogService.GetStringPrice(totalPrice - totalDiscount > 0 ? totalPrice - totalDiscount : 0), RelatedTitle = showMode == "related" ? SettingsCatalog.RelatedProductName : SettingsCatalog.AlternativeProductName, RelatedProducts = relatedProducts }; return(JsonConvert.SerializeObject(obj)); }