public DescriptionFile(String DescriptionType, int ID, String LocaleSetting, int SkinID) { m_DescriptionType = DescriptionType.Trim().ToLowerInvariant(); m_ID = ID; m_LocaleSetting = LocaleSetting; m_SkinID = SkinID; // Find the description file content. will be in /{descriptiontype}descriptions or some locale subdir. find by ID m_Root = CommonLogic.IIF(AppLogic.IsAdminSite, "../", "") + "descriptions/" + m_DescriptionType.ToLowerInvariant() + "/"; m_Contents = String.Empty; m_ContentsRAW = String.Empty; m_FN = String.Empty; if (AppLogic.AppConfigBool("UseNameForSectionDescriptionName")) { //Try SKU version first if (!FindNameFile()) { FindIDFile(); } } else { FindIDFile(); } if (m_FN.Length != 0 && CommonLogic.FileExists(m_FN)) { m_URL = Path.Combine(AppLogic.GetStoreHTTPLocation(false), m_URL); m_Contents = CommonLogic.ReadFile(m_FN, true); m_ContentsRAW = m_Contents; m_Contents = CommonLogic.ExtractBody(m_Contents); m_Contents = m_Contents.Replace("(!SKINID!)", SkinID.ToString()); } else { m_URL = String.Empty; m_FN = String.Empty; } }
public ProductSpecFile(int ProductID, String LocaleSetting, int SkinID, string SKU) { m_ProductID = ProductID; m_LocaleSetting = LocaleSetting; m_SkinID = SkinID; m_ProductSKU = SKU; m_Contents = String.Empty; m_ContentsRAW = String.Empty; m_FN = String.Empty; // Find the Specified ProductSpec content. will be in /descriptions/productspecs or some locale subdir. find by productid or SKU, whichever is provided. m_Root = CommonLogic.IIF(AppLogic.IsAdminSite, "../", "") + "descriptions/productspecs/"; if (AppLogic.AppConfigBool("UseSKUForProductDescriptionName")) { //Try SKU version first if (m_ProductSKU.Length == 0) { m_ProductSKU = AppLogic.GetProductSKU(ProductID); } if (!FindSKUFile()) { FindIDFile(); } } else { FindIDFile(); } if (FN.Length != 0 && CommonLogic.FileExists(FN)) { m_URL = Path.Combine(AppLogic.GetStoreHTTPLocation(false), m_URL); m_Contents = CommonLogic.ReadFile(FN, true); m_ContentsRAW = m_Contents; m_Contents = CommonLogic.ExtractBody(m_Contents); m_Contents = m_Contents.Replace("(!SKINID!)", SkinID.ToString()); } }
static public String GetSelectList(String SelectName, String OnChangeHandler, String CssClass, String SelectedCurrencyCode) { StringBuilder tmpS = new StringBuilder(4096); tmpS.Append("<select size=\"1\" id=\"" + SelectName + "\" name=\"" + SelectName + "\""); if (OnChangeHandler.Length != 0) { tmpS.Append(" onChange=\"" + OnChangeHandler + "\""); } if (CssClass.Length != 0) { tmpS.Append(" class=\"" + CssClass + "\""); } tmpS.Append(">"); foreach (XmlNode n in RatesDoc.SelectNodes("//Currency[@Published = 1]")) { string cc = XmlCommon.XmlAttribute(n, "CurrencyCode"); tmpS.Append("<option value=\"" + cc + "\" " + CommonLogic.IIF(SelectedCurrencyCode == cc, " selected ", "") + ">" + cc + " (" + XmlCommon.XmlAttribute(n, "Name") + ")</option>"); } tmpS.Append("</select>"); return(tmpS.ToString()); }
public string Update(int storeId, string Name, string LocaleSetting, string ConfigValue) { string err = String.Empty; try { err = Update(storeId, this.m_Stringresourceid, Name, LocaleSetting, ConfigValue); if (err == "") { this.StoreId = storeId; m_Name = CommonLogic.IIF(Name != null, Name, m_Name); m_Configvalue = CommonLogic.IIF(LocaleSetting != null, ConfigValue, m_Configvalue); m_Localesetting = CommonLogic.IIF(LocaleSetting != null, LocaleSetting, m_Localesetting); m_Modified = true; } } catch (Exception ex) { err = ex.Message; } return(err); }
public HierarchicalTableMgr(String TableName, String NodeName, String IDColumnName, String GUIDColumnName, String NameColumnName, String XmlPackageName, int CacheMinutes, int SetInitialContextToNodeID, bool OnlyPublishedEntitiesAndObjects, int StoreID) { m_TableName = TableName; m_NodeName = NodeName; m_IDColumnName = IDColumnName; m_GUIDColumnName = GUIDColumnName; m_NameColumnName = NameColumnName; m_CacheName = String.Format("HTM_{0}_{1}_{2}_{3}_{4}_{5}_{6}_{7}_{8}", TableName, NodeName, IDColumnName, GUIDColumnName, NameColumnName, XmlPackageName, OnlyPublishedEntitiesAndObjects.ToString(), AppLogic.IsAdminSite.ToString(), StoreID.ToString()); m_XmlPackageName = XmlPackageName; m_OnlyPublishedEntitiesAndObjects = OnlyPublishedEntitiesAndObjects; if (m_XmlDoc == null) { String RTParams = "EntityName=" + TableName + "&PublishedOnly=" + CommonLogic.IIF(m_OnlyPublishedEntitiesAndObjects, "1", "0"); if (StoreID > 0) { RTParams += "&FilterByStore=true&CurrentStoreID=" + StoreID.ToString(); } using (XmlPackage2 p = new XmlPackage2(m_XmlPackageName, null, 1, String.Empty, RTParams, String.Empty, false)) { m_FinalXml = p.TransformString(); m_DataSetXml = XmlCommon.XmlDecode(p.XmlSystemData); m_XmlDoc = new XmlDocument(); if (m_FinalXml.Length != 0) { using (StringReader sr = new StringReader(m_FinalXml)) { using (XmlReader xr = XmlReader.Create(sr)) { m_XmlDoc.Load(xr); } } } } } m_NumRootLevelNodes = m_XmlDoc.SelectSingleNode("/root").ChildNodes.Count; }
/// <summary> /// Generate a random security code /// </summary> /// <returns>An alpha-numeric string</returns> public String GenerateSecurityCode() { int maxTries = 1000; int i = 0; String randomCode = String.Empty; Random rnd = new Random(); int maxAscii = AppLogic.AppConfigNativeInt("Captcha.MaxAsciiValue"); int rndAscii; Regex rex = new Regex(CommonLogic.IIF(AppLogic.AppConfig("Captcha.AllowedCharactersRegex").Length == 0, "@[0-9]", AppLogic.AppConfig("Captcha.AllowedCharactersRegex"))); int codeLength = AppLogic.AppConfigNativeInt("Captcha.NumberOfCharacters"); if (codeLength < 6) { codeLength = 6; } if (codeLength > 20) { codeLength = 20; } if (maxAscii == 0) { maxAscii = 126; } try { do { // get a random ascii value rndAscii = rnd.Next(33, maxAscii); // determine if the character is allowed via the regex if (rex.Match(char.ConvertFromUtf32(rndAscii)).Success) { randomCode += char.ConvertFromUtf32(rndAscii); } i++; } while (randomCode.Length < codeLength && i < maxTries); } catch { // default it to something in case the Captcha.AllowedCharactersRegex // causes the match to break; randomCode = "934JWC"; } finally { // double check the length in case Captcha.AllowedCharactersRegex // is configured in such a way that no characters are ever matched // or the match has reached the maxTries if (randomCode.Length < codeLength) { randomCode = "934JWC"; } } return randomCode; }
public ArrayList GetEntityArrayList(int ForParentEntityID, String Prefix, int FilterEntityID, String LocaleSetting, bool AllowCaching) { ArrayList al; String CacheName = String.Format("GetEntityArrayList_{0}_{1}_{2}_{3}_{4}_{5}", m_EntitySpecs.m_EntityName, ForParentEntityID.ToString(), Prefix, FilterEntityID.ToString(), LocaleSetting, AppLogic.IsAdminSite.ToString()); if (AppLogic.CachingOn && AllowCaching) { al = (ArrayList)HttpContext.Current.Cache.Get(CacheName); if (al != null) { if (CommonLogic.ApplicationBool("DumpSQL")) { HttpContext.Current.Response.Write("Cache Hit Found!\n"); } return(al); } } al = new ArrayList(); StringWriter tmpS = new StringWriter(); String XslFile = "EntityArrayListXML"; XslCompiledTransform xForm; string XslFilePath = CommonLogic.SafeMapPath(string.Format("{0}/EntityHelper/{1}.xslt", AppLogic.AdminDir(), XslFile)); xForm = (XslCompiledTransform)HttpContext.Current.Cache.Get(XslFilePath); if (xForm == null) { xForm = new XslCompiledTransform(false); xForm.Load(XslFilePath); HttpContext.Current.Cache.Insert(XslFilePath, xForm, new CacheDependency(XslFilePath)); } XsltArgumentList xslArgs = new XsltArgumentList(); xslArgs.AddParam("ForParentEntityID", "", ForParentEntityID); xslArgs.AddParam("filterID", "", FilterEntityID); xslArgs.AddParam("custlocale", "", LocaleSetting); xslArgs.AddParam("deflocale", "", Localization.GetDefaultLocale()); xslArgs.AddParam("adminsite", "", AppLogic.IsAdminSite); xForm.Transform(m_TblMgr.XmlDoc, xslArgs, tmpS); XmlDocument returnedXML = new XmlDocument(); returnedXML.LoadXml(tmpS.ToString()); XmlNodeList entityNodes = returnedXML.SelectNodes("/Entities/Entity"); foreach (XmlNode n in entityNodes) { try { XmlNode idNode = n.SelectNodes("EntityId")[0]; XmlNode nameNode = n.SelectNodes("EntityName")[0]; int entityId; if (int.TryParse(idNode.InnerText, out entityId) && !string.IsNullOrEmpty(nameNode.InnerText)) { ListItemClass li = new ListItemClass(); li.Value = entityId; li.Item = Security.HtmlEncode(nameNode.InnerText); al.Add(li); } } catch (Exception) { } } if (AppLogic.AppConfigBool("XmlPackage.DumpTransform")) { try // don't let logging crash the site { StreamWriter sw = File.CreateText(CommonLogic.SafeMapPath(String.Format("{0}images/{1}_{2}_{3}.xfrm.xml", CommonLogic.IIF(AppLogic.IsAdminSite, "~/", ""), XslFile, m_EntitySpecs.m_EntityName, CommonLogic.IIF(AppLogic.IsAdminSite, "admin", "store")))); sw.WriteLine(XmlCommon.PrettyPrintXml(tmpS.ToString())); sw.Close(); } catch { } } if (AppLogic.CachingOn && AllowCaching) { HttpContext.Current.Cache.Insert(CacheName, al, null, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero); } return(al); }
/// <summary> /// Displays the product rating /// </summary> /// <param name="ThisCustomer">Customer object</param> /// <param name="ProductID">Product ID of the product rating to display</param> /// <param name="CategoryID">Category ID of the product rating to display</param> /// <param name="SectionID">Section ID of the product rating to display</param> /// <param name="ManufacturerID">Manufacturer ID of the product rating to display</param> /// <param name="SkinID">skin id of the page</param> /// <param name="encloseInTab">set to true if not to be displayed in a tabUI</param> /// <returns>returns string html to be rendered</returns> static public String Display(Customer ThisCustomer, int ProductID, int CategoryID, int SectionID, int ManufacturerID, int SkinID, bool encloseInTab) { string productName = AppLogic.GetProductName(ProductID, ThisCustomer.LocaleSetting); StringBuilder tmpS = new StringBuilder(50000); if (!AppLogic.IsAdminSite) { tmpS.Append("<input type=\"hidden\" name=\"ProductID\" value=\"" + ProductID.ToString() + "\">"); tmpS.Append("<input type=\"hidden\" name=\"CategoryID\" value=\"" + CategoryID.ToString() + "\">"); tmpS.Append("<input type=\"hidden\" name=\"SectionID\" value=\"" + SectionID.ToString() + "\">"); tmpS.Append("<input type=\"hidden\" name=\"ManufacturerID\" value=\"" + ManufacturerID.ToString() + "\">"); if (!encloseInTab) { tmpS.Append("<input type=\"hidden\" name=\"productTabs\" value=\"2\">"); } } if (encloseInTab) { tmpS.Append("<div class=\"group-header rating-header\">" + AppLogic.GetString("Header.ProductRatings", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</div>"); } // RATINGS BODY: string sql = string.Format("aspdnsf_ProductStats {0}, {1}", ProductID, AppLogic.StoreID()); int ratingsCount = 0; decimal ratingsAverage = 0; using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn())) { dbconn.Open(); using (IDataReader rs = DB.GetRS(sql, dbconn)) { rs.Read(); ratingsCount = DB.RSFieldInt(rs, "NumRatings"); int SumRatings = DB.RSFieldInt(rs, "SumRatings"); ratingsAverage = DB.RSFieldDecimal(rs, "AvgRating"); } } int[] ratingPercentages = new int[6]; // indexes 0-5, but we only use indexes 1-5 using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn())) { string query = string.Format("select Productid, rating, count(rating) as N from Rating with (NOLOCK) where Productid = {0} and StoreID = {1} group by Productid,rating order by rating", ProductID, AppLogic.StoreID()); dbconn.Open(); using (IDataReader rs = DB.GetRS(query, dbconn)) { while (rs.Read()) { int NN = DB.RSFieldInt(rs, "N"); Decimal pp = ((Decimal)NN) / ratingsCount; int pper = (int)(pp * 100.0M); ratingPercentages[DB.RSFieldInt(rs, "Rating")] = pper; } } } string sortDescription = AppLogic.GetString("ratings.cs.1", SkinID, Thread.CurrentThread.CurrentUICulture.Name); string filterDescription = string.Empty; string fieldSuffix = string.Empty; int orderIndex = 0; if ("OrderBy".Equals(CommonLogic.FormCanBeDangerousContent("__EVENTTARGET"), StringComparison.InvariantCultureIgnoreCase)) { orderIndex = CommonLogic.FormNativeInt("OrderBy"); } if (orderIndex == 0) { orderIndex = 3; } switch (orderIndex) { case 1: sortDescription = AppLogic.GetString("ratings.cs.1", SkinID, Thread.CurrentThread.CurrentUICulture.Name); break; case 2: sortDescription = AppLogic.GetString("ratings.cs.2", SkinID, Thread.CurrentThread.CurrentUICulture.Name); break; case 3: sortDescription = AppLogic.GetString("ratings.cs.3", SkinID, Thread.CurrentThread.CurrentUICulture.Name); break; case 4: sortDescription = AppLogic.GetString("ratings.cs.4", SkinID, Thread.CurrentThread.CurrentUICulture.Name); break; case 5: sortDescription = AppLogic.GetString("ratings.cs.5", SkinID, Thread.CurrentThread.CurrentUICulture.Name); break; case 6: sortDescription = AppLogic.GetString("ratings.cs.6", SkinID, Thread.CurrentThread.CurrentUICulture.Name); break; } int pageSize = AppLogic.AppConfigUSInt("RatingsPageSize"); int pageNumber = CommonLogic.QueryStringUSInt("PageNum"); if (pageNumber == 0) { pageNumber = 1; } if (pageSize == 0) { pageSize = 10; } if (CommonLogic.QueryStringCanBeDangerousContent("show") == "all") { pageSize = 1000000; pageNumber = 1; } SqlConnection conn = new SqlConnection(); conn.ConnectionString = DB.GetDBConn(); conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "aspdnsf_GetProductComments"; cmd.Parameters.Add(new SqlParameter("@ProductID", SqlDbType.Int)); cmd.Parameters.Add(new SqlParameter("@votingcustomer", SqlDbType.Int)); cmd.Parameters.Add(new SqlParameter("@pagesize", SqlDbType.Int)); cmd.Parameters.Add(new SqlParameter("@pagenum", SqlDbType.Int)); cmd.Parameters.Add(new SqlParameter("@sort", SqlDbType.TinyInt)); cmd.Parameters.Add(new SqlParameter("@storeID", SqlDbType.Int)); cmd.Parameters["@ProductID"].Value = ProductID; cmd.Parameters["@votingcustomer"].Value = ThisCustomer.CustomerID; cmd.Parameters["@pagesize"].Value = pageSize; cmd.Parameters["@pagenum"].Value = pageNumber; cmd.Parameters["@sort"].Value = orderIndex; cmd.Parameters["@storeID"].Value = AppLogic.StoreID(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); int rowsCount = Convert.ToInt32(dr["totalcomments"]); int pagesCount = Convert.ToInt32(dr["pages"]); dr.NextResult(); if (pageNumber > pagesCount && pageNumber > 1 && rowsCount == 0) { dr.Close(); HttpContext.Current.Response.Redirect("showProduct.aspx?ProductID=" + ProductID.ToString() + "&pagenum=" + (pageNumber - 1).ToString()); } int StartRow = (pageSize * (pageNumber - 1)) + 1; int StopRow = CommonLogic.IIF((StartRow + pageSize - 1) > rowsCount, rowsCount, StartRow + pageSize - 1); if (ratingsCount > 0) { tmpS.AppendFormat("<span itemprop=\"aggregateRating\" itemscope itemtype=\"{0}://schema.org/AggregateRating\">{1}", HttpContext.Current.Request.Url.Scheme, Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"ratingValue\" content=\"{0}\"/>{1}", ratingsAverage, Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"reviewCount\" content=\"{0}\"/>{1}", ratingsCount, Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"bestRating\" content=\"5\"/>{0}", Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"worstRating\" content=\"1\"/>{0}", Environment.NewLine); tmpS.AppendFormat("</span>{0}", Environment.NewLine); } tmpS.Append("<div class=\"page-row total-rating-row\">"); tmpS.Append(" <div class=\"rating-stars-wrap\">"); tmpS.Append(CommonLogic.BuildStarsImage(ratingsAverage, SkinID) + "<span class=\"ratings-average-wrap\">(" + String.Format("{0:f}", ratingsAverage) + ")</span>"); tmpS.Append(" </div>"); tmpS.Append(" <div class=\"rating-count-wrap\">"); tmpS.Append(" <span>" + AppLogic.GetString("ratings.cs.23", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span> " + ratingsCount.ToString()); tmpS.Append(" </div>"); tmpS.Append("</div>"); string rateScript = "javascript:RateIt(" + ProductID.ToString() + ");"; int productRating = Ratings.GetProductRating(ThisCustomer.CustomerID, ProductID); tmpS.Append("<div class=\"page-row rating-link-row\">"); if (productRating != 0) { tmpS.Append("<div class=\"rating-link-wrap\">"); tmpS.Append(" <span>" + AppLogic.GetString("ratings.cs.24", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + " " + productRating.ToString() + "</span>"); tmpS.Append("</div>"); if (!AppLogic.IsAdminSite) { tmpS.Append("<div class=\"rating-link-wrap\">"); tmpS.Append(" <a href=\"" + rateScript + "\">" + AppLogic.GetString("ratings.cs.25", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</a> "); tmpS.Append(" <span>"+ AppLogic.GetString("ratings.cs.26", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span>"); tmpS.Append("</div>"); } } else { if ((AppLogic.AppConfigBool("RatingsCanBeDoneByAnons") || ThisCustomer.IsRegistered) && !AppLogic.IsAdminSite) { tmpS.Append("<div class=\"rating-link-wrap\">"); tmpS.Append(" <a href=\"" + rateScript + "\">" + AppLogic.GetString("image.altText.10", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</a>"); tmpS.Append("</div>"); tmpS.Append("<div class=\"rating-link-wrap\">"); tmpS.Append(" <a href=\"" + rateScript + "\">" + AppLogic.GetString("ratings.cs.28", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</a> "); tmpS.Append(" <span>"+ AppLogic.GetString("ratings.cs.27", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span>"); tmpS.Append("</div>"); } else { tmpS.Append("<div class=\"rating-link-wrap\">"); tmpS.Append(" <span>" + AppLogic.GetString("ratings.cs.29", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span>"); tmpS.Append("</div>"); } } tmpS.Append("</div>"); if (rowsCount == 0) { tmpS.Append(AppLogic.GetString("ratings.cs.39", SkinID, Thread.CurrentThread.CurrentUICulture.Name)); if (AppLogic.AppConfigBool("RatingsCanBeDoneByAnons") || ThisCustomer.IsRegistered && !AppLogic.IsAdminSite) { tmpS.Append(" <a href=\"" + rateScript + "\">" + AppLogic.GetString("ratings.cs.40", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</a> " + AppLogic.GetString("ratings.cs.41", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</a>"); } } else { while (dr.Read()) { tmpS.AppendFormat("<div class=\"page-row rating-comment-row\" itemprop=\"review\" itemscope itemtype=\"{0}://schema.org/Review\">{1}", HttpContext.Current.Request.Url.Scheme, Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"datePublished\" content=\"{0}\"/>{1}", Convert.ToDateTime(dr["CreatedOn"]).ToString("yyyy-MM-dd"), Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"itemReviewed\" content=\"{0}\"/>{1}", productName, Environment.NewLine); tmpS.Append(" <div class=\"rating-author-wrap\">\n"); tmpS.Append(" <span class=\"rating-row-number\">"+ dr["rownum"].ToString() + ". </span><span class=\"rating-row-author\" itemprop=\"author\">" + HttpContext.Current.Server.HtmlEncode(CommonLogic.IIF(dr["FirstName"].ToString().Length == 0, AppLogic.GetString("ratings.cs.14", SkinID, Thread.CurrentThread.CurrentUICulture.Name), dr["FirstName"].ToString())) + "</span> <span class=\"rating-row-said\">" + AppLogic.GetString("ratings.cs.15", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + " " + Localization.ToThreadCultureShortDateString(Convert.ToDateTime(dr["CreatedOn"])) + ", " + AppLogic.GetString("ratings.cs.16", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + " </span>"); tmpS.Append(" </div>"); tmpS.AppendFormat("<div class=\"rating-comment-stars\" itemprop=\"reviewRating\" itemscope itemtype=\"{0}://schema.org/Rating\">{1}", HttpContext.Current.Request.Url.Scheme, Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"bestRating\" content=\"5\"/>{0}", Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"worstRating\" content=\"1\"/>{0}", Environment.NewLine); tmpS.AppendFormat("<meta itemprop=\"ratingValue\" content=\"{0}\"/>{1}", Convert.ToDecimal(dr["Rating"]), Environment.NewLine); tmpS.Append(CommonLogic.BuildStarsImage(Convert.ToDecimal(dr["Rating"]), SkinID)); tmpS.Append(" </div>"); tmpS.Append(" <div class=\"rating-comments\" itemprop=\"reviewBody\">\n"); tmpS.Append(HttpContext.Current.Server.HtmlEncode(dr["Comments"].ToString())); tmpS.Append(" </div>\n"); tmpS.Append("</div>\n"); tmpS.Append("<div class=\"form rating-comment-helpfulness-wrap\">"); tmpS.Append(" <div class=\"form-group\">"); if (ThisCustomer.CustomerID != Convert.ToInt32(dr["CustomerID"])) { if (!AppLogic.IsAdminSite) { tmpS.Append(AppLogic.GetString("ratings.cs.42", SkinID, Thread.CurrentThread.CurrentUICulture.Name)); tmpS.Append("<input TYPE=\"RADIO\" NAME=\"helpful_" + ProductID.ToString() + "_" + dr["CustomerID"].ToString() + "\" onClick=\"return RateComment('" + ProductID.ToString() + "','" + ThisCustomer.CustomerID + "','Yes','" + dr["CustomerID"].ToString() + "');\" " + CommonLogic.IIF(Convert.ToInt16(dr["CommentHelpFul"]) == 1, " checked ", "") + ">\n"); tmpS.Append("<span>" + AppLogic.GetString("ratings.cs.43", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span> \n"); tmpS.Append("<input TYPE=\"RADIO\" NAME=\"helpful_" + ProductID.ToString() + "_" + dr["CustomerID"].ToString() + "\" onClick=\"return RateComment('" + ProductID.ToString() + "','" + ThisCustomer.CustomerID + "','No','" + dr["CustomerID"].ToString() + "');\" " + CommonLogic.IIF(Convert.ToInt16(dr["CommentHelpFul"]) == 0, " checked ", "") + ">\n"); tmpS.Append("<span>" + AppLogic.GetString("ratings.cs.44", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span> \n"); } else { tmpS.Append(AppLogic.GetString("ratings.cs.42", SkinID, Thread.CurrentThread.CurrentUICulture.Name)); tmpS.Append("<input TYPE=\"RADIO\" NAME=\"helpful_" + ProductID.ToString() + "_" + dr["CustomerID"].ToString() + "\" " + CommonLogic.IIF(Convert.ToInt16(dr["CommentHelpFul"]) == 1, " checked ", "") + ">\n"); tmpS.Append("<span>" + AppLogic.GetString("ratings.cs.43", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span>\n"); tmpS.Append("<input TYPE=\"RADIO\" NAME=\"helpful_" + ProductID.ToString() + "_" + dr["CustomerID"].ToString() + "\" " + CommonLogic.IIF(Convert.ToInt16(dr["CommentHelpFul"]) == 0, " checked ", "") + ">\n"); tmpS.Append("<span>" + AppLogic.GetString("ratings.cs.44", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</span>\n"); } } tmpS.Append(" </div>\n"); tmpS.Append(" <div class=\"form-text rating-helpfulness-text\">"); tmpS.Append(" ("+ dr["FoundHelpful"].ToString() + " " + AppLogic.GetString("ratings.cs.17", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + " " + CommonLogic.IIF(ThisCustomer.CustomerID != Convert.ToInt32(dr["CustomerID"]), AppLogic.GetString("ratings.cs.18", SkinID, Thread.CurrentThread.CurrentUICulture.Name), AppLogic.GetString("ratings.cs.19", SkinID, Thread.CurrentThread.CurrentUICulture.Name)) + " " + AppLogic.GetString("ratings.cs.20", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + ", " + dr["FoundNotHelpful"].ToString() + " " + AppLogic.GetString("ratings.cs.21", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + ")"); tmpS.Append(" </div>\n"); tmpS.Append("</div>\n"); } } dr.Close(); if (rowsCount > 0) { tmpS.Append("<div class=\"page-row comments-count-wrap\">"); tmpS.Append(String.Format(AppLogic.GetString("ratings.cs.37", SkinID, Thread.CurrentThread.CurrentUICulture.Name), StartRow.ToString(), StopRow.ToString(), rowsCount.ToString())); if (pagesCount > 1) { tmpS.Append(" ("); if (pageNumber > 1) { tmpS.Append("<a href=\"showProduct.aspx?ProductID=" + CommonLogic.QueryStringUSInt("ProductID").ToString() + "&OrderBy=" + orderIndex.ToString() + "&pagenum=" + (pageNumber - 1).ToString() + "\">" + AppLogic.GetString("ratings.cs.10", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + " " + pageSize.ToString() + "</a>"); } if (pageNumber > 1 && pageNumber < pagesCount) { tmpS.Append(" | "); } if (pageNumber < pagesCount) { tmpS.Append("<a href=\"showProduct.aspx?ProductID=" + CommonLogic.QueryStringUSInt("ProductID").ToString() + "&OrderBy=" + orderIndex.ToString() + "&pagenum=" + (pageNumber + 1).ToString() + "\">" + AppLogic.GetString("ratings.cs.11", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + " " + pageSize.ToString() + "</a>"); } tmpS.Append(")"); } tmpS.Append("</div>\n"); tmpS.Append("<div class=\"page-row comments-pager-wrap\">"); if (pagesCount > 1) { tmpS.Append("<a href=\"showProduct.aspx?ProductID=" + CommonLogic.QueryStringUSInt("ProductID").ToString() + "&show=all\">" + AppLogic.GetString("ratings.cs.28", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</a> " + AppLogic.GetString("ratings.cs.38", SkinID, Thread.CurrentThread.CurrentUICulture.Name)); } tmpS.Append("</div>\n"); } // END RATINGS BODY: if (!AppLogic.IsAdminSite) { tmpS.Append("<div id=\"RateCommentDiv\" name=\"RateCommentDiv\" style=\"position:absolute; left:0px; top:0px; visibility:" + AppLogic.AppConfig("RatingsCommentFrameVisibility") + "; z-index:2000; \">\n"); tmpS.Append("<iframe name=\"RateCommentFrm\" id=\"RateCommentFrm\" width=\"400\" height=\"100\" hspace=\"0\" vspace=\"0\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" noresize scrolling=\"yes\" src=\"" + AppLogic.LocateImageURL("empty.htm") + "\"></iframe>\n"); tmpS.Append("</div>\n"); tmpS.Append("<script type=\"text/javascript\">\n"); tmpS.Append("function RateComment(ProductID,MyCustomerID,MyVote,RatersCustomerID)\n"); tmpS.Append(" {\n"); tmpS.Append(" RateCommentFrm.location = 'RateComment.aspx?Productid=' + ProductID + '&VotingCustomerID=' + MyCustomerID + '&MyVote=' + MyVote + '&CustomerID=' + RatersCustomerID\n"); tmpS.Append(" }\n"); tmpS.Append("</script>\n"); tmpS.Append("<script type=\"text/javascript\">\n"); tmpS.Append(" function RateIt(ProductID)\n"); tmpS.Append(" {\n"); tmpS.Append(" window.open('"+ AppLogic.ResolveUrl("~/rateit.aspx") + "?Productid=' + ProductID + '&refresh=no&returnurl=" + HttpContext.Current.Server.UrlEncode(CommonLogic.PageInvocation()) + "','ASPDNSF_ML" + CommonLogic.GetRandomNumber(1, 100000).ToString() + "','height=550,width=400,top=10,left=20,status=no,toolbar=no,menubar=no,scrollbars=yes,location=no')\n"); tmpS.Append(" }\n"); tmpS.Append("</SCRIPT>\n"); } return(tmpS.ToString()); }
/// <summary> /// Check if order is all free shipping /// </summary> /// <param name="orderInfoNode"></param> /// <returns>returns true if all order is free shipping</returns> private bool CheckIfAllFreeShipping(XmlNode orderInfoNode) { return(CommonLogic.IIF(XmlCommon.XmlFieldNativeInt(orderInfoNode, "allFreeShipping") == 1, true, false)); }
/// <summary> /// Displays the product rating /// </summary> /// <param name="customer">Customer object</param> /// <param name="productId">Product ID of the product rating to display</param> /// <param name="categoryId">Category ID of the product rating to display</param> /// <param name="sectionId">Section ID of the product rating to display</param> /// <param name="manufacturerId">Manufacturer ID of the product rating to display</param> /// <param name="skinId">skin id of the page</param> /// <param name="encloseInTab">set to true if not to be displayed in a tabUI</param> /// <returns>returns string html to be rendered</returns> static public string Display(Customer customer, int productId, int categoryId, int sectionId, int manufacturerId, int skinId, bool encloseInTab) { var productName = AppLogic.GetProductName(productId, customer.LocaleSetting); var outputString = new StringBuilder(50000); if (!AppLogic.IsAdminSite) { outputString.Append($"<input type=\"hidden\" name=\"ProductID\" value=\"{productId}\">"); outputString.Append($"<input type=\"hidden\" name=\"CategoryID\" value=\"{categoryId}\">"); outputString.Append($"<input type=\"hidden\" name=\"SectionID\" value=\"{sectionId}\">"); outputString.Append($"<input type=\"hidden\" name=\"ManufacturerID\" value=\"{manufacturerId}\">"); if (!encloseInTab) { outputString.Append("<input type=\"hidden\" name=\"productTabs\" value=\"2\">"); } } if (encloseInTab) { outputString.Append($"<h2 class=\"group-header rating-header\">{AppLogic.GetString("Header.ProductRatings")}</h2>"); } // RATINGS BODY: var productQuery = "aspdnsf_ProductStats @productId, @storeId"; var productParams = new SqlParameter[] { new SqlParameter("@productId", productId), new SqlParameter("@storeId", AppLogic.StoreID()) }; var ratingsCount = 0; var ratingsAverage = 0M; using (var connection = new SqlConnection(DB.GetDBConn())) { connection.Open(); using (var reader = DB.GetRS(productQuery, connection, productParams)) { reader.Read(); ratingsCount = DB.RSFieldInt(reader, "NumRatings"); ratingsAverage = DB.RSFieldDecimal(reader, "AvgRating"); } } var ratingPercentages = new int[6]; // indexes 0-5, but we only use indexes 1-5 using (var connection = new SqlConnection(DB.GetDBConn())) { var ratingQuery = @"SELECT ProductID, Rating, COUNT(Rating) AS N FROM Rating WITH (NOLOCK) WHERE Productid = @productId AND StoreID = @storeId GROUP BY Productid, Rating ORDER BY Rating" ; var ratingParams = new SqlParameter[] { new SqlParameter("@productId", productId), new SqlParameter("@storeId", AppLogic.StoreID()) }; connection.Open(); using (var reader = DB.GetRS(ratingQuery, connection, ratingParams)) { while (reader.Read()) { var numRatings = DB.RSFieldInt(reader, "N"); var ratingPercentage = ((decimal)numRatings) / ratingsCount; var ratingForDisplay = (int)(ratingPercentage * 100.0M); ratingPercentages[DB.RSFieldInt(reader, "Rating")] = ratingForDisplay; } } } var orderIndex = 0; if ("OrderBy".Equals(CommonLogic.FormCanBeDangerousContent("__EVENTTARGET"), StringComparison.InvariantCultureIgnoreCase)) { orderIndex = CommonLogic.FormNativeInt("OrderBy"); } if (orderIndex == 0) { orderIndex = 3; } var pageSize = AppLogic.AppConfigUSInt("RatingsPageSize"); var pageNumber = CommonLogic.QueryStringUSInt("PageNum"); if (pageNumber == 0) { pageNumber = 1; } if (pageSize == 0) { pageSize = 10; } if (CommonLogic.QueryStringCanBeDangerousContent("show") == "all") { pageSize = 1000000; pageNumber = 1; } using (var connection = new SqlConnection(DB.GetDBConn())) { connection.Open(); using (var command = new SqlCommand()) { command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "aspdnsf_GetProductComments"; command.Parameters.Add(new SqlParameter("@ProductID", SqlDbType.Int)); command.Parameters.Add(new SqlParameter("@votingcustomer", SqlDbType.Int)); command.Parameters.Add(new SqlParameter("@pagesize", SqlDbType.Int)); command.Parameters.Add(new SqlParameter("@pagenum", SqlDbType.Int)); command.Parameters.Add(new SqlParameter("@sort", SqlDbType.TinyInt)); command.Parameters.Add(new SqlParameter("@storeID", SqlDbType.Int)); command.Parameters["@ProductID"].Value = productId; command.Parameters["@votingcustomer"].Value = customer.CustomerID; command.Parameters["@pagesize"].Value = pageSize; command.Parameters["@pagenum"].Value = pageNumber; command.Parameters["@sort"].Value = orderIndex; command.Parameters["@storeID"].Value = AppLogic.StoreID(); var reader = command.ExecuteReader(); reader.Read(); var rowsCount = Convert.ToInt32(reader["totalcomments"]); var pagesCount = Convert.ToInt32(reader["pages"]); reader.NextResult(); if (pageNumber > pagesCount && pageNumber > 1 && rowsCount == 0) { reader.Close(); var redirectUrl = Url.BuildProductLink( id: productId, additionalRouteValues: new Dictionary <string, object> { { "pagenum", pageNumber - 1 } }); HttpContext.Current.Response.Redirect(redirectUrl); } var startRow = (pageSize * (pageNumber - 1)) + 1; var stopRow = (startRow + pageSize - 1) > rowsCount ? rowsCount : startRow + pageSize - 1; if (ratingsCount > 0) { outputString.Append($"<span itemprop=\"aggregateRating\" itemscope itemtype=\"https://schema.org/AggregateRating\">{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"ratingValue\" content=\"{ratingsAverage}\"/>{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"reviewCount\" content=\"{ratingsCount}\"/>{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"bestRating\" content=\"5\"/>{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"worstRating\" content=\"1\"/>{Environment.NewLine}"); outputString.Append($"</span>{Environment.NewLine}"); } outputString.Append("<div class=\"page-row total-rating-row\">"); outputString.Append(" <div class=\"rating-stars-wrap\">"); outputString.Append(BuildStarImages(ratingsAverage, skinId) + "<span class=\"ratings-average-wrap\"> (" + string.Format("{0:f}", ratingsAverage) + ")"); outputString.Append($"<span class=\"screen-reader-only\">{AppLogic.GetString("ratings.outof5")}</span></span>"); outputString.Append(" </div>"); outputString.Append(" <div class=\"rating-count-wrap\">"); outputString.Append($" <span>{AppLogic.GetString("ratings.cs.23")}</span> {ratingsCount}"); outputString.Append(" </div>"); outputString.Append("</div>"); var rateScript = $"javascript:RateIt({productId});"; var productRating = GetProductRating(customer.CustomerID, productId); outputString.Append("<div class=\"page-row rating-link-row\">"); if (productRating != 0) { outputString.Append("<div class=\"rating-link-wrap\">"); outputString.Append(" <span>" + AppLogic.GetString("ratings.cs.24", skinId, Thread.CurrentThread.CurrentUICulture.Name) + " " + productRating.ToString() + "</span>"); outputString.Append("</div>"); if (!AppLogic.IsAdminSite) { outputString.Append("<div class=\"rating-link-wrap\">"); outputString.Append($" <a class=\"btn btn-default change-rating-button\" href=\"{rateScript}\">{AppLogic.GetString("ratings.cs.25")}</a> "); outputString.Append($" <span>{AppLogic.GetString("ratings.cs.26")}</span>"); outputString.Append("</div>"); } } else { if ((AppLogic.AppConfigBool("RatingsCanBeDoneByAnons") || customer.IsRegistered) && !AppLogic.IsAdminSite) { outputString.Append("<div class=\"rating-link-wrap\">"); outputString.Append($" <a class=\"btn btn-default add-rating-button\" href=\"{rateScript}\">{AppLogic.GetString("ratings.cs.28")}</a> "); outputString.Append($" <span>{AppLogic.GetString("ratings.cs.27")}</span>"); outputString.Append("</div>"); } else { outputString.Append("<div class=\"rating-link-wrap\">"); outputString.Append($" <span>{AppLogic.GetString("ratings.cs.29")}</span>"); outputString.Append("</div>"); } } outputString.Append("</div>"); if (rowsCount > 0) { int idSuffix = 0; while (reader.Read()) { var firstName = string.IsNullOrEmpty(reader["FirstName"].ToString()) ? AppLogic.GetString("ratings.cs.14") : reader["FirstName"].ToString(); outputString.Append($"<div class=\"page-row rating-comment-row\" itemprop=\"review\" itemscope itemtype=\"https://schema.org/Review\">{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"datePublished\" content=\"{Convert.ToDateTime(reader["CreatedOn"]).ToString("yyyy-MM-dd")}\"/>{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"itemReviewed\" content=\"{productName}\"/>{Environment.NewLine}"); outputString.Append(" <div class=\"rating-author-wrap\">\n"); outputString.Append($" <span class=\"rating-row-number\">{reader["rownum"]}. </span><span class=\"rating-row-author\" itemprop=\"author\">" + HttpContext.Current.Server.HtmlEncode(firstName) + "</span> <span class=\"rating-row-said\">" + AppLogic.GetString("ratings.cs.15") + " " + Localization.ToThreadCultureShortDateString(Convert.ToDateTime(reader["CreatedOn"])) + ", " + AppLogic.GetString("ratings.cs.16") + " </span>"); var userRating = (int)(reader["Rating"]); outputString.Append(" </div>"); outputString.Append($"<div class=\"rating-comment-stars\" itemprop=\"reviewRating\" itemscope itemtype=\"https://schema.org/Rating\">{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"bestRating\" content=\"5\"/>{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"worstRating\" content=\"1\"/>{Environment.NewLine}"); outputString.Append($"<meta itemprop=\"ratingValue\" content=\"{userRating}\"/>{Environment.NewLine}"); outputString.Append($"<span class=\"screen-reader-only\">{userRating} {AppLogic.GetString("ratings.outof5")}</span></span>"); outputString.Append(BuildStarImages(Convert.ToDecimal(reader["Rating"]), skinId)); outputString.Append(" </div>"); outputString.Append(" <div class=\"rating-comments\" itemprop=\"reviewBody\">\n"); outputString.Append(HttpContext.Current.Server.HtmlEncode(reader["Comments"].ToString())); outputString.Append(" </div>\n"); outputString.Append("</div>\n"); outputString.Append("<div class=\"form rating-comment-helpfulness-wrap\">"); outputString.Append(" <div class=\"form-group\">"); outputString.Append(" <fieldset>"); if (customer.CustomerID != Convert.ToInt32(reader["CustomerID"])) { outputString.Append($"<legend id=\"ratings-legend\" class=\"rating-comment-helpfulness-legend\">{AppLogic.GetString("ratings.cs.42")}</legend>"); idSuffix++; if (!AppLogic.IsAdminSite) { outputString.Append($"<input id=\"helpfulyes_{idSuffix}\" type=\"radio\" name=\"helpful_{productId}_{reader["CustomerID"]}\" onClick=\"return RateComment('{productId}'," + $"'{customer.CustomerID}','Yes','{reader["CustomerID"]}');" + $"\" {CommonLogic.IIF(Convert.ToInt16(reader["CommentHelpFul"]) == 1, " checked ", string.Empty)}\">\n"); outputString.Append($"<label for=\"helpfulyes_{idSuffix}\">{AppLogic.GetString("ratings.cs.43")}</label> \n"); outputString.Append($"<input id=\"helpfulno_{idSuffix}\" type=\"radio\" name=\"helpful_{productId}_{reader["CustomerID"]}\" onClick=\"return RateComment('{productId}'," + $"'{customer.CustomerID}','No','{reader["CustomerID"]}');" + $"\" {CommonLogic.IIF(Convert.ToInt16(reader["CommentHelpFul"]) == 0, " checked ", string.Empty)}\">\n"); outputString.Append($"<label for=\"helpfulno_{idSuffix}\">{AppLogic.GetString("ratings.cs.44")}</label> \n"); } else { outputString.Append($"<input id=\"helpfulyes_{idSuffix}\" type=\"radio\" name=\"helpful_{productId}_{reader["CustomerID"]}\" " + $"{CommonLogic.IIF(Convert.ToInt16(reader["CommentHelpFul"]) == 1, " checked ", string.Empty)}>\n"); outputString.Append($"<label for=\"helpfulyes_{idSuffix}\">{AppLogic.GetString("ratings.cs.43")}</label>\n"); outputString.Append($"<input id=\"helpfulno_{idSuffix}\" type=\"radio\" name=\"helpful_{productId}_{reader["CustomerID"]}\" " + $"{ CommonLogic.IIF(Convert.ToInt16(reader["CommentHelpFul"]) == 0, " checked ", string.Empty)}>\n"); outputString.Append($"<label for=\"helpfulno_{idSuffix}\" >{AppLogic.GetString("ratings.cs.44")}</label>\n"); } } outputString.Append(" </fieldset>\n"); outputString.Append(" </div>\n"); outputString.Append(" <div class=\"form-text rating-helpfulness-text\">"); outputString.Append($" ({reader["FoundHelpful"].ToString()} {AppLogic.GetString("ratings.cs.17")} "+ $"{CommonLogic.IIF(customer.CustomerID != Convert.ToInt32(reader["CustomerID"]), AppLogic.GetString("ratings.cs.18"), AppLogic.GetString("ratings.cs.19"))} " + $"{AppLogic.GetString("ratings.cs.20")}, {reader["FoundNotHelpful"].ToString()} {AppLogic.GetString("ratings.cs.21")})"); outputString.Append(" </div>\n"); outputString.Append("</div>\n"); } } reader.Close(); if (rowsCount > 0) { outputString.Append("<div class=\"page-row comments-count-wrap\">"); outputString.AppendFormat(AppLogic.GetString("ratings.cs.37"), startRow, stopRow, rowsCount); if (pagesCount > 1) { outputString.Append(" ("); if (pageNumber > 1) { var url = Url.BuildProductLink( id: CommonLogic.QueryStringUSInt("ProductID"), additionalRouteValues: new Dictionary <string, object> { { "OrderBy", orderIndex }, { "pagenum", pageNumber - 1 }, }); outputString.AppendFormat( "<a href=\"{0}\">{1} {2}</a>", url, AppLogic.GetString("ratings.cs.10"), pageSize); } if (pageNumber > 1 && pageNumber < pagesCount) { outputString.Append(" | "); } if (pageNumber < pagesCount) { var url = Url.BuildProductLink( id: CommonLogic.QueryStringUSInt("ProductID"), additionalRouteValues: new Dictionary <string, object> { { "OrderBy", orderIndex }, { "pagenum", pageNumber + 1 }, }); outputString.AppendFormat( "<a href=\"{0}\">{1} {2}</a>", url, AppLogic.GetString("ratings.cs.11"), pageSize); } outputString.Append(")"); } outputString.Append("</div>\n"); outputString.Append("<div class=\"page-row comments-pager-wrap\">"); if (pagesCount > 1) { var url = Url.BuildProductLink( id: CommonLogic.QueryStringUSInt("ProductID"), additionalRouteValues: new Dictionary <string, object> { { "show", "all" }, { "pagenum", pageNumber + 1 }, }); outputString.AppendFormat( "<a href=\"{0}\">{1}</a> {2}", url, AppLogic.GetString("ratings.cs.28"), AppLogic.GetString("ratings.cs.38")); } outputString.Append("</div>\n"); } // END RATINGS BODY: if (!AppLogic.IsAdminSite) { var rateCommentUrl = Url.Action( actionName: ActionNames.RateComment, controllerName: ControllerNames.Rating); var rateProductUrl = Url.Action( actionName: ActionNames.Index, controllerName: ControllerNames.Rating); outputString.AppendLine($"<div id=\"RateCommentDiv\" name=\"RateCommentDiv\" style=\"position:absolute; left:0px; top:0px; visibility:{AppLogic.AppConfig("RatingsCommentFrameVisibility")}; z-index:2000; \">"); outputString.Append($"<iframe name=\"RateCommentFrm\" id=\"RateCommentFrm\" width=\"400\" height=\"100\" hspace=\"0\" vspace=\"0\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" noresize scrolling=\"yes\" src=\"{Url.Content("~/empty.htm")}\"></iframe>"); outputString.AppendLine("</div>"); var scriptBuilder = new StringBuilder(); scriptBuilder.AppendLine("<script type=\"text/javascript\">"); scriptBuilder.AppendLine("function RateComment(ProductID, MyCustomerID, MyVote, RatersCustomerID) {"); scriptBuilder.AppendLine($" RateCommentFrm.location = '{rateCommentUrl}?Productid=' + ProductID + '&VotingCustomerID=' + MyCustomerID + '&Vote=' + MyVote + '&RatingCustomerID=' + RatersCustomerID"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("function RateIt(ProductID) {"); scriptBuilder.AppendLine($" window.open('{rateProductUrl}?Productid=' + ProductID + '&refresh=no&returnurl={HttpContext.Current.Server.UrlEncode(CommonLogic.PageInvocation())}','ASPDNSF_ML{CommonLogic.GetRandomNumber(1, 100000)}','height=550,width=400,top=10,left=20,status=no,toolbar=no,menubar=no,scrollbars=yes,location=no')"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("</script>"); var httpContext = DependencyResolver.Current.GetService <HttpContextBase>(); var clientScriptRegistry = DependencyResolver.Current.GetService <IClientScriptRegistry>(); outputString.Append(clientScriptRegistry.RegisterInlineScript(httpContext, scriptBuilder.ToString())); } } } return(outputString.ToString()); }
internal static SiteMapEntity[] GetTopics(string group) { List <SiteMapEntity> _list = new List <SiteMapEntity>(); SqlCommand getCommand = new SqlCommand("select * from Topic where Deleted = 0 and Published=1 and ShowInSiteMap = 1 " + CommonLogic.IIF(SiteMap.Settings.TopicFiltering, " and (storeid = 0 or storeid =" + AppLogic.StoreID() + ")", "") + " order by storeid desc, DisplayOrder desc, name"); Action <System.Data.IDataReader> readTopics = rd => { while (rd.Read()) { SiteMapEntity entity = new SiteMapEntity(); entity.EntityID = rd.FieldInt("TopicID"); entity.Name = XmlCommon.GetLocaleEntry(rd.Field("Name"), Customer.Current.LocaleSetting, false); entity.SEName = XmlCommon.GetLocaleEntry(rd.Field("Name"), Customer.Current.LocaleSetting, false); entity.EntityType = "topic"; if (_list.FirstOrDefault(t => t.Name == entity.Name) == null) { _list.Add(entity); } } }; DB.UseDataReader(getCommand, readTopics); return(_list.ToArray()); }
private static string SignInOutLinkParser(Customer ThisCustomer) { return(AppLogic.ResolveUrl(CommonLogic.IIF(!ThisCustomer.IsRegistered, "~/signin.aspx", "~/signout.aspx"))); }
// these can change on EVERY page request!! public void BuildPageDynamicTokens() { if (m_DynamicTokens == null) { // page/customer specific items (that may change every page): m_DynamicTokens = new Hashtable(); if (CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx")) { m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING!)", AppLogic.GetGoogleEComTracking(ThisCustomer)); } else { m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING!)", String.Empty); } if (CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx")) { m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING_V2!)", String.Empty); } else { m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING_V2!)", AppLogic.GetGoogleEComTrackingV2(ThisCustomer, false)); } if (!AppLogic.VATIsEnabled()) { m_DynamicTokens.Add("(!VATREGISTRATIONID!)", String.Empty); } else { StringBuilder tmpS2 = new StringBuilder(1024); if (ThisCustomer.HasCustomerRecord) { tmpS2.Append("<span class=\"VATRegistrationIDPrompt\">" + AppLogic.GetString("setvatsetting.aspx.8", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + "</span><input type=\"text\" style=\"VATRegistrationID\" id=\"VATRegistrationID\" value=\"" + ThisCustomer.VATRegistrationID + "\">"); } m_DynamicTokens.Add("(!VATREGISTRATIONID!)", tmpS2.ToString()); } if (AppLogic.NumLocaleSettingsInstalled() < 2) { m_DynamicTokens.Add("(!COUNTRYDIVVISIBILITY!)", "hidden"); m_DynamicTokens.Add("(!COUNTRYDIVDISPLAY!)", "none"); m_DynamicTokens.Add("(!COUNTRYSELECTLIST!)", String.Empty); } else { m_DynamicTokens.Add("(!COUNTRYDIVVISIBILITY!)", "visible"); m_DynamicTokens.Add("(!COUNTRYDIVDISPLAY!)", "inline"); m_DynamicTokens.Add("(!COUNTRYSELECTLIST!)", AppLogic.GetCountrySelectList(ThisCustomer.LocaleSetting)); } if (Currency.NumPublishedCurrencies() < 2) { m_DynamicTokens.Add("(!CURRENCYDIVVISIBILITY!)", "hidden"); m_DynamicTokens.Add("(!CURRENCYDIVDISPLAY!)", "none"); m_DynamicTokens.Add("(!CURRENCYSELECTLIST!)", String.Empty); } else { m_DynamicTokens.Add("(!CURRENCYDIVVISIBILITY!)", "visible"); m_DynamicTokens.Add("(!CURRENCYDIVDISPLAY!)", "inline"); m_DynamicTokens.Add("(!CURRENCYSELECTLIST!)", AppLogic.GetCurrencySelectList(ThisCustomer)); } if (AppLogic.VATIsEnabled() && AppLogic.AppConfigBool("VAT.AllowCustomerToChooseSetting")) { m_DynamicTokens.Add("(!VATDIVVISIBILITY!)", "visible"); m_DynamicTokens.Add("(!VATDIVDISPLAY!)", "inline"); m_DynamicTokens.Add("(!VATSELECTLIST!)", AppLogic.GetVATSelectList(ThisCustomer)); } else { m_DynamicTokens.Add("(!VATDIVVISIBILITY!)", "hidden"); m_DynamicTokens.Add("(!VATDIVDISPLAY!)", "none"); m_DynamicTokens.Add("(!VATSELECTLIST!)", String.Empty); } if (!ThisCustomer.IsRegistered) { m_DynamicTokens.Add("(!SUBSCRIPTION_EXPIRATION!)", AppLogic.ro_NotApplicable); } else { if (ThisCustomer.SubscriptionExpiresOn.Equals(System.DateTime.MinValue)) { m_DynamicTokens.Add("(!SUBSCRIPTION_EXPIRATION!)", "Expired"); } else { m_DynamicTokens.Add("(!SUBSCRIPTION_EXPIRATION!)", Localization.ToThreadCultureShortDateString(ThisCustomer.SubscriptionExpiresOn)); } } m_DynamicTokens.Add("(!PAGEURL!)", HttpContext.Current.Server.UrlEncode(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"))); m_DynamicTokens.Add("(!RANDOM!)", CommonLogic.GetRandomNumber(1, 7).ToString()); m_DynamicTokens.Add("(!HDRID!)", CommonLogic.GetRandomNumber(1, 7).ToString()); m_DynamicTokens.Add("(!INVOCATION!)", HttpContext.Current.Server.HtmlEncode(CommonLogic.PageInvocation())); m_DynamicTokens.Add("(!REFERRER!)", HttpContext.Current.Server.HtmlEncode(CommonLogic.PageReferrer())); StringBuilder tmp = new StringBuilder(4096); tmp.Append("<!--\n"); tmp.Append("PAGE INVOCATION: " + HttpContext.Current.Server.HtmlEncode(CommonLogic.PageInvocation()) + "\n"); tmp.Append("PAGE REFERRER: " + HttpContext.Current.Server.HtmlEncode(CommonLogic.PageReferrer()) + "\n"); tmp.Append("STORE LOCALE: " + Localization.GetDefaultLocale() + "\n"); tmp.Append("STORE CURRENCY: " + Localization.GetPrimaryCurrency() + "\n"); tmp.Append("CUSTOMER ID: " + ThisCustomer.CustomerID.ToString() + "\n"); tmp.Append("AFFILIATE ID: " + ThisCustomer.AffiliateID.ToString() + "\n"); tmp.Append("CUSTOMER LOCALE: " + ThisCustomer.LocaleSetting + "\n"); tmp.Append("CURRENCY SETTING: " + ThisCustomer.CurrencySetting + "\n"); tmp.Append("CACHE MENUS: " + AppLogic.AppConfigBool("CacheMenus").ToString() + "\n"); tmp.Append("-->\n"); m_DynamicTokens.Add("(!PAGEINFO!)", tmp.ToString()); bool IsRegistered = CommonLogic.IIF(ThisCustomer != null, ThisCustomer.IsRegistered, false); String tmpS = String.Empty; if (IsRegistered) { if (!AppLogic.IsAdminSite) { tmpS = AppLogic.GetString("skinbase.cs.1", SkinID, ThisCustomer.LocaleSetting) + " <a class=\"username\" href=\"account.aspx\">" + ThisCustomer.FullName() + "</a>" + CommonLogic.IIF(ThisCustomer.CustomerLevelID != 0, " (" + ThisCustomer.CustomerLevelName + ")", ""); } m_DynamicTokens.Add("(!USER_NAME!)", tmpS); m_DynamicTokens.Add("(!USERNAME!)", tmpS); } else { m_DynamicTokens.Add("(!USER_NAME!)", String.Empty); m_DynamicTokens.Add("(!USERNAME!)", String.Empty); } m_DynamicTokens.Add("(!USER_MENU_NAME!)", CommonLogic.IIF(!IsRegistered, "my account", ThisCustomer.FullName())); m_DynamicTokens.Add("(!USER_MENU!)", AppLogic.GetUserMenu(ThisCustomer.IsRegistered, SkinID, ThisCustomer.LocaleSetting)); if (AppLogic.MicropayIsEnabled()) { tmpS = "Your " + AppLogic.GetString("account.aspx.11", SkinID, ThisCustomer.LocaleSetting) + " balance is: " + Localization.DecimalStringForDB(ThisCustomer.MicroPayBalance); m_DynamicTokens.Add("(!MICROPAY_BALANCE!)", tmpS); m_DynamicTokens.Add("(!MICROPAY_BALANCE_RAW!)", Localization.DecimalStringForDB(ThisCustomer.MicroPayBalance)); m_DynamicTokens.Add("(!MICROPAY_BALANCE_CURRENCY!)", ThisCustomer.CurrencyString(ThisCustomer.MicroPayBalance)); } tmpS = ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.ShoppingCart).ToString(); m_DynamicTokens.Add("(!NUM_CART_ITEMS!)", tmpS); tmpS = AppLogic.GetString("AppConfig.CartPrompt", SkinID, ThisCustomer.LocaleSetting); m_DynamicTokens.Add("(!CARTPROMPT!)", tmpS); tmpS = ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.WishCart).ToString(); m_DynamicTokens.Add("(!NUM_WISH_ITEMS!)", tmpS); tmpS = ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.GiftRegistryCart).ToString(); m_DynamicTokens.Add("(!NUM_GIFT_ITEMS!)", tmpS); tmpS = CommonLogic.IIF(!IsRegistered, AppLogic.GetString("skinbase.cs.4", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.5", SkinID, ThisCustomer.LocaleSetting)); m_DynamicTokens.Add("(!SIGNINOUT_TEXT!)", tmpS); m_DynamicTokens.Add("(!SIGNINOUT_LINK!)", CommonLogic.IIF(!IsRegistered, "signin.aspx", "signout.aspx")); String PN = CommonLogic.GetThisPageName(false); if (AppLogic.AppConfigBool("ShowMiniCart")) { if (PN.StartsWith("shoppingcart", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("checkout", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("cardinal", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("addtocart") || PN.IndexOf("_process", StringComparison.InvariantCultureIgnoreCase) != -1 || PN.StartsWith("lat_", StringComparison.InvariantCultureIgnoreCase)) { m_DynamicTokens.Add("(!MINICART!)", String.Empty); // don't show on these pages } else { m_DynamicTokens.Add("(!MINICART!)", ShoppingCart.DisplayMiniCart(ThisCustomer, SkinID, true)); } if (PN.StartsWith("shoppingcart", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("checkout", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("cardinal", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("addtocart", StringComparison.InvariantCultureIgnoreCase) || PN.IndexOf("_process", StringComparison.InvariantCultureIgnoreCase) != -1 || PN.StartsWith("lat_", StringComparison.InvariantCultureIgnoreCase)) { m_DynamicTokens.Add("(!MINICART_PLAIN!)", String.Empty); // don't show on these pages } else { m_DynamicTokens.Add("(!MINICART_PLAIN!)", ShoppingCart.DisplayMiniCart(ThisCustomer, SkinID, false)); } } m_DynamicTokens.Add("(!CUSTOMERID!)", ThisCustomer.CustomerID.ToString()); } }
// these are the same for ALL page requests since app start! public void BuildPageStaticTokens() { String m_CacheName = String.Empty; if (AppLogic.CachingOn) { m_CacheName = String.Format("StaticTokens_{0}_{1}_{2}_{3}_{4}_{5}", SkinID.ToString(), ThisCustomer.LocaleSetting, ThisCustomer.CurrencySetting, ThisCustomer.CustomerLevelID, ThisCustomer.AffiliateID, ThisCustomer.VATSettingReconciled); m_StaticTokens = (Hashtable)HttpContext.Current.Cache.Get(m_CacheName); } if (m_StaticTokens == null) { m_StaticTokens = new Hashtable(); m_StaticTokens.Add("(!STORE_VERSION!)", String.Empty); m_StaticTokens.Add("(!COPYRIGHTYEARS!)", AppLogic.AppConfig("StartingCopyrightYear") + "-" + DateTime.Now.Year.ToString()); if (AppLogic.AppConfigBool("CardinalCommerce.Centinel.Enabled")) { m_StaticTokens.Add("(!VBV!)", "<img src=\"" + AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/vbv.jpg") + "\" border=\"0\" alt=\"Store protected with Verified By Visa/MasterCard Secure Initiatives\">"); } else { m_StaticTokens.Add("(!VBV!)", String.Empty); } m_StaticTokens.Add("(!SKINID!)", SkinID.ToString()); m_StaticTokens.Add("(!RIGHTCOL!)", "The RIGHTCOL token is no longer supported. You should put the right column you want directly into your skin templtae.ascx design where you want it"); m_StaticTokens.Add("(!SITENAME!)", AppLogic.AppConfig("StoreName")); m_StaticTokens.Add("(!SITE_NAME!)", AppLogic.AppConfig("StoreName")); m_StaticTokens.Add("(!STORELOCALE!)", Localization.GetDefaultLocale()); m_StaticTokens.Add("(!LOCALESETTING!)", ThisCustomer.LocaleSetting); m_StaticTokens.Add("(!CUSTOMERLOCALE!)", ThisCustomer.LocaleSetting); m_StaticTokens.Add("(!CURRENCY_LOCALE_ROBOTS_TAG!)", String.Empty); //CommonLogic.IIF(ThisCustomer.CurrencySetting == Localization.GetPrimaryCurrency() && ThisCustomer.LocaleSetting == Localization.GetWebConfigLocale(), String.Empty, "<meta name=\"robots\" content=\"noindex,nofollow,noarchive\">")); // to prevent indexing of store pages in "foreign" currencies" m_StaticTokens.Add("(!SEARCH_BOX!)", AppLogic.GetSearchBox(SkinID, ThisCustomer.LocaleSetting)); m_StaticTokens.Add("(!COUNTRYBAR!)", AppLogic.GetCountryBar(ThisCustomer.LocaleSetting)); m_StaticTokens.Add("(!HELPBOX!)", AppLogic.GetHelpBox(SkinID, true, ThisCustomer.LocaleSetting, null)); m_StaticTokens.Add("(!HELPBOX_CONTENTS!)", AppLogic.GetHelpBox(SkinID, false, ThisCustomer.LocaleSetting, null)); m_StaticTokens.Add("(!NEWS_SUMMARY!)", AppLogic.GetNewsSummary(3)); m_StaticTokens.Add("(!CATEGORY_PROMPT!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.3", SkinID, ThisCustomer.LocaleSetting))); m_StaticTokens.Add("(!CATEGORY_PROMPT_SINGULAR!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.CategoryPromptSingular", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.CategoryPromptSingular", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.3", SkinID, ThisCustomer.LocaleSetting))); m_StaticTokens.Add("(!CATEGORY_PROMPT_PLURAL!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.2", SkinID, ThisCustomer.LocaleSetting)).ToUpperInvariant()); m_StaticTokens.Add("(!SECTION_PROMPT!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.2", SkinID, ThisCustomer.LocaleSetting))); m_StaticTokens.Add("(!SECTION_PROMPT_SINGULAR!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.SectionPromptSingular", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.SectionPromptSingular", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.2", SkinID, ThisCustomer.LocaleSetting))); m_StaticTokens.Add("(!SECTION_PROMPT_PLURAL!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.1", SkinID, ThisCustomer.LocaleSetting)).ToUpperInvariant()); m_StaticTokens.Add("(!MANUFACTURER_PROMPT!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.3", SkinID, ThisCustomer.LocaleSetting))); m_StaticTokens.Add("(!MANUFACTURER_PROMPT_SINGULAR!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.ManufacturerPromptSingular", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.ManufacturerPromptSingular", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.3", SkinID, ThisCustomer.LocaleSetting))); m_StaticTokens.Add("(!MANUFACTURER_PROMPT_PLURAL!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.2", SkinID, ThisCustomer.LocaleSetting)).ToUpperInvariant()); m_StaticTokens.Add("(!UNSUP_4!)", AppLogic.GetCategoryBox(AppLogic.AppConfigUSInt("KitCategoryID"), true, 5, false, "Our custom tailored kits provide everything you need in one package!", SkinID, ThisCustomer.LocaleSetting)); m_StaticTokens.Add("(!ADMIN_FOR!)", AppLogic.GetString("admin.main.ascx.AdminFor", 1, Localization.GetDefaultLocale())); foreach (String EntityName in AppLogic.ro_SupportedEntities) { String ENU = EntityName.ToUpperInvariant(); StringBuilder tmpSx = new StringBuilder(4096); EntityHelper Helper = AppLogic.LookupHelper(EntityName, 0); m_StaticTokens.Add("(!" + ENU + "_BROWSE_BOX!)", Helper.GetEntityBrowseBox(SkinID, ThisCustomer.LocaleSetting)); } m_StaticTokens = AspDotNetStorefront.Global.CompleteParser(m_StaticTokens); } if (AppLogic.CachingOn) { HttpContext.Current.Cache.Insert(m_CacheName, m_StaticTokens, null, System.DateTime.Now.AddMinutes(m_CacheMinutes), TimeSpan.Zero); } }
public SiteMapComponentArt(Dictionary <string, EntityHelper> EntityHelpers, int SkinID, Customer ThisCustomer, bool showCustomerService) { bool FromCache = false; String CacheName = String.Format("SiteMapComponentArt_{0}_{1}", SkinID.ToString(), ThisCustomer.LocaleSetting); if (AppLogic.CachingOn) { m_Contents = (String)HttpContext.Current.Cache.Get(CacheName); if (m_Contents != null) { FromCache = true; } } if (!FromCache) { StringBuilder tmpS = new StringBuilder(50000); tmpS.Append("<SiteMap>\n"); if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowCategories")) { // Categories: String s = AppLogic.LookupHelper("Category", 0).GetEntityComponentArtNode(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250); if (s.Length != 0) { if (AppLogic.IsAdminSite) { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\" NavigateUrl=\"newentities.aspx?entityname=category\">\n"); } else { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\">\n"); } tmpS.Append(s); tmpS.Append("</node>"); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowSections")) { // Sections: String s = AppLogic.LookupHelper("Section", 0).GetEntityComponentArtNode(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250); if (s.Length != 0) { if (AppLogic.IsAdminSite) { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\" NavigateUrl=\"newentities.aspx?entityname=section\">\n"); } else { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\">\n"); } tmpS.Append(s); tmpS.Append("</node>"); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowLibraries")) { // Libraries: String s = AppLogic.LookupHelper("Library", 0).GetEntityComponentArtNode(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowDocuments") && AppLogic.NumProductsInDB < 250); if (s.Length != 0) { if (AppLogic.IsAdminSite) { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.LibraryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\" NavigateUrl=\"newentities.aspx?entityname=library\">\n"); } else { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.LibraryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\">\n"); } tmpS.Append(s); tmpS.Append("</node>"); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowManufacturers")) { // Manufacturers: String s = AppLogic.LookupHelper("Manufacturer", 0).GetEntityComponentArtNode(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250); if (s.Length != 0) { if (AppLogic.IsAdminSite) { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\" NavigateUrl=\"newentities.aspx?entityname=manufacturer\">\n"); } else { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\">\n"); } tmpS.Append(s); tmpS.Append("</node>"); } } if (!AppLogic.IsAdminSite && AppLogic.AppConfigBool("SiteMap.ShowCustomerService") && showCustomerService) { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.CustomerService", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)) + "\">\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.YourAccount", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"account.aspx\" />\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.OrderHistory", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"account.aspx\" />\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.PolicyReturns", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"" + SE.MakeDriverLink("returns") + "\" />\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.Shipping", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"" + SE.MakeDriverLink("shipping") + "\" />\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.Contact", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"contactus.aspx\" />\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.PolicyPrivacy", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"" + SE.MakeDriverLink("privacy") + "\" />\n"); tmpS.Append(" <node Text=\""+ XmlCommon.XmlEncodeAttribute(AppLogic.GetString("menu.PolicySecurity", SkinID, ThisCustomer.LocaleSetting)) + "\" NavigateUrl=\"" + SE.MakeDriverLink("security") + "\" />\n"); tmpS.Append("</node>\n"); } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowTopics")) { // Topics: if (AppLogic.IsAdminSite) { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("sitemap.aspx.2", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\" NavigateUrl=\"topics.aspx\">\n"); } else { tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("sitemap.aspx.2", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\" NavigateUrl=\"\">\n"); } using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rs = DB.GetRS(string.Format("select Name,Title,TopicID,ShowInSiteMap from Topic with (NOLOCK) where {0} Deleted=0 and Published=1 and (SkinID IS NULL or SkinID=0 or SkinID={1}) Order By DisplayOrder, Name ASC", CommonLogic.IIF(AppLogic.IsAdminSite, "", "ShowInSiteMap=1 and "), SkinID.ToString()), con)) { string displayname = string.Empty; string name = string.Empty; while (rs.Read()) { String URL = String.Empty; name = DB.RSFieldByLocale(rs, "Name", ThisCustomer.LocaleSetting); if (AppLogic.IsAdminSite) { URL = String.Format("topics.aspx?EditTopicId={0}", DB.RSFieldInt(rs, "TopicID").ToString()); } else { URL = SE.MakeDriverLink(name); } displayname = XmlCommon.XmlEncodeAttribute(DB.RSFieldByLocale(rs, "Title", ThisCustomer.LocaleSetting)); if (displayname != string.Empty) { if (name.IndexOf("GOOGLE", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("PHONE", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("AFFILIATE", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("GIFTREGISTRY", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("WISHLIST", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("CHECKOUTANON", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("DOWNLOAD", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("GENRE", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("DISTRIBUTOR", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("VECTOR", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("CARTPAGEFOOTER", StringComparison.InvariantCultureIgnoreCase) == -1 && name.IndexOf("CODINSTRUCTIONS", StringComparison.InvariantCultureIgnoreCase) == -1) { tmpS.Append("<node Text=\"" + displayname + "\" NavigateUrl=\"" + XmlCommon.XmlEncodeAttribute(URL) + "\" />\n"); } } } } } // File Topics: // create an array to hold the list of files ArrayList fArray = new ArrayList(); // get information about our initial directory String SFP = CommonLogic.SafeMapPath(CommonLogic.IIF(AppLogic.IsAdminSite, "../", "") + "App_Templates/Skin_" + SkinID.ToString() + "/template.htm").Replace("template.htm", ""); DirectoryInfo dirInfo = new DirectoryInfo(SFP); // retrieve array of files & subdirectories FileSystemInfo[] myDir = dirInfo.GetFileSystemInfos(); for (int i = 0; i < myDir.Length; i++) { // check the file attributes // if a subdirectory, add it to the sArray // otherwise, add it to the fArray if (((Convert.ToUInt32(myDir[i].Attributes) & Convert.ToUInt32(FileAttributes.Directory)) > 0)) { } else { bool skipit = false; if (!myDir[i].FullName.EndsWith("htm", StringComparison.InvariantCultureIgnoreCase) || (myDir[i].FullName.IndexOf("TEMPLATE", StringComparison.InvariantCultureIgnoreCase) != -1) || (myDir[i].FullName.IndexOf("AFFILIATE_", StringComparison.InvariantCultureIgnoreCase) != -1) || (myDir[i].FullName.IndexOf(AppLogic.ro_PMMicropay, StringComparison.InvariantCultureIgnoreCase) != -1)) { skipit = true; } if (!skipit) { fArray.Add(Path.GetFileName(myDir[i].FullName)); } } } if (fArray.Count != 0) { // sort the files alphabetically fArray.Sort(0, fArray.Count, null); for (int i = 0; i < fArray.Count; i++) { String URL = String.Empty; if (!AppLogic.IsAdminSite) // admin site can't link to these kinds of topics { URL = SE.MakeDriverLink(fArray[i].ToString().Replace(".htm", "")); } tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(CommonLogic.Capitalize(fArray[i].ToString().Replace(".htm", ""))) + "\" " + CommonLogic.IIF(URL.Length != 0, "NavigateUrl=\"" + XmlCommon.XmlEncodeAttribute(URL) + "\"", "") + "/>\n"); } } tmpS.Append("</node>"); } tmpS.Append("</SiteMap>\n"); m_Contents = tmpS.ToString(); if (AppLogic.CachingOn) { HttpContext.Current.Cache.Insert(CacheName, m_Contents, null, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero); } } }
public static int GetProductsFirstEntity(int ProductID, string EntityName) { var tmp = 0; if (EntityName.Length == 0) { EntityName = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName; } var sql = string.Format("select top 1 a.EntityID from productentity a with (nolock) inner join (select distinct a.entityid, a.EntityType from productentity a with (nolock) left join EntityStore b with (nolock) on a.EntityID = b.EntityID where ({0} = 0 or b.StoreID = {1})) b " + "on a.EntityID = b.EntityID and a.EntityType=b.EntityType where ProductID = {2} and a.EntityType = {3} ORDER BY DisplayOrder", CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), ProductID, DB.SQuote(EntityName)); using (var dbconn = DB.dbConn()) { dbconn.Open(); using (var rs = DB.GetRS(sql, dbconn)) { if (rs.Read()) { tmp = DB.RSFieldInt(rs, "EntityID"); } } } return(tmp); }
public string GetObjectEntities(int ObjectID, bool ForObjectBrowser) { var sql = "select " + m_IDColumnName + " from " + m_EntitySpecs.m_ObjectName + "" + m_EntitySpecs.m_EntityName + " with (NOLOCK) where " + m_EntitySpecs.m_ObjectName + "ID=" + ObjectID.ToString() + CommonLogic.IIF(ForObjectBrowser, " and " + m_IDColumnName + " in (select " + m_IDColumnName + " from " + m_EntitySpecs.m_EntityName + " with (NOLOCK) where Deleted=0 " + CommonLogic.IIF(m_OnlyPublishedEntitiesAndObjects, "and Published=1", "") + " and ShowIn" + m_EntitySpecs.m_ObjectName + "Browser<>0)", ""); var tmpS = new StringBuilder(1000); using (var dbconn = DB.dbConn()) { dbconn.Open(); using (var rs = DB.GetRS(sql, dbconn)) { while (rs.Read()) { if (tmpS.Length != 0) { tmpS.Append(","); } tmpS.Append(DB.RSFieldInt(rs, m_IDColumnName).ToString()); } } } return(tmpS.ToString()); }
/// <summary> /// Converts all param keys in the m_SessionParms HashTable to an xml fragment of <param> nodes /// </summary> /// <returns></returns> private string SerializeParams() { StringBuilder sb = new StringBuilder("<params>", 1024); foreach (string s in m_SessionParms.Keys) { SessionParam sp = (SessionParam)m_SessionParms[s]; sb.Append("<param name=\"" + XmlCommon.XmlEncodeAttribute(s) + "\" val=\"" + XmlCommon.XmlEncodeAttribute(sp.ParamValue) + "\" " + CommonLogic.IIF(sp.ExpireOn.Equals(DateTime.MaxValue), "", "expireon=\"" + sp.ExpireOn.ToString() + "\"") + " />"); } sb.Append("</params>"); return(sb.ToString()); }
public SiteMap1(System.Collections.Generic.Dictionary <string, EntityHelper> EntityHelpers, int SkinID, Customer ThisCustomer) { bool FromCache = false; String CacheName = String.Format("SiteMap1_{0}_{1}", SkinID.ToString(), ThisCustomer.LocaleSetting); if (AppLogic.CachingOn) { m_Contents = (String)HttpContext.Current.Cache.Get(CacheName); if (m_Contents != null) { FromCache = true; } } if (!FromCache) { StringBuilder tmpS = new StringBuilder(50000); if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowCategories")) { // Categories: String s = AppLogic.LookupHelper("Category", 0).GetEntityULList(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250, true, "sitemapul", true, 0, String.Empty); if (s.Length != 0) { tmpS.Append("<b>"); if (AppLogic.IsAdminSite) { tmpS.Append("<a href=\"newentities.aspx?entityname=category\">"); } tmpS.Append(AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()); if (AppLogic.IsAdminSite) { tmpS.Append("</a>"); } tmpS.Append("</b>"); tmpS.Append(s); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowSections")) { // Sections: String s = AppLogic.LookupHelper("Section", 0).GetEntityULList(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250, true, "sitemapul", true, 0, String.Empty); if (s.Length != 0) { tmpS.Append("<b>"); if (AppLogic.IsAdminSite) { tmpS.Append("<a href=\"newentities.aspx?entityname=section\">"); } tmpS.Append(AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()); if (AppLogic.IsAdminSite) { tmpS.Append("</a>"); } tmpS.Append("</b>"); tmpS.Append(s); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowLibraries")) { // Libraries: String s = AppLogic.LookupHelper("Library", 0).GetEntityULList(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, AppLogic.AppConfigBool("SiteMap.ShowDocuments"), true, true, "sitemapul", true, 0, String.Empty); if (s.Length != 0) { tmpS.Append("<b>"); if (AppLogic.IsAdminSite) { tmpS.Append("<a href=\"newentities.aspx?entityname=library\">"); } tmpS.Append(AppLogic.GetString("AppConfig.LibraryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()); if (AppLogic.IsAdminSite) { tmpS.Append("</a>"); } tmpS.Append("</b>"); tmpS.Append(s); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowManufacturers")) { // Manufacturers: String s = AppLogic.LookupHelper("Manufacturer", 0).GetEntityULList(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, false, AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250, true, "sitemapul", true, 0, String.Empty); if (s.Length != 0) { tmpS.Append("<b>"); if (AppLogic.IsAdminSite) { tmpS.Append("<a href=\"newentities.aspx?entityname=manufacturer\">"); } tmpS.Append(AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()); if (AppLogic.IsAdminSite) { tmpS.Append("</a>"); } tmpS.Append("</b>"); tmpS.Append(s); } } if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowTopics")) { // Topics: tmpS.Append("<b>"); if (AppLogic.IsAdminSite) { tmpS.Append("<a href=\"topics.aspx\">"); } tmpS.Append(AppLogic.GetString("sitemap.aspx.2", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()); if (AppLogic.IsAdminSite) { tmpS.Append("</a>"); } tmpS.Append("</b>"); tmpS.Append("<ul class=\"sitemapul\">\n"); using (SqlConnection dbconn = DB.dbConn()) { dbconn.Open(); using (IDataReader rs = DB.GetRS(string.Format("select count(*) as N from Topic with (NOLOCK) where {0} Deleted=0 AND Published=1 and (SkinID IS NULL or SkinID=0 or SkinID={1}) ", CommonLogic.IIF(AppLogic.IsAdminSite, "", "ShowInSiteMap=1 and "), SkinID.ToString()) + "; " + string.Format("select Name,Title,TopicID from Topic with (NOLOCK) where {0} Deleted=0 and Published=1 and (SkinID IS NULL or SkinID=0 or SkinID={1}) Order By DisplayOrder, Name ASC", CommonLogic.IIF(AppLogic.IsAdminSite, "", "ShowInSiteMap=1 and "), SkinID.ToString()), dbconn)) { if (rs.Read() && DB.RSFieldInt(rs, "N") > 0) { if (rs.NextResult()) { while (rs.Read()) { tmpS.Append("<li>"); if (AppLogic.IsAdminSite) { tmpS.Append(String.Format("<a href=\"edittopic.aspx?topicid={0}\">", DB.RSFieldInt(rs, "TopicID").ToString())); } else { tmpS.Append("<a href=\"" + SE.MakeDriverLink(DB.RSFieldByLocale(rs, "Name", Localization.GetDefaultLocale())) + "\">"); } tmpS.Append(Security.HtmlEncode(DB.RSFieldByLocale(rs, "Title", Localization.GetDefaultLocale()))); tmpS.Append("</a>"); tmpS.Append("</li>\n"); } } } } } // File Topics: // create an array to hold the list of files ArrayList fArray = new ArrayList(); // get information about our initial directory String SFP = CommonLogic.SafeMapPath(CommonLogic.IIF(AppLogic.IsAdminSite, "../", "") + "App_Templates/Skin_" + SkinID.ToString() + "/template.htm").Replace("template.htm", ""); DirectoryInfo dirInfo = new DirectoryInfo(SFP); // retrieve array of files & subdirectories FileSystemInfo[] myDir = dirInfo.GetFileSystemInfos(); for (int i = 0; i < myDir.Length; i++) { // check the file attributes // if a subdirectory, add it to the sArray // otherwise, add it to the fArray if (((Convert.ToUInt32(myDir[i].Attributes) & Convert.ToUInt32(FileAttributes.Directory)) > 0)) { } else { bool skipit = false; if (!myDir[i].FullName.EndsWith("htm", StringComparison.InvariantCultureIgnoreCase) || (myDir[i].FullName.IndexOf("TEMPLATE", StringComparison.InvariantCultureIgnoreCase) != -1) || (myDir[i].FullName.IndexOf("AFFILIATE_", StringComparison.InvariantCultureIgnoreCase) != -1) || (myDir[i].FullName.IndexOf(AppLogic.ro_PMMicropay, StringComparison.InvariantCultureIgnoreCase) != -1)) { skipit = true; } if (!skipit) { fArray.Add(Path.GetFileName(myDir[i].FullName)); } } } if (fArray.Count != 0) { // sort the files alphabetically fArray.Sort(0, fArray.Count, null); for (int i = 0; i < fArray.Count; i++) { tmpS.Append("<li>"); if (!AppLogic.IsAdminSite) // admin site can't link to these kinds of topics { tmpS.Append("<a href=\"" + SE.MakeDriverLink(fArray[i].ToString().Replace(".htm", "")) + "\">"); } else { tmpS.Append("(file based topic) "); } tmpS.Append(Security.HtmlEncode(CommonLogic.Capitalize(fArray[i].ToString().Replace(".htm", "")))); if (!AppLogic.IsAdminSite) { tmpS.Append("</a>"); } tmpS.Append("</li>\n"); } } tmpS.Append("</ul>\n"); } m_Contents = tmpS.ToString(); if (AppLogic.CachingOn) { HttpContext.Current.Cache.Insert(CacheName, m_Contents, null, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero); } } }
private static string SignInOutTextParser(Customer ThisCustomer) { return(CommonLogic.IIF(!ThisCustomer.IsRegistered, AppLogic.GetString("skinbase.cs.4", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.5", ThisCustomer.SkinID, ThisCustomer.LocaleSetting))); }
// don't return any quotes, single quotes, or carraige returns in this string! static public String GetQuantityDiscountDisplayTable(int DID, int SkinID) { String CacheName = "GetQuantityDiscountDisplayTable_" + DID.ToString() + "_" + SkinID.ToString(); if (AppLogic.CachingOn) { String CacheData = (String)HttpContext.Current.Cache.Get(CacheName); if (CacheData != null) { if (CommonLogic.ApplicationBool("DumpSQL")) { HttpContext.Current.Response.Write("Cache Hit Found!"); } return(CacheData); } } Customer ThisCustomer = HttpContext.Current.GetCustomer(); bool fixedDiscount = isFixedQuantityDiscount(DID); StringBuilder tmpS = new StringBuilder(10000); String sql = "select * from dbo.QuantityDiscountTable with (NOLOCK) where QuantityDiscountID=" + DID.ToString() + " order by LowQuantity"; tmpS.Append("<table class=\"table table-striped quantity-discount-table\">"); tmpS.Append("<tr class=\"table-header\"><th scope=\"col\">" + AppLogic.GetString("common.cs.34", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</th><th scope=\"col\">" + CommonLogic.IIF(fixedDiscount, AppLogic.GetString("shoppingcart.cs.116", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + " ", "") + AppLogic.GetString("common.cs.35", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</th></tr>"); using (var con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (var rs = DB.GetRS(sql, con)) { while (rs.Read()) { tmpS.Append("<tr class=\"table-row\">"); tmpS.Append("<th scope=\"row\" class=\"quantity-cell table-row-header\">"); tmpS.Append(DB.RSFieldInt(rs, "LowQuantity").ToString() + CommonLogic.IIF(DB.RSFieldInt(rs, "HighQuantity") > 9999, "+", "-" + DB.RSFieldInt(rs, "HighQuantity").ToString())); tmpS.Append("</th>"); tmpS.Append("<td class=\"discount-cell\">"); if (fixedDiscount) { tmpS.Append(Localization.CurrencyStringForDisplayWithExchangeRate(DB.RSFieldDecimal(rs, "DiscountPercent"), ThisCustomer.CurrencySetting)); } else { tmpS.Append(DB.RSFieldDecimal(rs, "DiscountPercent").ToString("N" + AppLogic.AppConfigNativeInt("QuantityDiscount.PercentDecimalPlaces")) + "%"); } tmpS.Append("</td>"); tmpS.Append("</tr>"); } } } tmpS.Append("</table>"); if (AppLogic.CachingOn) { HttpContext.Current.Cache.Insert(CacheName, tmpS.ToString(), null, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero); } return(tmpS.ToString()); }
/// <summary> /// Gets the eval data. /// </summary> /// <param name="expression">The expression.</param> /// <param name="target">The target.</param> /// <param name="entry">The entry.</param> /// <returns></returns> public static object GetEvalData(string expression, Type target, string entry) { Customer ThisCustomer = AppLogic.GetCurrentCustomer(); bool IsRegistered = CommonLogic.IIF(ThisCustomer != null, ThisCustomer.IsRegistered, false); string[] values = expression.Split(','); string command = values[0]; switch (command.ToLowerInvariant()) { case "cartprompt": return(AppLogic.GetString("AppConfig.CartPrompt", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)); case "currency_locale_robots_tag": return(CurrencyLocaleRobotsTag(ThisCustomer)); case "num_cart_items": return(NumCartItemsParser(ThisCustomer)); case "pageinfo": return(PageInfoParser(ThisCustomer)); case "buysafeseal": return(BuySafeSealParser(ThisCustomer)); case "bongoextend": return(BongoExtendParser(ThisCustomer)); case "username": return(UserNameParser(ThisCustomer)); case "signinout_link": return(SignInOutLinkParser(ThisCustomer)); case "signinout_text": return(SignInOutTextParser(ThisCustomer)); case "skinid": return(ThisCustomer.SkinID.ToString()); case "stringresource": return(StringResourceParser(ThisCustomer, values)); case "stringresourceformat": return(StringResourceFormatParser(ThisCustomer, values)); case "appconfig": return(AppConfigParser(values)); case "appconfigbool": return(AppConfigBoolParser(values)); case "appconfigusint": return(AppConfigUSIntParser(values)); case "topic": return(TopicParser(ThisCustomer, values)); case "topictitle": return(Topic.GetTitle(values[1].Trim(), ThisCustomer.LocaleSetting, AppLogic.StoreID())); case "topiclink": return(SE.MakeDriverLink(values[1].Trim())); case "xmlpackage": if (values.Length >= 2) { string xmlPackageName = values[1]; string runtimeParams = values.Length >= 3 ? values[2] : string.Empty; return(RunXmlPackage(ThisCustomer, xmlPackageName.Trim(), runtimeParams.Trim())); } else { return("Invalid number of parameters"); } case "stringformat": return(StringFormat(expression)); case "user_menu_name": return(CommonLogic.IIF(!IsRegistered, "my account", ThisCustomer.FullName())); case "customerid": return(ThisCustomer.CustomerID.ToString()); case "skinimagedir": return(AppLogic.SkinImageDir()); case "skinimage": if (values.Length < 2) { return("{Image File name not specified}"); } string imgFile = values[1]; return(AppLogic.SkinImage(imgFile.Trim())); case "adminlink": return(AppLogic.AdminLinkUrl(values[1].Trim())); case "google_ecom_tracking_v2": if (AppLogic.AppConfigBool("Google.DeprecatedEcomTokens.Enabled")) { if (CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx")) { return(String.Empty); } else { return(AppLogic.GetGoogleEComTrackingV2(ThisCustomer, false)); } } else { return(String.Empty); } case "google_ecom_tracking_asynch": if (AppLogic.AppConfigBool("Google.DeprecatedEcomTokens.Enabled")) { if (CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx") || CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("mobileorderconfirmation.aspx")) { return(AppLogic.GetGoogleEComTrackingAsynch(ThisCustomer, true)); } else { return(AppLogic.GetGoogleEComTrackingAsynch(ThisCustomer, false)); } } else { return(String.Empty); } case "vbv": return(VBVParser(ThisCustomer)); default: return(string.Empty); } }
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 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(); } } }
/// <summary> /// Check if order is All Downloads /// </summary> /// <param name="orderInfoNode"></param> /// <returns>returns true if order is all downloads</returns> private bool CheckIfAllDownloads(XmlNode orderInfoNode) { return(CommonLogic.IIF(XmlCommon.XmlFieldNativeInt(orderInfoNode, "allDownloads") == 1, true, false)); }
/// <summary> /// Builds ImgDHTML /// </summary> void BuildImageGalleryScript(string productIdSuffix, bool m_WatermarksEnabled, UrlHelper urlHelper) { var scriptBuilder = new StringBuilder(4096); scriptBuilder.AppendLine("<script type=\"text/javascript\">"); scriptBuilder.AppendLine("var ProductPicIndex" + productIdSuffix + " = 1;"); scriptBuilder.AppendLine("var ProductColor" + productIdSuffix + " = '';"); scriptBuilder.AppendLine("var boardpics" + productIdSuffix + " = new Array();"); scriptBuilder.AppendLine("var boardpicslg" + productIdSuffix + " = new Array();"); scriptBuilder.AppendLine("var boardpicslgAltText" + productIdSuffix + " = new Array();"); scriptBuilder.AppendLine("var boardpicslgwidth" + productIdSuffix + " = new Array();"); scriptBuilder.AppendLine("var boardpicslgheight" + productIdSuffix + " = new Array();"); var product = new Product(ProductId); var altText = HttpContext.Current.Server.UrlEncode( string.IsNullOrEmpty(product.SEAltText) ? string.Format(AppLogic.GetString("popup.alttext"), product.LocaleName) : product.SEAltText); var popupImageBuilder = DependencyResolver.Current.GetService <IPopupImageBuilder>(); for (int i = 1; i <= ImageCountIndex; i++) { foreach (string c in VariantColors) { string MdUrl = ImageUrl(i, c, nameof(ProductImageSize.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", nameof(ProductImageSize.medium), ""); } } scriptBuilder.AppendLine("boardpics" + productIdSuffix + "['" + i.ToString() + "," + c + "'] = '" + MdWatermarkedUrl + "';"); string LgUrl = ImageUrl(i, c, nameof(ProductImageSize.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", nameof(ProductImageSize.large), ""); } } scriptBuilder.AppendLine("boardpicslg" + productIdSuffix + "['" + i.ToString() + "," + c + "'] = '" + LgWatermarkedUrl + "';"); if (LgUrl.Length > 0) { var encodedAltText = popupImageBuilder.EncodePopupAltText($"Picture {i} {altText}"); scriptBuilder.AppendLine("boardpicslgAltText" + productIdSuffix + "['" + i.ToString() + "," + c + "'] = '" + encodedAltText + "';"); System.Drawing.Size lgsz = CommonLogic.GetImagePixelSize(LgUrl); scriptBuilder.AppendLine("boardpicslgwidth" + productIdSuffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Width.ToString() + "';"); scriptBuilder.AppendLine("boardpicslgheight" + productIdSuffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Height.ToString() + "';"); } } } scriptBuilder.AppendLine("function changecolorimg" + productIdSuffix + "() {"); scriptBuilder.AppendLine(" var scidx = ProductPicIndex"+ productIdSuffix + " + ',' + ProductColor" + productIdSuffix + ".toLowerCase();"); scriptBuilder.AppendLine(" document.ProductPic"+ ProductId.ToString() + ".src=boardpics" + productIdSuffix + "[scidx];"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("function popuplarge" + productIdSuffix + "() {"); scriptBuilder.AppendLine(" var scidx = ProductPicIndex"+ productIdSuffix + " + ',' + ProductColor" + productIdSuffix + ".toLowerCase();"); scriptBuilder.AppendLine(" var LargeSrc = encodeURIComponent(boardpicslg"+ productIdSuffix + "[scidx]);"); scriptBuilder.AppendLine(" if(boardpicslg"+ productIdSuffix + "[scidx] != '') {"); var popupUrl = urlHelper.Action(ActionNames.PopUp, ControllerNames.Image); scriptBuilder.AppendLine(" window.open('"+ popupUrl + "?" + RouteDataKeys.ImagePath + "=' + LargeSrc + '&altText=' + boardpicslgAltText" + productIdSuffix + "[scidx],'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" + productIdSuffix + "[scidx] + ',height=' + boardpicslgheight" + productIdSuffix + "[scidx] + ',left=0,top=0');"); scriptBuilder.AppendLine(" } else {"); scriptBuilder.AppendLine(" alert('There is no large image available for this picture');"); scriptBuilder.AppendLine(" }"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("function setcolorpicidx" + productIdSuffix + "(idx) {"); scriptBuilder.AppendLine(" ProductPicIndex"+ productIdSuffix + " = idx;"); scriptBuilder.AppendLine(" changecolorimg"+ productIdSuffix + "();"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("function setActive(element) {"); scriptBuilder.AppendLine(" adnsf$('li.page-link').removeClass('active');"); scriptBuilder.AppendLine(" adnsf$('a.page-number').children().remove();"); scriptBuilder.AppendLine(" adnsf$(element).parent().addClass('active');"); scriptBuilder.AppendLine(" adnsf$(element).append('<span class=\"screen-reader-only\"> Selected</span>');"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("function cleansizecoloroption" + productIdSuffix + "(theVal) {"); scriptBuilder.AppendLine(" if(theVal.indexOf('[') != -1) {"); scriptBuilder.AppendLine(" theVal = theVal.substring(0, theVal.indexOf('['))"); scriptBuilder.AppendLine(" }"); scriptBuilder.AppendLine(" theVal = theVal.replace(/[\\W]/g,\"\");"); scriptBuilder.AppendLine(" theVal = theVal.toLowerCase();"); scriptBuilder.AppendLine(" return theVal;"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("function setcolorpic" + productIdSuffix + "(color) {"); scriptBuilder.AppendLine(" while(color != unescape(color)) {"); scriptBuilder.AppendLine(" color = unescape(color);"); scriptBuilder.AppendLine(" }"); scriptBuilder.AppendLine(" if(color == '-,-' || color == '-') {"); scriptBuilder.AppendLine(" color = '';"); scriptBuilder.AppendLine(" }"); scriptBuilder.AppendLine(" if(color != '' && color.indexOf(',') != -1) {"); scriptBuilder.AppendLine(" color = color.substring(0,color.indexOf(',')).replace(new RegExp(\"'\", 'gi'), '');"); // remove sku from color select value scriptBuilder.AppendLine(" }"); scriptBuilder.AppendLine(" if(color != '' && color.indexOf('[') != -1) {"); scriptBuilder.AppendLine(" color = color.substring(0,color.indexOf('[')).replace(new RegExp(\"'\", 'gi'), '');"); scriptBuilder.AppendLine(" color = color.replace(/[\\s]+$/g,\"\");"); scriptBuilder.AppendLine(" }"); scriptBuilder.AppendLine(" ProductColor"+ productIdSuffix + " = cleansizecoloroption" + productIdSuffix + "(color);"); scriptBuilder.AppendLine(" changecolorimg"+ productIdSuffix + "();"); scriptBuilder.AppendLine(" return (true);"); scriptBuilder.AppendLine("}"); scriptBuilder.AppendLine("</script>"); GalleryScript = scriptBuilder.ToString(); }
/// <summary> /// Check if order is all system products /// </summary> /// <param name="orderInfoNode"></param> /// <returns>returns true if order is all system products</returns> private bool CheckIfAllSystemProducts(XmlNode orderInfoNode) { return(CommonLogic.IIF(XmlCommon.XmlFieldNativeInt(orderInfoNode, "allSystemproducts") == 1, true, false)); ; }
public DataSet LoadFromDBEntity() { SqlConnection dbconn = new SqlConnection(); dbconn.ConnectionString = DB.GetDBConn(); dbconn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = dbconn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "aspdnsf_GetProductsEntity"; if (CategoryID != 0) { cmd.Parameters.Add(new SqlParameter("@CategoryID", SqlDbType.Int)); cmd.Parameters["@CategoryID"].Value = m_CategoryID; } if (SectionID != 0) { cmd.Parameters.Add(new SqlParameter("@SectionID", SqlDbType.Int)); cmd.Parameters["@SectionID"].Value = m_SectionID; } if (ManufacturerID != 0) { cmd.Parameters.Add(new SqlParameter("@ManufacturerID", SqlDbType.Int)); cmd.Parameters["@ManufacturerID"].Value = m_ManufacturerID; } if (DistributorID != 0) { cmd.Parameters.Add(new SqlParameter("@distributorID", SqlDbType.Int)); cmd.Parameters["@distributorID"].Value = m_DistributorID; } if (GenreID != 0) { cmd.Parameters.Add(new SqlParameter("@genreID", SqlDbType.Int)); cmd.Parameters["@genreID"].Value = m_GenreID; } if (VectorID != 0) { cmd.Parameters.Add(new SqlParameter("@vectorID", SqlDbType.Int)); cmd.Parameters["@vectorID"].Value = m_VectorID; } if (!AppLogic.IsAdminSite && AffiliateID != 0 && AppLogic.AppConfigBool("FilterProductsByAffiliate")) { cmd.Parameters.Add(new SqlParameter("@AffiliateID", SqlDbType.Int)); cmd.Parameters["@AffiliateID"].Value = m_AffiliateID; } /********************************** * Modified by : mark * Date : 11.16.2006 * No. : 97 *********************************/ // let's supply the product type as 0 to indicate // that don't want to filter by ProductType // which we will validate in the stored procedure cmd.Parameters.Add(new SqlParameter("@ProductTypeID", SqlDbType.Int)); cmd.Parameters["@ProductTypeID"].Value = m_ProductTypeID; /****** end modification ****************/ cmd.Parameters.Add(new SqlParameter("@ViewType", SqlDbType.Int)); cmd.Parameters["@ViewType"].Value = CommonLogic.IIF(m_ReturnAllVariants || m_SearchMatch.Length != 0, 0, 1); cmd.Parameters.Add(new SqlParameter("@StatsFirst", SqlDbType.Int)); cmd.Parameters["@StatsFirst"].Value = 0; if (m_SearchMatch.Length != 0) { cmd.Parameters.Add(new SqlParameter("@SearchStr", SqlDbType.NVarChar)); cmd.Parameters["@SearchStr"].Value = m_SearchMatch; cmd.Parameters.Add(new SqlParameter("@ExtSearch", SqlDbType.Int)); cmd.Parameters["@ExtSearch"].Value = CommonLogic.IIF(m_SearchDescriptionAndSummaryFields, 1, 0); } cmd.Parameters.Add(new SqlParameter("@PublishedOnly", SqlDbType.Int)); cmd.Parameters["@PublishedOnly"].Value = CommonLogic.IIF(m_PublishedOnly, 1, 0); cmd.Parameters.Add(new SqlParameter("@OnSaleOnly", SqlDbType.Int)); cmd.Parameters["@OnSaleOnly"].Value = CommonLogic.IIF(m_OnSaleOnly, 1, 0); if (m_SearchIndex.Length != 0) { cmd.Parameters.Add(new SqlParameter("@SearchIndex", SqlDbType.Char)); cmd.Parameters["@SearchIndex"].Value = m_SearchIndex; } if (m_SortOrder.Length != 0) { cmd.Parameters.Add(new SqlParameter("@SortOrder", SqlDbType.VarChar)); cmd.Parameters["@SortOrder"].Value = (m_SortOrder.Length > 0 ? m_SortOrder : "ASC"); } if (m_SortBy.Length != 0) { cmd.Parameters.Add(new SqlParameter("@SortBy", SqlDbType.VarChar)); cmd.Parameters["@SortBy"].Value = (m_SortBy.Length > 0 ? m_SortBy : "Name"); } m_Products = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(m_Products, "Table"); dbconn.Close(); DataRow PagingStatsRow = m_Products.Tables[1].Rows[0]; m_NumPages = DB.RowFieldInt(PagingStatsRow, "Pages"); System.Collections.Generic.Dictionary <int, bool> hTable = new System.Collections.Generic.Dictionary <int, bool>(); foreach (DataRow drow in m_Products.Tables[0].Rows) { if (!hTable.ContainsKey((int)drow["ProductID"])) { hTable.Add((int)drow["ProductID"], true); } else { drow.Delete(); } } m_Products.AcceptChanges(); m_NumProducts = m_Products.Tables[0].Rows.Count; return(m_Products); }
public DataSet LoadFromDB(bool IncludeAll) { SqlConnection dbconn = new SqlConnection(); dbconn.ConnectionString = DB.GetDBConn(); dbconn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = dbconn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "aspdnsf_GetProducts"; if (IncludeAll) { cmd.Parameters.Add(new SqlParameter("@IncludeAll", SqlDbType.Int)); cmd.Parameters["@IncludeAll"].Value = IncludeAll; } if (CategoryID != 0) { cmd.Parameters.Add(new SqlParameter("@CategoryID", SqlDbType.Int)); cmd.Parameters["@CategoryID"].Value = m_CategoryID; } if (SectionID != 0) { cmd.Parameters.Add(new SqlParameter("@SectionID", SqlDbType.Int)); cmd.Parameters["@SectionID"].Value = m_SectionID; } if (ManufacturerID != 0) { cmd.Parameters.Add(new SqlParameter("@ManufacturerID", SqlDbType.Int)); cmd.Parameters["@ManufacturerID"].Value = m_ManufacturerID; } if (DistributorID != 0) { cmd.Parameters.Add(new SqlParameter("@distributorID", SqlDbType.Int)); cmd.Parameters["@distributorID"].Value = m_DistributorID; } if (GenreID != 0) { cmd.Parameters.Add(new SqlParameter("@genreID", SqlDbType.Int)); cmd.Parameters["@genreID"].Value = m_GenreID; } if (VectorID != 0) { cmd.Parameters.Add(new SqlParameter("@vectorID", SqlDbType.Int)); cmd.Parameters["@vectorID"].Value = m_VectorID; } if (!AppLogic.IsAdminSite && AppLogic.AppConfigBool("FilterProductsByLocaleSetting")) { if (m_LocaleID != 0) { cmd.Parameters.Add(new SqlParameter("@LocaleID", SqlDbType.Int)); cmd.Parameters["@LocaleID"].Value = m_LocaleID; } } if (AppLogic.IsAdminSite) { cmd.Parameters.Add(new SqlParameter("@InventoryFilter", SqlDbType.Int)); cmd.Parameters["@InventoryFilter"].Value = -1; } else if (AppLogic.AppConfigUSInt("MinimumInventoryFilter") > m_InventoryFilter) { cmd.Parameters.Add(new SqlParameter("@InventoryFilter", SqlDbType.Int)); cmd.Parameters["@InventoryFilter"].Value = AppLogic.AppConfigUSInt("MinimumInventoryFilter"); } else { cmd.Parameters.Add(new SqlParameter("@InventoryFilter", SqlDbType.Int)); cmd.Parameters["@InventoryFilter"].Value = m_InventoryFilter; } // leave null for no filtering. 0 passed in this case will filter to customer level 0!! // This is the only param that has this special treatment if (!AppLogic.IsAdminSite && AppLogic.AppConfigBool("FilterProductsByCustomerLevel")) { // we are filtering normally: cmd.Parameters.Add(new SqlParameter("@CustomerLevelID", SqlDbType.Int)); cmd.Parameters["@CustomerLevelID"].Value = m_CustomerLevelID; } if (!AppLogic.IsAdminSite && AffiliateID != 0 && AppLogic.AppConfigBool("FilterProductsByAffiliate")) { cmd.Parameters.Add(new SqlParameter("@AffiliateID", SqlDbType.Int)); cmd.Parameters["@AffiliateID"].Value = m_AffiliateID; } if (ProductTypeID != 0) { cmd.Parameters.Add(new SqlParameter("@ProductTypeID", SqlDbType.Int)); cmd.Parameters["@ProductTypeID"].Value = m_ProductTypeID; } cmd.Parameters.Add(new SqlParameter("@ViewType", SqlDbType.Int)); cmd.Parameters["@ViewType"].Value = CommonLogic.IIF(m_ReturnAllVariants || m_SearchMatch.Length != 0, 0, 1); cmd.Parameters.Add(new SqlParameter("@ExcludePacks", SqlDbType.Int)); cmd.Parameters["@ExcludePacks"].Value = CommonLogic.IIF(m_ExcludePacks, 1, 0); cmd.Parameters.Add(new SqlParameter("@ExcludeKits", SqlDbType.Int)); cmd.Parameters["@ExcludeKits"].Value = CommonLogic.IIF(m_ExcludeKits, 1, 0); cmd.Parameters.Add(new SqlParameter("@ExcludeSysProds", SqlDbType.Int)); cmd.Parameters["@ExcludeSysProds"].Value = CommonLogic.IIF(m_ExcludeSystemProducts, 1, 0); if (m_PrimarySortEntity != ProductCollectionSortEntity.Undefined) { cmd.Parameters.Add(new SqlParameter("@SortEntity", SqlDbType.Int)); cmd.Parameters["@SortEntity"].Value = (int)m_PrimarySortEntity; } if (PageSize != 0) { if (PageNum == 0) { PageNum = 1; } cmd.Parameters.Add(new SqlParameter("@pagesize", SqlDbType.Int)); cmd.Parameters["@pagesize"].Value = m_PageSize; cmd.Parameters.Add(new SqlParameter("@pagenum", SqlDbType.Int)); cmd.Parameters["@pagenum"].Value = m_PageNum; } else { // no paging cmd.Parameters.Add(new SqlParameter("@pagesize", SqlDbType.Int)); cmd.Parameters["@pagesize"].Value = 9999999; // shouldn't ever exceed this, but of course, someone will. someday, and blame us :) cmd.Parameters.Add(new SqlParameter("@pagenum", SqlDbType.Int)); cmd.Parameters["@pagenum"].Value = m_PageNum; } cmd.Parameters.Add(new SqlParameter("@StatsFirst", SqlDbType.Int)); cmd.Parameters["@StatsFirst"].Value = 0; if (SearchMatch.Length != 0) { cmd.Parameters.Add(new SqlParameter("@SearchStr", SqlDbType.NVarChar)); cmd.Parameters["@SearchStr"].Value = SearchMatch; cmd.Parameters.Add(new SqlParameter("@ExtSearch", SqlDbType.Int)); cmd.Parameters["@ExtSearch"].Value = CommonLogic.IIF(m_SearchDescriptionAndSummaryFields, 1, 0); } cmd.Parameters.Add(new SqlParameter("@PublishedOnly", SqlDbType.Int)); cmd.Parameters["@PublishedOnly"].Value = CommonLogic.IIF(m_PublishedOnly, 1, 0); cmd.Parameters.Add(new SqlParameter("@OnSaleOnly", SqlDbType.Int)); cmd.Parameters["@OnSaleOnly"].Value = CommonLogic.IIF(m_OnSaleOnly, 1, 0); m_Products = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(m_Products, "Table"); dbconn.Close(); DataRow PagingStatsRow = m_Products.Tables[1].Rows[0]; m_NumPages = DB.RowFieldInt(PagingStatsRow, "Pages"); m_NumProducts = m_Products.Tables[0].Rows.Count; return(m_Products); }
public string ExecuteFeed(Customer ThisCustomer, String RuntimeParams) { string folderpath = CommonLogic.IIF(AppLogic.IsAdminSite, CommonLogic.SafeMapPath("../images/"), CommonLogic.SafeMapPath("images")); string retval = string.Empty; try { string filename = String.Empty; if (FTPFilename.Length == 0) { FTPFilename = XmlPackage + ".txt"; } //Strip all of the remote pathing stuff before setting the local filename if (FTPFilename.IndexOf("/") != -1) { filename = FTPFilename.Substring(FTPFilename.LastIndexOf("/")).Trim('/'); } else { filename = FTPFilename; } filename = Path.Combine(folderpath, filename); String[] Files; Files = Directory.GetFileSystemEntries(folderpath); foreach (string Element in Files) { try { if (Element.Substring(Element.LastIndexOf("\\")).Trim('\\').Substring(0, FTPFilename.Substring(0, FTPFilename.LastIndexOf(".")).Length) == FTPFilename.Substring(0, FTPFilename.LastIndexOf("."))) { File.Delete(Element); } } catch { } } string HideProductsWithLessThanThisInventoryLevel = AppLogic.AppConfig("HideProductsWithLessThanThisInventoryLevel"); if (HideProductsWithLessThanThisInventoryLevel == null || HideProductsWithLessThanThisInventoryLevel == "") { HideProductsWithLessThanThisInventoryLevel = "0"; } // SELECT query for getting the total number of rows StringBuilder SqlQuery = new StringBuilder(10000); SqlQuery.Append("SELECT COUNT(*) FROM (select p.productid, p.name, isnull(pv.name, '') VariantName, p.description, p.sename, p.ImageFileNameOverride, p.SKU, isnull(p.FroogleDescription, '') ProductFroogleDescription, p.SEKeywords, "); SqlQuery.Append("p.ManufacturerPartNumber, pv.price, isnull(pv.saleprice, 0) saleprice, isnull(pv.FroogleDescription, '') VariantFroogleDescription, isnull(pv.description, '') VariantDescr from dbo.product p "); SqlQuery.Append("join dbo.productvariant pv on p.productid = pv.productid left join (select variantid, sum(quan) inventory from dbo.inventory group by variantid) i on pv.variantid = i.variantid where p.IsSystem=0 and p.deleted = 0 "); SqlQuery.Append("and p.published = 1 and p.ExcludeFromPriceFeeds = 0 and pv.isdefault = 1 and case p.TrackInventoryBySizeAndColor when 1 then isnull(i.inventory, 0) else pv.inventory end >= " + HideProductsWithLessThanThisInventoryLevel + ") AS tmp"); // Code for query execution string err; object objReturn; Int32 RowCount; SqlConnection cn = new SqlConnection(DB.GetDBConn()); SqlCommand cmd = new SqlCommand(); cn.Open(); cmd.Connection = cn; cmd.CommandText = SqlQuery.ToString(); cmd.CommandType = CommandType.Text; try { // Get the result of the query objReturn = cmd.ExecuteScalar(); // Check if result is null if (objReturn != null) { RowCount = (Int32)objReturn; string newFileNames = string.Empty; // The lower and upper bounds of the records to be retrieved Int32 LowerBound = 1; Int32 UpperBound = (LowerBound - 1) + 20000; // Looping for processing of records by 20000 while (RowCount > 0) { if (RowCount < 20000) { UpperBound = (LowerBound - 1) + RowCount; RowCount = 0; } else { RowCount -= 20000; } // Add parameters to feed.googlebase.xml.config RuntimeParams += String.Format("LowerBound={0}", LowerBound); RuntimeParams += String.Format("&UpperBound={0}", UpperBound); // Same as the old code string feeddocument = AppLogic.RunXmlPackage(m_Xmlpackage, null, ThisCustomer, 1, "", RuntimeParams, false, false); feeddocument = feeddocument.Replace("encoding=\"utf-16\"", ""); // Construction of the new filename. New filename will be old filename concatenated to the record numbers being processed, e.g. googlefeed1_20000 string filenamePrefix = LowerBound.ToString() + "_" + UpperBound.ToString(); string newFileName; if (filename.LastIndexOf(".") < 1) { newFileName = filename + filenamePrefix; } else { newFileName = filename.Insert(filename.LastIndexOf("."), filenamePrefix); } if (newFileNames == string.Empty) { newFileNames = newFileName; } else { newFileNames = string.Concat(newFileNames, ",", newFileName); } using (StreamWriter sw = new StreamWriter(newFileName, false)) { sw.Write(feeddocument); sw.Close(); } if (this.CanAutoFTP) { FtpClient ftp = new FtpClient(this.FTPServer + ":" + this.FTPPort.ToString(), this.FTPUsername, this.FTPPassword); //retval = ftp.Upload(filename, this.FTPFilename); retval = ftp.Upload(newFileName.Trim(), this.FTPFilename); } else { //retval = "The file " + this.FTPFilename + " has been created in the /images folder of your website"; retval = "The file(s) " + newFileNames.Trim() + " has been created in the /images folder of your website"; } LowerBound += 20000; UpperBound += 20000; filenamePrefix = ""; feeddocument = ""; RuntimeParams = ""; } } } catch (Exception ex) { err = ex.Message; return(err); } cn.Close(); cmd.Dispose(); cn.Dispose(); return(retval); } catch (Exception ex) { return(ex.Message); } }