/// <summary> /// Check in orderInfoNode if a coupon is applied /// </summary> /// <param name="orderInfoNode"></param> /// <returns>returns true if there is a couponcode and coupon includes free shipping</returns> private bool CheckIfCouponApplied(XmlNode orderInfoNode) { bool hasCouponApplied = CommonLogic.IIF(!CommonLogic.IsStringNullOrEmpty(XmlCommon.XmlField(orderInfoNode, "CouponCode")), true, false); bool couponIncludesFreeshipping = CommonLogic.IIF(XmlCommon.XmlFieldNativeInt(orderInfoNode, "CouponIncludesFreeShipping") == 1, true, false); return(hasCouponApplied && couponIncludesFreeshipping); }
/// <summary> /// Utility function to check if a string value is included within the commadelimited string to match with /// </summary> /// <param name="stringValue">the string to look for</param> /// <param name="commaDelimitedList">the comma delimited string to search at</param> /// <returns></returns> public static bool StringInCommaDelimitedStringList(string stringValue, string commaDelimitedList) { try { if (CommonLogic.IsStringNullOrEmpty(stringValue) || CommonLogic.IsStringNullOrEmpty(commaDelimitedList)) { return(false); } string[] individualValues = commaDelimitedList.Split(','); foreach (string valueToMatch in individualValues) { if (valueToMatch.ToUpperInvariant().Trim().Equals(stringValue.ToUpperInvariant().Trim())) { return(true); } } } catch { return(false); } return(false); }
private static XPathNavigator GetMenuXml(string xmlPackageName) { Customer thisCustomer = Customer.Current; string menuXml = AppLogic.RunXmlPackage(xmlPackageName, null, thisCustomer, DEFAULT_SKINID, string.Empty, string.Empty, false, false); if (CommonLogic.IsStringNullOrEmpty(menuXml)) { throw new InvalidOperationException("Menu xml cannot be empty string!!!"); } XmlDocument doc = new XmlDocument(); try { Regex pattern = new Regex(@"\(!(.*?)!\)"); MatchEvaluator findAndReplaceStringResourced = new MatchEvaluator(StringResourceMatch); menuXml = pattern.Replace(menuXml, findAndReplaceStringResourced); doc.LoadXml(menuXml); } catch { throw new InvalidOperationException("Invalid Menu Xml!!!"); } return(doc.CreateNavigator()); }
public static KitComposition FromForm(Customer ThisCustomer, int ProductID, int VariantID) { KitComposition composition = new KitComposition(0); string kitContents = CommonLogic.FormCanBeDangerousContent("KitItems"); if (!string.IsNullOrEmpty(kitContents)) { string[] selectedItems = kitContents.Split(','); foreach (string kitGroup in selectedItems) { string[] groups = kitGroup.Split('+'); int groupID = int.Parse(groups[0]); int itemID = int.Parse(groups[1]); KitCartItem selectedKitItem = new KitCartItem(); selectedKitItem.CustomerID = ThisCustomer.CustomerID; selectedKitItem.ProductID = ProductID; selectedKitItem.VariantID = VariantID; selectedKitItem.KitGroupID = groupID; selectedKitItem.KitItemID = itemID; composition.Compositions.Add(selectedKitItem); } } // process text options HttpContext ctx = HttpContext.Current; foreach (KitCartItem item in composition.Compositions) { string id = string.Format("KitItemTextOption_{0}_{1}", item.KitGroupID, item.KitItemID); string text = CommonLogic.FormCanBeDangerousContent(id); if (!CommonLogic.IsStringNullOrEmpty(text)) { item.TextOption = text; } } // process file upload foreach (KitCartItem item in composition.Compositions) { // NOTE: // We don't use the group id for file upload string id = string.Format("KitItemFileUpload_{0}", item.KitItemID); HttpPostedFile file = ctx.Request.Files[id]; if (null != file) { item.FileName = file.FileName; item.ImageFile = file; } else { // must be edit mode id = string.Format("KitItemFile_{0}", item.KitItemID); string savedFile = CommonLogic.FormCanBeDangerousContent(id); if (!CommonLogic.IsStringNullOrEmpty(savedFile)) { item.TextOption = savedFile; } } } return(composition); }
public void ProcessRequest(HttpContext context) { if (!AppLogic.AppConfigBool("Watermark.Enabled")) { return; } string querystringImageURL = CommonLogic.QueryStringCanBeDangerousContent("imgurl"); if (string.IsNullOrEmpty(querystringImageURL)) { return; } context.Response.CacheControl = "private"; context.Response.Expires = 0; context.Response.AddHeader("pragma", "no-cache"); string mappedImageUrl = HttpContext.Current.Request.MapPath(querystringImageURL); bool sourceImageExists = CommonLogic.FileExists(mappedImageUrl) && !mappedImageUrl.Contains("nopicture.gif") && !mappedImageUrl.Contains("nopictureicon.gif"); if (sourceImageExists) { string imgSize = CommonLogic.QueryStringCanBeDangerousContent("size"); string copyrightText = AppLogic.AppConfig("Watermark.CopyrightText"); string copyrightImageUrl = string.Empty; if (string.IsNullOrEmpty(copyrightText)) { copyrightText = AppLogic.AppConfig("StoreName"); } switch (imgSize.ToLower()) { case "icon": copyrightImageUrl = AppLogic.AppConfig("Watermark.CopyrightImage.Icon"); break; case "medium": copyrightImageUrl = AppLogic.AppConfig("Watermark.CopyrightImage.Medium"); break; case "large": copyrightImageUrl = AppLogic.AppConfig("Watermark.CopyrightImage.Large"); break; default: copyrightImageUrl = AppLogic.AppConfig("Watermark.CopyrightImage.Icon"); break; } if (!CommonLogic.IsStringNullOrEmpty(copyrightImageUrl)) { copyrightImageUrl = CommonLogic.IIF(copyrightImageUrl.StartsWith("/"), copyrightImageUrl.Remove(0, 1), copyrightImageUrl); } // TODO: Image must be fully qualified (System.Drawing.Image) to support VB conversion // During conversion System.Drawing will be lost...must be re-added System.Drawing.Image imgPhoto = CommonLogic.LoadImage(mappedImageUrl); if (!string.IsNullOrEmpty(copyrightText) || !string.IsNullOrEmpty(copyrightImageUrl)) { //If a copyright image is used and exists on disk, clear copyright text if (!string.IsNullOrEmpty(copyrightImageUrl) && CommonLogic.FileExists(copyrightImageUrl)) { copyrightText = string.Empty; } try { imgPhoto = CommonLogic.AddWatermark(imgPhoto, copyrightText, copyrightImageUrl); } catch (Exception ex) { SysLog.LogException(ex, MessageTypeEnum.GeneralException, MessageSeverityEnum.Error); } } if (mappedImageUrl.EndsWith(".jpeg", StringComparison.InvariantCultureIgnoreCase)) { context.Response.ContentType = "image/jpeg"; EncoderParameters encoderParameters = new EncoderParameters(); encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 100L); imgPhoto.Save(context.Response.OutputStream, ImageCodecInfo.GetImageEncoders()[1], encoderParameters); } if (mappedImageUrl.EndsWith(".jpg", StringComparison.InvariantCultureIgnoreCase)) { context.Response.ContentType = "image/jpg"; EncoderParameters encoderParameters = new EncoderParameters(); encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 100L); imgPhoto.Save(context.Response.OutputStream, ImageCodecInfo.GetImageEncoders()[1], encoderParameters); } if (mappedImageUrl.EndsWith(".gif", StringComparison.InvariantCultureIgnoreCase)) { context.Response.ContentType = "image/gif"; imgPhoto.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif); } if (mappedImageUrl.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase)) { context.Response.ContentType = "image/png"; imgPhoto.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif); } imgPhoto.Dispose(); } }