protected void Page_Load(object sender, System.EventArgs e)
        {
            if (AppLogic.AppConfigBool("GoNonSecureAgain"))
            {
                SkinBase.GoNonSecureAgain();
            }

            // this may be overwridden by the XmlPackage below!
            SectionTitle = AppLogic.GetString("news.aspx.1", SkinID, ThisCustomer.LocaleSetting, true);

            // set the Customer context, and set the SkinBase context, so meta tags to be set if they are not blank in the XmlPackage results
            XmlPackage1.SetContext = this;

            XSLTExtensionBase xslt = new XSLTExtensionBase(ThisCustomer, 1);

            xslt.ExtractBody("");
        }
        private void AddEntityMenuXsl(XmlDocument doc, string EntityName, HierarchicalTableMgr m_TblMgr, XmlNode mnuItem, int ForParentEntityID, string NodeClass)
        {
            if (mnuItem == null)
            {
                return;
            }

            var    tmpS    = new StringWriter();
            var    xForm   = new XslCompiledTransform();
            string XslFile = "EntityMenuList";

            xForm.Load(CommonLogic.SafeMapPath("EntityHelper/" + XslFile + ".xslt"));
            XsltArgumentList xslArgs = new XsltArgumentList();

            xslArgs.AddParam("entity", "", EntityName);
            xslArgs.AddParam("custlocale", "", Page.ThisCustomer.LocaleSetting);
            xslArgs.AddParam("deflocale", "", Localization.WebConfigLocale);
            xslArgs.AddParam("ForParentEntityID", "", ForParentEntityID);
            xslArgs.AddParam("adminsite", "", false);
            xslArgs.AddParam("nodeclass", "", NodeClass);
            xslArgs.AddParam("suppresstoparrow", "", CommonLogic.IIF(NodeClass.Length != 0, "1", "0"));

            //let's call the extensions :)
            Customer thisCustomer = ((InterpriseSuiteEcommercePrincipal)HttpContext.Current.User).ThisCustomer;

            if (null != thisCustomer)
            {
                XSLTExtensionBase ext = new XSLTExtensionBase(thisCustomer, thisCustomer.SkinID);
                xslArgs.AddExtensionObject("urn:ise", ext);
            }

            xForm.Transform(m_TblMgr.XmlDoc, xslArgs, tmpS);
            if (AppLogic.AppConfigBool("XmlPackage.DumpTransform"))
            {
                try // don't let logging crash the site
                {
                    var sw = File.CreateText(CommonLogic.SafeMapPath(string.Format("images/{0}_{1}_{2}.xfrm.xml", XslFile, EntityName, "store")));
                    sw.WriteLine(XmlCommon.PrettyPrintXml(tmpS.ToString()));
                    sw.Close();
                }
                catch { }
            }

            if (tmpS.ToString().Length == 0)
            {
                return;
            }

            if (NodeClass.Length != 0) // this means we are adding to the ROOT level, not as children!
            {
                // Create a document fragment to contain the XML to be inserted.
                var docFrag = doc.CreateDocumentFragment();

                // Set the contents of the document fragment.
                docFrag.InnerXml = tmpS.ToString();

                // Add the children of the document fragment to the original document.
                mnuItem.ParentNode.InsertAfter(docFrag, mnuItem);

                // now get rid of the parent placeholder node!
                doc.SelectSingleNode("/SiteMap").RemoveChild(mnuItem);
            }
            else
            {
                mnuItem.InnerXml = tmpS.ToString();
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Customer ThisCustomer = ((AspDotNetStorefrontPrincipal)Context.User).ThisCustomer;

            int ProductID = CommonLogic.QueryStringUSInt("ProductID");
            int VariantID = CommonLogic.QueryStringUSInt("VariantID");

            if (ProductID == 0)
            {
                ProductID = AppLogic.GetVariantProductID(VariantID);
            }

            String st         = AppLogic.AppConfig("AjaxPricingPrompt").Replace("+", " ");
            String ChosenSize = CommonLogic.QueryStringCanBeDangerousContent("Size");

            ChosenSize = ChosenSize.Replace("[" + st, "[");
            ChosenSize = Regex.Replace(ChosenSize, "\\s+", "", RegexOptions.Compiled);
            String ChosenSizeSimple = String.Empty;
            String ChosenColor      = CommonLogic.QueryStringCanBeDangerousContent("Color");

            ChosenColor = ChosenColor.Replace("[" + st, "[");
            ChosenColor = Regex.Replace(ChosenColor, "\\s+", "", RegexOptions.Compiled);
            String  ChosenColorSimple  = String.Empty;
            Decimal SizePriceModifier  = System.Decimal.Zero;
            Decimal ColorPriceModifier = System.Decimal.Zero;

            if (ChosenSize.IndexOf("[") != -1)
            {
                int i1 = ChosenSize.IndexOf("[");
                int i2 = ChosenSize.IndexOf("]");
                if (i1 != -1 && i2 != -1)
                {
                    SizePriceModifier = Localization.ParseNativeDecimal(ChosenSize.Substring(i1 + 1, i2 - i1 - 1).Replace("$", "").Replace(",", ""));
                }
                ChosenSizeSimple = ChosenSize.Substring(0, i1);
            }
            if (ChosenColor.IndexOf("[") != -1)
            {
                int i1 = ChosenColor.IndexOf("[");
                int i2 = ChosenColor.IndexOf("]");
                if (i1 != -1 && i2 != -1)
                {
                    ColorPriceModifier = Localization.ParseNativeDecimal(ChosenColor.Substring(i1 + 1, i2 - i1 - 1).Replace("$", "").Replace(",", ""));
                }
                ChosenColorSimple = ChosenColor.Substring(0, i1);
            }

            Decimal FinalPriceDelta = SizePriceModifier + ColorPriceModifier;

            String NewPRText = "Not Available";

            XSLTExtensionBase xslte = new XSLTExtensionBase(ThisCustomer, ThisCustomer.SkinID);

            using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
            {
                con.Open();
                using (IDataReader rs = DB.GetRS("select p.*, pv.VariantID, pv.name VariantName, pv.Price, pv.Description VariantDescription, isnull(pv.SalePrice, 0) SalePrice, isnull(SkuSuffix, '') SkuSuffix, pv.Dimensions, pv.Weight, isnull(pv.Points, 0) Points, sp.name SalesPromptName, case when pcl.productid is null then 0 else isnull(e.Price, 0) end ExtendedPrice FROM Product p join productvariant pv on p.ProductID = pv.ProductID join SalesPrompt sp on p.SalesPromptID = sp.SalesPromptID left join ExtendedPrice e on pv.VariantID=e.VariantID and e.CustomerLevelID=" + ThisCustomer.CustomerLevelID.ToString() + " left join ProductCustomerLevel pcl with (NOLOCK) on p.ProductID = pcl.ProductID and pcl.CustomerLevelID = " + ThisCustomer.CustomerLevelID.ToString() + " WHERE p.ProductID = " + ProductID.ToString() + " and p.Deleted = 0 and pv.Deleted = 0 and p.Published = 1 and pv.VariantID=" + VariantID.ToString() + " and pv.Published = 1 ORDER BY p.ProductID, pv.DisplayOrder, pv.Name", con))
                {
                    if (rs.Read())
                    {
                        NewPRText = xslte.GetVariantPrice(VariantID.ToString(),
                                                          CommonLogic.IIF(DB.RSFieldBool(rs, "HidePriceUntilCart"), "1", "0"),
                                                          Localization.DecimalStringForDB(DB.RSFieldDecimal(rs, "Price")),
                                                          Localization.DecimalStringForDB(DB.RSFieldDecimal(rs, "SalePrice")),
                                                          Localization.DecimalStringForDB(DB.RSFieldDecimal(rs, "ExtendedPrice")),
                                                          DB.RSFieldInt(rs, "Points").ToString(),
                                                          DB.RSField(rs, "SalesPromptName"),
                                                          "1",
                                                          DB.RSFieldInt(rs, "TaxClassID").ToString(),
                                                          Localization.DecimalStringForDB(System.Decimal.Zero)).Replace("Price:", "Base Price:");
                        NewPRText += "<br/>";
                        NewPRText += xslte.GetVariantPrice(VariantID.ToString(),
                                                           CommonLogic.IIF(DB.RSFieldBool(rs, "HidePriceUntilCart"), "1", "0"),
                                                           Localization.DecimalStringForDB(DB.RSFieldDecimal(rs, "Price")),
                                                           Localization.DecimalStringForDB(DB.RSFieldDecimal(rs, "SalePrice")),
                                                           Localization.DecimalStringForDB(DB.RSFieldDecimal(rs, "ExtendedPrice")),
                                                           DB.RSFieldInt(rs, "Points").ToString(),
                                                           DB.RSField(rs, "SalesPromptName"),
                                                           "1",
                                                           DB.RSFieldInt(rs, "TaxClassID").ToString(),
                                                           Localization.DecimalStringForDB(FinalPriceDelta)); //.Replace("Price:", "Price as Selected:");
                    }
                }
            }

            Response.Expires     = -1;
            Response.ContentType = "application/xml";
            XmlWriter writer = new XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);

            writer.WriteStartDocument();
            writer.WriteStartElement("root");

            writer.WriteElementString("CustomerID", ThisCustomer.CustomerID.ToString());
            writer.WriteElementString("CustomerLevelID", ThisCustomer.CustomerLevelID.ToString());
            writer.WriteElementString("ProductID", ProductID.ToString());
            writer.WriteElementString("VariantID", VariantID.ToString());

            writer.WriteStartElement("Size");
            writer.WriteElementString("Input", ChosenSize);
            writer.WriteElementString("Text", ChosenSizeSimple);
            writer.WriteElementString("Delta", Localization.DecimalStringForDB(SizePriceModifier));
            writer.WriteEndElement();

            writer.WriteStartElement("Color");
            writer.WriteElementString("Input", ChosenColor);
            writer.WriteElementString("Text", ChosenColorSimple);
            writer.WriteElementString("Delta", Localization.DecimalStringForDB(ColorPriceModifier));
            writer.WriteEndElement();

            writer.WriteElementString("ChosenAttributesPriceDelta", Localization.DecimalStringForDB(FinalPriceDelta));
            writer.WriteElementString("PriceHTML", NewPRText);
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Flush();
        }