コード例 #1
0
        // 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());
        }
コード例 #2
0
        public String GetEntityBreadcrumb(int EntityID, String LocaleSetting)
        {
            String CacheName = String.Format("GetEntityBreadcrumb_{0}_{1}_{2}_{3}", m_EntitySpecs.m_EntityName, EntityID.ToString(), LocaleSetting, AppLogic.IsAdminSite.ToString());

            if (AppLogic.CachingOn)
            {
                String Menu = (String)HttpContext.Current.Cache.Get(CacheName);
                if (Menu != null)
                {
                    if (CommonLogic.ApplicationBool("DumpSQL"))
                    {
                        HttpContext.Current.Response.Write("Cache Hit Found!\n");
                    }
                    return(Menu);
                }
            }
            String  tmpS = String.Empty;
            String  URL  = String.Empty;
            XmlNode n    = m_TblMgr.SetContext(EntityID);

            if (EntityID != 0 && n != null)
            {
                n = m_TblMgr.MoveParent(n);
                while (n != null)
                {
                    if (AppLogic.IsAdminSite)
                    {
                        URL = String.Format("entity.aspx?entityname={0}&entityid={1}", m_EntitySpecs.m_EntityName, m_TblMgr.CurrentID(n));
                    }
                    else
                    {
                        URL = Url.BuildEntityLink(m_EntitySpecs.m_EntityName, m_TblMgr.CurrentID(n), m_TblMgr.CurrentField(n, "SEName"));
                    }
                    tmpS = String.Format("<a href=\"{0}\">{1}</a> &rarr; ", URL, m_TblMgr.CurrentName(n, LocaleSetting)) + tmpS;
                    n    = m_TblMgr.MoveParent(n);
                }
                n = m_TblMgr.SetContext(EntityID);
                if (AppLogic.IsAdminSite)
                {
                    URL = String.Format("entity.aspx?entityname={0}&entityid={1}", m_EntitySpecs.m_EntityName, m_TblMgr.CurrentID(n));
                }
                else
                {
                    URL = Url.BuildEntityLink(m_EntitySpecs.m_EntityName, m_TblMgr.CurrentID(n), m_TblMgr.CurrentField(n, "SEName"));
                }
                tmpS += String.Format("<a href=\"{0}\">{1}</a>", URL, m_TblMgr.CurrentName(n, LocaleSetting));
            }

            if (AppLogic.CachingOn)
            {
                HttpContext.Current.Cache.Insert(CacheName, tmpS, null, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
            }
            return(tmpS);
        }
コード例 #3
0
        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);
        }