コード例 #1
0
ファイル: Ratings.cs プロジェクト: lulzzz/BrandStore
        /// <summary>
        /// Deletes the rating.
        /// </summary>
        /// <param name="RatingID">The RatingID.</param>
        static public void DeleteRating(int RatingID)
        {
            if (RatingID != 0)
            {
                int CustID = 0;
                int ProdID = 0;

                using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                {
                    dbconn.Open();
                    using (IDataReader rs = DB.GetRS("select * from Rating   with (NOLOCK)  where RatingID=" + RatingID.ToString(), dbconn))
                    {
                        if (rs.Read())
                        {
                            CustID = DB.RSFieldInt(rs, "CustomerID");
                            ProdID = DB.RSFieldInt(rs, "ProductID");
                        }
                    }
                }

                DB.ExecuteSQL("delete from Rating where RatingID=" + CommonLogic.QueryStringUSInt("DeleteID").ToString());
                if (CustID != 0 && ProdID != 0)
                {
                    DB.ExecuteSQL(string.Format("delete from RatingCommentHelpfulness where RatingCustomerID={0} and ProductID={1} and StoreID={2}", CustID, ProdID, AppLogic.StoreID()));
                }
            }
        }
コード例 #2
0
ファイル: Paging.cs プロジェクト: vijayamazon/CaniGold.Store
        private static int EnforcePageNum(int PageNum)
        {
            if (PageNum == 0)
            {
                PageNum = CommonLogic.QueryStringUSInt("PageNum");
            }
            if (PageNum == 0)
            {
                PageNum = 1;
            }

            return(PageNum);
        }
コード例 #3
0
ファイル: Ratings.cs プロジェクト: lulzzz/BrandStore
        /// <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());
        }
コード例 #4
0
        /// <summary>
        /// Format the currency value into it's localized currency pattern
        /// </summary>
        /// <param name="sCurrencyValue">The currency value</param>
        /// <param name="sTargetCurrency">The target currency to base on</param>
        /// <returns>The formatted currency string</returns>
        public virtual string FormatCurrencyWithoutCurrencyCode(string sCurrencyValue, string sTargetCurrency)
        {
            InputValidator iv             = new InputValidator("FormatCurrencyWithoutCurrencyCode");
            decimal        value          = iv.ValidateDecimal("CurrencyValue", sCurrencyValue);
            string         targetCurrency = iv.ValidateString("TargetCurrency", sTargetCurrency);

            decimal amt = Currency.Convert(value, Localization.GetPrimaryCurrency(), targetCurrency);

            String tmpS = String.Empty;
            // get currency specs for display control:
            String DisplaySpec         = Currency.GetDisplaySpec(targetCurrency);
            String DisplayLocaleFormat = Currency.GetDisplayLocaleFormat(targetCurrency);

            if (DisplaySpec.Length != 0)
            {
                CultureInfo ci = new CultureInfo(DisplayLocaleFormat);

                if (DisplaySpec.LastIndexOf(',') > DisplaySpec.LastIndexOf("."))
                {
                    ci.NumberFormat.CurrencyDecimalSeparator = ",";

                    if (DisplaySpec.LastIndexOf(".") > -1)
                    {
                        ci.NumberFormat.CurrencyGroupSeparator = ".";
                    }
                }

                if (!DisplaySpec.StartsWith("#"))
                {
                    int indexOf = DisplaySpec.IndexOf('#');

                    if (indexOf > -1)
                    {
                        ci.NumberFormat.CurrencySymbol = DisplaySpec.Substring(0, indexOf);
                    }
                }

                tmpS = amt.ToString("C", ci.NumberFormat);
            }
            else if (DisplayLocaleFormat.Length != 0)
            {
                CultureInfo formatter = new CultureInfo(DisplayLocaleFormat);

                // for debugging purposes
                if (CommonLogic.QueryStringUSInt("dec") > 0)
                {
                    int decimalPlaces = CommonLogic.QueryStringUSInt("dec");
                    formatter.NumberFormat.CurrencyDecimalDigits = decimalPlaces;
                }

                tmpS = amt.ToString("C", formatter);
                if (tmpS.StartsWith("("))
                {
                    tmpS = "-" + tmpS.Replace("(", "").Replace(")", "");
                }
            }
            else
            {
                tmpS = Localization.CurrencyStringForDisplayWithoutExchangeRate(amt, false);                 // use some generic default!
            }

            return(tmpS);
        }
コード例 #5
0
ファイル: Ratings.cs プロジェクト: vijayamazon/CaniGold.Store
        /// <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());
        }
コード例 #6
0
ファイル: Parser.cs プロジェクト: lulzzz/BrandStore
        /// <summary>
        /// Takes command string and parameters and returns the result string of the command.
        /// </summary>
        protected string DispatchCommand(string command, Hashtable parameters)
        {
            string result = "(!" + command + "!)";

            command = command.ToLowerInvariant().Replace("username", "user_name");
            XSLTExtensions ExtObj = new XSLTExtensions(m_ThisCustomer, m_SkinID);

            switch (command)
            {
            case "obfuscatedemail":
            {
                String EMail = CommonLogic.HashtableParam(parameters, "email");
                //No longer supported.  Just return the email address.
                result = EMail;
                break;
            }

            case "remoteurl":     // (!RemoteUrl URL=""!)
            {
                String URL = CommonLogic.HashtableParam(parameters, "url");
                if (URL.Length != 0)
                {
                    result = ExtObj.RemoteUrl(URL);
                }
                break;
            }

            case "pagingcontrol":
            {
                // (!PagingControl BaseURL="" PageNum="N" NumPages="M"!)
                String BaseURL  = CommonLogic.HashtableParam(parameters, "baseurl");        // optional, will use existing QUERY_STRING if not provided
                int    PageNum  = CommonLogic.HashtableParamUSInt(parameters, "pagenum");   // optional, can get from QUERY_STRING if not provided
                int    NumPages = CommonLogic.HashtableParamUSInt(parameters, "numpages");  // required
                result = ExtObj.PagingControl(BaseURL, PageNum.ToString(), NumPages.ToString());
                break;
            }

            case "skinid":
            {
                // (!SKINID!)
                result = SkinID.ToString();
                break;
            }

            case "customerid":
            {
                // (!CUSTOMERID!)
                if (ThisCustomer != null)
                {
                    result = ThisCustomer.CustomerID.ToString();
                }
                else
                {
                    result = String.Empty;
                }
                break;
            }

            case "user_name":
            {
                result = ExtObj.User_Name();
                break;
            }

            case "user_menu_name":
            {
                result = ExtObj.User_Menu_Name();
                break;
            }

            case "store_version":
            {
                // (!STORE_VERSION!)
                result = String.Empty;
                break;
            }

            case "manufacturerlink":
            {
                // (!ManufacturerLink ManufacturerID="N" SEName="xxx" IncludeATag="true/false" InnerText="Some Text"!)
                int    ManufacturerID = CommonLogic.HashtableParamUSInt(parameters, "manufacturerid");
                String SEName         = CommonLogic.HashtableParam(parameters, "sename");
                bool   IncludeATag    = CommonLogic.HashtableParamBool(parameters, "includeatag");
                result = ExtObj.ManufacturerLink(ManufacturerID.ToString(), SEName, IncludeATag.ToString());
                break;
            }

            case "categorylink":
            {
                // (!CategoryLink CategoryID="N" SEName="xxx" IncludeATag="true/false"!)
                int    CategoryID  = CommonLogic.HashtableParamUSInt(parameters, "categoryid");
                String SEName      = CommonLogic.HashtableParam(parameters, "sename");
                bool   IncludeATag = CommonLogic.HashtableParamBool(parameters, "includeatag");
                result = ExtObj.CategoryLink(CategoryID.ToString(), SEName, IncludeATag.ToString());
                break;
            }

            case "sectionlink":
            {
                // (!SectionLink SectionID="N" SEName="xxx" IncludeATag="true/false"!)
                int    SectionID   = CommonLogic.HashtableParamUSInt(parameters, "sectionid");
                String SEName      = CommonLogic.HashtableParam(parameters, "sename");
                bool   IncludeATag = CommonLogic.HashtableParamBool(parameters, "includeatag");
                result = ExtObj.SectionLink(SectionID.ToString(), SEName, IncludeATag.ToString());
                break;
            }

            case "librarylink":
            {
                // (!LibraryLink LibraryID="N" SEName="xxx" IncludeATag="true/false"!)
                int    LibraryID   = CommonLogic.HashtableParamUSInt(parameters, "libraryid");
                String SEName      = CommonLogic.HashtableParam(parameters, "sename");
                bool   IncludeATag = CommonLogic.HashtableParamBool(parameters, "includeatag");
                result = ExtObj.LibraryLink(LibraryID.ToString(), SEName, IncludeATag.ToString());
                break;
            }

            case "productlink":
            {
                // (!ProductLink ProductID="N" SEName="xxx" IncludeATag="true/false"!)
                int    ProductID   = CommonLogic.HashtableParamUSInt(parameters, "productid");
                String SEName      = CommonLogic.HashtableParam(parameters, "sename");
                bool   IncludeATag = CommonLogic.HashtableParamBool(parameters, "includeatag");
                result = ExtObj.ProductLink(ProductID.ToString(), SEName, IncludeATag.ToString());
                break;
            }

            case "upsellproducts":
            {
                // (!UpsellProducts ProductID="N"!)
                int ProductID = CommonLogic.HashtableParamUSInt(parameters, "productid");
                result = ExtObj.ShowUpsellProducts(ProductID.ToString());
                break;
            }

            case "relatedproducts":
            {
                // (!RelatedProducts ProductID="N"!)
                int ProductID = CommonLogic.HashtableParamUSInt(parameters, "productid");
                result = ExtObj.RelatedProducts(ProductID.ToString());
                break;
            }

            case "documentlink":
            {
                // (!DocumentLink DocumentID="N" SEName="xxx" IncludeATag="true/false"!)
                int    DocumentID  = CommonLogic.HashtableParamUSInt(parameters, "documentid");
                String SEName      = CommonLogic.HashtableParam(parameters, "sename");
                bool   IncludeATag = CommonLogic.HashtableParamBool(parameters, "includeatag");
                result = ExtObj.DocumentLink(DocumentID.ToString(), SEName, IncludeATag.ToString());
                break;
            }

            case "productandcategorylink":
            {
                // (!ProductAndCategoryLink ProductID="N" CategoryID="M" SEName="xxx" IncludeATag="true/false"!)
                int    ProductID   = CommonLogic.HashtableParamUSInt(parameters, "productid");
                String SEName      = CommonLogic.HashtableParam(parameters, "sename");
                int    CategoryID  = CommonLogic.HashtableParamUSInt(parameters, "categoryid");
                bool   IncludeATag = CommonLogic.HashtableParamBool(parameters, "includeatag");
                result = ExtObj.ProductandCategoryLink(ProductID.ToString(), SEName, CategoryID.ToString(), IncludeATag.ToString());
                break;
            }

            case "productandsectionlink":
            {
                // (!ProductAndSectionLink ProductID="N" SectionID="M" SEName="xxx" IncludeATag="true/false"!)
                int    ProductID   = CommonLogic.HashtableParamUSInt(parameters, "productid");
                String SEName      = CommonLogic.HashtableParam(parameters, "sename");
                int    SectionID   = CommonLogic.HashtableParamUSInt(parameters, "sectionid");
                bool   IncludeATag = CommonLogic.HashtableParamBool(parameters, "includeatag");
                result = ExtObj.ProductandSectionLink(ProductID.ToString(), SEName, SectionID.ToString(), IncludeATag.ToString());
                break;
            }

            case "productandmanufacturerlink":
            {
                // (!ProductAndManufacturerLink ProductID="N" ManufacturerID="M" SEName="xxx" IncludeATag="true/false"!)
                int    ProductID      = CommonLogic.HashtableParamUSInt(parameters, "productid");
                String SEName         = CommonLogic.HashtableParam(parameters, "sename");
                int    ManufacturerID = CommonLogic.HashtableParamUSInt(parameters, "manufacturerid");
                bool   IncludeATag    = CommonLogic.HashtableParamBool(parameters, "includeatag");
                result = ExtObj.ProductandManufacturerLink(ProductID.ToString(), SEName, ManufacturerID.ToString(), IncludeATag.ToString());
                break;
            }

            case "productpropername":
            {
                // (!ProductProperName ProductID="N" VariantID="M"!)
                int ProductID = CommonLogic.HashtableParamUSInt(parameters, "productid");
                int VariantID = CommonLogic.HashtableParamUSInt(parameters, "variantid");
                result = ExtObj.ProductProperName(ProductID.ToString(), VariantID.ToString());
                break;
            }

            case "documentandlibrarylink":
            {
                // (!DocumentAndLibraryLink DocumentID="N" LibraryID="M" SEName="xxx" IncludeATag="true/false"!)
                int    DocumentID  = CommonLogic.HashtableParamUSInt(parameters, "documentid");
                String SEName      = CommonLogic.HashtableParam(parameters, "sename");
                int    LibraryID   = CommonLogic.HashtableParamUSInt(parameters, "libraryid");
                bool   IncludeATag = CommonLogic.HashtableParamBool(parameters, "includeatag");
                result = ExtObj.DocumentandLibraryLink(DocumentID.ToString(), SEName, LibraryID.ToString(), IncludeATag.ToString());
                break;
            }

            case "entitylink":
            {
                // (!EntityLink EntityID="N" EntityName="xxx" SEName="xxx" IncludeATag="true/false"!)
                int    EntityID    = CommonLogic.HashtableParamUSInt(parameters, "entityid");
                String SEName      = CommonLogic.HashtableParam(parameters, "sename");
                String EntityName  = CommonLogic.HashtableParam(parameters, "entityname");
                bool   IncludeATag = CommonLogic.HashtableParamBool(parameters, "includeatag");
                result = ExtObj.EntityLink(EntityID.ToString(), SEName, EntityName, IncludeATag.ToString());
                break;
            }

            case "objectlink":
            {
                // (!ObjectLink ObjectID="N" ObjectName="xxx" SEName="xxx" IncludeATag="true/false"!)
                int    ObjectID    = CommonLogic.HashtableParamUSInt(parameters, "objectid");
                String SEName      = CommonLogic.HashtableParam(parameters, "sename");
                String ObjectName  = CommonLogic.HashtableParam(parameters, "objectname");
                bool   IncludeATag = CommonLogic.HashtableParamBool(parameters, "includeatag");
                result = ExtObj.ObjectLink(ObjectID.ToString(), SEName, ObjectName, IncludeATag.ToString());
                break;
            }

            case "productandentitylink":
            {
                // (!ProductAndEntityLink ProductID="N" EntityID="M" EntityName="xxx" SEName="xxx" IncludeATag="true/false"!)
                int    ProductID   = CommonLogic.HashtableParamUSInt(parameters, "productid");
                String SEName      = CommonLogic.HashtableParam(parameters, "sename");
                int    EntityID    = CommonLogic.HashtableParamUSInt(parameters, "entityid");
                String EntityName  = CommonLogic.HashtableParam(parameters, "entityname");
                bool   IncludeATag = CommonLogic.HashtableParamBool(parameters, "includeatag");
                String InnerText   = CommonLogic.HashtableParam(parameters, "innertext");
                result = ExtObj.ProductandEntityLink(ProductID.ToString(), SEName, EntityID.ToString(), EntityName, IncludeATag.ToString());
                break;
            }

            case "topic":
            {
                // (!Topic TopicID="M"!) or (!Topic ID="M"!) or (!Topic Name="xxx"!)
                int TopicID = CommonLogic.HashtableParamUSInt(parameters, "id");
                if (TopicID == 0)
                {
                    TopicID = CommonLogic.HashtableParamUSInt(parameters, "topicid");
                }
                String LS = Localization.GetDefaultLocale();
                if (ThisCustomer != null)
                {
                    LS = ThisCustomer.LocaleSetting;
                }
                if (TopicID != 0)
                {
                    Topic t = new Topic(TopicID, LS, SkinID, null);
                    result = t.Contents;
                }
                else
                {
                    String TopicName = CommonLogic.HashtableParam(parameters, "name");
                    if (TopicName.Length != 0)
                    {
                        Topic t = new Topic(TopicName, LS, SkinID, null);
                        result = t.Contents;
                    }
                }
                break;
            }

            case "appconfig":
            {
                // (!AppConfig Name="xxx"!)
                String AppConfigName = CommonLogic.HashtableParam(parameters, "name");
                result = ExtObj.AppConfig(AppConfigName);
                break;
            }

            case "stringresource":
            {
                // (!StringResource Name="xxx"!)
                String StringResourceName = CommonLogic.HashtableParam(parameters, "name");
                result = ExtObj.StringResource(StringResourceName);
                break;
            }

            case "getstring":
            {
                // (!GetString Name="xxx"!)
                String StringResourceName = CommonLogic.HashtableParam(parameters, "name");
                result = ExtObj.StringResource(StringResourceName);
                break;
            }

            case "loginoutprompt":
            {
                // (!LoginOutPrompt!)
                result = AppLogic.GetLoginBox(SkinID);
                break;
            }

            case "searchbox":
            {
                // (!SearchBox!)
                result = ExtObj.SearchBox();
                break;
            }

            case "helpbox":
            {
                // (!HelpBox!)
                result = ExtObj.HelpBox();
                break;
            }

            case "addtocartform":
            {
                int  ProductID = CommonLogic.HashtableParamUSInt(parameters, "productid");
                int  VariantID = CommonLogic.HashtableParamUSInt(parameters, "variantid");
                bool ColorChangeProductImage = CommonLogic.HashtableParamBool(parameters, "colorchangeproductimage");
                result = ExtObj.AddtoCartForm(ProductID.ToString(), VariantID.ToString(), ColorChangeProductImage.ToString());
                break;
            }

            case "lookupimage":
            {
                int    ID = CommonLogic.HashtableParamUSInt(parameters, "id");
                String EntityOrObjectName = CommonLogic.HashtableParam(parameters, "type");
                String DesiredSize        = CommonLogic.HashtableParam(parameters, "size");
                bool   IncludeATag        = CommonLogic.HashtableParamBool(parameters, "includeatag");
                result = ExtObj.LookupImage(ID.ToString(), EntityOrObjectName, DesiredSize, IncludeATag.ToString());
                break;
            }

            case "productnavlinks":
            {
                int  ProductID   = CommonLogic.HashtableParamUSInt(parameters, "productid");
                int  CategoryID  = CommonLogic.QueryStringUSInt("CategoryID");     // should really get them from parameters, NOT from the querystring, but whatever...
                int  SectionID   = CommonLogic.QueryStringUSInt("SectionID");      // should really get them from parameters, NOT from the querystring, but whatever...
                bool UseGraphics = CommonLogic.HashtableParamBool(parameters, "usegraphics");
                result = ExtObj.ProductNavLinks(ProductID.ToString(), CategoryID.ToString(), SectionID.ToString(), UseGraphics.ToString());
                break;
            }

            case "emailproducttofriend":
            {
                int ProductID  = CommonLogic.HashtableParamUSInt(parameters, "productid");
                int CategoryID = CommonLogic.HashtableParamUSInt(parameters, "categoryid");
                result = ExtObj.EmailProductToFriend(ProductID.ToString(), CategoryID.ToString());
                break;
            }

            case "productdescriptionfile":
            {
                int  ProductID       = CommonLogic.HashtableParamUSInt(parameters, "productid");
                bool IncludeBRBefore = CommonLogic.HashtableParamBool(parameters, "includebrbefore");
                result = ExtObj.ProductDescriptionFile(ProductID.ToString(), IncludeBRBefore.ToString());
                break;
            }

            case "productspecs":
            {
                int  ProductID       = CommonLogic.HashtableParamUSInt(parameters, "productid");
                bool IncludeBRBefore = CommonLogic.HashtableParamBool(parameters, "includebrbefore");
                result = ExtObj.ProductSpecs(ProductID.ToString(), IncludeBRBefore.ToString());
                break;
            }

            case "productratings":
            {
                int  ProductID       = CommonLogic.HashtableParamUSInt(parameters, "productid");
                int  CategoryID      = CommonLogic.QueryStringUSInt("CategoryID");     // should really get them from parameters, NOT from the querystring, but whatever...
                int  SectionID       = CommonLogic.QueryStringUSInt("SectionID");      // should really get them from parameters, NOT from the querystring, but whatever...
                int  ManufacturerID  = CommonLogic.QueryStringUSInt("ManufacturerID"); // should really get them from parameters, NOT from the querystring, but whatever...
                bool IncludeBRBefore = CommonLogic.HashtableParamBool(parameters, "includebrbefore");
                result = ExtObj.ProductRatings(ProductID.ToString(), CategoryID.ToString(), SectionID.ToString(), ManufacturerID.ToString(), IncludeBRBefore.ToString());
                break;
            }

            case "formatcurrency":
            {
                decimal CurrencyValue = CommonLogic.HashtableParamNativeDecimal(parameters, "value");
                String  LocaleSetting = CommonLogic.HashtableParam(parameters, "localesetting");
                result = ExtObj.FormatCurrency(CurrencyValue.ToString());
                break;
            }

            case "getspecialsboxexpandedrandom":
            {
                int    CategoryID   = CommonLogic.HashtableParamUSInt(parameters, "categoryid");
                bool   ShowPics     = CommonLogic.HashtableParamBool(parameters, "showpics");
                bool   IncludeFrame = CommonLogic.HashtableParamBool(parameters, "includeframe");
                String Teaser       = CommonLogic.HashtableParam(parameters, "teaser");
                result = ExtObj.GetSpecialsBoxExpandedRandom(CategoryID.ToString(), ShowPics.ToString(), IncludeFrame.ToString(), Teaser);
                break;
            }

            case "getspecialsboxexpanded":
            {
                int    CategoryID   = CommonLogic.HashtableParamUSInt(parameters, "categoryid");
                int    ShowNum      = CommonLogic.HashtableParamUSInt(parameters, "shownum");
                bool   ShowPics     = CommonLogic.HashtableParamBool(parameters, "showpics");
                bool   IncludeFrame = CommonLogic.HashtableParamBool(parameters, "includeframe");
                String Teaser       = CommonLogic.HashtableParam(parameters, "teaser");
                result = ExtObj.GetSpecialsBoxExpanded(CategoryID.ToString(), ShowNum.ToString(), ShowPics.ToString(), IncludeFrame.ToString(), Teaser);
                break;
            }

            case "getnewsboxexpanded":
            {
                bool   ShowCopy     = CommonLogic.HashtableParamBool(parameters, "showcopy");
                int    ShowNum      = CommonLogic.HashtableParamUSInt(parameters, "shownum");
                bool   IncludeFrame = CommonLogic.HashtableParamBool(parameters, "includeframe");
                String Teaser       = CommonLogic.HashtableParam(parameters, "teaser");
                result = ExtObj.GetNewsBoxExpanded(ShowCopy.ToString(), ShowNum.ToString(), IncludeFrame.ToString(), Teaser);
                break;
            }

            case "xmlpackage":
            {
                // (!XmlPackage Name="xxx" version="N"!)
                // version can only be 2 at this time, or blank
                String    PackageName       = CommonLogic.HashtableParam(parameters, "name");
                String    VersionID         = CommonLogic.HashtableParam(parameters, "version"); // optional
                Hashtable userruntimeparams = parameters;
                userruntimeparams.Remove("name");
                userruntimeparams.Remove("version");
                string runtimeparams = String.Empty;
                foreach (DictionaryEntry de in userruntimeparams)
                {
                    runtimeparams += de.Key.ToString() + "=" + de.Value.ToString() + "&";
                }
                if (runtimeparams.Length > 0)
                {
                    runtimeparams = runtimeparams.Substring(0, runtimeparams.Length - 1);
                }

                if (PackageName.Length != 0)
                {
                    if (PackageName.EndsWith(".xslt", StringComparison.InvariantCultureIgnoreCase) && VersionID != "2")
                    {
                        throw new ArgumentException("Version 1 XmlPackages are no longer supported!");
                    }
                    else
                    {
                        // WARNING YOU COULD CAUSE ENDLESS RECURSION HERE! if your XmlPackage refers to itself in some direct, or INDIRECT! way!!
                        result = AppLogic.RunXmlPackage(PackageName, this, ThisCustomer, SkinID, String.Empty, runtimeparams, true, true);
                    }
                }
                break;
            }
            }
            return(result);
        }