예제 #1
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 {
         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);
     }
 }
예제 #2
0
        /// <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));
        }
예제 #3
0
        /// <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);
        }
        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);
        }
예제 #5
0
        /// <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;
                }
            }
        }
예제 #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);
            }
        }
예제 #8
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 {
         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);
     }
 }
예제 #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;
        }
예제 #10
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");
                }
            }
        }
예제 #11
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>
 /// Sets the shipping general settings properties.
 /// </summary>
 private void SetShippingGeneralSettingsProperties()
 {
     lblShippingBufferCurrencySymbol.Text = SiteSettingCache.GetSiteSettings().CurrencySymbol;
 }
예제 #13
0
 /// <summary>
 /// Loads the site settings.
 /// </summary>
 private void LoadSiteSettings()
 {
     siteSettings = SiteSettingCache.GetSiteSettings();;
 }