void BuildUrlsForMediumImages() { ImageUrlsMedium = new string[ImageNumbers.Length, VariantColors.Length]; for (int j = ImageNumbers.GetLowerBound(0); j <= ImageNumbers.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(ImageNumbers[j]); for (int i = VariantColors.GetLowerBound(0); i <= VariantColors.GetUpperBound(0); i++) { if (ProductSku == string.Empty) { ImageUrlsMedium[j, i] = AppLogic.LookupProductImageByNumberAndColor(ProductId, SkinId, LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(VariantColors[i]), nameof(ProductImageSize.medium)); } else { ImageUrlsMedium[j, i] = AppLogic.LookupProductImageByNumberAndColor(ProductId, SkinId, ProductSku, LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(VariantColors[i]), nameof(ProductImageSize.medium)); } } } for (int j = ImageNumbers.GetLowerBound(0); j <= ImageNumbers.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(ImageNumbers[j]); if (ImageUrlsMedium[j, 0].IndexOf("nopicture") == -1) { ImageCountIndex = ImgIdx; } } }
static public bool PreChargeLookupAndStoreSession(Customer customer, int orderNumber, decimal cartTotal, string cardNumber, string expMonth, string expYear) { // use cardinal pre-auth fraud screening: var ACSUrl = string.Empty; var Payload = string.Empty; var TransactionID = string.Empty; var CardinalLookupResult = string.Empty; if (PreChargeLookup(cardNumber, Localization.ParseUSInt(expYear), Localization.ParseUSInt(expMonth), orderNumber, cartTotal, string.Empty, out ACSUrl, out Payload, out TransactionID, out CardinalLookupResult)) { // redirect to intermediary page which gets card password from user: customer.ThisCustomerSession["Cardinal.LookupResult"] = CardinalLookupResult; customer.ThisCustomerSession["Cardinal.ACSUrl"] = ACSUrl; customer.ThisCustomerSession["Cardinal.Payload"] = Payload; customer.ThisCustomerSession["Cardinal.TransactionID"] = TransactionID; customer.ThisCustomerSession["Cardinal.OrderNumber"] = orderNumber.ToString(); return(true); } else { customer.ThisCustomerSession["Cardinal.LookupResult"] = CardinalLookupResult; } return(false); }
// returns the <FieldName> element value of the currently active node as an integer public int CurrentFieldInt(XmlNode CurrentContext, String FieldName) { if (CurrentContext == null) { return(0); } return(Localization.ParseUSInt(XmlCommon.XmlField(CurrentContext, FieldName))); }
/// <summary> /// The QueryString of the request /// </summary> /// <param name="key">QueryString key</param> /// <param name="native">Parse native or parse based on culture</param> /// <returns></returns> public int IntValue(string key, ParseType parse) { if (this[key] == null) { return(0); } else { return(parse == ParseType.Native ? Localization.ParseNativeInt(this[key].ToString()): Localization.ParseUSInt(this[key].ToString())); } }
void BuildUrlsForIconImages(bool m_WatermarksEnabled) { ImageUrlsIcon = new string[ImageNumbers.Length, VariantColors.Length]; for (int x = ImageNumbers.GetLowerBound(0); x <= ImageNumbers.GetUpperBound(0); x++) { int ImgIdx = Localization.ParseUSInt(ImageNumbers[x]); for (int i = VariantColors.GetLowerBound(0); i <= VariantColors.GetUpperBound(0); i++) { string Url = string.Empty; if (ProductSku == string.Empty) { Url = AppLogic.LookupProductImageByNumberAndColor(ProductId, SkinId, LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(VariantColors[i]), nameof(ProductImageSize.icon)); } else { Url = AppLogic.LookupProductImageByNumberAndColor(ProductId, SkinId, ProductSku, LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(VariantColors[i]), nameof(ProductImageSize.icon)); } if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1) { if (Url.StartsWith("/")) { ImageUrlsIcon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length); } else { ImageUrlsIcon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1); } if (ImageUrlsIcon[x, i].StartsWith("/")) { ImageUrlsIcon[x, i] = ImageUrlsIcon[x, i].TrimStart('/'); } } else { ImageUrlsIcon[x, i] = Url; } } } for (int x = ImageNumbers.GetLowerBound(0); x <= ImageNumbers.GetUpperBound(0); x++) { int ImgIdx = Localization.ParseUSInt(ImageNumbers[x]); if (ImageUrlsIcon[x, 0].IndexOf("nopicture") == -1) { ImageCountIndex = ImgIdx; } } }
public void LoadFromDB() { string suffix = "_" + m_ProductID.ToString(); string pvsuffix = "_" + m_ProductID.ToString() + "_" + m_VariantID.ToString(); m_ImageNumbersSplit = m_ImageNumbers.Split(','); bool m_WatermarksEnabled = AppLogic.AppConfigBool("Watermark.Enabled"); m_ColorsSplit = new String[1] { "" }; if (m_Colors == String.Empty) { using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn())) { dbconn.Open(); using (IDataReader rs = DB.GetRS("select Colors from productvariant with (NOLOCK) where VariantID=" + m_VariantID.ToString(), dbconn)) { if (rs.Read()) { m_Colors = DB.RSFieldByLocale(rs, "Colors", Localization.GetDefaultLocale()); // remember to add "empty" color to front, for no color selected if (m_Colors.Length != 0) { m_ColorsSplit = ("," + m_Colors).Split(','); } } } } } else { m_ColorsSplit = ("," + m_Colors).Split(','); } if (m_Colors.Length != 0) { for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String s2 = AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]); m_ColorsSplit[i] = CommonLogic.MakeSafeFilesystemName(s2); } } if (AppLogic.AppConfigBool("MultiImage.UseProductIconPics")) { m_ImageUrlsicon = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length]; for (int x = m_ImageNumbersSplit.GetLowerBound(0); x <= m_ImageNumbersSplit.GetUpperBound(0); x++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[x]); for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String Url = string.Empty; if (m_ProductSKU == string.Empty) { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "icon"); } else { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "icon"); } if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1) { if (Url.StartsWith("/")) { m_ImageUrlsicon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length); } else { m_ImageUrlsicon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1); } if (m_ImageUrlsicon[x, i].StartsWith("/")) { m_ImageUrlsicon[x, i] = m_ImageUrlsicon[x, i].TrimStart('/'); } } else { m_ImageUrlsicon[x, i] = Url; } } } for (int x = m_ImageNumbersSplit.GetLowerBound(0); x <= m_ImageNumbersSplit.GetUpperBound(0); x++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[x]); if (m_ImageUrlsicon[x, 0].IndexOf("nopicture") == -1) { m_MaxImageIndex = ImgIdx; } } } m_ImageUrlsmedium = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length]; for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]); for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String Url = string.Empty; if (m_ProductSKU == string.Empty) { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "medium"); } else { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "medium"); } if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1) { if (Url.StartsWith("/")) { m_ImageUrlsmedium[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length); } else { m_ImageUrlsmedium[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1); } if (m_ImageUrlsmedium[j, i].StartsWith("/")) { m_ImageUrlsmedium[j, i] = m_ImageUrlsmedium[j, i].TrimStart('/'); } } else { m_ImageUrlsmedium[j, i] = Url; } } } for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]); if (m_ImageUrlsmedium[j, 0].IndexOf("nopicture") == -1) { m_MaxImageIndex = ImgIdx; } } m_ImageUrlslarge = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length]; for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]); for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String Url = string.Empty; if (m_ProductSKU == string.Empty) { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "large"); } else { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "large"); } if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1) { if (Url.StartsWith("/")) { m_ImageUrlslarge[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length); } else { m_ImageUrlslarge[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1); } if (m_ImageUrlslarge[j, i].StartsWith("/")) { m_ImageUrlslarge[j, i] = m_ImageUrlslarge[j, i].TrimStart('/'); } m_HasSomeLarge = true; } else if (Url.Length == 0 || Url.IndexOf("nopicture") != -1) { m_ImageUrlslarge[j, i] = String.Empty; } else { m_HasSomeLarge = true; m_ImageUrlslarge[j, i] = Url; } } } if (!IsEmpty()) { bool AttemptZoomify = AppLogic.AppConfigBool("Zoomify.Active") && (AppLogic.AppConfigBool("Zoomify.GalleryMedium") || AppLogic.AppConfigBool("Zoomify.ProductMedium")); bool GalleryZoomify = AttemptZoomify && AppLogic.AppConfigBool("Zoomify.GalleryMedium"); StringBuilder tmpS = new StringBuilder(4096); tmpS.Append("<script type=\"text/javascript\">\n"); tmpS.Append("var ProductPicIndex" + suffix + " = 1;\n"); tmpS.Append("var ProductColor" + suffix + " = '';\n"); tmpS.Append("var boardpics" + suffix + " = new Array();\n"); tmpS.Append("var boardpicslg" + suffix + " = new Array();\n"); tmpS.Append("var boardpicslgwidth" + suffix + " = new Array();\n"); tmpS.Append("var boardpicslgheight" + suffix + " = new Array();\n"); if (AttemptZoomify) { tmpS.Append("var boardpicsZ" + suffix + " = new Array();\n"); } for (int i = 1; i <= m_MaxImageIndex; i++) { foreach (String c in m_ColorsSplit) { String MdUrl = ImageUrl(i, c, "medium").ToLowerInvariant(); String MdWatermarkedUrl = MdUrl; if (m_WatermarksEnabled) { if (MdUrl.Length > 0) { string[] split = MdUrl.Split('/'); string lastPart = split.Last(); MdUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", "medium", ""); } } tmpS.Append("boardpics" + suffix + "['" + i.ToString() + "," + c + "'] = '" + MdWatermarkedUrl + "';\n"); String LgUrl = ImageUrl(i, c, "large").ToLowerInvariant(); String LgWatermarkedUrl = LgUrl; if (m_WatermarksEnabled) { if (LgUrl.Length > 0) { string[] split = LgUrl.Split('/'); string lastPart = split.Last(); LgUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", "large", ""); } } tmpS.Append("boardpicslg" + suffix + "['" + i.ToString() + "," + c + "'] = '" + LgWatermarkedUrl + "';\n"); if (LgUrl.Length > 0) { System.Drawing.Size lgsz = CommonLogic.GetImagePixelSize(LgUrl); tmpS.Append("boardpicslgwidth" + suffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Width.ToString() + "';\n"); tmpS.Append("boardpicslgheight" + suffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Height.ToString() + "';\n"); } if (AttemptZoomify) { String ZMdUrl = string.Empty; // Yes we use the large url here, because the Zoomify data is always in Large if (LgUrl.Length > 0) { ZMdUrl = LgUrl.Remove(LgUrl.Length - 4); // remove extension } if (GalleryZoomify && CommonLogic.FileExists(CommonLogic.SafeMapPath(LgUrl))) { tmpS.Append("boardpicsZ" + suffix + "['" + i.ToString() + "," + c + "'] = '" + AppLogic.RunXmlPackage("Zoomify.Medium", null, null, m_SkinID, "", "ImagePath=" + ZMdUrl + "&AltSrc=" + LgUrl, false, false).Replace("\r\n", " ").Replace("\r", " ").Replace("\n", " ").Replace("'", "\\'") + "';\n"); // the Replace's are to make the xmlpackage output consumable by javascript } else { tmpS.Append("boardpicsZ" + suffix + "['" + i.ToString() + "," + c + "'] = '';\n"); } } } } if (AttemptZoomify) { tmpS.Append("function changeContent(markup)\n"); tmpS.Append("{\n"); tmpS.Append(" id='divProductPicZ"+ m_ProductID.ToString() + "';\n"); tmpS.Append(" if (document.getElementById || document.all)\n"); tmpS.Append(" {\n"); tmpS.Append(" var el = document.getElementById? document.getElementById(id): document.all[id];\n"); tmpS.Append(" if (el && typeof el.innerHTML != \"undefined\") el.innerHTML = markup;\n"); tmpS.Append(" }\n"); tmpS.Append("}\n"); } tmpS.Append("function changecolorimg" + suffix + "()\n"); tmpS.Append("{\n"); tmpS.Append(" var scidx = ProductPicIndex"+ suffix + " + ',' + ProductColor" + suffix + ".toLowerCase();\n"); if (AttemptZoomify) { tmpS.Append("if (boardpicsZ" + suffix + "[scidx]!='') {\n"); tmpS.Append(" divProductPicZ" + m_ProductID.ToString() + ".style.display='inline';\n"); tmpS.Append(" divProductPic" + m_ProductID.ToString() + ".style.display='none';\n"); tmpS.Append(" changeContent(boardpicsZ" + suffix + "[scidx]); }\n"); tmpS.Append("else {\n"); tmpS.Append(" divProductPicZ" + m_ProductID.ToString() + ".style.display='none';\n"); tmpS.Append(" divProductPic" + m_ProductID.ToString() + ".style.display='inline';\n"); tmpS.Append(" document.ProductPic" + m_ProductID.ToString() + ".src=boardpics" + suffix + "[scidx]; }\n"); } else { tmpS.Append(" document.ProductPic"+ m_ProductID.ToString() + ".src=boardpics" + suffix + "[scidx];\n"); } tmpS.Append("}\n"); tmpS.Append("function popuplarge" + suffix + "()\n"); tmpS.Append("{\n"); tmpS.Append(" var scidx = ProductPicIndex"+ suffix + " + ',' + ProductColor" + suffix + ".toLowerCase();\n"); tmpS.Append(" var LargeSrc = boardpicslg"+ suffix + "[scidx];\n"); if (m_WatermarksEnabled) { tmpS.AppendFormat(" var imageName = LargeSrc.split(\"/\").pop(-1);{0}", Environment.NewLine); tmpS.AppendFormat(" LargeSrc = 'watermark.axd?size=large&imgurl=images/product/large/' + imageName;{0}", Environment.NewLine); } tmpS.Append("if(boardpicslg" + suffix + "[scidx] != '')\n"); tmpS.Append("{\n"); tmpS.Append(" window.open('popup.aspx?src=' + LargeSrc,'LargerImage"+ CommonLogic.GetRandomNumber(1, 100000) + "','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",resizable=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",copyhistory=no,width=' + boardpicslgwidth" + suffix + "[scidx] + ',height=' + boardpicslgheight" + suffix + "[scidx] + ',left=0,top=0');\n"); tmpS.Append("}\n"); tmpS.Append("else\n"); tmpS.Append("{\n"); tmpS.Append(" alert('There is no large image available for this picture');\n"); tmpS.Append("}\n"); tmpS.Append("}\n"); tmpS.Append("function setcolorpicidx" + suffix + "(idx)\n"); tmpS.Append("{\n"); tmpS.Append(" ProductPicIndex"+ suffix + " = idx;\n"); tmpS.Append(" changecolorimg"+ suffix + "();\n"); tmpS.Append("}\n"); tmpS.Append("function setActive(element)\n"); tmpS.Append("{\n"); tmpS.Append(" adnsf$('li.page-link').removeClass('active');\n"); tmpS.Append(" adnsf$(element).parent().addClass('active');\n"); tmpS.Append("}\n"); tmpS.Append("function cleansizecoloroption" + suffix + "(theVal)\n"); tmpS.Append("{\n"); tmpS.Append(" if(theVal.indexOf('[') != -1){theVal = theVal.substring(0, theVal.indexOf('['))}"); tmpS.Append(" theVal = theVal.replace(/[\\W]/g,\"\");\n"); tmpS.Append(" theVal = theVal.toLowerCase();\n"); tmpS.Append(" return theVal;\n"); tmpS.Append("}\n"); tmpS.Append("function setcolorpic" + suffix + "(color)\n"); tmpS.Append("{\n"); tmpS.Append(" while(color != unescape(color))\n"); tmpS.Append(" {\n"); tmpS.Append(" color = unescape(color);\n"); tmpS.Append(" }\n"); tmpS.Append(" if(color == '-,-' || color == '-')\n"); tmpS.Append(" {\n"); tmpS.Append(" color = '';\n"); tmpS.Append(" }\n"); tmpS.Append(" if(color != '' && color.indexOf(',') != -1)\n"); tmpS.Append(" {\n"); tmpS.Append(" color = color.substring(0,color.indexOf(',')).replace(new RegExp(\"'\", 'gi'), '');\n"); // remove sku from color select value tmpS.Append(" }\n"); tmpS.Append(" if(color != '' && color.indexOf('[') != -1)\n"); tmpS.Append(" {\n"); tmpS.Append(" color = color.substring(0,color.indexOf('[')).replace(new RegExp(\"'\", 'gi'), '');\n"); tmpS.Append(" color = color.replace(/[\\s]+$/g,\"\");\n"); tmpS.Append(" }\n"); tmpS.Append(" ProductColor"+ suffix + " = cleansizecoloroption" + suffix + "(color);\n"); tmpS.Append(" changecolorimg"+ suffix + "();\n"); tmpS.Append(" setcolorlisttoactiveitem"+ suffix + "(color);\n"); tmpS.Append(" return (true);\n"); tmpS.Append("}\n"); // this one (without suffix) added back for backwards compatibility with older existing product data, where // the swatch map called to this js routine directly tmpS.Append("function setcolorpic(color)\n"); tmpS.Append("{\n"); tmpS.Append(" if(color == '-,-' || color == '-')\n"); tmpS.Append(" {\n"); tmpS.Append(" color = '';\n"); tmpS.Append(" }\n"); tmpS.Append(" if(color != '' && color.indexOf(',') != -1)\n"); tmpS.Append(" {\n"); tmpS.Append(" color = color.substring(0,color.indexOf(',')).replace(new RegExp(\"'\", 'gi'), '');\n"); // remove sku from color select value tmpS.Append(" }\n"); tmpS.Append(" if(color != '' && color.indexOf('[') != -1)\n"); tmpS.Append(" {\n"); tmpS.Append(" color = color.substring(0,color.indexOf('[')).replace(new RegExp(\"'\", 'gi'), '');\n"); tmpS.Append(" color = color.replace(/[\\s]+$/g,\"\");\n"); tmpS.Append(" }\n"); tmpS.Append(" ProductColor"+ suffix + " = cleansizecoloroption" + suffix + "(color);\n"); tmpS.Append(" changecolorimg"+ suffix + "();\n"); tmpS.Append(" setcolorlisttoactiveitem"+ suffix + "(color.toLowerCase());\n"); tmpS.Append(" return (true);\n"); tmpS.Append("}\n"); tmpS.Append("function setcolorlisttoactiveitem" + suffix + "(color)\n"); tmpS.Append("{\n"); tmpS.Append("var lst = document.getElementById('Color" + pvsuffix + "');\n"); tmpS.Append("var matchColor = cleansizecoloroption" + suffix + "(color);\n"); tmpS.Append("for (var i=0; i < lst.length; i++)\n"); tmpS.Append(" {\n"); tmpS.Append("var value = lst[i].value;\n"); tmpS.Append("var arrayValue = value.split(',');\n"); tmpS.Append("var lstColor = cleansizecoloroption" + suffix + "(arrayValue[0]);\n"); //tmpS.Append(" var lstColor = cleansizecoloroption" + suffix + "(lst[i].value);\n"); tmpS.Append(" if (lstColor == matchColor)\n"); tmpS.Append(" {\n"); tmpS.Append(" lst.selectedIndex = i;\n"); tmpS.Append(" return (true);\n"); tmpS.Append(" }\n"); tmpS.Append(" }\n"); tmpS.Append("return (true);\n"); tmpS.Append("}\n"); tmpS.Append("</script>\n"); m_ImgDHTML = tmpS.ToString(); bool useMicros = AppLogic.AppConfigBool("UseImagesForMultiNav"); bool microAction = CommonLogic.IIF(AppLogic.AppConfigBool("UseRolloverForMultiNav"), true, false); if (m_MaxImageIndex > 1) { tmpS.Remove(0, tmpS.Length); if (!AppLogic.AppConfigBool("MultiImage.UseProductIconPics") && !useMicros) { tmpS.Append("<ul class=\"pagination image-paging\">"); for (int i = 1; i <= m_MaxImageIndex; i++) { if (i == 1) { tmpS.Append("<li class=\"page-link active\">"); } else { tmpS.Append("<li class=\"page-link\">"); } tmpS.Append(string.Format("<a href=\"javascript:void(0);\" onclick='setcolorpicidx{0}({1});setActive(this);' class=\"page-number\">{1}</a>", suffix, i)); tmpS.Append("</li>"); } tmpS.Append("</ul>"); } else { tmpS.Append("<div class=\"product-gallery-items\">"); for (int i = 1; i <= m_MaxImageIndex; i++) { tmpS.Append("<div class=\"product-gallery-item\">"); tmpS.Append(" <div class=\"gallery-item-inner\">"); if (AppLogic.AppConfigBool("MultiImage.UseProductIconPics")) { string strImageTag = "<img class='product-gallery-image' onclick='setcolorpicidx{0}({1});setImageURL(\"{2}\")' alt='Show Picture {1}' src='{2}' border='0' />"; tmpS.AppendFormat(strImageTag, new object[] { suffix, i, m_ImageUrlsicon[i - 1, 0].ToString() }); } else { // check for different extensions but don't let the non existance leave a gap // or crash because it can't find an image String ImageLoc = String.Empty; if (AppLogic.AppConfigBool("UseSKUForProductImageName")) { using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn())) { dbconn.Open(); using (IDataReader skus = DB.GetRS("SELECT p.SKU FROM Product p with (NOLOCK) WHERE p.ProductID=" + m_ProductID.ToString(), dbconn)) { try { String microSKU = String.Empty; if (skus.Read()) { microSKU = DB.RSField(skus, "SKU"); } ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + ".gif"); if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + "_" + ".gif"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + ".jpg"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + "_" + ".jpg"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + ".png"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + "_" + ".png"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("App_Themes/skin_" + m_SkinID + "/images/nopicturemicro.gif"); } } catch { } } } } else { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + ".gif"); if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + "_" + ".gif"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + ".jpg"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + "_" + ".jpg"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + ".png"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + "_" + ".png"); } if (!CommonLogic.FileExists(ImageLoc)) { ImageLoc = AppLogic.LocateImageURL("App_Themes/skin_" + m_SkinID + "/images/nopicturemicro.gif"); } } // if not using rollover to change the images if (!microAction && ImageLoc.Length > 0) { string strImageTag = string.Format("<img class='product-gallery-image' onclick='setcolorpicidx{0}({1});setImageURL(\"{2}\")' alt='Show Picture {1}' src='{2}' border='0' />", new object[] { suffix, i, ImageLoc }); tmpS.Append(strImageTag); } else if (ImageLoc.Length > 0) { string strImageTag = string.Format("<img class='product-gallery-image' onMouseOver='setcolorpicidx{0}({1});setImageURL(\"{2}\")' alt='Show Picture {1}' src='{2}' border='0' />", new object[] { suffix, i, ImageLoc }); tmpS.Append(strImageTag); } } tmpS.Append(" </div>"); tmpS.Append("</div>"); } tmpS.Append("</div>"); } m_ImgGalIcons = tmpS.ToString(); } } }
public static int CookieUSInt(String paramName) { String tmpS = CookieCanBeDangerousContent(paramName, true); return(Localization.ParseUSInt(tmpS)); }
public static int ApplicationUSInt(String paramName) { String tmpS = Application(paramName); return(Localization.ParseUSInt(tmpS)); }
public static int QueryStringUSInt(String paramName) { String tmpS = QueryStringCanBeDangerousContent(paramName); return(Localization.ParseUSInt(tmpS)); }
public int SessionUSInt(String paramName) { String tmpS = Session(paramName); return(Localization.ParseUSInt(tmpS)); }
public bool Commit() { bool commited = false; Customer ThisCustomer = AppLogic.GetCurrentCustomer(); if (ThisCustomer.IsAdminUser) { bool topicexists = GetTopicID(TopicName, AppLogic.StoreID()) > 0; // ok to add them: if (!topicexists) { StringBuilder sql = new StringBuilder(2500); String NewGUID = DB.GetNewGUID(); sql.Append("insert into Topic(TopicGUID,Name,SkinID,DisplayOrder,ContentsBGColor,PageBGColor,GraphicsColor,Title,Description,Password,RequiresSubscription,HTMLOk,RequiresDisclaimer,ShowInSiteMap,SEKeywords,SEDescription,SETitle) values("); sql.Append(DB.SQuote(NewGUID) + ","); sql.Append(DB.SQuote(AppLogic.FormLocaleXml(TopicName, LocaleSetting)) + ","); sql.Append(Localization.ParseUSInt(SkinID.ToString()) + ","); sql.Append(Localization.ParseUSInt(DisplayOrder.ToString()) + ","); sql.Append(DB.SQuote(ContentsBGColor) + ","); sql.Append(DB.SQuote(PageBGColor) + ","); sql.Append(DB.SQuote(GraphicsColor) + ","); sql.Append(DB.SQuote(AppLogic.FormLocaleXml(SectionTitle, LocaleSetting)) + ","); if (Contents.Length != 0) { sql.Append(DB.SQuote(Contents) + ","); } else { sql.Append("NULL,"); } if (Password.Trim().Length != 0) { sql.Append(DB.SQuote(Password) + ","); } else { sql.Append("NULL,"); } sql.Append(CommonLogic.IIF(RequiresSubscription, "1", "0") + ","); sql.Append(CommonLogic.IIF(HTMLOk, "1", "0") + ","); sql.Append(CommonLogic.IIF(RequiresDisclaimer, "1", "0") + ","); sql.Append(CommonLogic.IIF(ShowInSiteMap, "1", "0") + ","); if (AppLogic.FormLocaleXml("ltSEKeywords").Length != 0) { sql.Append(DB.SQuote(AppLogic.FormLocaleXml(SEKeywords, LocaleSetting)) + ","); } else { sql.Append("NULL,"); } if (AppLogic.FormLocaleXml("ltSEDescription").Length != 0) { sql.Append(DB.SQuote(AppLogic.FormLocaleXml(SEDescription, LocaleSetting)) + ","); } else { sql.Append("NULL,"); } if (AppLogic.FormLocaleXml("ltSETitle").Length != 0) { sql.Append(DB.SQuote(AppLogic.FormLocaleXml(SETitle, LocaleSetting))); } else { sql.Append("NULL"); } sql.Append(")"); try { DB.ExecuteSQL(sql.ToString()); commited = true; LoadFromDB(AppLogic.StoreID()); } catch { commited = false; } } } return(commited); }
public void LoadFromDB() { var suffix = "_" + m_ProductID.ToString(); m_ImageNumbersSplit = m_ImageNumbers.Split(','); var m_WatermarksEnabled = AppLogic.AppConfigBool("Watermark.Enabled"); var urlHelper = DependencyResolver.Current.GetService <UrlHelper>(); m_ColorsSplit = new String[1] { "" }; if (m_Colors == string.Empty) { using (var dbconn = new SqlConnection(DB.GetDBConn())) { dbconn.Open(); using (var rs = DB.GetRS("select Colors from productvariant with (NOLOCK) where VariantID=" + m_VariantID.ToString(), dbconn)) { if (rs.Read()) { m_Colors = DB.RSFieldByLocale(rs, "Colors", Localization.GetDefaultLocale()); // remember to add "empty" color to front, for no color selected if (m_Colors.Length != 0) { m_ColorsSplit = ("," + m_Colors).Split(','); } } } } } else { m_ColorsSplit = ("," + m_Colors).Split(','); } if (m_Colors.Length != 0) { for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String s2 = AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]); m_ColorsSplit[i] = CommonLogic.MakeSafeFilesystemName(s2); } } if (AppLogic.AppConfigBool("MultiImage.UseProductIconPics")) { m_ImageUrlsicon = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length]; for (int x = m_ImageNumbersSplit.GetLowerBound(0); x <= m_ImageNumbersSplit.GetUpperBound(0); x++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[x]); for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String Url = string.Empty; if (m_ProductSKU == string.Empty) { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "icon"); } else { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "icon"); } if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1) { if (Url.StartsWith("/")) { m_ImageUrlsicon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length); } else { m_ImageUrlsicon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1); } if (m_ImageUrlsicon[x, i].StartsWith("/")) { m_ImageUrlsicon[x, i] = m_ImageUrlsicon[x, i].TrimStart('/'); } } else { m_ImageUrlsicon[x, i] = Url; } } } for (int x = m_ImageNumbersSplit.GetLowerBound(0); x <= m_ImageNumbersSplit.GetUpperBound(0); x++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[x]); if (m_ImageUrlsicon[x, 0].IndexOf("nopicture") == -1) { m_MaxImageIndex = ImgIdx; } } } m_ImageUrlsmedium = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length]; for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]); for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { if (m_ProductSKU == string.Empty) { m_ImageUrlsmedium[j, i] = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "medium"); } else { m_ImageUrlsmedium[j, i] = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "medium"); } } } for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]); if (m_ImageUrlsmedium[j, 0].IndexOf("nopicture") == -1) { m_MaxImageIndex = ImgIdx; } } m_ImageUrlslarge = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length]; for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++) { int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]); for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++) { String Url = string.Empty; if (m_ProductSKU == string.Empty) { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "large"); } else { Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "large"); } if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1) { if (Url.StartsWith("/")) { m_ImageUrlslarge[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length); } else { m_ImageUrlslarge[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1); } if (m_ImageUrlslarge[j, i].StartsWith("/")) { m_ImageUrlslarge[j, i] = m_ImageUrlslarge[j, i].TrimStart('/'); } m_HasSomeLarge = true; } else if (Url.Length == 0 || Url.IndexOf("nopicture") != -1) { m_ImageUrlslarge[j, i] = String.Empty; } else { m_HasSomeLarge = true; m_ImageUrlslarge[j, i] = Url; } } } if (!IsEmpty()) { StringBuilder tmpS = new StringBuilder(4096); tmpS.Append("<script type=\"text/javascript\">\n"); tmpS.Append("var ProductPicIndex" + suffix + " = 1;\n"); tmpS.Append("var ProductColor" + suffix + " = '';\n"); tmpS.Append("var boardpics" + suffix + " = new Array();\n"); tmpS.Append("var boardpicslg" + suffix + " = new Array();\n"); tmpS.Append("var boardpicslgwidth" + suffix + " = new Array();\n"); tmpS.Append("var boardpicslgheight" + suffix + " = new Array();\n"); for (int i = 1; i <= m_MaxImageIndex; i++) { foreach (String c in m_ColorsSplit) { String MdUrl = ImageUrl(i, c, "medium").ToLowerInvariant(); String MdWatermarkedUrl = MdUrl; if (m_WatermarksEnabled) { if (MdUrl.Length > 0) { string[] split = MdUrl.Split('/'); string lastPart = split.Last(); MdUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", "medium", ""); } } tmpS.Append("boardpics" + suffix + "['" + i.ToString() + "," + c + "'] = '" + MdWatermarkedUrl + "';\n"); String LgUrl = ImageUrl(i, c, "large").ToLowerInvariant(); String LgWatermarkedUrl = LgUrl; if (m_WatermarksEnabled) { if (LgUrl.Length > 0) { string[] split = LgUrl.Split('/'); string lastPart = split.Last(); LgUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", "large", ""); } } tmpS.Append("boardpicslg" + suffix + "['" + i.ToString() + "," + c + "'] = '" + LgWatermarkedUrl + "';\n"); if (LgUrl.Length > 0) { System.Drawing.Size lgsz = CommonLogic.GetImagePixelSize(LgUrl); tmpS.Append("boardpicslgwidth" + suffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Width.ToString() + "';\n"); tmpS.Append("boardpicslgheight" + suffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Height.ToString() + "';\n"); } } } tmpS.Append("function changecolorimg" + suffix + "()\n"); tmpS.Append("{\n"); tmpS.Append(" var scidx = ProductPicIndex"+ suffix + " + ',' + ProductColor" + suffix + ".toLowerCase();\n"); tmpS.Append(" document.ProductPic"+ m_ProductID.ToString() + ".src=boardpics" + suffix + "[scidx];\n"); tmpS.Append("}\n"); tmpS.Append("function popuplarge" + suffix + "()\n"); tmpS.Append("{\n"); tmpS.Append(" var scidx = ProductPicIndex"+ suffix + " + ',' + ProductColor" + suffix + ".toLowerCase();\n"); tmpS.Append(" var LargeSrc = encodeURIComponent(boardpicslg"+ suffix + "[scidx]);\n"); tmpS.Append("if(boardpicslg" + suffix + "[scidx] != '')\n"); tmpS.Append("{\n"); var popupUrl = urlHelper.Action(ActionNames.PopUp, ControllerNames.Image); tmpS.Append(" window.open('"+ popupUrl + "?" + RouteDataKeys.ImagePath + "=' + LargeSrc,'LargerImage" + CommonLogic.GetRandomNumber(1, 100000) + "','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",resizable=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",copyhistory=no,width=' + boardpicslgwidth" + suffix + "[scidx] + ',height=' + boardpicslgheight" + suffix + "[scidx] + ',left=0,top=0');\n"); tmpS.Append("}\n"); tmpS.Append("else\n"); tmpS.Append("{\n"); tmpS.Append(" alert('There is no large image available for this picture');\n"); tmpS.Append("}\n"); tmpS.Append("}\n"); tmpS.Append("function setcolorpicidx" + suffix + "(idx)\n"); tmpS.Append("{\n"); tmpS.Append(" ProductPicIndex"+ suffix + " = idx;\n"); tmpS.Append(" changecolorimg"+ suffix + "();\n"); tmpS.Append("}\n"); tmpS.Append("function setActive(element)\n"); tmpS.Append("{\n"); tmpS.Append(" adnsf$('li.page-link').removeClass('active');\n"); tmpS.Append(" adnsf$(element).parent().addClass('active');\n"); tmpS.Append("}\n"); tmpS.Append("function cleansizecoloroption" + suffix + "(theVal)\n"); tmpS.Append("{\n"); tmpS.Append(" if(theVal.indexOf('[') != -1){theVal = theVal.substring(0, theVal.indexOf('['))}"); tmpS.Append(" theVal = theVal.replace(/[\\W]/g,\"\");\n"); tmpS.Append(" theVal = theVal.toLowerCase();\n"); tmpS.Append(" return theVal;\n"); tmpS.Append("}\n"); tmpS.Append("function setcolorpic" + suffix + "(color)\n"); tmpS.Append("{\n"); tmpS.Append(" while(color != unescape(color))\n"); tmpS.Append(" {\n"); tmpS.Append(" color = unescape(color);\n"); tmpS.Append(" }\n"); tmpS.Append(" if(color == '-,-' || color == '-')\n"); tmpS.Append(" {\n"); tmpS.Append(" color = '';\n"); tmpS.Append(" }\n"); tmpS.Append(" if(color != '' && color.indexOf(',') != -1)\n"); tmpS.Append(" {\n"); tmpS.Append(" color = color.substring(0,color.indexOf(',')).replace(new RegExp(\"'\", 'gi'), '');\n"); // remove sku from color select value tmpS.Append(" }\n"); tmpS.Append(" if(color != '' && color.indexOf('[') != -1)\n"); tmpS.Append(" {\n"); tmpS.Append(" color = color.substring(0,color.indexOf('[')).replace(new RegExp(\"'\", 'gi'), '');\n"); tmpS.Append(" color = color.replace(/[\\s]+$/g,\"\");\n"); tmpS.Append(" }\n"); tmpS.Append(" ProductColor"+ suffix + " = cleansizecoloroption" + suffix + "(color);\n"); tmpS.Append(" changecolorimg"+ suffix + "();\n"); tmpS.Append(" return (true);\n"); tmpS.Append("}\n"); tmpS.Append("</script>\n"); m_ImgDHTML = tmpS.ToString(); bool useMicros = AppLogic.AppConfigBool("UseImagesForMultiNav"); bool microAction = CommonLogic.IIF(AppLogic.AppConfigBool("UseRolloverForMultiNav"), true, false); if (m_MaxImageIndex > 1) { tmpS.Remove(0, tmpS.Length); if (!AppLogic.AppConfigBool("MultiImage.UseProductIconPics") && !useMicros) { tmpS.Append("<ul class=\"pagination image-paging\">"); for (int i = 1; i <= m_MaxImageIndex; i++) { if (i == 1) { tmpS.Append("<li class=\"page-link active\">"); } else { tmpS.Append("<li class=\"page-link\">"); } tmpS.Append(string.Format("<a href=\"javascript:void(0);\" onclick='setcolorpicidx{0}({1});setActive(this);' class=\"page-number\">{1}</a>", suffix, i)); tmpS.Append("</li>"); } tmpS.Append("</ul>"); } else { tmpS.Append("<div class=\"product-gallery-items\">"); for (int i = 1; i <= m_MaxImageIndex; i++) { tmpS.Append("<div class=\"product-gallery-item\">"); tmpS.Append(" <div class=\"gallery-item-inner\">"); var imageUrl = GetImageUrl( size: AppLogic.AppConfigBool("MultiImage.UseProductIconPics") ? "icon" : "micro", identifier: AppLogic.AppConfigBool("UseSKUForProductImageName") ? m_ProductSKU : m_ProductID.ToString(), index: i); // if not using rollover to change the images if (!microAction && imageUrl.Length > 0) { var strImageTag = string.Format("<img class='product-gallery-image' onclick='setcolorpicidx{0}({1});' alt='Show Picture {1}' src='{2}' border='0' />", suffix, i, imageUrl ); tmpS.Append(strImageTag); } else if (imageUrl.Length > 0) { var strImageTag = string.Format("<img class='product-gallery-image' onMouseOver='setcolorpicidx{0}({1});' alt='Show Picture {1}' src='{2}' border='0' />", suffix, i, imageUrl ); tmpS.Append(strImageTag); } tmpS.Append(" </div>"); tmpS.Append("</div>"); } tmpS.Append("</div>"); } m_ImgGalIcons = tmpS.ToString(); } } }
public int ToUSInt() { return(Localization.ParseUSInt(this.ConfigValue)); }
public bool Update() { bool updated = false; Customer ThisCustomer = Customer.Current; if (ThisCustomer.IsAdminUser) { int StoreID = AppLogic.StoreID(); int thisTopicID = GetTopicID(TopicName, StoreID); bool topicexists = thisTopicID > 0; // ok to update: if (topicexists) { StringBuilder sql = new StringBuilder(2500); sql.Append("update Topic set "); sql.Append("Name=" + DB.SQuote(AppLogic.FormLocaleXml("Name", TopicName, LocaleSetting, "topic", Convert.ToInt32(thisTopicID))) + ","); sql.Append("SkinID=" + Localization.ParseUSInt(SkinID.ToString()) + ","); sql.Append("DisplayOrder=" + Localization.ParseUSInt(DisplayOrder.ToString()) + ","); sql.Append("ContentsBGColor=" + DB.SQuote(ContentsBGColor) + ","); sql.Append("PageBGColor=" + DB.SQuote(PageBGColor) + ","); sql.Append("GraphicsColor=" + DB.SQuote(GraphicsColor) + ","); sql.Append("Title=" + DB.SQuote(AppLogic.FormLocaleXml("Title", SectionTitle, LocaleSetting, "topic", Convert.ToInt32(thisTopicID))) + ","); if (Contents.Length != 0) { sql.Append("Description=" + DB.SQuote(Contents) + ","); } else { sql.Append("Description=NULL,"); } if (Password.Trim().Length != 0) { sql.Append("Password="******","); } else { sql.Append("Password=NULL,"); } sql.Append("RequiresSubscription=" + CommonLogic.IIF(RequiresSubscription, "1", "0") + ","); sql.Append("HTMLOk=" + CommonLogic.IIF(HTMLOk, "1", "0") + ","); sql.Append("RequiresDisclaimer=" + CommonLogic.IIF(RequiresDisclaimer, "1", "0") + ","); sql.Append("ShowInSiteMap=" + CommonLogic.IIF(ShowInSiteMap, "1", "0") + ","); if (AppLogic.FormLocaleXml("ltSEKeywords").Length != 0) { sql.Append("SEKeywords=" + DB.SQuote(AppLogic.FormLocaleXml("SEKeywords", SEKeywords, LocaleSetting, "topic", Convert.ToInt32(thisTopicID))) + ","); } else { sql.Append("SEKeywords=NULL,"); } if (AppLogic.FormLocaleXml("ltSEDescription").Length != 0) { sql.Append("SEDescription=" + DB.SQuote(AppLogic.FormLocaleXml("SEDescription", SEDescription, LocaleSetting, "topic", Convert.ToInt32(thisTopicID))) + ","); } else { sql.Append("SEDescription=NULL,"); } if (AppLogic.FormLocaleXml("ltSETitle").Length != 0) { sql.Append("SETitle=" + DB.SQuote(AppLogic.FormLocaleXml("SETitle", SETitle, LocaleSetting, "topic", Convert.ToInt32(thisTopicID)))); } else { sql.Append("SETitle=NULL"); } sql.Append(" where TopicID=" + thisTopicID.ToString()); try { DB.ExecuteSQL(sql.ToString()); updated = true; LoadFromDB(AppLogic.StoreID()); } catch { updated = false; } } } return(updated); }
public static int XmlFieldUSInt(XmlNode node, String fieldName) { String tmpS = XmlField(node, fieldName); return(Localization.ParseUSInt(tmpS)); }
public static int XmlAttributeUSInt(XmlNode node, String AttributeName) { String tmpS = XmlAttribute(node, AttributeName); return(Localization.ParseUSInt(tmpS)); }
public static int ZoneLookup(String zip) { int ZipCodePrefixLength = AppLogic.AppConfigNativeInt("ZipCodePrefixLength"); if (ZipCodePrefixLength < 0) { ZipCodePrefixLength = 3; } if (ZipCodePrefixLength > 5) { ZipCodePrefixLength = 5; } zip = zip.Trim().PadRight(5, '0'); String ZipSubStr = zip.Substring(0, ZipCodePrefixLength); int ZipSubStrInt = 0; try { ZipSubStrInt = Localization.ParseUSInt(ZipSubStr); } catch { return(AppLogic.AppConfigUSInt("ZoneIDForNoMatch")); // something bad as input zip } int ZoneID = 0; using (SqlConnection dbconn = DB.dbConn()) { dbconn.Open(); using (IDataReader rs = DB.GetRS("select * from ShippingZone with (NOLOCK)", dbconn)) { while (rs.Read()) { String[] thisZipList = Regex.Replace(DB.RSField(rs, "ZipCodes"), "\\s+", "", RegexOptions.Compiled).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (String s in thisZipList) { // is it a single 3 digit prefix, or a range: if (s.IndexOf("-") == -1) { String s2 = s.Substring(0, ZipCodePrefixLength); // single item: int LowPrefix = 0; try { if (CommonLogic.IsInteger(s2)) { LowPrefix = Localization.ParseUSInt(s2); } } catch { } if (LowPrefix == ZipSubStrInt) { ZoneID = DB.RSFieldInt(rs, "ShippingZoneID"); break; } } else { // range: String[] s2 = s.Split('-'); int LowPrefix = 0; int HighPrefix = 0; try { String s2a; s2a = s2[0].Substring(0, ZipCodePrefixLength); String s2b; s2b = s2[1].Substring(0, ZipCodePrefixLength); if (CommonLogic.IsInteger(s2a)) { LowPrefix = Localization.ParseUSInt(s2a); } if (CommonLogic.IsInteger(s2b)) { HighPrefix = Localization.ParseUSInt(s2b); } } catch { } if (LowPrefix <= ZipSubStrInt && ZipSubStrInt <= HighPrefix) { ZoneID = DB.RSFieldInt(rs, "ShippingZoneID"); break; } } } } } } if (ZoneID == 0) { ZoneID = AppLogic.AppConfigUSInt("ZoneIDForNoMatch"); } return(ZoneID); }