Example #1
0
        private bool FindIDFile()
        {
            if (m_ID != 0)
            {
                // try to locate by id.htm
                m_URL = Path.Combine(m_Root, m_ID.ToString() + "." + m_LocaleSetting + ".htm");
                m_FN  = CommonLogic.SafeMapPath(m_URL);
                if (CommonLogic.FileExists(m_FN))
                {
                    return(true);
                }

                // try default store locale path:
                m_URL = Path.Combine(m_Root, m_ID.ToString() + "." + Localization.GetDefaultLocale() + ".htm");
                m_FN  = CommonLogic.SafeMapPath(m_URL);
                if (CommonLogic.FileExists(m_FN))
                {
                    return(true);
                }

                // try skin (NULL) path:
                m_URL = Path.Combine(m_Root, m_ID.ToString() + ".htm");
                m_FN  = CommonLogic.SafeMapPath(m_URL);
                if (CommonLogic.FileExists(m_FN))
                {
                    return(true);
                }
            }
            m_URL = String.Empty;
            m_FN  = String.Empty;
            return(false);
        }
Example #2
0
        public IEnumerable <string> GenerateXmlPackageNameVariations(string requestedFileName, Customer customer)
        {
            if (!requestedFileName.EndsWith(XmlPackage.XmlPackageExtension, StringComparison.OrdinalIgnoreCase))
            {
                requestedFileName += XmlPackage.XmlPackageExtension;
            }

            // Build a list of localized filenames to try
            var customerLocale = customer != null
                                ? customer.LocaleSetting
                                : Localization.GetDefaultLocale();

            return(new[]
            {
                requestedFileName.Replace(
                    XmlPackage.XmlPackageExtension,
                    string.Format(".{0}{1}", customerLocale, XmlPackage.XmlPackageExtension)),

                requestedFileName.Replace(
                    XmlPackage.XmlPackageExtension,
                    string.Format(".{0}{1}", Localization.GetDefaultLocale(), XmlPackage.XmlPackageExtension)),

                requestedFileName,
            }
                   .Distinct(StringComparer.OrdinalIgnoreCase));
        }
 static public String ToNativeDateTimeString(DateTime dt)
 {
     if (dt.Equals(System.DateTime.MinValue))
     {
         return(String.Empty);
     }
     return(dt.ToString(new CultureInfo(Localization.GetDefaultLocale())));
 }
Example #4
0
 public Topic(String TopicName, String LocaleSetting, int SkinID, Parser UseParser, int StoreID)
 {
     m_TopicName        = TopicName.Trim();
     m_LocaleSetting    = LocaleSetting;
     m_SkinID           = SkinID;
     m_TopicID          = Topic.GetTopicID(TopicName, Localization.GetDefaultLocale(), StoreID);   // always find topics by MASTER locale name!
     m_CommandHashtable = new Hashtable();
     m_CmdMatchEval     = new MatchEvaluator(CommandMatchEvaluator);
     m_UseParser        = UseParser;
     m_StoreID          = StoreID;
     LoadFromDB(StoreID);
 }
Example #5
0
        private static string CurrencyLocaleRobotsTag(Customer ThisCustomer)
        {
            string tmp = string.Empty;

            if (ThisCustomer.CurrencySetting != Localization.GetPrimaryCurrency() &&
                ThisCustomer.LocaleSetting != Localization.GetDefaultLocale())
            {
                tmp = "<meta name=\"robots\" content=\"noindex,nofollow,noarchive\">";
            }

            return(tmp);
        }
Example #6
0
        static public void Send(Order order, String FromEMailAddress, String MailServer, Customer ViewingCustomer)
        {
            // change in v6.1, the Dispatch_ToPhoneNumber must now be the full cell message address (e.g. [email protected]) or whatever
            // is needed. You can also dispatch to multiple cells by separating them with a comma.
            String SMSTo = AppLogic.AppConfig("Dispatch_ToPhoneNumber");

            if (SMSTo.Length != 0)
            {
                Decimal OrderThreshold = System.Decimal.Zero;
                if (AppLogic.AppConfig("Dispatch_OrderThreshold").Length != 0)
                {
                    try
                    {
                        String s = AppLogic.AppConfig("Dispatch_OrderThreshold").Replace("$", "");                                // strip the $ out if present
                        OrderThreshold = Localization.ParseUSDecimal(s);
                    }
                    catch {}
                }
                if (order.Total(true) >= OrderThreshold)
                {
                    try
                    {
                        SMSTo = SMSTo.Replace(";", ",");
                        String SMSSubject = AppLogic.AppConfig("Dispatch_SiteName");
                        if (SMSSubject.Length != 0)
                        {
                            SMSSubject = AppLogic.GetString("sms.cs.1", 1, Localization.GetDefaultLocale());
                        }
                        String PackageName = AppLogic.AppConfig("XmlPackage.NewOrderAdminSMSNotification");
                        if (PackageName.Length != 0)
                        {
                            String SMSBody = AppLogic.RunXmlPackage(PackageName, null, null, order.SkinID, String.Empty, "OrderNumber=" + order.OrderNumber.ToString(), false, false);
                            if (SMSBody.Length > AppLogic.AppConfigUSInt("Dispatch_MAX_SMS_MSG_LENGTH"))
                            {
                                SMSBody = SMSBody.Substring(0, AppLogic.AppConfigUSInt("Dispatch_MAX_SMS_MSG_LENGTH"));
                            }
                            string   s    = String.Empty;
                            string[] sAry = SMSTo.Split(',');
                            for (int i = 0; i < sAry.Length; i++)
                            {
                                String s2 = sAry[i].Trim();
                                if (s2.Length != 0)
                                {
                                    AppLogic.SendMail(SMSSubject, SMSBody, false, FromEMailAddress, FromEMailAddress, s2, s2, "", MailServer);
                                }
                            }
                        }
                    }
                    catch {}
                }
            }
        }
        // no exchange rate is ever applied!
        // input amt is assumed to be in the store's PRIMARY CURRENCY!
        // converted to web.config locale format
        static public String CurrencyStringForDisplayWithoutExchangeRate(decimal amt, bool ShowCurrency)
        {
            String tmpS = amt.ToString("C", new CultureInfo(Localization.GetDefaultLocale()));

            if (tmpS.StartsWith("("))
            {
                tmpS = "-" + tmpS.Replace("(", "").Replace(")", "");
            }
            if (ShowCurrency && Currency.NumPublishedCurrencies() > 1)
            {
                tmpS = String.Format("{0} ({1})", tmpS, Localization.GetPrimaryCurrency());
            }
            return(tmpS);
        }
Example #8
0
        public static int GetTopicID(String TopicName, String LocaleSetting, int StoreID)
        {
            if (String.IsNullOrEmpty(LocaleSetting))
            {
                LocaleSetting = Localization.GetDefaultLocale();
            }
            string localeMatch = BuildLocaleSearchString(LocaleSetting, TopicName);
            int    tmp         = 0;
            String topicSQL    = "select TopicID from Topic where (StoreID={1} or 0={0}) AND Deleted=0 AND Published=1 and (lower(Name)={2} OR Name like '%' + {3} + '%') order by storeid";

            using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
            {
                con.Open();
                using (IDataReader rs = DB.GetRS(string.Format(topicSQL
                                                               , CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowTopicFiltering") == true, 1, 0)
                                                               , StoreID
                                                               , DB.SQuote(TopicName.ToLowerInvariant())
                                                               , DB.SQuote(localeMatch))
                                                 , con))
                {
                    if (rs.Read())
                    {
                        tmp = DB.RSFieldInt(rs, "TopicID");
                    }
                }
            }

            if (tmp == 0)
            {
                StoreID = 0;
                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rs = DB.GetRS(string.Format(topicSQL
                                                                   , CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowTopicFiltering") == true, 1, 0)
                                                                   , StoreID
                                                                   , DB.SQuote(TopicName.ToLowerInvariant())
                                                                   , DB.SQuote(localeMatch))
                                                     , con))
                    {
                        if (rs.Read())
                        {
                            tmp = DB.RSFieldInt(rs, "TopicID");
                        }
                    }
                }
            }
            return(tmp);
        }
Example #9
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);
        }
Example #10
0
        /// <summary>
        /// Determines a localized value for the current locale for any product property when multiple locales are being used
        /// </summary>
        /// <param name="val">The unlocalized string value to localize</param>
        /// <returns>A localized string based on the current locale</returns>
        public String LocalizedValue(String val)
        {
            Customer ThisCustomer = AppLogic.GetCurrentCustomer();

            String LocalValue = val;

            if (ThisCustomer != null)
            {
                LocalValue = XmlCommon.GetLocaleEntry(val, ThisCustomer.LocaleSetting, true);
            }
            else
            {
                LocalValue = XmlCommon.GetLocaleEntry(val, Localization.GetDefaultLocale(), true);
            }

            return(LocalValue);
        }
Example #11
0
        private static string PageInfoParser(Customer ThisCustomer)
        {
            StringBuilder tmp = new StringBuilder(4096);

            tmp.Append("<!--\n");
            tmp.Append("PAGE INVOCATION: " + HttpContext.Current.Server.HtmlEncode(CommonLogic.PageInvocation()) + "\n");
            tmp.Append("PAGE REFERRER: " + HttpContext.Current.Server.HtmlEncode(CommonLogic.PageReferrer()) + "\n");
            tmp.Append("STORE LOCALE: " + Localization.GetDefaultLocale() + "\n");
            tmp.Append("STORE CURRENCY: " + Localization.GetPrimaryCurrency() + "\n");
            tmp.Append("CUSTOMER ID: " + ThisCustomer.CustomerID.ToString() + "\n");
            tmp.Append("AFFILIATE ID: " + ThisCustomer.AffiliateID.ToString() + "\n");
            tmp.Append("CUSTOMER LOCALE: " + ThisCustomer.LocaleSetting + "\n");
            tmp.Append("CURRENCY SETTING: " + ThisCustomer.CurrencySetting + "\n");
            tmp.Append("CACHE MENUS: " + AppLogic.AppConfigBool("CacheMenus").ToString() + "\n");
            tmp.Append("-->\n");

            return(tmp.ToString());
        }
Example #12
0
        private bool FindNameFile()
        {
            try
            {
                m_Name = AppLogic.GetEntityName(m_DescriptionType, m_ID, m_LocaleSetting);

                if (m_Name.Length != 0)
                {
                    // try specified locale
                    m_URL = Path.Combine(m_Root, m_Name + "." + m_LocaleSetting + ".htm");
                    m_FN  = CommonLogic.SafeMapPath(m_URL);
                    if (CommonLogic.FileExists(m_FN))
                    {
                        return(true);
                    }

                    // try default store locale path:
                    m_URL = Path.Combine(m_Root, m_Name + "." + Localization.GetDefaultLocale() + ".htm");
                    m_FN  = CommonLogic.SafeMapPath(m_URL);
                    if (CommonLogic.FileExists(m_FN))
                    {
                        return(true);
                    }

                    // try base (NULL) path:
                    m_URL = Path.Combine(m_Root, m_Name + ".htm");
                    m_FN  = CommonLogic.SafeMapPath(m_URL);
                    if (CommonLogic.FileExists(m_FN))
                    {
                        return(true);
                    }
                }
                m_URL = String.Empty;
                m_FN  = String.Empty;
                return(false);
            }
            catch
            {
                return(false);
            }
        }
        private bool FindSKUFile()
        {
            try
            {
                if (m_ProductSKU.Length != 0)
                {
                    // try specified locale first
                    m_URL = Path.Combine(m_Root, m_ProductSKU + "." + m_LocaleSetting + ".htm");
                    m_FN  = CommonLogic.SafeMapPath(m_URL);
                    if (CommonLogic.FileExists(m_FN))
                    {
                        return(true);
                    }

                    // try default store locale path:
                    m_URL = Path.Combine(m_Root, m_ProductSKU + "." + Localization.GetDefaultLocale() + ".htm");
                    m_FN  = CommonLogic.SafeMapPath(m_URL);
                    if (CommonLogic.FileExists(m_FN))
                    {
                        return(true);
                    }

                    // try base (NULL) path:
                    m_URL = Path.Combine(m_Root, m_ProductSKU + ".htm");
                    m_FN  = CommonLogic.SafeMapPath(m_URL);
                    if (CommonLogic.FileExists(m_FN))
                    {
                        return(true);
                    }
                }
                m_URL = String.Empty;
                m_FN  = String.Empty;
                return(false);
            }
            catch
            {
                return(false);
            }
        }
Example #14
0
        // assumes this "xmlnode" n has <ml>...</ml> markup on it!
        public static String GetLocaleEntry(XmlNode n, String LocaleSetting, bool fallBack)
        {
            String tmpS = String.Empty;

            if (n != null)
            {
                if (n.InnerText.StartsWith("&lt;ml&gt;", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(GetLocaleEntry(XmlDecode(n.InnerText), LocaleSetting, fallBack));
                }
                if (n.HasChildNodes && n.FirstChild.LocalName.Equals("ml", StringComparison.InvariantCultureIgnoreCase))
                {
                    String WebConfigLocale = Localization.GetDefaultLocale();
                    try
                    {
                        XmlNode node = n.SelectSingleNode("ml/locale[@name=\"" + LocaleSetting + "\"]");
                        if (fallBack && (node == null))
                        {
                            node = n.SelectSingleNode("ml/locale[@name=\"" + WebConfigLocale + "\"]");
                        }
                        if (node != null)
                        {
                            tmpS = node.InnerText.Trim();
                        }
                        if (tmpS.Length != 0)
                        {
                            tmpS = XmlCommon.XmlDecode(tmpS);
                        }
                    }
                    catch { }
                }
                else
                {
                    tmpS = n.InnerText.Trim(); // for backwards compatibility...they have no locale info, so just return the field.
                }
            }

            return(tmpS);
        }
Example #15
0
        private static string TopicParser(Customer ThisCustomer, string[] values)
        {
            Parser p = null;

            if (values.Length > 2 && values[2].EqualsIgnoreCase("true"))
            {
                p = new Parser(ThisCustomer.SkinID, ThisCustomer);
            }

            String LS = Localization.GetDefaultLocale(), tmp = "";

            if (ThisCustomer != null)
            {
                LS = ThisCustomer.LocaleSetting;
            }

            if (values[1].Length != 0)
            {
                Topic t = new Topic(values[1], LS, ThisCustomer.SkinID, p);
                tmp = t.Contents;
            }

            return(tmp);
        }
 void BuildVariantColors()
 {
     VariantColors = new string[1] {
         ""
     };
     if (VariantColorsCsv == string.Empty)
     {
         using (var dbconn = new SqlConnection(DB.GetDBConn()))
         {
             dbconn.Open();
             using (var rs = DB.GetRS("select Colors from productvariant   with (NOLOCK)  where VariantID=" + VariantId.ToString(), dbconn))
             {
                 if (rs.Read())
                 {
                     VariantColorsCsv = DB.RSFieldByLocale(rs, "Colors", Localization.GetDefaultLocale());                             // remember to add "empty" color to front, for no color selected
                     if (VariantColorsCsv.Length != 0)
                     {
                         VariantColors = ("," + VariantColorsCsv).Split(',');
                     }
                 }
             }
         }
     }
     else
     {
         VariantColors = ("," + VariantColorsCsv).Split(',');
     }
     if (VariantColorsCsv.Length != 0)
     {
         for (int i = VariantColors.GetLowerBound(0); i <= VariantColors.GetUpperBound(0); i++)
         {
             string s2 = AppLogic.RemoveAttributePriceModifier(VariantColors[i]);
             VariantColors[i] = CommonLogic.MakeSafeFilesystemName(s2);
         }
     }
 }
Example #17
0
        public SiteMap1(System.Collections.Generic.Dictionary <string, EntityHelper> EntityHelpers, int SkinID, Customer ThisCustomer)
        {
            bool   FromCache = false;
            String CacheName = String.Format("SiteMap1_{0}_{1}", SkinID.ToString(), ThisCustomer.LocaleSetting);

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

            if (!FromCache)
            {
                StringBuilder tmpS = new StringBuilder(50000);

                if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowCategories"))
                {
                    // Categories:
                    String s = AppLogic.LookupHelper("Category", 0).GetEntityULList(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250, true, "sitemapul", true, 0, String.Empty);
                    if (s.Length != 0)
                    {
                        tmpS.Append("<b>");
                        if (AppLogic.IsAdminSite)
                        {
                            tmpS.Append("<a href=\"newentities.aspx?entityname=category\">");
                        }
                        tmpS.Append(AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant());
                        if (AppLogic.IsAdminSite)
                        {
                            tmpS.Append("</a>");
                        }
                        tmpS.Append("</b>");
                        tmpS.Append(s);
                    }
                }

                if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowSections"))
                {
                    // Sections:
                    String s = AppLogic.LookupHelper("Section", 0).GetEntityULList(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, true, AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250, true, "sitemapul", true, 0, String.Empty);
                    if (s.Length != 0)
                    {
                        tmpS.Append("<b>");
                        if (AppLogic.IsAdminSite)
                        {
                            tmpS.Append("<a href=\"newentities.aspx?entityname=section\">");
                        }
                        tmpS.Append(AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant());
                        if (AppLogic.IsAdminSite)
                        {
                            tmpS.Append("</a>");
                        }
                        tmpS.Append("</b>");
                        tmpS.Append(s);
                    }
                }

                if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowLibraries"))
                {
                    // Libraries:
                    String s = AppLogic.LookupHelper("Library", 0).GetEntityULList(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, AppLogic.AppConfigBool("SiteMap.ShowDocuments"), true, true, "sitemapul", true, 0, String.Empty);
                    if (s.Length != 0)
                    {
                        tmpS.Append("<b>");
                        if (AppLogic.IsAdminSite)
                        {
                            tmpS.Append("<a href=\"newentities.aspx?entityname=library\">");
                        }
                        tmpS.Append(AppLogic.GetString("AppConfig.LibraryPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant());
                        if (AppLogic.IsAdminSite)
                        {
                            tmpS.Append("</a>");
                        }
                        tmpS.Append("</b>");
                        tmpS.Append(s);
                    }
                }

                if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowManufacturers"))
                {
                    // Manufacturers:
                    String s = AppLogic.LookupHelper("Manufacturer", 0).GetEntityULList(0, ThisCustomer.LocaleSetting, ThisCustomer.AffiliateID, ThisCustomer.CustomerLevelID, false, AppLogic.AppConfigBool("SiteMap.ShowProducts") && AppLogic.NumProductsInDB < 250, true, "sitemapul", true, 0, String.Empty);
                    if (s.Length != 0)
                    {
                        tmpS.Append("<b>");
                        if (AppLogic.IsAdminSite)
                        {
                            tmpS.Append("<a href=\"newentities.aspx?entityname=manufacturer\">");
                        }
                        tmpS.Append(AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant());
                        if (AppLogic.IsAdminSite)
                        {
                            tmpS.Append("</a>");
                        }
                        tmpS.Append("</b>");
                        tmpS.Append(s);
                    }
                }

                if (AppLogic.IsAdminSite || AppLogic.AppConfigBool("SiteMap.ShowTopics"))
                {
                    // Topics:
                    tmpS.Append("<b>");
                    if (AppLogic.IsAdminSite)
                    {
                        tmpS.Append("<a href=\"topics.aspx\">");
                    }
                    tmpS.Append(AppLogic.GetString("sitemap.aspx.2", SkinID, ThisCustomer.LocaleSetting).ToUpperInvariant());
                    if (AppLogic.IsAdminSite)
                    {
                        tmpS.Append("</a>");
                    }
                    tmpS.Append("</b>");
                    tmpS.Append("<ul class=\"sitemapul\">\n");

                    using (SqlConnection dbconn = DB.dbConn())
                    {
                        dbconn.Open();
                        using (IDataReader rs = DB.GetRS(string.Format("select count(*) as N from Topic with (NOLOCK) where {0} Deleted=0 AND Published=1 and (SkinID IS NULL or SkinID=0 or SkinID={1}) ", CommonLogic.IIF(AppLogic.IsAdminSite, "", "ShowInSiteMap=1 and "), SkinID.ToString()) + "; " + string.Format("select Name,Title,TopicID from Topic with (NOLOCK) where {0} Deleted=0 and Published=1 and (SkinID IS NULL or SkinID=0 or SkinID={1}) Order By DisplayOrder, Name ASC", CommonLogic.IIF(AppLogic.IsAdminSite, "", "ShowInSiteMap=1 and "), SkinID.ToString()), dbconn))
                        {
                            if (rs.Read() && DB.RSFieldInt(rs, "N") > 0)
                            {
                                if (rs.NextResult())
                                {
                                    while (rs.Read())
                                    {
                                        tmpS.Append("<li>");
                                        if (AppLogic.IsAdminSite)
                                        {
                                            tmpS.Append(String.Format("<a href=\"edittopic.aspx?topicid={0}\">", DB.RSFieldInt(rs, "TopicID").ToString()));
                                        }
                                        else
                                        {
                                            tmpS.Append("<a href=\"" + SE.MakeDriverLink(DB.RSFieldByLocale(rs, "Name", Localization.GetDefaultLocale())) + "\">");
                                        }
                                        tmpS.Append(Security.HtmlEncode(DB.RSFieldByLocale(rs, "Title", Localization.GetDefaultLocale())));
                                        tmpS.Append("</a>");
                                        tmpS.Append("</li>\n");
                                    }
                                }
                            }
                        }
                    }

                    // File Topics:
                    // create an array to hold the list of files
                    ArrayList fArray = new ArrayList();

                    // get information about our initial directory
                    String SFP = CommonLogic.SafeMapPath(CommonLogic.IIF(AppLogic.IsAdminSite, "../", "") + "App_Templates/Skin_" + SkinID.ToString() + "/template.htm").Replace("template.htm", "");

                    DirectoryInfo dirInfo = new DirectoryInfo(SFP);

                    // retrieve array of files & subdirectories
                    FileSystemInfo[] myDir = dirInfo.GetFileSystemInfos();

                    for (int i = 0; i < myDir.Length; i++)
                    {
                        // check the file attributes

                        // if a subdirectory, add it to the sArray
                        // otherwise, add it to the fArray
                        if (((Convert.ToUInt32(myDir[i].Attributes) & Convert.ToUInt32(FileAttributes.Directory)) > 0))
                        {
                        }
                        else
                        {
                            bool skipit = false;
                            if (!myDir[i].FullName.EndsWith("htm", StringComparison.InvariantCultureIgnoreCase) ||
                                (myDir[i].FullName.IndexOf("TEMPLATE", StringComparison.InvariantCultureIgnoreCase) != -1) ||
                                (myDir[i].FullName.IndexOf("AFFILIATE_", StringComparison.InvariantCultureIgnoreCase) != -1) ||
                                (myDir[i].FullName.IndexOf(AppLogic.ro_PMMicropay, StringComparison.InvariantCultureIgnoreCase) != -1))
                            {
                                skipit = true;
                            }
                            if (!skipit)
                            {
                                fArray.Add(Path.GetFileName(myDir[i].FullName));
                            }
                        }
                    }

                    if (fArray.Count != 0)
                    {
                        // sort the files alphabetically
                        fArray.Sort(0, fArray.Count, null);
                        for (int i = 0; i < fArray.Count; i++)
                        {
                            tmpS.Append("<li>");
                            if (!AppLogic.IsAdminSite) // admin site can't link to these kinds of topics
                            {
                                tmpS.Append("<a href=\"" + SE.MakeDriverLink(fArray[i].ToString().Replace(".htm", "")) + "\">");
                            }
                            else
                            {
                                tmpS.Append("(file based topic) ");
                            }
                            tmpS.Append(Security.HtmlEncode(CommonLogic.Capitalize(fArray[i].ToString().Replace(".htm", ""))));
                            if (!AppLogic.IsAdminSite)
                            {
                                tmpS.Append("</a>");
                            }
                            tmpS.Append("</li>\n");
                        }
                    }
                    tmpS.Append("</ul>\n");
                }
                m_Contents = tmpS.ToString();
                if (AppLogic.CachingOn)
                {
                    HttpContext.Current.Cache.Insert(CacheName, m_Contents, null, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                }
            }
        }
Example #18
0
        // ----------------------------------------------------------------
        //
        // SIMPLE Xml FIELD ROUTINES
        //
        // ----------------------------------------------------------------

        public static String GetLocaleEntry(String S, String LocaleSetting, bool fallBack)
        {
            String tmpS = String.Empty;

            if (S.Length == 0)
            {
                return(tmpS);
            }
            if (S.StartsWith("&lt;ml&gt;", StringComparison.InvariantCultureIgnoreCase))
            {
                S = XmlDecode(S);
            }
            if (S.StartsWith("<ml>", StringComparison.InvariantCultureIgnoreCase))
            {
                String WebConfigLocale = Localization.GetDefaultLocale();
                if (AppLogic.AppConfigBool("UseXmlDOMForLocaleExtraction"))
                {
                    try
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(S);
                        XmlNode node = doc.DocumentElement.SelectSingleNode("//locale[@name=\"" + LocaleSetting + "\"]");
                        if (fallBack && (node == null))
                        {
                            node = doc.DocumentElement.SelectSingleNode("//locale[@name=\"" + WebConfigLocale + "\"]");
                        }
                        if (node != null)
                        {
                            tmpS = node.InnerText.Trim();
                        }
                        if (tmpS.Length != 0)
                        {
                            tmpS = XmlCommon.XmlDecode(tmpS);
                        }
                    }
                    catch { }
                }
                else
                {
                    // for speed, we are using lightweight simple string token extraction here, not full Xml DOM for speed
                    // return what is between <locale name=\"en-US\">...</locale>, Xml Decoded properly.
                    // we have a good locale field formatted field, so try to get desired locale:
                    if (S.IndexOf("<locale name=\"" + LocaleSetting + "\">") != -1)
                    {
                        tmpS = CommonLogic.ExtractToken(S, "<locale name=\"" + LocaleSetting + "\">", "</locale>");
                    }
                    else if (fallBack && (S.IndexOf("<locale name=\"" + WebConfigLocale + "\">") != -1))
                    {
                        tmpS = CommonLogic.ExtractToken(S, "<locale name=\"" + WebConfigLocale + "\">", "</locale>");
                    }
                    else
                    {
                        tmpS = String.Empty;
                    }
                    if (tmpS.Length != 0)
                    {
                        tmpS = XmlCommon.XmlDecode(tmpS);
                    }
                }
            }
            else
            {
                tmpS = S; // for backwards compatibility...they have no locale info, so just return the field.
            }
            return(tmpS);
        }
Example #19
0
        /// <summary>
        /// Formats and extracts details from an exception for log entry
        /// </summary>
        /// <param name="ex">The exception to format</param>
        /// <returns></returns>
        public static string FormatExceptionForLog(Exception ex)
        {
            try              // Never let logging crash the site!
            {
                StringBuilder details = new StringBuilder();

                try                 // In case returning the page name fails, still log the rest of the data
                {
                    details.Append(AppLogic.GetString("admin.systemlog.PageURL", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + Security.ScrubCCNumbers(CommonLogic.GetThisPageName(true)) + "\r\n");
                }
                catch { }

                if (ex.InnerException != null)
                {
                    details.Append(AppLogic.GetString("admin.systemlog.Source", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + ex.InnerException.Source + "\r\n");
                    details.Append(AppLogic.GetString("admin.systemlog.Message", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + ex.InnerException.Message + "\r\n");
                    details.Append(AppLogic.GetString("admin.systemlog.StackTrace", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + "\r\n" + ex.InnerException.StackTrace + "\r\n");
                }
                else
                {
                    details.Append(AppLogic.GetString("admin.systemlog.Source", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + ex.Source + "\r\n");
                    details.Append(AppLogic.GetString("admin.systemlog.Message", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + ex.Message + "\r\n");
                    details.Append(AppLogic.GetString("admin.systemlog.StackTrace", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + "\r\n" + ex.StackTrace + "\r\n");
                }
                return(details.ToString());
            }
            catch
            {
                return(String.Empty);
            }
        }
Example #20
0
        public void LoadFromDB()
        {
            string suffix   = "_" + m_ProductID.ToString();
            string pvsuffix = "_" + m_ProductID.ToString() + "_" + m_VariantID.ToString();

            m_ImageNumbersSplit = m_ImageNumbers.Split(',');
            bool m_WatermarksEnabled = AppLogic.AppConfigBool("Watermark.Enabled");


            m_ColorsSplit = new String[1] {
                ""
            };
            if (m_Colors == String.Empty)
            {
                using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                {
                    dbconn.Open();
                    using (IDataReader rs = DB.GetRS("select Colors from productvariant   with (NOLOCK)  where VariantID=" + m_VariantID.ToString(), dbconn))
                    {
                        if (rs.Read())
                        {
                            m_Colors = DB.RSFieldByLocale(rs, "Colors", Localization.GetDefaultLocale());                             // remember to add "empty" color to front, for no color selected
                            if (m_Colors.Length != 0)
                            {
                                m_ColorsSplit = ("," + m_Colors).Split(',');
                            }
                        }
                    }
                }
            }
            else
            {
                m_ColorsSplit = ("," + m_Colors).Split(',');
            }
            if (m_Colors.Length != 0)
            {
                for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++)
                {
                    String s2 = AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]);
                    m_ColorsSplit[i] = CommonLogic.MakeSafeFilesystemName(s2);
                }
            }

            if (AppLogic.AppConfigBool("MultiImage.UseProductIconPics"))
            {
                m_ImageUrlsicon = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length];
                for (int x = m_ImageNumbersSplit.GetLowerBound(0); x <= m_ImageNumbersSplit.GetUpperBound(0); x++)
                {
                    int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[x]);
                    for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++)
                    {
                        String Url = string.Empty;
                        if (m_ProductSKU == string.Empty)
                        {
                            Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "icon");
                        }
                        else
                        {
                            Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "icon");
                        }
                        if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1)
                        {
                            if (Url.StartsWith("/"))
                            {
                                m_ImageUrlsicon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length);
                            }
                            else
                            {
                                m_ImageUrlsicon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1);
                            }

                            if (m_ImageUrlsicon[x, i].StartsWith("/"))
                            {
                                m_ImageUrlsicon[x, i] = m_ImageUrlsicon[x, i].TrimStart('/');
                            }
                        }
                        else
                        {
                            m_ImageUrlsicon[x, i] = Url;
                        }
                    }
                }
                for (int x = m_ImageNumbersSplit.GetLowerBound(0); x <= m_ImageNumbersSplit.GetUpperBound(0); x++)
                {
                    int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[x]);
                    if (m_ImageUrlsicon[x, 0].IndexOf("nopicture") == -1)
                    {
                        m_MaxImageIndex = ImgIdx;
                    }
                }
            }

            m_ImageUrlsmedium = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length];
            for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++)
            {
                int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]);
                for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++)
                {
                    String Url = string.Empty;
                    if (m_ProductSKU == string.Empty)
                    {
                        Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "medium");
                    }
                    else
                    {
                        Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "medium");
                    }
                    if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1)
                    {
                        if (Url.StartsWith("/"))
                        {
                            m_ImageUrlsmedium[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length);
                        }
                        else
                        {
                            m_ImageUrlsmedium[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1);
                        }

                        if (m_ImageUrlsmedium[j, i].StartsWith("/"))
                        {
                            m_ImageUrlsmedium[j, i] = m_ImageUrlsmedium[j, i].TrimStart('/');
                        }
                    }
                    else
                    {
                        m_ImageUrlsmedium[j, i] = Url;
                    }
                }
            }
            for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++)
            {
                int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]);
                if (m_ImageUrlsmedium[j, 0].IndexOf("nopicture") == -1)
                {
                    m_MaxImageIndex = ImgIdx;
                }
            }

            m_ImageUrlslarge = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length];
            for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++)
            {
                int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]);
                for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++)
                {
                    String Url = string.Empty;
                    if (m_ProductSKU == string.Empty)
                    {
                        Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "large");
                    }
                    else
                    {
                        Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "large");
                    }

                    if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1)
                    {
                        if (Url.StartsWith("/"))
                        {
                            m_ImageUrlslarge[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length);
                        }
                        else
                        {
                            m_ImageUrlslarge[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1);
                        }

                        if (m_ImageUrlslarge[j, i].StartsWith("/"))
                        {
                            m_ImageUrlslarge[j, i] = m_ImageUrlslarge[j, i].TrimStart('/');
                        }

                        m_HasSomeLarge = true;
                    }
                    else if (Url.Length == 0 || Url.IndexOf("nopicture") != -1)
                    {
                        m_ImageUrlslarge[j, i] = String.Empty;
                    }
                    else
                    {
                        m_HasSomeLarge         = true;
                        m_ImageUrlslarge[j, i] = Url;
                    }
                }
            }

            if (!IsEmpty())
            {
                bool AttemptZoomify = AppLogic.AppConfigBool("Zoomify.Active") && (AppLogic.AppConfigBool("Zoomify.GalleryMedium") || AppLogic.AppConfigBool("Zoomify.ProductMedium"));
                bool GalleryZoomify = AttemptZoomify && AppLogic.AppConfigBool("Zoomify.GalleryMedium");

                StringBuilder tmpS = new StringBuilder(4096);
                tmpS.Append("<script type=\"text/javascript\">\n");
                tmpS.Append("var ProductPicIndex" + suffix + " = 1;\n");
                tmpS.Append("var ProductColor" + suffix + " = '';\n");
                tmpS.Append("var boardpics" + suffix + " = new Array();\n");
                tmpS.Append("var boardpicslg" + suffix + " = new Array();\n");
                tmpS.Append("var boardpicslgwidth" + suffix + " = new Array();\n");
                tmpS.Append("var boardpicslgheight" + suffix + " = new Array();\n");
                if (AttemptZoomify)
                {
                    tmpS.Append("var boardpicsZ" + suffix + " = new Array();\n");
                }
                for (int i = 1; i <= m_MaxImageIndex; i++)
                {
                    foreach (String c in m_ColorsSplit)
                    {
                        String MdUrl            = ImageUrl(i, c, "medium").ToLowerInvariant();
                        String MdWatermarkedUrl = MdUrl;

                        if (m_WatermarksEnabled)
                        {
                            if (MdUrl.Length > 0)
                            {
                                string[] split    = MdUrl.Split('/');
                                string   lastPart = split.Last();
                                MdUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", "medium", "");
                            }
                        }

                        tmpS.Append("boardpics" + suffix + "['" + i.ToString() + "," + c + "'] = '" + MdWatermarkedUrl + "';\n");

                        String LgUrl            = ImageUrl(i, c, "large").ToLowerInvariant();
                        String LgWatermarkedUrl = LgUrl;

                        if (m_WatermarksEnabled)
                        {
                            if (LgUrl.Length > 0)
                            {
                                string[] split    = LgUrl.Split('/');
                                string   lastPart = split.Last();
                                LgUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", "large", "");
                            }
                        }

                        tmpS.Append("boardpicslg" + suffix + "['" + i.ToString() + "," + c + "'] = '" + LgWatermarkedUrl + "';\n");

                        if (LgUrl.Length > 0)
                        {
                            System.Drawing.Size lgsz = CommonLogic.GetImagePixelSize(LgUrl);
                            tmpS.Append("boardpicslgwidth" + suffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Width.ToString() + "';\n");
                            tmpS.Append("boardpicslgheight" + suffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Height.ToString() + "';\n");
                        }

                        if (AttemptZoomify)
                        {
                            String ZMdUrl = string.Empty;

                            // Yes we use the large url here, because the Zoomify data is always in Large
                            if (LgUrl.Length > 0)
                            {
                                ZMdUrl = LgUrl.Remove(LgUrl.Length - 4);                                 // remove extension
                            }

                            if (GalleryZoomify && CommonLogic.FileExists(CommonLogic.SafeMapPath(LgUrl)))
                            {
                                tmpS.Append("boardpicsZ" + suffix + "['" + i.ToString() + "," + c + "'] = '" + AppLogic.RunXmlPackage("Zoomify.Medium", null, null, m_SkinID, "", "ImagePath=" + ZMdUrl + "&AltSrc=" + LgUrl, false, false).Replace("\r\n", " ").Replace("\r", " ").Replace("\n", " ").Replace("'", "\\'") + "';\n");                                 // the Replace's are to make the xmlpackage output consumable by javascript
                            }
                            else
                            {
                                tmpS.Append("boardpicsZ" + suffix + "['" + i.ToString() + "," + c + "'] = '';\n");
                            }
                        }
                    }
                }

                if (AttemptZoomify)
                {
                    tmpS.Append("function changeContent(markup)\n");
                    tmpS.Append("{\n");
                    tmpS.Append("	id='divProductPicZ"+ m_ProductID.ToString() + "';\n");
                    tmpS.Append("	if (document.getElementById || document.all)\n");
                    tmpS.Append("	{\n");
                    tmpS.Append("		var el = document.getElementById? document.getElementById(id): document.all[id];\n");
                    tmpS.Append("		if (el && typeof el.innerHTML != \"undefined\") el.innerHTML = markup;\n");
                    tmpS.Append("	}\n");
                    tmpS.Append("}\n");
                }

                tmpS.Append("function changecolorimg" + suffix + "()\n");
                tmpS.Append("{\n");
                tmpS.Append("	var scidx = ProductPicIndex"+ suffix + " + ',' + ProductColor" + suffix + ".toLowerCase();\n");

                if (AttemptZoomify)
                {
                    tmpS.Append("if (boardpicsZ" + suffix + "[scidx]!='') {\n");
                    tmpS.Append("  divProductPicZ" + m_ProductID.ToString() + ".style.display='inline';\n");
                    tmpS.Append("  divProductPic" + m_ProductID.ToString() + ".style.display='none';\n");
                    tmpS.Append("  changeContent(boardpicsZ" + suffix + "[scidx]); }\n");
                    tmpS.Append("else {\n");
                    tmpS.Append("  divProductPicZ" + m_ProductID.ToString() + ".style.display='none';\n");
                    tmpS.Append("  divProductPic" + m_ProductID.ToString() + ".style.display='inline';\n");
                    tmpS.Append("  document.ProductPic" + m_ProductID.ToString() + ".src=boardpics" + suffix + "[scidx]; }\n");
                }
                else
                {
                    tmpS.Append("	document.ProductPic"+ m_ProductID.ToString() + ".src=boardpics" + suffix + "[scidx];\n");
                }

                tmpS.Append("}\n");

                tmpS.Append("function popuplarge" + suffix + "()\n");
                tmpS.Append("{\n");
                tmpS.Append("	var scidx = ProductPicIndex"+ suffix + " + ',' + ProductColor" + suffix + ".toLowerCase();\n");
                tmpS.Append("	var LargeSrc = boardpicslg"+ suffix + "[scidx];\n");

                if (m_WatermarksEnabled)
                {
                    tmpS.AppendFormat("	var imageName = LargeSrc.split(\"/\").pop(-1);{0}", Environment.NewLine);
                    tmpS.AppendFormat("	LargeSrc = 'watermark.axd?size=large&imgurl=images/product/large/' + imageName;{0}", Environment.NewLine);
                }
                tmpS.Append("if(boardpicslg" + suffix + "[scidx] != '')\n");
                tmpS.Append("{\n");
                tmpS.Append("	window.open('popup.aspx?src=' + LargeSrc,'LargerImage"+ CommonLogic.GetRandomNumber(1, 100000) + "','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",resizable=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",copyhistory=no,width=' + boardpicslgwidth" + suffix + "[scidx] + ',height=' + boardpicslgheight" + suffix + "[scidx] + ',left=0,top=0');\n");
                tmpS.Append("}\n");
                tmpS.Append("else\n");
                tmpS.Append("{\n");
                tmpS.Append("	alert('There is no large image available for this picture');\n");
                tmpS.Append("}\n");
                tmpS.Append("}\n");

                tmpS.Append("function setcolorpicidx" + suffix + "(idx)\n");
                tmpS.Append("{\n");
                tmpS.Append("	ProductPicIndex"+ suffix + " = idx;\n");
                tmpS.Append("	changecolorimg"+ suffix + "();\n");
                tmpS.Append("}\n");

                tmpS.Append("function setActive(element)\n");
                tmpS.Append("{\n");
                tmpS.Append("	adnsf$('li.page-link').removeClass('active');\n");
                tmpS.Append("	adnsf$(element).parent().addClass('active');\n");
                tmpS.Append("}\n");

                tmpS.Append("function cleansizecoloroption" + suffix + "(theVal)\n");
                tmpS.Append("{\n");
                tmpS.Append("   if(theVal.indexOf('[') != -1){theVal = theVal.substring(0, theVal.indexOf('['))}");
                tmpS.Append("	theVal = theVal.replace(/[\\W]/g,\"\");\n");
                tmpS.Append("	theVal = theVal.toLowerCase();\n");
                tmpS.Append("	return theVal;\n");
                tmpS.Append("}\n");

                tmpS.Append("function setcolorpic" + suffix + "(color)\n");
                tmpS.Append("{\n");

                tmpS.Append("	while(color != unescape(color))\n");
                tmpS.Append("	{\n");
                tmpS.Append("		color = unescape(color);\n");
                tmpS.Append("	}\n");

                tmpS.Append("	if(color == '-,-' || color == '-')\n");
                tmpS.Append("	{\n");
                tmpS.Append("		color = '';\n");
                tmpS.Append("	}\n");

                tmpS.Append("	if(color != '' && color.indexOf(',') != -1)\n");
                tmpS.Append("	{\n");

                tmpS.Append("		color = color.substring(0,color.indexOf(',')).replace(new RegExp(\"'\", 'gi'), '');\n");                     // remove sku from color select value

                tmpS.Append("	}\n");
                tmpS.Append("	if(color != '' && color.indexOf('[') != -1)\n");
                tmpS.Append("	{\n");

                tmpS.Append("	    color = color.substring(0,color.indexOf('[')).replace(new RegExp(\"'\", 'gi'), '');\n");
                tmpS.Append("		color = color.replace(/[\\s]+$/g,\"\");\n");

                tmpS.Append("	}\n");
                tmpS.Append("	ProductColor"+ suffix + " = cleansizecoloroption" + suffix + "(color);\n");

                tmpS.Append("	changecolorimg"+ suffix + "();\n");
                tmpS.Append("	setcolorlisttoactiveitem"+ suffix + "(color);\n");
                tmpS.Append("	return (true);\n");
                tmpS.Append("}\n");

                // this one (without suffix) added back for backwards compatibility with older existing product data, where
                // the swatch map called to this js routine directly
                tmpS.Append("function setcolorpic(color)\n");
                tmpS.Append("{\n");

                tmpS.Append("	if(color == '-,-' || color == '-')\n");
                tmpS.Append("	{\n");
                tmpS.Append("		color = '';\n");
                tmpS.Append("	}\n");

                tmpS.Append("	if(color != '' && color.indexOf(',') != -1)\n");
                tmpS.Append("	{\n");

                tmpS.Append("		color = color.substring(0,color.indexOf(',')).replace(new RegExp(\"'\", 'gi'), '');\n");                     // remove sku from color select value

                tmpS.Append("	}\n");
                tmpS.Append("	if(color != '' && color.indexOf('[') != -1)\n");
                tmpS.Append("	{\n");

                tmpS.Append("	    color = color.substring(0,color.indexOf('[')).replace(new RegExp(\"'\", 'gi'), '');\n");
                tmpS.Append("		color = color.replace(/[\\s]+$/g,\"\");\n");

                tmpS.Append("	}\n");
                tmpS.Append("	ProductColor"+ suffix + " = cleansizecoloroption" + suffix + "(color);\n");

                tmpS.Append("	changecolorimg"+ suffix + "();\n");
                tmpS.Append("	setcolorlisttoactiveitem"+ suffix + "(color.toLowerCase());\n");
                tmpS.Append("	return (true);\n");
                tmpS.Append("}\n");

                tmpS.Append("function setcolorlisttoactiveitem" + suffix + "(color)\n");
                tmpS.Append("{\n");

                tmpS.Append("var lst = document.getElementById('Color" + pvsuffix + "');\n");

                tmpS.Append("var matchColor = cleansizecoloroption" + suffix + "(color);\n");

                tmpS.Append("for (var i=0; i < lst.length; i++)\n");
                tmpS.Append("   {\n");

                tmpS.Append("var value = lst[i].value;\n");
                tmpS.Append("var arrayValue = value.split(',');\n");
                tmpS.Append("var lstColor = cleansizecoloroption" + suffix + "(arrayValue[0]);\n");

                //tmpS.Append("	var lstColor = cleansizecoloroption" + suffix + "(lst[i].value);\n");

                tmpS.Append("   if (lstColor == matchColor)\n");
                tmpS.Append("      {\n");
                tmpS.Append("		lst.selectedIndex = i;\n");
                tmpS.Append("		return (true);\n");
                tmpS.Append("      }\n");
                tmpS.Append("   }\n");

                tmpS.Append("return (true);\n");
                tmpS.Append("}\n");

                tmpS.Append("</script>\n");
                m_ImgDHTML = tmpS.ToString();

                bool useMicros = AppLogic.AppConfigBool("UseImagesForMultiNav");

                bool microAction = CommonLogic.IIF(AppLogic.AppConfigBool("UseRolloverForMultiNav"), true, false);

                if (m_MaxImageIndex > 1)
                {
                    tmpS.Remove(0, tmpS.Length);

                    if (!AppLogic.AppConfigBool("MultiImage.UseProductIconPics") && !useMicros)
                    {
                        tmpS.Append("<ul class=\"pagination image-paging\">");
                        for (int i = 1; i <= m_MaxImageIndex; i++)
                        {
                            if (i == 1)
                            {
                                tmpS.Append("<li class=\"page-link active\">");
                            }
                            else
                            {
                                tmpS.Append("<li class=\"page-link\">");
                            }

                            tmpS.Append(string.Format("<a href=\"javascript:void(0);\" onclick='setcolorpicidx{0}({1});setActive(this);' class=\"page-number\">{1}</a>", suffix, i));
                            tmpS.Append("</li>");
                        }
                        tmpS.Append("</ul>");
                    }
                    else
                    {
                        tmpS.Append("<div class=\"product-gallery-items\">");
                        for (int i = 1; i <= m_MaxImageIndex; i++)
                        {
                            tmpS.Append("<div class=\"product-gallery-item\">");
                            tmpS.Append("	<div class=\"gallery-item-inner\">");
                            if (AppLogic.AppConfigBool("MultiImage.UseProductIconPics"))
                            {
                                string strImageTag = "<img class='product-gallery-image' onclick='setcolorpicidx{0}({1});setImageURL(\"{2}\")' alt='Show Picture {1}' src='{2}' border='0' />";
                                tmpS.AppendFormat(strImageTag, new object[] {
                                    suffix,
                                    i,
                                    m_ImageUrlsicon[i - 1, 0].ToString()
                                });
                            }
                            else
                            {
                                // check for different extensions but don't let the non existance leave a gap
                                // or crash because it can't find an image
                                String ImageLoc = String.Empty;
                                if (AppLogic.AppConfigBool("UseSKUForProductImageName"))
                                {
                                    using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                                    {
                                        dbconn.Open();
                                        using (IDataReader skus = DB.GetRS("SELECT p.SKU FROM Product p  with (NOLOCK)  WHERE p.ProductID=" + m_ProductID.ToString(), dbconn))
                                        {
                                            try
                                            {
                                                String microSKU = String.Empty;
                                                if (skus.Read())
                                                {
                                                    microSKU = DB.RSField(skus, "SKU");
                                                }
                                                ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + ".gif");
                                                if (!CommonLogic.FileExists(ImageLoc))
                                                {
                                                    ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + "_" + ".gif");
                                                }
                                                if (!CommonLogic.FileExists(ImageLoc))
                                                {
                                                    ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + ".jpg");
                                                }
                                                if (!CommonLogic.FileExists(ImageLoc))
                                                {
                                                    ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + "_" + ".jpg");
                                                }
                                                if (!CommonLogic.FileExists(ImageLoc))
                                                {
                                                    ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + ".png");
                                                }
                                                if (!CommonLogic.FileExists(ImageLoc))
                                                {
                                                    ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + microSKU.ToString() + "_" + i.ToString() + "_" + ".png");
                                                }
                                                if (!CommonLogic.FileExists(ImageLoc))
                                                {
                                                    ImageLoc = AppLogic.LocateImageURL("App_Themes/skin_" + m_SkinID + "/images/nopicturemicro.gif");
                                                }
                                            }
                                            catch { }
                                        }
                                    }
                                }
                                else
                                {
                                    ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + ".gif");
                                    if (!CommonLogic.FileExists(ImageLoc))
                                    {
                                        ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + "_" + ".gif");
                                    }
                                    if (!CommonLogic.FileExists(ImageLoc))
                                    {
                                        ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + ".jpg");
                                    }
                                    if (!CommonLogic.FileExists(ImageLoc))
                                    {
                                        ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + "_" + ".jpg");
                                    }
                                    if (!CommonLogic.FileExists(ImageLoc))
                                    {
                                        ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + ".png");
                                    }
                                    if (!CommonLogic.FileExists(ImageLoc))
                                    {
                                        ImageLoc = AppLogic.LocateImageURL("images/product/micro/" + m_ProductID.ToString() + "_" + i.ToString() + "_" + ".png");
                                    }
                                    if (!CommonLogic.FileExists(ImageLoc))
                                    {
                                        ImageLoc = AppLogic.LocateImageURL("App_Themes/skin_" + m_SkinID + "/images/nopicturemicro.gif");
                                    }
                                }

                                // if not using rollover to change the images
                                if (!microAction && ImageLoc.Length > 0)
                                {
                                    string strImageTag = string.Format("<img class='product-gallery-image' onclick='setcolorpicidx{0}({1});setImageURL(\"{2}\")' alt='Show Picture {1}' src='{2}' border='0' />",
                                                                       new object[]
                                    {
                                        suffix, i, ImageLoc
                                    });
                                    tmpS.Append(strImageTag);
                                }
                                else if (ImageLoc.Length > 0)
                                {
                                    string strImageTag = string.Format("<img class='product-gallery-image' onMouseOver='setcolorpicidx{0}({1});setImageURL(\"{2}\")' alt='Show Picture {1}' src='{2}' border='0' />",
                                                                       new object[]
                                    {
                                        suffix, i, ImageLoc
                                    });
                                    tmpS.Append(strImageTag);
                                }
                            }
                            tmpS.Append("	</div>");
                            tmpS.Append("</div>");
                        }
                        tmpS.Append("</div>");
                    }

                    m_ImgGalIcons = tmpS.ToString();
                }
            }
        }
Example #21
0
        public void Load(int shoppingCartRecordId)
        {
            var sqlParams = new List <SqlParameter>();

            sqlParams.Add(DB.CreateSQLParameter("@ShoppingCartRecID", SqlDbType.Int, 4, shoppingCartRecordId, ParameterDirection.Input));

            using (var dbconn = DB.dbConn())
            {
                dbconn.Open();
                using (var dr = DB.GetRS("SELECT osc.OrderNumber, osc.CustomerId, osc.OrderedProductVariantName, osc.OrderedProductName, osc.DownloadStatus, osc.DownloadLocation, osc.DownloadValidDays, osc.DownloadCategory, osc.DownloadReleasedOn, osc.CreatedOn FROM Orders_ShoppingCart osc(NOLOCK) LEFT JOIN Orders o(NOLOCK) ON osc.OrderNumber = o.OrderNumber WHERE o.TransactionState NOT IN('REFUNDED', 'VOIDED') AND ShoppingCartRecID = @ShoppingCartRecID", sqlParams.ToArray(), dbconn))
                {
                    if (dr.Read())
                    {
                        ShoppingCartRecordId = shoppingCartRecordId;
                        OrderNumber          = DB.RSFieldInt(dr, "OrderNumber");
                        CustomerId           = DB.RSFieldInt(dr, "CustomerId");
                        DownloadName         = DB.RSFieldByLocale(dr, "OrderedProductVariantName", Localization.GetDefaultLocale()).Length > 0 ? string.Format("{0} - {1}", DB.RSFieldByLocale(dr, "OrderedProductName", Localization.GetDefaultLocale()), DB.RSFieldByLocale(dr, "OrderedProductVariantName", Localization.GetDefaultLocale())) : DB.RSFieldByLocale(dr, "OrderedProductName", Localization.GetDefaultLocale());
                        DownloadLocation     = DB.RSField(dr, "DownloadLocation") ?? string.Empty;
                        DownloadCategory     = DB.RSField(dr, "DownloadCategory") ?? string.Empty;
                        Status      = (DownloadItemStatus)DB.RSFieldInt(dr, "DownloadStatus");
                        ValidDays   = DB.RSFieldInt(dr, "DownloadValidDays");
                        PurchasedOn = DB.RSFieldDateTime(dr, "CreatedOn");
                        ReleasedOn  = DB.RSFieldDateTime(dr, "DownloadReleasedOn");

                        if (Status != DownloadItemStatus.Pending && ValidDays > 0)
                        {
                            ExpiresOn = ReleasedOn.AddDays(ValidDays);

                            if (DateTime.Now > ReleasedOn.AddDays(ValidDays))
                            {
                                Status = DownloadItemStatus.Expired;
                            }
                        }
                        ContentType = DownloadLocation.Length > 0 ? GetMimeType(Path.GetExtension(DownloadLocation)) : string.Empty;
                    }
                }
            }
        }
Example #22
0
        public void Create(int orderNumber, CartItem c)
        {
            var variant = new ProductVariant(c.VariantID);

            using (var cn = new SqlConnection(DB.GetDBConn()))
            {
                cn.Open();
                using (var cmd = new SqlCommand(@"update orders_ShoppingCart set                                
									DownloadCategory=@DownloadCategory, 
									DownloadValidDays=@DownloadValidDays,
									DownloadLocation=@DownloadLocation,
									DownloadStatus=@DownloadStatus
									where OrderNumber=@OrderNumber and ShoppingCartRecID=@ShoppingCartRecID"                                    , cn))
                {
                    cmd.Parameters.Add(new SqlParameter("@DownloadCategory", SqlDbType.NText));
                    cmd.Parameters.Add(new SqlParameter("@DownloadValidDays", SqlDbType.Int));
                    cmd.Parameters.Add(new SqlParameter("@DownloadLocation", SqlDbType.NText));
                    cmd.Parameters.Add(new SqlParameter("@DownloadStatus", SqlDbType.Int));
                    cmd.Parameters.Add(new SqlParameter("@OrderNumber", SqlDbType.Int));
                    cmd.Parameters.Add(new SqlParameter("@ShoppingCartRecID", SqlDbType.Int));

                    cmd.Parameters["@DownloadCategory"].Value  = AppLogic.GetFirstProductEntity(AppLogic.LookupHelper("Category", 0), c.ProductID, false, Localization.GetDefaultLocale());
                    cmd.Parameters["@DownloadValidDays"].Value = variant.DownloadValidDays;
                    cmd.Parameters["@DownloadLocation"].Value  = variant.DownloadLocation;
                    cmd.Parameters["@DownloadStatus"].Value    = (int)DownloadItemStatus.Pending;
                    cmd.Parameters["@OrderNumber"].Value       = orderNumber;
                    cmd.Parameters["@ShoppingCartRecID"].Value = c.ShoppingCartRecordID;

                    cmd.ExecuteNonQuery();
                }
            }
        }
 public ProductDescriptionFile(int ProductID, int SkinID)
     : this(ProductID, Localization.GetDefaultLocale(), SkinID)
 {
 }
Example #24
0
        // these are the same for ALL page requests since app start!
        public void BuildPageStaticTokens()
        {
            String m_CacheName = String.Empty;

            if (AppLogic.CachingOn)
            {
                m_CacheName    = String.Format("StaticTokens_{0}_{1}_{2}_{3}_{4}_{5}", SkinID.ToString(), ThisCustomer.LocaleSetting, ThisCustomer.CurrencySetting, ThisCustomer.CustomerLevelID, ThisCustomer.AffiliateID, ThisCustomer.VATSettingReconciled);
                m_StaticTokens = (Hashtable)HttpContext.Current.Cache.Get(m_CacheName);
            }
            if (m_StaticTokens == null)
            {
                m_StaticTokens = new Hashtable();
                m_StaticTokens.Add("(!STORE_VERSION!)", String.Empty);
                m_StaticTokens.Add("(!COPYRIGHTYEARS!)", AppLogic.AppConfig("StartingCopyrightYear") + "-" + DateTime.Now.Year.ToString());
                if (AppLogic.AppConfigBool("CardinalCommerce.Centinel.Enabled"))
                {
                    m_StaticTokens.Add("(!VBV!)", "<img src=\"" + AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/vbv.jpg") + "\" border=\"0\" alt=\"Store protected with Verified By Visa/MasterCard Secure Initiatives\">");
                }
                else
                {
                    m_StaticTokens.Add("(!VBV!)", String.Empty);
                }
                m_StaticTokens.Add("(!SKINID!)", SkinID.ToString());
                m_StaticTokens.Add("(!RIGHTCOL!)", "The RIGHTCOL token is no longer supported. You should put the right column you want directly into your skin templtae.ascx design where you want it");
                m_StaticTokens.Add("(!SITENAME!)", AppLogic.AppConfig("StoreName"));
                m_StaticTokens.Add("(!SITE_NAME!)", AppLogic.AppConfig("StoreName"));
                m_StaticTokens.Add("(!STORELOCALE!)", Localization.GetDefaultLocale());
                m_StaticTokens.Add("(!LOCALESETTING!)", ThisCustomer.LocaleSetting);
                m_StaticTokens.Add("(!CUSTOMERLOCALE!)", ThisCustomer.LocaleSetting);
                m_StaticTokens.Add("(!CURRENCY_LOCALE_ROBOTS_TAG!)", String.Empty); //CommonLogic.IIF(ThisCustomer.CurrencySetting == Localization.GetPrimaryCurrency() && ThisCustomer.LocaleSetting == Localization.GetWebConfigLocale(), String.Empty, "<meta name=\"robots\" content=\"noindex,nofollow,noarchive\">")); // to prevent indexing of store pages in "foreign" currencies"
                m_StaticTokens.Add("(!SEARCH_BOX!)", AppLogic.GetSearchBox(SkinID, ThisCustomer.LocaleSetting));
                m_StaticTokens.Add("(!COUNTRYBAR!)", AppLogic.GetCountryBar(ThisCustomer.LocaleSetting));
                m_StaticTokens.Add("(!HELPBOX!)", AppLogic.GetHelpBox(SkinID, true, ThisCustomer.LocaleSetting, null));
                m_StaticTokens.Add("(!HELPBOX_CONTENTS!)", AppLogic.GetHelpBox(SkinID, false, ThisCustomer.LocaleSetting, null));
                m_StaticTokens.Add("(!NEWS_SUMMARY!)", AppLogic.GetNewsSummary(3));
                m_StaticTokens.Add("(!CATEGORY_PROMPT!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.3", SkinID, ThisCustomer.LocaleSetting)));
                m_StaticTokens.Add("(!CATEGORY_PROMPT_SINGULAR!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.CategoryPromptSingular", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.CategoryPromptSingular", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.3", SkinID, ThisCustomer.LocaleSetting)));
                m_StaticTokens.Add("(!CATEGORY_PROMPT_PLURAL!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.CategoryPromptPlural", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.2", SkinID, ThisCustomer.LocaleSetting)).ToUpperInvariant());
                m_StaticTokens.Add("(!SECTION_PROMPT!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.2", SkinID, ThisCustomer.LocaleSetting)));
                m_StaticTokens.Add("(!SECTION_PROMPT_SINGULAR!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.SectionPromptSingular", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.SectionPromptSingular", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.2", SkinID, ThisCustomer.LocaleSetting)));
                m_StaticTokens.Add("(!SECTION_PROMPT_PLURAL!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.SectionPromptPlural", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.1", SkinID, ThisCustomer.LocaleSetting)).ToUpperInvariant());
                m_StaticTokens.Add("(!MANUFACTURER_PROMPT!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.3", SkinID, ThisCustomer.LocaleSetting)));
                m_StaticTokens.Add("(!MANUFACTURER_PROMPT_SINGULAR!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.ManufacturerPromptSingular", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.ManufacturerPromptSingular", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.3", SkinID, ThisCustomer.LocaleSetting)));
                m_StaticTokens.Add("(!MANUFACTURER_PROMPT_PLURAL!)", CommonLogic.IIF(AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting).Length != 0, AppLogic.GetString("AppConfig.ManufacturerPromptPlural", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.2", SkinID, ThisCustomer.LocaleSetting)).ToUpperInvariant());
                m_StaticTokens.Add("(!UNSUP_4!)", AppLogic.GetCategoryBox(AppLogic.AppConfigUSInt("KitCategoryID"), true, 5, false, "Our custom tailored kits provide everything you need in one package!", SkinID, ThisCustomer.LocaleSetting));
                m_StaticTokens.Add("(!ADMIN_FOR!)", AppLogic.GetString("admin.main.ascx.AdminFor", 1, Localization.GetDefaultLocale()));

                foreach (String EntityName in AppLogic.ro_SupportedEntities)
                {
                    String        ENU    = EntityName.ToUpperInvariant();
                    StringBuilder tmpSx  = new StringBuilder(4096);
                    EntityHelper  Helper = AppLogic.LookupHelper(EntityName, 0);

                    m_StaticTokens.Add("(!" + ENU + "_BROWSE_BOX!)", Helper.GetEntityBrowseBox(SkinID, ThisCustomer.LocaleSetting));
                }
                m_StaticTokens = AspDotNetStorefront.Global.CompleteParser(m_StaticTokens);
            }
            if (AppLogic.CachingOn)
            {
                HttpContext.Current.Cache.Insert(m_CacheName, m_StaticTokens, null, System.DateTime.Now.AddMinutes(m_CacheMinutes), TimeSpan.Zero);
            }
        }
Example #25
0
        // these can change on EVERY page request!!
        public void BuildPageDynamicTokens()
        {
            if (m_DynamicTokens == null)
            {
                // page/customer specific items (that may change every page):
                m_DynamicTokens = new Hashtable();

                if (CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx"))
                {
                    m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING!)", AppLogic.GetGoogleEComTracking(ThisCustomer));
                }
                else
                {
                    m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING!)", String.Empty);
                }

                if (CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx"))
                {
                    m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING_V2!)", String.Empty);
                }
                else
                {
                    m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING_V2!)", AppLogic.GetGoogleEComTrackingV2(ThisCustomer, false));
                }

                if (!AppLogic.VATIsEnabled())
                {
                    m_DynamicTokens.Add("(!VATREGISTRATIONID!)", String.Empty);
                }
                else
                {
                    StringBuilder tmpS2 = new StringBuilder(1024);
                    if (ThisCustomer.HasCustomerRecord)
                    {
                        tmpS2.Append("<span class=\"VATRegistrationIDPrompt\">" + AppLogic.GetString("setvatsetting.aspx.8", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + "</span><input type=\"text\" style=\"VATRegistrationID\" id=\"VATRegistrationID\" value=\"" + ThisCustomer.VATRegistrationID + "\">");
                    }
                    m_DynamicTokens.Add("(!VATREGISTRATIONID!)", tmpS2.ToString());
                }

                if (AppLogic.NumLocaleSettingsInstalled() < 2)
                {
                    m_DynamicTokens.Add("(!COUNTRYDIVVISIBILITY!)", "hidden");
                    m_DynamicTokens.Add("(!COUNTRYDIVDISPLAY!)", "none");
                    m_DynamicTokens.Add("(!COUNTRYSELECTLIST!)", String.Empty);
                }
                else
                {
                    m_DynamicTokens.Add("(!COUNTRYDIVVISIBILITY!)", "visible");
                    m_DynamicTokens.Add("(!COUNTRYDIVDISPLAY!)", "inline");
                    m_DynamicTokens.Add("(!COUNTRYSELECTLIST!)", AppLogic.GetCountrySelectList(ThisCustomer.LocaleSetting));
                }

                if (Currency.NumPublishedCurrencies() < 2)
                {
                    m_DynamicTokens.Add("(!CURRENCYDIVVISIBILITY!)", "hidden");
                    m_DynamicTokens.Add("(!CURRENCYDIVDISPLAY!)", "none");
                    m_DynamicTokens.Add("(!CURRENCYSELECTLIST!)", String.Empty);
                }
                else
                {
                    m_DynamicTokens.Add("(!CURRENCYDIVVISIBILITY!)", "visible");
                    m_DynamicTokens.Add("(!CURRENCYDIVDISPLAY!)", "inline");
                    m_DynamicTokens.Add("(!CURRENCYSELECTLIST!)", AppLogic.GetCurrencySelectList(ThisCustomer));
                }

                if (AppLogic.VATIsEnabled() && AppLogic.AppConfigBool("VAT.AllowCustomerToChooseSetting"))
                {
                    m_DynamicTokens.Add("(!VATDIVVISIBILITY!)", "visible");
                    m_DynamicTokens.Add("(!VATDIVDISPLAY!)", "inline");
                    m_DynamicTokens.Add("(!VATSELECTLIST!)", AppLogic.GetVATSelectList(ThisCustomer));
                }
                else
                {
                    m_DynamicTokens.Add("(!VATDIVVISIBILITY!)", "hidden");
                    m_DynamicTokens.Add("(!VATDIVDISPLAY!)", "none");
                    m_DynamicTokens.Add("(!VATSELECTLIST!)", String.Empty);
                }

                if (!ThisCustomer.IsRegistered)
                {
                    m_DynamicTokens.Add("(!SUBSCRIPTION_EXPIRATION!)", AppLogic.ro_NotApplicable);
                }
                else
                {
                    if (ThisCustomer.SubscriptionExpiresOn.Equals(System.DateTime.MinValue))
                    {
                        m_DynamicTokens.Add("(!SUBSCRIPTION_EXPIRATION!)", "Expired");
                    }
                    else
                    {
                        m_DynamicTokens.Add("(!SUBSCRIPTION_EXPIRATION!)", Localization.ToThreadCultureShortDateString(ThisCustomer.SubscriptionExpiresOn));
                    }
                }

                m_DynamicTokens.Add("(!PAGEURL!)", HttpContext.Current.Server.UrlEncode(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING")));
                m_DynamicTokens.Add("(!RANDOM!)", CommonLogic.GetRandomNumber(1, 7).ToString());
                m_DynamicTokens.Add("(!HDRID!)", CommonLogic.GetRandomNumber(1, 7).ToString());
                m_DynamicTokens.Add("(!INVOCATION!)", HttpContext.Current.Server.HtmlEncode(CommonLogic.PageInvocation()));
                m_DynamicTokens.Add("(!REFERRER!)", HttpContext.Current.Server.HtmlEncode(CommonLogic.PageReferrer()));

                StringBuilder tmp = new StringBuilder(4096);
                tmp.Append("<!--\n");
                tmp.Append("PAGE INVOCATION: " + HttpContext.Current.Server.HtmlEncode(CommonLogic.PageInvocation()) + "\n");
                tmp.Append("PAGE REFERRER: " + HttpContext.Current.Server.HtmlEncode(CommonLogic.PageReferrer()) + "\n");
                tmp.Append("STORE LOCALE: " + Localization.GetDefaultLocale() + "\n");
                tmp.Append("STORE CURRENCY: " + Localization.GetPrimaryCurrency() + "\n");
                tmp.Append("CUSTOMER ID: " + ThisCustomer.CustomerID.ToString() + "\n");
                tmp.Append("AFFILIATE ID: " + ThisCustomer.AffiliateID.ToString() + "\n");
                tmp.Append("CUSTOMER LOCALE: " + ThisCustomer.LocaleSetting + "\n");
                tmp.Append("CURRENCY SETTING: " + ThisCustomer.CurrencySetting + "\n");
                tmp.Append("CACHE MENUS: " + AppLogic.AppConfigBool("CacheMenus").ToString() + "\n");
                tmp.Append("-->\n");
                m_DynamicTokens.Add("(!PAGEINFO!)", tmp.ToString());

                bool IsRegistered = CommonLogic.IIF(ThisCustomer != null, ThisCustomer.IsRegistered, false);

                String tmpS = String.Empty;

                if (IsRegistered)
                {
                    if (!AppLogic.IsAdminSite)
                    {
                        tmpS = AppLogic.GetString("skinbase.cs.1", SkinID, ThisCustomer.LocaleSetting) + " <a class=\"username\" href=\"account.aspx\">" + ThisCustomer.FullName() + "</a>" + CommonLogic.IIF(ThisCustomer.CustomerLevelID != 0, "&nbsp;(" + ThisCustomer.CustomerLevelName + ")", "");
                    }
                    m_DynamicTokens.Add("(!USER_NAME!)", tmpS);
                    m_DynamicTokens.Add("(!USERNAME!)", tmpS);
                }
                else
                {
                    m_DynamicTokens.Add("(!USER_NAME!)", String.Empty);
                    m_DynamicTokens.Add("(!USERNAME!)", String.Empty);
                }

                m_DynamicTokens.Add("(!USER_MENU_NAME!)", CommonLogic.IIF(!IsRegistered, "my account", ThisCustomer.FullName()));
                m_DynamicTokens.Add("(!USER_MENU!)", AppLogic.GetUserMenu(ThisCustomer.IsRegistered, SkinID, ThisCustomer.LocaleSetting));
                if (AppLogic.MicropayIsEnabled())
                {
                    tmpS = "Your " + AppLogic.GetString("account.aspx.11", SkinID, ThisCustomer.LocaleSetting) + " balance is: " + Localization.DecimalStringForDB(ThisCustomer.MicroPayBalance);
                    m_DynamicTokens.Add("(!MICROPAY_BALANCE!)", tmpS);
                    m_DynamicTokens.Add("(!MICROPAY_BALANCE_RAW!)", Localization.DecimalStringForDB(ThisCustomer.MicroPayBalance));
                    m_DynamicTokens.Add("(!MICROPAY_BALANCE_CURRENCY!)", ThisCustomer.CurrencyString(ThisCustomer.MicroPayBalance));
                }
                tmpS = ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.ShoppingCart).ToString();
                m_DynamicTokens.Add("(!NUM_CART_ITEMS!)", tmpS);
                tmpS = AppLogic.GetString("AppConfig.CartPrompt", SkinID, ThisCustomer.LocaleSetting);
                m_DynamicTokens.Add("(!CARTPROMPT!)", tmpS);
                tmpS = ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.WishCart).ToString();
                m_DynamicTokens.Add("(!NUM_WISH_ITEMS!)", tmpS);
                tmpS = ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.GiftRegistryCart).ToString();
                m_DynamicTokens.Add("(!NUM_GIFT_ITEMS!)", tmpS);
                tmpS = CommonLogic.IIF(!IsRegistered, AppLogic.GetString("skinbase.cs.4", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.5", SkinID, ThisCustomer.LocaleSetting));
                m_DynamicTokens.Add("(!SIGNINOUT_TEXT!)", tmpS);
                m_DynamicTokens.Add("(!SIGNINOUT_LINK!)", CommonLogic.IIF(!IsRegistered, "signin.aspx", "signout.aspx"));
                String PN = CommonLogic.GetThisPageName(false);
                if (AppLogic.AppConfigBool("ShowMiniCart"))
                {
                    if (PN.StartsWith("shoppingcart", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("checkout", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("cardinal", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("addtocart") || PN.IndexOf("_process", StringComparison.InvariantCultureIgnoreCase) != -1 || PN.StartsWith("lat_", StringComparison.InvariantCultureIgnoreCase))
                    {
                        m_DynamicTokens.Add("(!MINICART!)", String.Empty); // don't show on these pages
                    }
                    else
                    {
                        m_DynamicTokens.Add("(!MINICART!)", ShoppingCart.DisplayMiniCart(ThisCustomer, SkinID, true));
                    }
                    if (PN.StartsWith("shoppingcart", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("checkout", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("cardinal", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("addtocart", StringComparison.InvariantCultureIgnoreCase) || PN.IndexOf("_process", StringComparison.InvariantCultureIgnoreCase) != -1 || PN.StartsWith("lat_", StringComparison.InvariantCultureIgnoreCase))
                    {
                        m_DynamicTokens.Add("(!MINICART_PLAIN!)", String.Empty); // don't show on these pages
                    }
                    else
                    {
                        m_DynamicTokens.Add("(!MINICART_PLAIN!)", ShoppingCart.DisplayMiniCart(ThisCustomer, SkinID, false));
                    }
                }
                m_DynamicTokens.Add("(!CUSTOMERID!)", ThisCustomer.CustomerID.ToString());
            }
        }
Example #26
0
        // returns true if no errors, and card is enrolled:
        static public bool PreChargeLookup(string cardNumber,
                                           int cardExpirationYear,
                                           int cardExpirationMonth,
                                           int orderNumber,
                                           decimal orderTotal,
                                           string orderDescription,
                                           out string acsUrl,
                                           out string payload,
                                           out string transactionId,
                                           out string cardinalLookupResult)
        {
            var ccRequest     = new CardinalCommerce.CentinelRequest();
            var ccResponse    = new CardinalCommerce.CentinelResponse();
            var numAttempts   = AppLogic.AppConfigUSInt("CardinalCommerce.Centinel.NumRetries");
            var callSucceeded = false;

            payload       = string.Empty;
            acsUrl        = String.Empty;
            transactionId = String.Empty;

            // ==================================================================================
            // Construct the cmpi_lookup message
            // ==================================================================================

            ccRequest.add("MsgType", AppLogic.AppConfig("CardinalCommerce.Centinel.MsgType.Lookup"));
            ccRequest.add("Version", "1.7");
            ccRequest.add("ProcessorId", AppLogic.AppConfig("CardinalCommerce.Centinel.ProcessorID"));
            ccRequest.add("MerchantId", AppLogic.AppConfig("CardinalCommerce.Centinel.MerchantID"));
            ccRequest.add("TransactionPwd", AppLogic.AppConfig("CardinalCommerce.Centinel.TransactionPwd"));
            ccRequest.add("TransactionType", "C");             //C = Credit Card / Debit Card Authentication.
            ccRequest.add("Amount", Localization.CurrencyStringForGatewayWithoutExchangeRate(orderTotal).Replace(",", "").Replace(".", ""));
            ccRequest.add("CurrencyCode", Localization.StoreCurrencyNumericCode());
            ccRequest.add("CardNumber", cardNumber);
            ccRequest.add("CardExpMonth", cardExpirationMonth.ToString().PadLeft(2, '0'));
            ccRequest.add("CardExpYear", cardExpirationYear.ToString().PadLeft(4, '0'));
            ccRequest.add("OrderNumber", orderNumber.ToString());

            // Optional fields
            ccRequest.add("OrderDescription", orderDescription);
            ccRequest.add("UserAgent", CommonLogic.ServerVariables("HTTP_USER_AGENT"));
            ccRequest.add("Recurring", "N");

            if (numAttempts == 0)
            {
                numAttempts = 1;
            }

            for (int i = 1; i <= numAttempts; i++)
            {
                callSucceeded = true;
                try
                {
                    var URL = AppLogic.AppConfigBool("CardinalCommerce.Centinel.IsLive")
                                                ? AppLogic.AppConfig("CardinalCommerce.Centinel.TransactionUrl.Live")
                                                : AppLogic.AppConfig("CardinalCommerce.Centinel.TransactionUrl.Test");

                    ccResponse = ccRequest.sendHTTP(URL, AppLogic.AppConfigUSInt("CardinalCommerce.Centinel.MapsTimeout"));
                }
                catch
                {
                    callSucceeded = false;
                }
                if (callSucceeded)
                {
                    break;
                }
            }

            if (callSucceeded)
            {
                var errorNo  = ccResponse.getValue("ErrorNo");
                var enrolled = ccResponse.getValue("Enrolled");
                payload       = ccResponse.getValue("Payload");
                acsUrl        = ccResponse.getValue("ACSUrl");
                transactionId = ccResponse.getValue("TransactionId");

                cardinalLookupResult = ccResponse.getUnparsedResponse();

                ccRequest  = null;
                ccResponse = null;

                //======================================================================================
                // Assert that there was no error code returned and the Cardholder is enrolled in the
                // Payment Authentication Program prior to starting the Authentication process.
                //======================================================================================

                if (errorNo == "0" && enrolled == "Y")
                {
                    return(true);
                }
                return(false);
            }
            ccRequest            = null;
            ccResponse           = null;
            cardinalLookupResult = AppLogic.GetString("cardinal.cs.1", 1, Localization.GetDefaultLocale());
            return(false);
        }
Example #27
0
        /// <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);
        }
Example #28
0
        public void LoadFromDB()
        {
            var suffix = "_" + m_ProductID.ToString();

            m_ImageNumbersSplit = m_ImageNumbers.Split(',');
            var m_WatermarksEnabled = AppLogic.AppConfigBool("Watermark.Enabled");
            var urlHelper           = DependencyResolver.Current.GetService <UrlHelper>();

            m_ColorsSplit = new String[1] {
                ""
            };
            if (m_Colors == string.Empty)
            {
                using (var dbconn = new SqlConnection(DB.GetDBConn()))
                {
                    dbconn.Open();
                    using (var rs = DB.GetRS("select Colors from productvariant   with (NOLOCK)  where VariantID=" + m_VariantID.ToString(), dbconn))
                    {
                        if (rs.Read())
                        {
                            m_Colors = DB.RSFieldByLocale(rs, "Colors", Localization.GetDefaultLocale());                             // remember to add "empty" color to front, for no color selected
                            if (m_Colors.Length != 0)
                            {
                                m_ColorsSplit = ("," + m_Colors).Split(',');
                            }
                        }
                    }
                }
            }
            else
            {
                m_ColorsSplit = ("," + m_Colors).Split(',');
            }
            if (m_Colors.Length != 0)
            {
                for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++)
                {
                    String s2 = AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]);
                    m_ColorsSplit[i] = CommonLogic.MakeSafeFilesystemName(s2);
                }
            }

            if (AppLogic.AppConfigBool("MultiImage.UseProductIconPics"))
            {
                m_ImageUrlsicon = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length];
                for (int x = m_ImageNumbersSplit.GetLowerBound(0); x <= m_ImageNumbersSplit.GetUpperBound(0); x++)
                {
                    int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[x]);
                    for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++)
                    {
                        String Url = string.Empty;
                        if (m_ProductSKU == string.Empty)
                        {
                            Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "icon");
                        }
                        else
                        {
                            Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "icon");
                        }
                        if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1)
                        {
                            if (Url.StartsWith("/"))
                            {
                                m_ImageUrlsicon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length);
                            }
                            else
                            {
                                m_ImageUrlsicon[x, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1);
                            }

                            if (m_ImageUrlsicon[x, i].StartsWith("/"))
                            {
                                m_ImageUrlsicon[x, i] = m_ImageUrlsicon[x, i].TrimStart('/');
                            }
                        }
                        else
                        {
                            m_ImageUrlsicon[x, i] = Url;
                        }
                    }
                }
                for (int x = m_ImageNumbersSplit.GetLowerBound(0); x <= m_ImageNumbersSplit.GetUpperBound(0); x++)
                {
                    int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[x]);
                    if (m_ImageUrlsicon[x, 0].IndexOf("nopicture") == -1)
                    {
                        m_MaxImageIndex = ImgIdx;
                    }
                }
            }

            m_ImageUrlsmedium = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length];
            for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++)
            {
                int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]);
                for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++)
                {
                    if (m_ProductSKU == string.Empty)
                    {
                        m_ImageUrlsmedium[j, i] = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "medium");
                    }
                    else
                    {
                        m_ImageUrlsmedium[j, i] = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "medium");
                    }
                }
            }
            for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++)
            {
                int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]);
                if (m_ImageUrlsmedium[j, 0].IndexOf("nopicture") == -1)
                {
                    m_MaxImageIndex = ImgIdx;
                }
            }

            m_ImageUrlslarge = new String[m_ImageNumbersSplit.Length, m_ColorsSplit.Length];
            for (int j = m_ImageNumbersSplit.GetLowerBound(0); j <= m_ImageNumbersSplit.GetUpperBound(0); j++)
            {
                int ImgIdx = Localization.ParseUSInt(m_ImageNumbersSplit[j]);
                for (int i = m_ColorsSplit.GetLowerBound(0); i <= m_ColorsSplit.GetUpperBound(0); i++)
                {
                    String Url = string.Empty;
                    if (m_ProductSKU == string.Empty)
                    {
                        Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "large");
                    }
                    else
                    {
                        Url = AppLogic.LookupProductImageByNumberAndColor(m_ProductID, m_SkinID, m_ProductSKU, m_LocaleSetting, ImgIdx, AppLogic.RemoveAttributePriceModifier(m_ColorsSplit[i]), "large");
                    }

                    if (m_WatermarksEnabled && Url.Length != 0 && Url.IndexOf("nopicture") == -1)
                    {
                        if (Url.StartsWith("/"))
                        {
                            m_ImageUrlslarge[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length);
                        }
                        else
                        {
                            m_ImageUrlslarge[j, i] = Url.Substring(HttpContext.Current.Request.ApplicationPath.Length - 1);
                        }

                        if (m_ImageUrlslarge[j, i].StartsWith("/"))
                        {
                            m_ImageUrlslarge[j, i] = m_ImageUrlslarge[j, i].TrimStart('/');
                        }

                        m_HasSomeLarge = true;
                    }
                    else if (Url.Length == 0 || Url.IndexOf("nopicture") != -1)
                    {
                        m_ImageUrlslarge[j, i] = String.Empty;
                    }
                    else
                    {
                        m_HasSomeLarge         = true;
                        m_ImageUrlslarge[j, i] = Url;
                    }
                }
            }

            if (!IsEmpty())
            {
                StringBuilder tmpS = new StringBuilder(4096);
                tmpS.Append("<script type=\"text/javascript\">\n");
                tmpS.Append("var ProductPicIndex" + suffix + " = 1;\n");
                tmpS.Append("var ProductColor" + suffix + " = '';\n");
                tmpS.Append("var boardpics" + suffix + " = new Array();\n");
                tmpS.Append("var boardpicslg" + suffix + " = new Array();\n");
                tmpS.Append("var boardpicslgwidth" + suffix + " = new Array();\n");
                tmpS.Append("var boardpicslgheight" + suffix + " = new Array();\n");

                for (int i = 1; i <= m_MaxImageIndex; i++)
                {
                    foreach (String c in m_ColorsSplit)
                    {
                        String MdUrl            = ImageUrl(i, c, "medium").ToLowerInvariant();
                        String MdWatermarkedUrl = MdUrl;

                        if (m_WatermarksEnabled)
                        {
                            if (MdUrl.Length > 0)
                            {
                                string[] split    = MdUrl.Split('/');
                                string   lastPart = split.Last();
                                MdUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", "medium", "");
                            }
                        }

                        tmpS.Append("boardpics" + suffix + "['" + i.ToString() + "," + c + "'] = '" + MdWatermarkedUrl + "';\n");

                        String LgUrl            = ImageUrl(i, c, "large").ToLowerInvariant();
                        String LgWatermarkedUrl = LgUrl;

                        if (m_WatermarksEnabled)
                        {
                            if (LgUrl.Length > 0)
                            {
                                string[] split    = LgUrl.Split('/');
                                string   lastPart = split.Last();
                                LgUrl = AppLogic.LocateImageURL(lastPart, "PRODUCT", "large", "");
                            }
                        }

                        tmpS.Append("boardpicslg" + suffix + "['" + i.ToString() + "," + c + "'] = '" + LgWatermarkedUrl + "';\n");

                        if (LgUrl.Length > 0)
                        {
                            System.Drawing.Size lgsz = CommonLogic.GetImagePixelSize(LgUrl);
                            tmpS.Append("boardpicslgwidth" + suffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Width.ToString() + "';\n");
                            tmpS.Append("boardpicslgheight" + suffix + "['" + i.ToString() + "," + c + "'] = '" + lgsz.Height.ToString() + "';\n");
                        }
                    }
                }

                tmpS.Append("function changecolorimg" + suffix + "()\n");
                tmpS.Append("{\n");
                tmpS.Append("	var scidx = ProductPicIndex"+ suffix + " + ',' + ProductColor" + suffix + ".toLowerCase();\n");

                tmpS.Append("	document.ProductPic"+ m_ProductID.ToString() + ".src=boardpics" + suffix + "[scidx];\n");

                tmpS.Append("}\n");

                tmpS.Append("function popuplarge" + suffix + "()\n");
                tmpS.Append("{\n");
                tmpS.Append("	var scidx = ProductPicIndex"+ suffix + " + ',' + ProductColor" + suffix + ".toLowerCase();\n");
                tmpS.Append("	var LargeSrc = encodeURIComponent(boardpicslg"+ suffix + "[scidx]);\n");
                tmpS.Append("if(boardpicslg" + suffix + "[scidx] != '')\n");
                tmpS.Append("{\n");
                var popupUrl = urlHelper.Action(ActionNames.PopUp, ControllerNames.Image);
                tmpS.Append("	window.open('"+ popupUrl + "?" + RouteDataKeys.ImagePath + "=' + LargeSrc,'LargerImage" + CommonLogic.GetRandomNumber(1, 100000) + "','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",resizable=" + CommonLogic.IIF(AppLogic.AppConfigBool("ResizableLargeImagePopup"), "yes", "no") + ",copyhistory=no,width=' + boardpicslgwidth" + suffix + "[scidx] + ',height=' + boardpicslgheight" + suffix + "[scidx] + ',left=0,top=0');\n");
                tmpS.Append("}\n");
                tmpS.Append("else\n");
                tmpS.Append("{\n");
                tmpS.Append("	alert('There is no large image available for this picture');\n");
                tmpS.Append("}\n");
                tmpS.Append("}\n");

                tmpS.Append("function setcolorpicidx" + suffix + "(idx)\n");
                tmpS.Append("{\n");
                tmpS.Append("	ProductPicIndex"+ suffix + " = idx;\n");
                tmpS.Append("	changecolorimg"+ suffix + "();\n");
                tmpS.Append("}\n");

                tmpS.Append("function setActive(element)\n");
                tmpS.Append("{\n");
                tmpS.Append("	adnsf$('li.page-link').removeClass('active');\n");
                tmpS.Append("	adnsf$(element).parent().addClass('active');\n");
                tmpS.Append("}\n");

                tmpS.Append("function cleansizecoloroption" + suffix + "(theVal)\n");
                tmpS.Append("{\n");
                tmpS.Append("   if(theVal.indexOf('[') != -1){theVal = theVal.substring(0, theVal.indexOf('['))}");
                tmpS.Append("	theVal = theVal.replace(/[\\W]/g,\"\");\n");
                tmpS.Append("	theVal = theVal.toLowerCase();\n");
                tmpS.Append("	return theVal;\n");
                tmpS.Append("}\n");

                tmpS.Append("function setcolorpic" + suffix + "(color)\n");
                tmpS.Append("{\n");

                tmpS.Append("	while(color != unescape(color))\n");
                tmpS.Append("	{\n");
                tmpS.Append("		color = unescape(color);\n");
                tmpS.Append("	}\n");

                tmpS.Append("	if(color == '-,-' || color == '-')\n");
                tmpS.Append("	{\n");
                tmpS.Append("		color = '';\n");
                tmpS.Append("	}\n");

                tmpS.Append("	if(color != '' && color.indexOf(',') != -1)\n");
                tmpS.Append("	{\n");

                tmpS.Append("		color = color.substring(0,color.indexOf(',')).replace(new RegExp(\"'\", 'gi'), '');\n");                     // remove sku from color select value

                tmpS.Append("	}\n");
                tmpS.Append("	if(color != '' && color.indexOf('[') != -1)\n");
                tmpS.Append("	{\n");

                tmpS.Append("	    color = color.substring(0,color.indexOf('[')).replace(new RegExp(\"'\", 'gi'), '');\n");
                tmpS.Append("		color = color.replace(/[\\s]+$/g,\"\");\n");

                tmpS.Append("	}\n");
                tmpS.Append("	ProductColor"+ suffix + " = cleansizecoloroption" + suffix + "(color);\n");

                tmpS.Append("	changecolorimg"+ suffix + "();\n");
                tmpS.Append("	return (true);\n");
                tmpS.Append("}\n");

                tmpS.Append("</script>\n");
                m_ImgDHTML = tmpS.ToString();

                bool useMicros = AppLogic.AppConfigBool("UseImagesForMultiNav");

                bool microAction = CommonLogic.IIF(AppLogic.AppConfigBool("UseRolloverForMultiNav"), true, false);

                if (m_MaxImageIndex > 1)
                {
                    tmpS.Remove(0, tmpS.Length);

                    if (!AppLogic.AppConfigBool("MultiImage.UseProductIconPics") && !useMicros)
                    {
                        tmpS.Append("<ul class=\"pagination image-paging\">");
                        for (int i = 1; i <= m_MaxImageIndex; i++)
                        {
                            if (i == 1)
                            {
                                tmpS.Append("<li class=\"page-link active\">");
                            }
                            else
                            {
                                tmpS.Append("<li class=\"page-link\">");
                            }

                            tmpS.Append(string.Format("<a href=\"javascript:void(0);\" onclick='setcolorpicidx{0}({1});setActive(this);' class=\"page-number\">{1}</a>", suffix, i));
                            tmpS.Append("</li>");
                        }
                        tmpS.Append("</ul>");
                    }
                    else
                    {
                        tmpS.Append("<div class=\"product-gallery-items\">");
                        for (int i = 1; i <= m_MaxImageIndex; i++)
                        {
                            tmpS.Append("<div class=\"product-gallery-item\">");
                            tmpS.Append("	<div class=\"gallery-item-inner\">");

                            var imageUrl = GetImageUrl(
                                size: AppLogic.AppConfigBool("MultiImage.UseProductIconPics") ? "icon" : "micro",
                                identifier: AppLogic.AppConfigBool("UseSKUForProductImageName") ? m_ProductSKU : m_ProductID.ToString(),
                                index: i);

                            // if not using rollover to change the images
                            if (!microAction && imageUrl.Length > 0)
                            {
                                var strImageTag = string.Format("<img class='product-gallery-image' onclick='setcolorpicidx{0}({1});' alt='Show Picture {1}' src='{2}' border='0' />",
                                                                suffix,
                                                                i,
                                                                imageUrl
                                                                );
                                tmpS.Append(strImageTag);
                            }
                            else if (imageUrl.Length > 0)
                            {
                                var strImageTag = string.Format("<img class='product-gallery-image' onMouseOver='setcolorpicidx{0}({1});' alt='Show Picture {1}' src='{2}' border='0' />",
                                                                suffix,
                                                                i,
                                                                imageUrl
                                                                );
                                tmpS.Append(strImageTag);
                            }
                            tmpS.Append("	</div>");
                            tmpS.Append("</div>");
                        }
                        tmpS.Append("</div>");
                    }

                    m_ImgGalIcons = tmpS.ToString();
                }
            }
        }
Example #29
0
 public DescriptionFile(String DescriptionType, int ID, int SkinID)
     : this(DescriptionType, ID, Localization.GetDefaultLocale(), SkinID)
 {
 }
Example #30
0
        static public string PreChargeAuthenticate(int orderNumber,
                                                   string paRes,
                                                   string transactionId,
                                                   out string paResStatus,
                                                   out string signatureVerification,
                                                   out string errorNumber,
                                                   out string errorDescription,
                                                   out string cardinalAuthenticateResult)
        {
            var ccRequest     = new CardinalCommerce.CentinelRequest();
            var ccResponse    = new CardinalCommerce.CentinelResponse();
            var numAttempts   = AppLogic.AppConfigUSInt("CardinalCommerce.Centinel.NumRetries");
            var callSucceeded = false;

            errorNumber           = string.Empty;
            errorDescription      = string.Empty;
            paResStatus           = string.Empty;
            signatureVerification = string.Empty;


            if (paRes.Length == 0 || transactionId.Length == 0)
            {
                cardinalAuthenticateResult = AppLogic.GetString("cardinal.cs.3", 1, Localization.GetDefaultLocale());
                return(AppLogic.GetString("cardinal.cs.2", 1, Localization.GetDefaultLocale()));
            }
            else
            {
                // ==================================================================================
                // Construct the cmpi_authenticate message
                // ==================================================================================

                ccRequest.add("MsgType", AppLogic.AppConfig("CardinalCommerce.Centinel.MsgType.Authenticate"));                 //cmpi_authenticate
                ccRequest.add("Version", "1.7");
                ccRequest.add("ProcessorId", AppLogic.AppConfig("CardinalCommerce.Centinel.ProcessorID"));
                ccRequest.add("MerchantId", AppLogic.AppConfig("CardinalCommerce.Centinel.MerchantID"));
                ccRequest.add("TransactionType", "C");
                ccRequest.add("TransactionPwd", AppLogic.AppConfig("CardinalCommerce.Centinel.TransactionPwd"));
                ccRequest.add("TransactionId", transactionId);
                ccRequest.add("PAResPayload", HttpContext.Current.Server.HtmlEncode(paRes));

                if (numAttempts == 0)
                {
                    numAttempts = 1;
                }

                for (int i = 1; i <= numAttempts; i++)
                {
                    callSucceeded = true;
                    try
                    {
                        var URL = AppLogic.AppConfigBool("CardinalCommerce.Centinel.IsLive")
                                                        ? AppLogic.AppConfig("CardinalCommerce.Centinel.TransactionUrl.Live")
                                                        : AppLogic.AppConfig("CardinalCommerce.Centinel.TransactionUrl.Test");

                        ccResponse = ccRequest.sendHTTP(URL, AppLogic.AppConfigUSInt("CardinalCommerce.Centinel.MapsTimeout"));
                    }
                    catch
                    {
                        callSucceeded = false;
                    }
                    if (callSucceeded)
                    {
                        break;
                    }
                }

                if (callSucceeded)
                {
                    errorNumber           = ccResponse.getValue("ErrorNo");
                    errorDescription      = ccResponse.getValue("ErrorDesc");
                    paResStatus           = ccResponse.getValue("PAResStatus");
                    signatureVerification = ccResponse.getValue("SignatureVerification");

                    cardinalAuthenticateResult = ccResponse.getUnparsedResponse();
                    var response = ccResponse.getUnparsedResponse();
                    return(response);
                }

                cardinalAuthenticateResult = AppLogic.GetString("cardinal.cs.4", 1, Localization.GetDefaultLocale());
                return(AppLogic.GetString("cardinal.cs.5", 1, Localization.GetDefaultLocale()));
            }
        }