/// <summary>
        /// Gets the product thumbnail url if enabled
        /// </summary>
        /// <param name="imageUrl">url of the product image</param>
        /// <param name="server">instance of the HttpServerUtility</param>
        /// <returns>Thumbnail url</returns>
        public static string GetProductThumbnailUrl(string imageUrl)
        {
            SiteSettings siteSettings = SiteSettingCache.GetSiteSettings();

            if (siteSettings.GenerateThumbs)
            {
                string thumbnail = imageUrl.Replace("product/", string.Format("product/thumbs/{0}x{1}_", siteSettings.ThumbSmallWidth, siteSettings.ThumbSmallHeight));
                if (File.Exists(HttpContext.Current.Server.MapPath(thumbnail)))
                {
                    return(thumbnail);
                }
                else if (File.Exists(HttpContext.Current.Server.MapPath(imageUrl))) //Thumbnails don't exist so lets generate them...
                {
                    try {
                        using (FileStream fs = File.Open(HttpContext.Current.Server.MapPath(imageUrl), FileMode.Open, FileAccess.Read, FileShare.None)) {
                            ImageProcess.ResizeAndSave(fs, Path.GetFileName(imageUrl), HttpContext.Current.Server.MapPath(@"~/repository/product/thumbs/"), siteSettings.ThumbSmallWidth, siteSettings.ThumbSmallHeight);
                        }
                    }
                    catch {
                        return(imageUrl);
                    }
                    return(thumbnail);
                }
            }
            return(imageUrl);
        }
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
         SetDefaulProperties();
         SiteSettings siteSettings = SiteSettingCache.GetSiteSettings();;
         if (siteSettings.CollectSearchTerms)
         {
             LoadSearchTerms();
         }
         if (!string.IsNullOrEmpty(siteSettings.NewsFeedUrl))
         {
             news.NewsFeedUrl = siteSettings.NewsFeedUrl;
         }
         else
         {
             string newsFeedUrl = ConfigurationManager.AppSettings["defaultNewsFeedUrl"];
             if (!string.IsNullOrEmpty(newsFeedUrl))
             {
                 if (news != null)//it's not caching
                 {
                     news.NewsFeedUrl = newsFeedUrl;
                 }
             }
         }
         if (!Page.IsPostBack)
         {
             LoadToDo();
             LoadOrders();
         }
     }
     catch (Exception ex) {
         Logger.Error(typeof(_default).Name + ".Page_Load", ex);
         Master.MessageCenter.DisplayCriticalMessage(ex.Message);
     }
 }
        /// <summary>
        /// Gets the formatted date.
        /// </summary>
        /// <param name="date">The date.</param>
        /// <returns></returns>
        public static string GetFormattedDate(DateTime date)
        {
            SiteSettings siteSettings = SiteSettingCache.GetSiteSettings();
            CultureInfo  cultureInfo  = new CultureInfo(siteSettings.Language);

            return(date.ToString("D", cultureInfo));
        }
        public PayPalProPaymentProvider(string apiUserName, string apiPassword, string signature, string businessEmail, string isLive)
        {
            //Validator.ValidateStringArgumentIsNotNullOrEmptyString(apiUserName, API_USERNAME);
            //Validator.ValidateStringArgumentIsNotNullOrEmptyString(apiPassword, API_PASSWORD);
            //Validator.ValidateStringArgumentIsNotNullOrEmptyString(signature, SIGNATURE);
            Validator.ValidateStringArgumentIsNotNullOrEmptyString(isLive, ISLIVE);

            bool         IsLive       = false; //default to the sandbox
            bool         isParsed     = bool.TryParse(isLive, out IsLive);
            SiteSettings siteSettings = SiteSettingCache.GetSiteSettings();

            _payPalService = new PayPal.PayPalService(IsLive, apiUserName, apiPassword, signature, businessEmail, siteSettings.CurrencyCode);
        }
        /// <summary>
        /// Gets the formatted amount.
        /// </summary>
        /// <param name="amount">The amount.</param>
        /// <param name="formatWithCurrencySymbol">if set to <c>true</c> [format with currency symbol].</param>
        /// <returns></returns>
        public static string GetFormattedAmount(decimal amount, bool formatWithCurrencySymbol)
        {
            SiteSettings siteSettings = SiteSettingCache.GetSiteSettings();
            CultureInfo  cultureInfo  = new CultureInfo(siteSettings.Language);

            if (formatWithCurrencySymbol)
            {
                return(string.Format("{0} {1}", siteSettings.CurrencySymbol, decimal.Round(amount, cultureInfo.NumberFormat.CurrencyDecimalDigits).ToString(cultureInfo)));
            }
            else
            {
                return(decimal.Round(amount, cultureInfo.NumberFormat.CurrencyDecimalDigits).ToString(cultureInfo));
            }
        }
        /// <summary>
        /// Gets the inventory.
        /// </summary>
        /// <param name="skuId">The sku id.</param>
        public void GetInventory(string skuId)
        {
            if (ThisPage.Product.AllowNegativeInventories)
            {
                ThisPage.AddToCart.Enabled = true;
            }
            else
            {
                Sku sku = ProductCache.GetSKU(skuId);
                if (sku.SkuId > 0 && sku.Inventory > 0)
                {
                    string previouslySelectedValue = ThisPage.Quantity.SelectedValue;
                    ThisPage.AddToCart.Enabled = true;
                    ThisPage.Quantity.Enabled  = true;
                    ThisPage.Quantity.Items.Clear();

                    if (sku.Inventory < SiteSettingCache.GetSiteSettings().MaxProductsAddToCart)
                    {
                        for (int i = 1; i <= sku.Inventory; i++)
                        {
                            ThisPage.Quantity.Items.Add(new ListItem(i.ToString(), i.ToString()));
                        }
                    }
                    else
                    {
                        for (int i = 1; i <= SiteSettingCache.GetSiteSettings().MaxProductsAddToCart; i++)
                        {
                            ThisPage.Quantity.Items.Add(new ListItem(i.ToString(), i.ToString()));
                        }
                    }

                    //If they selected a quantity and the quantity is valid for the new selection then keep it selected
                    //Otherwise, select the first one.
                    if (ThisPage.Quantity.Items.FindByValue(previouslySelectedValue) != null)
                    {
                        ThisPage.Quantity.SelectedValue = previouslySelectedValue;
                    }
                    else
                    {
                        ThisPage.Quantity.SelectedIndex = 0;
                    }
                }
                else
                {
                    ThisPage.Quantity.Enabled  = false;
                    ThisPage.AddToCart.Enabled = false;
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
                productId = Utility.GetIntParameter("productId");
                view      = Utility.GetParameter("view");
                if (view == "g")
                {
                    SetGeneralProperties();
                    SiteSettings siteSettings = SiteSettingCache.GetSiteSettings();
                    if (productId > 0)
                    {
                        product = new Product(productId);
                    }
                    else
                    {
                        product = new Product();
                    }

                    if (!Page.IsPostBack)
                    {
                        LoadManufacturer();
                        LoadProductStatus();
                        LoadProductType();
                        LoadShippingEstimate();
                        LoadTaxRates();
                        txtBaseSku.Text                   = product.BaseSku;
                        txtName.Text                      = product.Name;
                        txtShortDescription.Value         = HttpUtility.HtmlDecode(product.ShortDescription);
                        txtOurPrice.Text                  = StoreUtility.GetFormattedAmount(product.OurPrice, false);
                        txtRetailPrice.Text               = StoreUtility.GetFormattedAmount(product.RetailPrice, false);
                        ddlManufacturer.SelectedValue     = product.ManufacturerId.ToString();
                        ddlStatus.SelectedValue           = product.ProductStatusDescriptorId.ToString();
                        ddlTaxRate.SelectedValue          = product.TaxRateId.ToString();
                        ddlProductType.SelectedValue      = product.ProductTypeId.ToString();
                        ddlShippingEstimate.SelectedValue = product.ShippingEstimateId.ToString();
                        txtWeight.Text                    = product.Weight.ToString();
                        txtLength.Text                    = product.Length.ToString();
                        txtHeight.Text                    = product.Height.ToString();
                        txtWidth.Text                     = product.Width.ToString();
                    }
                    lblOurPriceCurrencySymbol.Text    = siteSettings.CurrencySymbol;
                    lblRetailPriceCurrencySymbol.Text = siteSettings.CurrencySymbol;
                }
            }
            catch (Exception ex) {
                Logger.Error(typeof(general).Name + ".Page_Load", ex);
                base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
            }
        }
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
         SiteSettings siteSettings = SiteSettingCache.GetSiteSettings();
         cultureInfo = new CultureInfo(siteSettings.Language);
         SetAttributeEditProperties();
         LoadAttributes();
         if (!Page.IsPostBack)
         {
             LoadAttributeTypes();
         }
     }
     catch (Exception ex) {
         Logger.Error(typeof(attributeedit).Name + ".Page_Load", ex);
         Master.MessageCenter.DisplayCriticalMessage(ex.Message);
     }
 }
Beispiel #9
0
        /// <summary>
        /// Handles the PreRequestHandlerExecute event of the Application control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
        {
            SiteSettings siteSettings = null;

            try {
                siteSettings = SiteSettingCache.GetSiteSettings();
            }
            catch (Exception) {
                //swallow it - probably no connection string during install
            }

            string cultureName = ""; //default this. TODO: Get this into installer?

            if (siteSettings != null)
            {
                cultureName = siteSettings.Language ?? cultureName;
            }
            System.Threading.Thread.CurrentThread.CurrentCulture   = System.Globalization.CultureInfo.CreateSpecificCulture(cultureName);
            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
        }
 /// <summary>
 /// Saves the specified site settings.
 /// </summary>
 /// <param name="siteSettings">The site settings.</param>
 public void Save(SiteSettings siteSettings)
 {
     try {
         DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
         int id = databaseConfigurationProvider.SaveConfiguration(SiteSettings.SECTION_NAME, siteSettings, WebUtility.GetUserName());
         SiteSettingCache.RemoveSiteSettingsFromCache();
         if (id > 0)
         {
             MasterPage.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblSiteSettingsSaved"));
         }
         else
         {
             MasterPage.MessageCenter.DisplayFailureMessage(LocalizationUtility.GetText("lblSiteSettingsNotSaved"));
         }
     }
     catch (Exception ex) {
         Logger.Error("Save", ex);
         MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
     }
 }
Beispiel #11
0
        /// <summary>
        /// Handles the PostAuthenticateRequest event of the context control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void context_PostAuthenticateRequest(object sender, EventArgs e)
        {
            HttpContext  context      = ((HttpApplication)sender).Context;
            SiteSettings siteSettings = null;

            try {
                siteSettings = SiteSettingCache.GetSiteSettings();
            }
            catch (Exception) {
                //swallow it - probably no connection string during install
            }
            if (siteSettings != null)
            {
                if (siteSettings.IsStoreClosed && !context.User.IsInRole("Administrator") &&
                    !context.Request.Url.ToString().Contains("login.aspx"))
                {
                    context.RewritePath("~/storeclosed.aspx");
                }
            }
        }
 /// <summary>
 /// Handles the Click event of the btnSave control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try {
         PaymentServiceSettings paymentServiceSettings = new PaymentServiceSettings();
         ProviderSettings       settings = new ProviderSettings();
         settings.Name = typeof(PayPalProPaymentProvider).Name;
         settings.Type = typeof(PayPalProPaymentProvider).AssemblyQualifiedName;
         settings.Parameters.Add("ApiUserName", "username");
         settings.Parameters.Add("ApiPassword", "password");
         settings.Parameters.Add("Signature", "signature");
         settings.Parameters.Add("IsLive", "false");
         paymentServiceSettings.ProviderSettingsCollection.Add(settings);
         DatabaseConfigurationProvider config = new DatabaseConfigurationProvider();
         config.SaveConfiguration(PaymentServiceSettings.SECTION_NAME, paymentServiceSettings, WebUtility.GetUserName());
         SiteSettingCache.RemoveSiteSettingsFromCache();
     }
     catch (Exception ex) {
         Logger.Error(typeof(paymentserviceconfiguration).Name + ".Page_Load", ex);
         Master.MessageCenter.DisplayCriticalMessage(ex.Message);
     }
 }
Beispiel #13
0
        /// <summary>
        /// Replaces the constants in notification.
        /// </summary>
        /// <param name="order">The order.</param>
        /// <param name="notificationBody">The notification body.</param>
        /// <param name="notification">The notification.</param>
        /// <returns></returns>
        private string ReplaceConstantsInNotification(Order order, string notificationBody, Notification notification)
        {
            //#NAME#
            if (order.BillingAddress != null)
            {
                notificationBody = notificationBody.Replace("#NAME#", order.BillingAddress.FirstName + " " + order.BillingAddress.LastName);
            }

            //#ORDERNUMBER#
            notificationBody = notificationBody.Replace("#ORDERNUMBER#", order.OrderNumber);

            //#ORDERDATE#
            notificationBody = notificationBody.Replace("#ORDERDATE#", order.TransactionCollection[0].TransactionDate.ToShortDateString());

            //#DATE#
            notificationBody = notificationBody.Replace("#DATE#", DateTime.UtcNow.ToShortDateString());

            //#TRACKINGNUMBER#
            notificationBody = notificationBody.Replace("#TRACKINGNUMBER#", order.ShippingTrackingNumber);

            //#ORDER#
            notificationBody = notificationBody.Replace("#ORDER#", order.ToHtml());

            //#TAGLINE#
            SiteSettings siteSettings = SiteSettingCache.GetSiteSettings();;

            notificationBody = notificationBody.Replace("#TAGLINE#", siteSettings.TagLine);

            //#ADMINPRODUCTLINK#
            notificationBody = notificationBody.Replace("#ADMINPRODUCTLINK#", Utility.GetSiteRoot() + "/admin/orders.aspx?oid=" + order.OrderId);

            //#SITELINK#
            notificationBody = notificationBody.Replace("#SITELINK#", Utility.GetSiteRoot());

            //#STOREEMAIL#
            notificationBody = notificationBody.Replace("#STOREEMAIL#", "<a href='mailto:" + notification.FromEmail + "'>" + notification.FromEmail + "</a>");

            return(notificationBody);
        }
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try {
                mailSettings.Contact = txtEmail.Text.Trim();

                DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
                int id = databaseConfigurationProvider.SaveConfiguration(MailSettings.SECTION_NAME, mailSettings, WebUtility.GetUserName());
                SiteSettingCache.RemoveSiteSettingsFromCache();
                if (id > 0)
                {
                    Master.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblMailSettingsSaved"));
                }
                else
                {
                    Master.MessageCenter.DisplayFailureMessage(LocalizationUtility.GetText("lblMailSettingsNotSaved"));
                }
            }
            catch (Exception ex) {
                Logger.Error(typeof(mailconfiguration).Name + ".btnSave_Click", ex);
                Master.MessageCenter.DisplayCriticalMessage(ex.Message);
            }
        }
 /// <summary>
 /// Sets the shipping general settings properties.
 /// </summary>
 private void SetShippingGeneralSettingsProperties()
 {
     lblShippingBufferCurrencySymbol.Text = SiteSettingCache.GetSiteSettings().CurrencySymbol;
 }
 /// <summary>
 /// Loads the site settings.
 /// </summary>
 private void LoadSiteSettings()
 {
     siteSettings = SiteSettingCache.GetSiteSettings();;
 }