Пример #1
0
            internal void GetProducts()
            {
                SqlCommand            retCmd = cmdGetProduct();
                List <SiteMapProduct> xList  = new List <SiteMapProduct>();

                if (SiteMap.Settings.ProductFiltering)
                {
                    retCmd.Parameters["@StoreID"].Value = AppLogic.StoreID();
                }

                Action <System.Data.IDataReader> readEntities = rd =>
                {
                    while (rd.Read())
                    {
                        SiteMapProduct prd = new SiteMapProduct();
                        prd.EntityID      = rd.FieldInt("ProductID");
                        prd.MappingEntity = this.EntityType;
                        prd.Name          = XmlCommon.GetLocaleEntry(rd.Field("Name"), Customer.Current.LocaleSetting, false);
                        prd.SEName        = rd.Field("SEName");
                        xList.Add(prd);
                    }
                };

                DB.UseDataReader(retCmd, readEntities);
                Products = xList.ToArray();
            }
Пример #2
0
        public static String GetXPathEntry(String S, String XPath)
        {
            String tmpS = String.Empty;

            if (S.Length == 0)
            {
                return(tmpS);
            }
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(S);
                XmlNode node = doc.DocumentElement.SelectSingleNode(XPath);
                if (node != null)
                {
                    tmpS = node.InnerText;
                }
                if (tmpS.Length != 0)
                {
                    tmpS = XmlCommon.XmlDecode(tmpS);
                }
            }
            catch {}
            return(tmpS);
        }
Пример #3
0
        /// <summary>
        /// Check if customer level includes free shipping
        /// </summary>
        /// <param name="orderInfoNode"></param>
        /// <returns>returns true if customer level includes free shipping</returns>
        private bool CheckIfLevelHasFreeShipping(XmlNode orderInfoNode)
        {
            bool hascustomerLevel     = CommonLogic.IIF(XmlCommon.XmlFieldNativeInt(orderInfoNode, "LevelID") != 0, true, false);
            bool levelHasFreeShipping = CommonLogic.IIF(XmlCommon.XmlFieldNativeInt(orderInfoNode, "LevelHasFreeShipping") == 1, true, false);

            return(hascustomerLevel && levelHasFreeShipping);
        }
Пример #4
0
        /// <summary>
        /// Check in orderInfoNode if a coupon is applied
        /// </summary>
        /// <param name="orderInfoNode"></param>
        /// <returns>returns true if there is a couponcode and coupon includes free shipping</returns>
        private bool CheckIfCouponApplied(XmlNode orderInfoNode)
        {
            bool hasCouponApplied           = CommonLogic.IIF(!CommonLogic.IsStringNullOrEmpty(XmlCommon.XmlField(orderInfoNode, "CouponCode")), true, false);
            bool couponIncludesFreeshipping = CommonLogic.IIF(XmlCommon.XmlFieldNativeInt(orderInfoNode, "CouponIncludesFreeShipping") == 1, true, false);

            return(hasCouponApplied && couponIncludesFreeshipping);
        }
Пример #5
0
        /// <summary>
        /// Attaches an element named ShippingNotRequired that serves as a flag whether our order does not require shipping checking all the available factors
        /// </summary>
        /// <param name="nav">The XPathNavigator</param>
        private void CheckIfWeShouldRequireShipping(XPathNavigator nav)
        {
            XmlNode orderInfoNode         = GetXmlNode(nav.SelectSingleNode("Order/OrderInfo"));
            bool    weDontRequireShipping = false;

            if (AppLogic.AppConfigBool("SkipShippingOnCheckout") == true)
            {
                weDontRequireShipping = true;
            }
            else
            {
                bool isMultiShipping        = XmlCommon.XmlFieldBool(orderInfoNode, "multiship");
                bool allAreDownloadProducts = XmlCommon.XmlFieldBool(orderInfoNode, "allDownloads");
                bool allAreSystemProducts   = XmlCommon.XmlFieldBool(orderInfoNode, "allSystemproducts");

                weDontRequireShipping = isMultiShipping == false &&
                                        (allAreDownloadProducts || allAreSystemProducts);

                if (weDontRequireShipping == false)
                {
                    // now check if all of the line items is No Shipping Required..
                    XPathNodeIterator lineItemsThatAreNotFreeShippingIfAnyNodeIterator = nav.Select("OrderItems/Item[FreeShipping != 2]");
                    weDontRequireShipping = !lineItemsThatAreNotFreeShippingIfAnyNodeIterator.MoveNext();
                }
            }

            XmlNode shippingNotRequiredNode = orderInfoNode.OwnerDocument.CreateNode(XmlNodeType.Element, "ShippingNotRequired", string.Empty);

            shippingNotRequiredNode.InnerText = XmlCommon.XmlEncode(weDontRequireShipping.ToString());
            orderInfoNode.InsertAfter(shippingNotRequiredNode, orderInfoNode.LastChild);
        }
Пример #6
0
        /// <summary>
        /// Check if order is free shipping and customer selects free shipping methods
        /// </summary>
        /// <param name="nav">xml</param>
        private void CheckIfFreeShipping(XPathNavigator nav)
        {
            XmlNode orderInfoNode = GetXmlNode(nav.SelectSingleNode("Order/OrderInfo"));

            bool freeShipping = false;

            if ((CheckIfCouponApplied(orderInfoNode) || CheckIfLevelHasFreeShipping(orderInfoNode)) || (CheckIfAllDownloads(orderInfoNode) || CheckIfAllFreeShipping(orderInfoNode) || CheckIfAllSystemProducts(orderInfoNode)))
            {
                freeShipping = true;
            }

            bool customerChoseFreeShippingMethod = true;

            if (AppLogic.AppConfigBool("FreeShippingAllowsRateSelection"))
            {
                int    shippingMethodId  = XmlCommon.XmlFieldNativeInt(orderInfoNode, "ShippingMethodID");
                string commaSeparatedIds = AppLogic.AppConfig("ShippingMethodIDIfFreeShippingIsOn");

                customerChoseFreeShippingMethod = CommonLogic.IntegerIsInIntegerList(shippingMethodId, commaSeparatedIds);
            }

            freeShipping = freeShipping && customerChoseFreeShippingMethod;

            XmlNode isFreeShippingNode = orderInfoNode.OwnerDocument.CreateNode(XmlNodeType.Element, "IsFreeShipping", string.Empty);

            isFreeShippingNode.InnerText = XmlCommon.XmlEncode(freeShipping.ToString());
            orderInfoNode.InsertAfter(isFreeShippingNode, orderInfoNode.LastChild);
        }
Пример #7
0
        public static String XmlFieldExtended(XmlNode node, String fieldName)
        {
            XmlNode n = node.SelectSingleNode(fieldName);

            if (n == null)
            {
                return(String.Empty);
            }
            String fldVal = String.Empty;

            if (n.InnerXml.Length != 0 && !n.InnerXml.StartsWith("<![CDATA["))
            {
                fldVal = n.InnerXml;
            }
            else
            {
                fldVal = XmlCommon.XmlField(node, fieldName);
            }
            if (fldVal.Length == 0)
            {
                if (n.NodeType == XmlNodeType.CDATA)
                {
                    fldVal = n.Value;
                }
            }
            return(fldVal);
        }
Пример #8
0
            public new static NestedSiteMapEntity[] GetEntities(string EntityType)
            {
                Dictionary <int, NestedSiteMapEntity> _list = new Dictionary <int, NestedSiteMapEntity>();

                SqlCommand getCommand = getEntitySQL(EntityType);
                Action <System.Data.IDataReader> readEntities = rd =>
                {
                    while (rd.Read())
                    {
                        NestedSiteMapEntity entity = new NestedSiteMapEntity();
                        entity.EntityID       = rd.FieldInt("ID");
                        entity.Name           = XmlCommon.GetLocaleEntry(rd.Field("Name"), Customer.Current.LocaleSetting, false);
                        entity.SEName         = rd.Field("SEName");
                        entity.ParentEntityID = rd.FieldInt("ParentID");
                        entity.EntityType     = EntityType;
                        entity.GetProducts();
                        _list.Add(entity.EntityID, entity);
                    }
                };

                DB.UseDataReader(getCommand, readEntities);


                return(OrganizeEntities(_list).ToArray());
            }
Пример #9
0
        public static String XmlFieldByLocale(XmlNode node, String fieldName, String LocaleSetting)
        {
            String  fieldVal = String.Empty;
            XmlNode n        = node.SelectSingleNode(@fieldName);

            if (n != null)
            {
                if (n.InnerText.StartsWith("&lt;ml&gt;", StringComparison.InvariantCultureIgnoreCase))
                {
                    fieldVal = GetLocaleEntry(XmlCommon.XmlDecode(n.InnerText.Trim()), LocaleSetting, true);
                }
                if (n.HasChildNodes && n.FirstChild.LocalName.Equals("ml", StringComparison.InvariantCultureIgnoreCase))
                {
                    fieldVal = GetLocaleEntry(n, LocaleSetting, true);
                }
                else
                {
                    fieldVal = n.InnerText.Trim();
                }
            }
            if (fieldVal.StartsWith("<ml>", StringComparison.InvariantCultureIgnoreCase))
            {
                fieldVal = GetLocaleEntry(fieldVal, LocaleSetting, true);
            }

            return(fieldVal);
        }
Пример #10
0
        public static int createSession(int customerid, string ParamName, string SessionValue, string ipaddr)
        {
            ParamName = ParamName.ToLowerInvariant();

            int           SessionID = 0;
            string        err       = String.Empty;
            SqlConnection cn        = new SqlConnection(DB.GetDBConn());

            cn.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = cn;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "dbo.aspdnsf_SessionInsert";

            cmd.Parameters.Add(new SqlParameter("@CustomerID", SqlDbType.Int, 4));
            cmd.Parameters.Add(new SqlParameter("@SessionValue", SqlDbType.NText));
            cmd.Parameters.Add(new SqlParameter("@ipaddr", SqlDbType.VarChar, 15));
            cmd.Parameters.Add(new SqlParameter("@CustomerSessionID", SqlDbType.Int, 4)).Direction = ParameterDirection.Output;

            cmd.Parameters["@CustomerID"].Value = customerid;

            StringBuilder sessionparams = new StringBuilder(1024);

            sessionparams.Append("<params>");
            if (ParamName != null && ParamName != "")
            {
                sessionparams.Append("<param name=\"");
                sessionparams.Append(XmlCommon.XmlEncodeAttribute(ParamName));
                sessionparams.Append("\" val=\"");
                sessionparams.Append(XmlCommon.XmlEncodeAttribute(SessionValue));
                sessionparams.Append("\"/>");
            }
            sessionparams.Append("</params>");
            cmd.Parameters["@SessionValue"].Value = sessionparams.ToString();

            if (ipaddr == null)
            {
                cmd.Parameters["@ipaddr"].Value = DBNull.Value;
            }
            else
            {
                cmd.Parameters["@ipaddr"].Value = ipaddr;
            }

            try
            {
                cmd.ExecuteNonQuery();
                SessionID = Convert.ToInt32(cmd.Parameters["@CustomerSessionID"].Value);
            }
            catch (Exception ex)
            {
                err = ex.Message;
            }

            cn.Close();
            cmd.Dispose();
            cn.Dispose();
            return(SessionID);
        }
 // returns the <FieldName> element value of the currently active node
 public String CurrentFieldByLocale(XmlNode CurrentContext, String FieldName, String LocaleSetting)
 {
     if (CurrentContext == null)
     {
         return(String.Empty);
     }
     return(XmlCommon.XmlFieldByLocale(CurrentContext, FieldName, LocaleSetting));
 }
 // returns the <FieldName> element value of the currently active node
 public String CurrentField(XmlNode CurrentContext, String FieldName)
 {
     if (CurrentContext == null)
     {
         return(String.Empty);
     }
     return(XmlCommon.XmlField(CurrentContext, FieldName));
 }
Пример #13
0
 // returns the <FieldName> element value of the currently active node as a Single
 public Single CurrentFieldSingle(XmlNode CurrentContext, String FieldName)
 {
     if (CurrentContext == null)
     {
         return(0.0F);
     }
     return(Localization.ParseNativeSingle(XmlCommon.XmlField(CurrentContext, FieldName)));
 }
Пример #14
0
 // returns the <FieldName> element value of the currently active node as a DateTime
 public DateTime CurrentFieldDateTime(XmlNode CurrentContext, String FieldName)
 {
     if (CurrentContext == null)
     {
         return(System.DateTime.MinValue);
     }
     return(Localization.ParseNativeDateTime(XmlCommon.XmlField(CurrentContext, FieldName)));
 }
Пример #15
0
 // returns the <FieldName> element value of the currently active node as a Decimal
 public Decimal CurrentFieldDecimal(XmlNode CurrentContext, String FieldName)
 {
     if (CurrentContext == null)
     {
         return(System.Decimal.Zero);
     }
     return(Localization.ParseNativeDecimal(XmlCommon.XmlField(CurrentContext, FieldName)));
 }
 // returns the GUID of the currently active node
 public String CurrentGUID(XmlNode CurrentContext)
 {
     if (CurrentContext == null)
     {
         return(String.Empty);
     }
     return(XmlCommon.XmlField(CurrentContext, m_GUIDColumnName));
 }
 // returns the id of the currently active node
 public int CurrentID(XmlNode CurrentContext)
 {
     if (CurrentContext == null)
     {
         return(0);
     }
     return(XmlCommon.XmlFieldUSInt(CurrentContext, m_IDColumnName));
 }
Пример #18
0
 // returns the <FieldName> element value of the currently active node as a long
 public long CurrentFieldLong(XmlNode CurrentContext, String FieldName)
 {
     if (CurrentContext == null)
     {
         return(0);
     }
     return(Localization.ParseUSLong(XmlCommon.XmlField(CurrentContext, FieldName)));
 }
Пример #19
0
            public virtual XmlNode ToSiteMapTopicNode(XmlDocument context)
            {
                String tName = XmlCommon.GetLocaleEntry(Name, Customer.Current.LocaleSetting, true);

                Topic t = new Topic(tName, Customer.Current.LocaleSetting);

                return(SiteMapNode(t.SectionTitle, SE.MakeDriverLink(tName), context));
            }
Пример #20
0
        public static CustomerSession CreateCustomerSession(int customerid, string SessionName, string SessionValue, string ipaddr)
        {
            CustomerSession cs = null;

            using (var cn = new SqlConnection(DB.GetDBConn()))
            {
                cn.Open();
                using (var cmd = new SqlCommand())
                {
                    cmd.Connection  = cn;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "dbo.aspdnsf_SessionInsert";

                    cmd.Parameters.Add(new SqlParameter("@CustomerID", SqlDbType.Int, 4));
                    cmd.Parameters.Add(new SqlParameter("@SessionValue", SqlDbType.NText));
                    cmd.Parameters.Add(new SqlParameter("@ipaddr", SqlDbType.VarChar, 15));
                    cmd.Parameters.Add(new SqlParameter("@CustomerSessionID", SqlDbType.Int, 4)).Direction = ParameterDirection.Output;

                    cmd.Parameters["@CustomerID"].Value = customerid;

                    var sessionparams = new StringBuilder(1024);
                    sessionparams.Append("<params>");
                    if (SessionName != null && SessionName != "")
                    {
                        sessionparams.Append("<param name=\"");
                        sessionparams.Append(XmlCommon.XmlEncodeAttribute(SessionName));
                        sessionparams.Append("\" val=\"");
                        sessionparams.Append(XmlCommon.XmlEncodeAttribute(SessionValue));
                        sessionparams.Append("\"/>");
                    }
                    sessionparams.Append("</params>");
                    cmd.Parameters["@SessionValue"].Value = sessionparams.ToString();

                    if (ipaddr == null)
                    {
                        cmd.Parameters["@ipaddr"].Value = DBNull.Value;
                    }
                    else
                    {
                        cmd.Parameters["@ipaddr"].Value = ipaddr;
                    }

                    try
                    {
                        cmd.ExecuteNonQuery();
                        var SessionID = Convert.ToInt32(cmd.Parameters["@CustomerSessionID"].Value);
                        cs = new CustomerSession(SessionID, false);
                    }
                    catch (Exception ex)
                    {
                        SysLog.LogException(ex, MessageTypeEnum.DatabaseException, MessageSeverityEnum.Error);
                    }
                }
            }
            return(cs);
        }
Пример #21
0
        static public String GetName(int CurrencyID)
        {
            String  tmpS = String.Empty;
            XmlNode n    = RatesDoc.SelectSingleNode("//Currency[@CurrencyID=" + CurrencyID.ToString() + "]");

            if (n != null)
            {
                tmpS = XmlCommon.XmlAttribute(n, "Name");
            }
            return(tmpS);
        }
Пример #22
0
        public SiteMapPhoneOrder(System.Collections.Generic.Dictionary <string, EntityHelper> EntityHelpers, int SkinID, Customer ThisCustomer, String IGD)
        {
            bool   FromCache = false;
            String CacheName = String.Format("SiteMapPhoneOrder_{0}_{1}_{2}", SkinID.ToString(), ThisCustomer.LocaleSetting, IGD);

            if (AppLogic.CachingOn)
            {
                m_Contents = (String)HttpContext.Current.Cache.Get(CacheName);
                if (m_Contents != null)
                {
                    FromCache = true;
                }
            }

            if (!FromCache)
            {
                StringBuilder tmpS = new StringBuilder(50000);
                tmpS.Append("<SiteMap>\n");

                // Categories:
                String s = AppLogic.LookupHelper("Category", 0).GetEntityPhoneOrderNode(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, true, IGD);
                if (s.Length != 0)
                {
                    tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\">\n");
                    tmpS.Append(s);
                    tmpS.Append("</node>");
                }

                // Sections:
                s = AppLogic.LookupHelper("Section", 0).GetEntityPhoneOrderNode(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, true, IGD);
                if (s.Length != 0)
                {
                    tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\">\n");
                    tmpS.Append(s);
                    tmpS.Append("</node>");
                }

                // Manufacturers:
                s = AppLogic.LookupHelper("Manufacturer", 0).GetEntityPhoneOrderNode(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, true, IGD);
                if (s.Length != 0)
                {
                    tmpS.Append("<node Text=\"" + XmlCommon.XmlEncodeAttribute(AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant()) + "\">\n");
                    tmpS.Append(s);
                    tmpS.Append("</node>");
                }

                tmpS.Append("</SiteMap>\n");
                m_Contents = tmpS.ToString();
                if (AppLogic.CachingOn)
                {
                    HttpContext.Current.Cache.Insert(CacheName, m_Contents, null, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                }
            }
        }
Пример #23
0
        private static string StringResourceMatch(Match match)
        {
            String l = match.Groups[1].Value;
            string s = HttpUtility.HtmlEncode(AppLogic.GetString(l, DEFAULT_SKINID, Customer.Current.LocaleSetting));

            if (s == null || s.Length == 0 || s == l)
            {
                s = match.Value;
            }
            return(XmlCommon.XmlEncode(s));
        }
Пример #24
0
        /// <summary>
        /// Converts all param keys in the m_SessionParms HashTable to an xml fragment of <param> nodes
        /// </summary>
        /// <returns></returns>
        private string SerializeParams()
        {
            StringBuilder sb = new StringBuilder("<params>", 1024);

            foreach (string s in m_SessionParms.Keys)
            {
                SessionParam sp = (SessionParam)m_SessionParms[s];
                sb.Append("<param name=\"" + XmlCommon.XmlEncodeAttribute(s) + "\" val=\"" + XmlCommon.XmlEncodeAttribute(sp.ParamValue) + "\" " + CommonLogic.IIF(sp.ExpireOn.Equals(DateTime.MaxValue), "", "expireon=\"" + sp.ExpireOn.ToString() + "\"") + " />");
            }
            sb.Append("</params>");
            return(sb.ToString());
        }
Пример #25
0
        static public int GetCurrencyID(String CurrencyCode)
        {
            if (CurrencyCode.Length == 0)
            {
                return(0);
            }
            int     tmpS = 0;
            XmlNode n    = RatesDoc.SelectSingleNode("//Currency[@CurrencyCode=" + CommonLogic.SQuote(CurrencyCode) + "]");

            if (n != null)
            {
                tmpS = XmlCommon.XmlAttributeNativeInt(n, "CurrencyID");
            }
            return(tmpS);
        }
Пример #26
0
        static public Decimal GetExchangeRate(String CurrencyCode)
        {
            if (CurrencyCode.Length == 0)
            {
                throw new ArgumentException("Invalid CurrencyCode (empty string)");
            }
            Decimal tmpS = System.Decimal.Zero;
            XmlNode n    = RatesDoc.SelectSingleNode("//Currency[@CurrencyCode=" + CommonLogic.SQuote(CurrencyCode) + "]");

            if (n != null)
            {
                tmpS = XmlCommon.XmlAttributeUSDecimal(n, "ExchangeRate");
            }
            return(tmpS);
        }
Пример #27
0
        // for paymentech gateway, which is kind of silly:
        static public String XmlEncodeMaxLength(String s, int MaxChars)
        {
            String result = String.Empty;

            foreach (char c in s)
            {
                String sx = new String(c, 1);
                sx = XmlCommon.XmlEncode(sx);
                if (result.Length + sx.Length < MaxChars)
                {
                    result += sx;
                }
            }
            return(result);
        }
Пример #28
0
        static public String GetDisplaySpec(String CurrencyCode)
        {
            if (CurrencyCode.Length == 0)
            {
                throw new ArgumentException("Invalid CurrencyCode (empty string)");
            }
            String  tmpS = String.Empty;
            XmlNode n    = RatesDoc.SelectSingleNode("//Currency[@CurrencyCode=" + CommonLogic.SQuote(CurrencyCode) + "]");

            if (n != null)
            {
                tmpS = XmlCommon.XmlAttribute(n, "DisplaySpec");
            }
            return(tmpS);
        }
Пример #29
0
        static public String GetCurrencyCode(String Name)
        {
            if (Name.Length == 0)
            {
                throw new ArgumentException("Invalid Currency Name (empty string)");
            }
            String  tmpS = String.Empty;
            XmlNode n    = RatesDoc.SelectSingleNode("//Currency[@Name=" + Name + "]");

            if (n != null)
            {
                tmpS = XmlCommon.XmlAttribute(n, "CurrencyCode");
            }
            return(tmpS);
        }
Пример #30
0
        public string LocalizedValue(string unlocalizedValue)
        {
            var customer       = AppLogic.GetCurrentCustomer();
            var localizedValue = unlocalizedValue;

            if (customer != null)
            {
                localizedValue = XmlCommon.GetLocaleEntry(unlocalizedValue, customer.LocaleSetting, true);
            }
            else
            {
                localizedValue = XmlCommon.GetLocaleEntry(unlocalizedValue, Localization.GetDefaultLocale(), true);
            }

            return(localizedValue);
        }