/// <summary> /// Select Primary Address /// </summary> /// <param name="addressID">addressID</param> private void SelectPrimaryAddress(int addressID) { int addressType = GetAddressType(Request.QueryString["AddressType"]); if (addressType == (int)AddressTypes.Billing) { ThisCustomer.UpdateCustomer(new SqlParameter[] { new SqlParameter("BillingAddressID", addressID) }); } else if (addressType == (int)AddressTypes.Shipping) { ThisCustomer.UpdateCustomer(new SqlParameter[] { new SqlParameter("ShippingAddressID", addressID) }); } LoadAddresses(addressType); }
protected override void OnPreInit(EventArgs e) { if (HttpContext.Current != null) { //Have to call GetPropertyValue once before you actually need it to initialize the PropertyValues collection HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString(); #region SkinID //If it's mobile, bypass all the rest if (!AppLogic.IsAdminSite && MobileHelper.isMobile()) { MobileHelper.SetCustomerToMobileSkinId(ThisCustomer); SkinID = ThisCustomer.SkinID; } else { //SkinId querystring overrides everything but mobile if (CommonLogic.QueryStringUSInt("skinid") > 0) { SkinID = CommonLogic.QueryStringUSInt("skinid"); //Customer has a querystring so save this to the profile. if (HttpContext.Current.Profile != null) { HttpContext.Current.Profile.SetPropertyValue("SkinID", this.SkinID.ToString()); } } //Check to see if we are previewing the skin else if (CommonLogic.QueryStringUSInt("previewskinid") > 0) { SkinID = CommonLogic.QueryStringUSInt("previewskinid"); //Customer has a preview querystring so save this to the profile. if (HttpContext.Current.Profile != null) { HttpContext.Current.Profile.SetPropertyValue("PreviewSkinID", this.SkinID.ToString()); } } //Use the preview profile value if we have one else if (HttpContext.Current.Profile != null && HttpContext.Current.Profile.PropertyValues["PreviewSkinID"] != null && CommonLogic.IsInteger(HttpContext.Current.Profile.GetPropertyValue("PreviewSkinID").ToString())) { int skinFromProfile = int.Parse(HttpContext.Current.Profile.GetPropertyValue("PreviewSkinID").ToString()); if (skinFromProfile > 0) { SkinID = skinFromProfile; } } //Pull the skinid from the current profile else if (HttpContext.Current.Profile != null && CommonLogic.IsInteger(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString())) { int skinFromProfile = int.Parse(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString()); if (skinFromProfile > 0) { SkinID = skinFromProfile; } } } //Now save the skinID to the customer record. This is not used OOB. if (ThisCustomer.SkinID != this.SkinID) { ThisCustomer.SkinID = this.SkinID; ThisCustomer.UpdateCustomer(new SqlParameter[] { new SqlParameter("SkinID", this.SkinID) }); } #endregion if (CommonLogic.QueryStringUSInt("affiliateid") > 0) { HttpContext.Current.Profile.SetPropertyValue("AffiliateID", CommonLogic.QueryStringUSInt("affiliateid").ToString()); } if (HttpContext.Current.Request.UrlReferrer != null && HttpContext.Current.Request.UrlReferrer.Authority != HttpContext.Current.Request.Url.Authority) { HttpContext.Current.Profile.SetPropertyValue("Referrer", HttpContext.Current.Request.UrlReferrer.ToString()); } // don't fire disclaimer logic on admin pages if (!AppLogic.IsAdminSite && CommonLogic.QueryStringCanBeDangerousContent("ReturnURL").IndexOf(AppLogic.AppConfig("AdminDir")) == -1 && (AppLogic.AppConfigBool("SiteDisclaimerRequired") && CommonLogic.CookieCanBeDangerousContent("SiteDisclaimerAccepted", true).Length == 0)) { String ThisPageURL = CommonLogic.GetThisPageName(true) + "?" + CommonLogic.ServerVariables("QUERY_STRING"); Response.Redirect("disclaimer.aspx?returnURL=" + Server.UrlEncode(ThisPageURL)); } #region Impersonation bool IGDQueryClear = false; m_IGD = CommonLogic.QueryStringCanBeDangerousContent("IGD").Trim(); if (m_IGD.Length == 0 && CommonLogic.ServerVariables("QUERY_STRING").IndexOf("IGD=") != -1) { m_IGD = String.Empty; // there was IGD={blank} in the query string, so forcefully clear IGD! IGDQueryClear = true; } bool IsStartOfImpersonation = m_IGD.Length != 0; // the url invocation starts the impersonation only! if (!IGDQueryClear && m_IGD.Length == 0) { if (ThisCustomer.IsAdminUser) { // pull out the impersonation IGD from the customer session, if any m_IGD = ThisCustomer.ThisCustomerSession["IGD"]; } } if (IGDQueryClear) { // forcefully clear any IGD for this customer, just to be safe! ThisCustomer.ThisCustomerSession["IGD"] = ""; ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = ""; } Customer PhoneCustomer = null; if (m_IGD.Length != 0) { if (ThisCustomer.IsAdminUser) { try { Guid IGD = new Guid(m_IGD); PhoneCustomer = new Customer(IGD); PhoneCustomer.IsImpersonated = true; } catch { ThisCustomer.ThisCustomerSession["IGD"] = ""; ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = ""; m_IGD = string.Empty; } } if (PhoneCustomer != null && PhoneCustomer.HasCustomerRecord) { int ImpersonationTimeoutInMinutes = AppLogic.AppConfigUSInt("ImpersonationTimeoutInMinutes"); if (ImpersonationTimeoutInMinutes == 0) { ImpersonationTimeoutInMinutes = 20; } if (PhoneCustomer.ThisCustomerSession.LastActivity >= DateTime.Now.AddMinutes(-ImpersonationTimeoutInMinutes)) { ThisCustomer.ThisCustomerSession["IGD"] = IGD; m_AdminCustomer = ThisCustomer; // save the owning admin user doing the impersonation here ThisCustomer = PhoneCustomer; // build the impersonation customer the phone order customer bool IsAdmin = CommonLogic.ApplicationBool("IsAdminSite"); if (!HttpContext.Current.Items.Contains("IsBeingImpersonated")) { HttpContext.Current.Items.Add("IsBeingImpersonated", "true"); } } else { if (HttpContext.Current.Items.Contains("IsBeingImpersonated")) { HttpContext.Current.Items["IsBeingImpersonated"] = "false"; } ThisCustomer.ThisCustomerSession["IGD"] = ""; ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = ""; m_IGD = string.Empty; //Response.Redirect("t-phoneordertimeout.aspx"); Response.Redirect(SE.MakeDriverLink("phoneordertimeout")); } } } #endregion Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Localization.GetDefaultLocale()); Thread.CurrentThread.CurrentUICulture = new CultureInfo(ThisCustomer.LocaleSetting); m_TemplateName = GetTemplateName(); if (!AppLogic.IsAdminSite) { ThisCustomer = MobileRedirectController.SkinBaseHook(SkinID, ThisCustomer); if (SkinID == Vortx.Data.Config.MobilePlatform.SkinId && MobileHelper.isMobile()) { m_TemplateName = "template.master"; } } //needs to come after the mobile check m_Parser = new Parser(m_EntityHelpers, SkinID, ThisCustomer); String SkinDirectory = String.Empty; String PageTheme = String.Empty; SkinDirectory = "Skin_" + this.SkinID.ToString(); PageTheme = "Skin_" + this.SkinID.ToString(); if (!m_TemplateName.EndsWith(".master", StringComparison.OrdinalIgnoreCase)) { m_TemplateName = m_TemplateName + ".master"; } this.MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName; this.Theme = PageTheme; if (!CommonLogic.FileExists(this.MasterPageFile)) { this.SkinID = AppLogic.DefaultSkinID(); m_TemplateName = "template.master"; SkinDirectory = "Skin_" + this.SkinID.ToString(); PageTheme = "Skin_" + this.SkinID.ToString(); this.MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName; this.Theme = PageTheme; } } base.OnPreInit(e); }
public void ProcessCart(bool DoingFullCheckout, bool ForceOnePageCheckout, bool InternationalCheckout) { Response.CacheControl = "private"; Response.Expires = 0; Response.AddHeader("pragma", "no-cache"); ThisCustomer.RequireCustomerRecord(); CartTypeEnum cte = CartTypeEnum.ShoppingCart; if (CommonLogic.QueryStringCanBeDangerousContent("CartType").Length != 0) { cte = (CartTypeEnum)CommonLogic.QueryStringUSInt("CartType"); } cart = new ShoppingCart(1, ThisCustomer, cte, 0, false); if (cart.InventoryTrimmed || this.InventoryTrimmed) { HandleInventoryTrimmed(); return; //Bail and warn the customer that their cart changed before putting them into checkout } if (cart.IsEmpty()) { cart.ClearCoupon(); // can't have this at this point: switch (cte) { case CartTypeEnum.ShoppingCart: Response.Redirect("shoppingcart.aspx"); break; case CartTypeEnum.WishCart: Response.Redirect("wishlist.aspx"); break; case CartTypeEnum.GiftRegistryCart: Response.Redirect("giftregistry.aspx"); break; default: Response.Redirect("shoppingcart.aspx"); break; } } // update cart quantities: UpdateCartQuantity(); // save coupon code, no need to reload cart object // will update customer record also: if (cte == CartTypeEnum.ShoppingCart) { cart.SetCoupon(CouponCode.Text, true); // kind of backwards, but if DisallowOrderNotes is false, then // allow order notes if (!AppLogic.AppConfigBool("DisallowOrderNotes")) { if (OrderNotes.Text.Trim().Length > 0) { SqlParameter sp = new SqlParameter("@OrderNotes", SqlDbType.NText); sp.Value = OrderNotes.Text.Trim(); SqlParameter[] spa = { sp }; ThisCustomer.UpdateCustomer(spa); } } // rebind the cart summary control to handle coupon ctrlCartSummary.DataSource = cart; // check for upsell products if (CommonLogic.FormCanBeDangerousContent("Upsell").Length != 0) { foreach (String s in CommonLogic.FormCanBeDangerousContent("Upsell").Split(',')) { int ProductID = Localization.ParseUSInt(s); if (ProductID != 0) { int VariantID = AppLogic.GetProductsDefaultVariantID(ProductID); if (VariantID != 0) { int NewRecID = cart.AddItem(ThisCustomer, ThisCustomer.PrimaryShippingAddressID, ProductID, VariantID, 1, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, CartTypeEnum.ShoppingCart, true, false, 0, System.Decimal.Zero); Decimal PR = AppLogic.GetUpsellProductPrice(0, ProductID, ThisCustomer.CustomerLevelID); SqlParameter[] spa = { DB.CreateSQLParameter("@Price", SqlDbType.Decimal, 10, PR, ParameterDirection.Input), DB.CreateSQLParameter("@CartRecID", SqlDbType.Int, 4, NewRecID, ParameterDirection.Input) }; DB.ExecuteSQL("update shoppingcart set IsUpsell=1, ProductPrice=@Price where ShoppingCartRecID=@CartRecID", spa); } } } } if (cart.CheckInventory(ThisCustomer.CustomerID)) { ErrorMsgLabel.Text += Server.HtmlEncode(AppLogic.GetString("shoppingcart_process.aspx.1", SkinID, ThisCustomer.LocaleSetting)); // inventory got adjusted, send them back to the cart page to confirm the new values! } } if (cte == CartTypeEnum.WishCart) { Response.Redirect("wishlist.aspx"); } if (cte == CartTypeEnum.GiftRegistryCart) { Response.Redirect("giftregistry.aspx"); } cart.ClearShippingOptions(); if (DoingFullCheckout) { bool validated = cart.MeetsMinimumOrderAmount(AppLogic.AppConfigUSDecimal("CartMinOrderAmount")) && cart.MeetsMinimumOrderQuantity(AppLogic.AppConfigUSInt("MinCartItemsBeforeCheckout")) && !cart.ExceedsMaximumOrderQuantity(AppLogic.AppConfigUSInt("MaxCartItemsBeforeCheckout")) && (!cart.HasCoupon() || cart.CouponIsValid); if (validated) { AppLogic.eventHandler("BeginCheckout").CallEvent("&BeginCheckout=true"); if (InternationalCheckout) { Response.Redirect("internationalcheckout.aspx"); } if ((ThisCustomer.IsRegistered || ThisCustomer.EMail.Length != 0) && (ThisCustomer.Password.Length == 0 || ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0 || !ThisCustomer.HasAtLeastOneAddress())) { Response.Redirect("createaccount.aspx?checkout=true"); } if (!ThisCustomer.IsRegistered || ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0 || !ThisCustomer.HasAtLeastOneAddress()) { Response.Redirect("createaccount.aspx?checkout=true"); } else { if (AppLogic.AppConfigBool("SkipShippingOnCheckout") || cart.IsAllSystemComponents() || cart.IsAllDownloadComponents()) { if (cart.ContainsGiftCard()) { Response.Redirect("checkoutgiftcard.aspx"); } else { Response.Redirect("checkoutpayment.aspx"); } } if ((cart.HasMultipleShippingAddresses() || cart.HasGiftRegistryComponents()) && cart.TotalQuantity() <= AppLogic.MultiShipMaxNumItemsAllowed() && cart.CartAllowsShippingMethodSelection) { Response.Redirect("checkoutshippingmult.aspx"); } else { Response.Redirect("checkoutshipping.aspx"); } } } InitializePageContent(); } //Make sure promotions is updated when the cart changes BindPromotions(); }
public void btnUpdateAccount_Click(object sender, EventArgs e) { ctrlAccount.PasswordValidate = ctrlAccount.Password; ctrlAccount.PasswordConfirmValidate = ctrlAccount.PasswordConfirm; ctrlAccount.Over13 = ctrlAccount.Over13; lblErrorMessage.Text = String.Empty; pnlErrorMsg.Visible = false; Page.Validate("account"); if (Page.IsValid) { String EMailField = ctrlAccount.Email.ToLowerInvariant().Trim(); NewEmailAddressAllowed = Customer.NewEmailPassesDuplicationRules(EMailField, ThisCustomer.CustomerID, false); bool emailisvalid = new EmailAddressValidator().IsValidEmailAddress(EMailField); if (!emailisvalid) { lblAcctUpdateMsg.Text = AppLogic.GetString("createaccount.aspx.17", SkinID, ThisCustomer.LocaleSetting); } if (!NewEmailAddressAllowed || !emailisvalid) { EMailField = ThisCustomer.EMail; // preserve the old email but go ahead and update their account with other changes below } string pwd = null; object saltkey = null; if (ctrlAccount.Password.Trim().Length > 0) { Password p = new Password(ctrlAccount.Password); pwd = p.SaltedPassword; saltkey = p.Salt; } bool HasActiveRecurring = ThisCustomer.HasActiveRecurringOrders(true); ctrlAccount.ShowSaveCCNote = false; if (!ctrlAccount.SaveCC && (HasActiveRecurring && !AppLogic.AppConfigBool("Recurring.UseGatewayInternalBilling"))) { ctrlAccount.SaveCC = true; ctrlAccount.ShowSaveCCNote = true; } String vtr = ctrlAccount.VATRegistrationID; if (!AppLogic.AppConfigBool("VAT.Enabled")) { vtr = null; ctrlAccount.ShowVATRegistrationIDInvalid = false; ctrlAccount.VATRegistrationID = String.Empty; } else { Exception vatServiceException; Boolean vatIsValid = AppLogic.VATRegistrationIDIsValid(ThisCustomer, vtr, out vatServiceException); if (ctrlAccount.VATRegistrationID.Length == 0 || vatIsValid) { ctrlAccount.ShowVATRegistrationIDInvalid = false; } else { if (vatServiceException != null && vatServiceException.Message.Length > 0) { if (vatServiceException.Message.Length > 255) { lblErrorMessage.Text = Server.HtmlEncode(vatServiceException.Message.Substring(0, 255)); } else { lblErrorMessage.Text = Server.HtmlEncode(vatServiceException.Message); } } else { lblErrorMessage.Text = "account.aspx.91".StringResource(); } pnlErrorMsg.Visible = lblErrorMessage.Text.Length > 0; vtr = null; ctrlAccount.ShowVATRegistrationIDInvalid = true; ctrlAccount.VATRegistrationID = String.Empty; } } string strDOB = null; if (AppLogic.AppConfigBool("Account.ShowBirthDateField")) { strDOB = ctrlAccount.DOBMonth + "/" + ctrlAccount.DOBDay + "/" + ctrlAccount.DOBYear; } ThisCustomer.UpdateCustomer( /*CustomerLevelID*/ null, /*EMail*/ EMailField, /*SaltedAndHashedPassword*/ pwd, /*SaltKey*/ saltkey, /*DateOfBirth*/ strDOB, /*Gender*/ null, /*FirstName*/ ctrlAccount.FirstName, /*LastName*/ ctrlAccount.LastName, /*Notes*/ null, /*SkinID*/ null, /*Phone*/ ctrlAccount.Phone, /*AffiliateID*/ null, /*Referrer*/ null, /*CouponCode*/ null, /*OkToEmail*/ CommonLogic.IIF(ctrlAccount.OKToEmailYes, 1, 0), /*IsAdmin*/ null, /*BillingEqualsShipping*/ null, /*LastIPAddress*/ null, /*OrderNotes*/ null, /*SubscriptionExpiresOn*/ null, /*RTShipRequest*/ null, /*RTShipResponse*/ null, /*OrderOptions*/ null, /*LocaleSetting*/ null, /*MicroPayBalance*/ null, /*RecurringShippingMethodID*/ null, /*RecurringShippingMethod*/ null, /*BillingAddressID*/ null, /*ShippingAddressID*/ null, /*GiftRegistryGUID*/ null, /*GiftRegistryIsAnonymous*/ null, /*GiftRegistryAllowSearchByOthers*/ null, /*GiftRegistryNickName*/ null, /*GiftRegistryHideShippingAddresses*/ null, /*CODCompanyCheckAllowed*/ null, /*CODNet30Allowed*/ null, /*ExtensionData*/ null, /*FinalizationData*/ null, /*Deleted*/ null, /*Over13Checked*/ CommonLogic.IIF(ctrlAccount.Over13, 1, 0), /*CurrencySetting*/ null, /*VATSetting*/ null, /*VATRegistrationID*/ vtr, /*StoreCCInDB*/ CommonLogic.IIF(ctrlAccount.SaveCC, 1, 0), /*IsRegistered*/ null, /*LockedUntil*/ null, /*AdminCanViewCC*/ null, /*BadLogin*/ null, /*Active*/ null, /*PwdChangeRequired*/ null, /*RegisterDate*/ null, /*StoreId*/ null ); AccountUpdated = true; } RefreshPage(); }
private void CreateAccount() { SetPasswordFields(); string AccountName = (ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim()).Trim(); if (SkipRegistration) { Page.Validate("skipreg"); } else { if (ctrlAccount.Password.Contains('\xFF') || ctrlAccount.Password.Length == 0) { ctrlAccount.PasswordValidate = ViewState["custpwd"].ToString(); } else { ctrlAccount.PasswordValidate = ctrlAccount.Password; } if (ctrlAccount.PasswordConfirm.Contains('\xFF') || ctrlAccount.PasswordConfirm.Length == 0) { ctrlAccount.PasswordConfirmValidate = ViewState["custpwd2"].ToString(); } else { ctrlAccount.PasswordConfirmValidate = ctrlAccount.PasswordConfirm; } ctrlAccount.Over13 = ctrlAccount.Over13; if ((!ThisCustomer.IsRegistered) && (ctrlAccount.Password.Length == 0 || ctrlAccount.PasswordConfirm.Length == 0)) { ErrorMsgLabel.Text = "createaccount.aspx.6".StringResource(); ResetScrollPosition(); return; } Page.Validate("registration"); if (RequireSecurityCode) { if (Session["SecurityCode"] != null) { String sCode = Session["SecurityCode"].ToString(); String fCode = ctrlAccount.txtSecurityCode.Text; Boolean codeMatch = false; if (AppLogic.AppConfigBool("Captcha.CaseSensitive")) { if (fCode.Equals(sCode)) { codeMatch = true; } } else { if (fCode.Equals(sCode, StringComparison.InvariantCultureIgnoreCase)) { codeMatch = true; } } if (!codeMatch) { ErrorMsgLabel.Text = string.Format(AppLogic.GetString("lat_signin_process.aspx.5", SkinID, ThisCustomer.LocaleSetting), sCode, fCode); ctrlAccount.txtSecurityCode.Text = String.Empty; ctrlAccount.imgAccountSecurityImage.ImageUrl = "~/Captcha.ashx?id=1"; ResetScrollPosition(); return; } } else { ErrorMsgLabel.Text = string.Format(AppLogic.GetString("lat_signin_process.aspx.5", SkinID, ThisCustomer.LocaleSetting), "", ctrlAccount.txtSecurityCode.Text); ctrlAccount.txtSecurityCode.Text = String.Empty; ctrlAccount.imgAccountSecurityImage.ImageUrl = "~/Captcha.ashx?id=1"; ResetScrollPosition(); return; } } if (!Page.IsValid && RequireSecurityCode) { Session["SecurityCode"] = CommonLogic.GenerateRandomCode(6); } } //ctrlBillingAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlBillingAddress.Country); //ctrlShippingAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlBillingAddress.Country); Page.Validate("createacccount"); if (Page.IsValid && AccountName.Length > 0) { //String EMailField = CommonLogic.IIF(SkipRegistration, txtSkipRegEmail.Text.ToLowerInvariant().Trim(), ctrlAccount.Email.ToLowerInvariant().Trim()); String EMailField = ctrlAccount.Email.ToLowerInvariant().Trim(); bool NewEmailAllowed = Customer.NewEmailPassesDuplicationRules(EMailField, ThisCustomer.CustomerID, false); String PWD = ViewState["custpwd"].ToString(); Password p = new Password(PWD); String newpwd = p.SaltedPassword; System.Nullable <int> newsaltkey = p.Salt; Password blankpwd = new Password("", ThisCustomer.SaltKey); if (!(ThisCustomer.Password == "" || ThisCustomer.Password == blankpwd.SaltedPassword)) { // do NOT allow passwords to be changed on this page. this is only for creating an account. // if they want to change their password, they must use their account page newpwd = null; newsaltkey = null; } if (NewEmailAllowed) { AppLogic.eventHandler("CreateAccount").CallEvent("&CreateAccount=true"); ThisCustomer.UpdateCustomer( /*CustomerLevelID*/ null, /*EMail*/ EMailField, /*SaltedAndHashedPassword*/ newpwd, /*SaltKey*/ newsaltkey, /*DateOfBirth*/ null, /*Gender*/ null, /*FirstName*/ ctrlAccount.FirstName, /*LastName*/ ctrlAccount.LastName, /*Notes*/ null, /*SkinID*/ null, /*Phone*/ ctrlAccount.Phone, /*AffiliateID*/ null, /*Referrer*/ null, /*CouponCode*/ null, /*OkToEmail*/ CommonLogic.IIF(ctrlAccount.OKToEmailYes, 1, 0), /*IsAdmin*/ null, /*BillingEqualsShipping*/ CommonLogic.IIF(AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo"), 0, 1), /*LastIPAddress*/ null, /*OrderNotes*/ null, /*SubscriptionExpiresOn*/ null, /*RTShipRequest*/ null, /*RTShipResponse*/ null, /*OrderOptions*/ null, /*LocaleSetting*/ null, /*MicroPayBalance*/ null, /*RecurringShippingMethodID*/ null, /*RecurringShippingMethod*/ null, /*BillingAddressID*/ null, /*ShippingAddressID*/ null, /*GiftRegistryGUID*/ null, /*GiftRegistryIsAnonymous*/ null, /*GiftRegistryAllowSearchByOthers*/ null, /*GiftRegistryNickName*/ null, /*GiftRegistryHideShippingAddresses*/ null, /*CODCompanyCheckAllowed*/ null, /*CODNet30Allowed*/ null, /*ExtensionData*/ null, /*FinalizationData*/ null, /*Deleted*/ null, /*Over13Checked*/ CommonLogic.IIF(ctrlAccount.Over13, 1, 0), /*CurrencySetting*/ null, /*VATSetting*/ null, /*VATRegistrationID*/ null, /*StoreCCInDB*/ CommonLogic.IIF(ctrlAccount.ShowSaveCC, ctrlAccount.SaveCC, true), /*IsRegistered*/ CommonLogic.IIF(SkipRegistration, 0, 1), /*LockedUntil*/ null, /*AdminCanViewCC*/ null, /*BadLogin*/ null, /*Active*/ null, /*PwdChangeRequired*/ null, /*RegisterDate*/ null, /*StoreId*/ AppLogic.StoreID() ); if (ctrlAccount.OKToEmailYes) { AddToNewsletterList(ctrlAccount.FirstName, ctrlAccount.LastName, EMailField); } if (AppLogic.AppConfigBool("Vat.Enabled") && ctrlAccount.VATRegistrationID.Length > 0) { String vtr = ctrlAccount.VATRegistrationID.Trim(); Exception vatServiceException = null; if (AppLogic.VATRegistrationIDIsValid("UK", vtr, out vatServiceException)) { ThisCustomer.SetVATRegistrationID(vtr); } else { vtr = String.Empty; if (vatServiceException != null && !String.IsNullOrEmpty(vatServiceException.Message)) { if (vatServiceException.Message.Length > 255) { ErrorMsgLabel.Text = Server.HtmlEncode(vatServiceException.Message.Substring(0, 255)); } else { ErrorMsgLabel.Text = Server.HtmlEncode(vatServiceException.Message); } } else { ErrorMsgLabel.Text = "account.aspx.91".StringResource(); } return; } } if (AppLogic.AppConfigBool("DynamicRelatedProducts.Enabled") || AppLogic.AppConfigBool("RecentlyViewedProducts.Enabled")) { ThisCustomer.ReplaceProductViewFromAnonymous(); } } if (Checkout) { if (!NewEmailAllowed) { ErrorMsgLabel.Text = AppLogic.GetString("createaccount_process.aspx.1", 1, Localization.GetDefaultLocale()); InitializePageContent(); } else { if (AppLogic.AppConfigBool("SendWelcomeEmail") && EMailField.IndexOf("@") != -1) { // don't let a simple welcome stop checkout! try { string body = AppLogic.RunXmlPackage(AppLogic.AppConfig("XmlPackage.WelcomeEmail"), null, ThisCustomer, this.SkinID, "", "fullname=" + ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim(), false, false, this.EntityHelpers); AppLogic.SendMail(AppLogic.GetString("createaccount.aspx.79", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), body, true, AppLogic.AppConfig("MailMe_FromAddress"), AppLogic.AppConfig("MailMe_FromName"), EMailField, ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim(), "", AppLogic.MailServer()); } catch { } } Response.Redirect("mobilegetaddress.aspx?addresstype=billing&" + BuildRedirectQuerystring()); } } else { if (!NewEmailAllowed) { DB.ExecuteSQL("update customer set EMail='', IsRegistered = 0 where CustomerID=" + ThisCustomer.CustomerID); ErrorMsgLabel.Text = AppLogic.GetString("createaccount_process.aspx.1", 1, Localization.GetDefaultLocale()); InitializePageContent(); } else { if (AppLogic.AppConfigBool("SendWelcomeEmail") && EMailField.IndexOf("@") != -1) { // don't let a simple welcome stop checkout! try { string body = AppLogic.RunXmlPackage(AppLogic.AppConfig("XmlPackage.WelcomeEmail"), null, ThisCustomer, this.SkinID, "", "", false, false, this.EntityHelpers); AppLogic.SendMail(AppLogic.GetString("createaccount.aspx.79", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), body, true, AppLogic.AppConfig("MailMe_FromAddress"), AppLogic.AppConfig("MailMe_FromName"), EMailField, ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim(), "", AppLogic.MailServer()); } catch { } } if (VerifyAddressPrompt) { if (AllowShipToDifferentThanBillTo) { Response.Redirect("address.aspx?Checkout=False&AddressType=Shipping&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult); } else { Response.Redirect("address.aspx?Checkout=False&AddressType=Billing&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult); } } else { Response.Redirect("account.aspx?newaccount=true"); } } } } else { ErrorMsgLabel.Text += "" + AppLogic.GetString("createaccount.aspx.84", 1, Localization.GetDefaultLocale()) + ""; if (AccountName.Length == 0) { ErrorMsgLabel.Text += "• " + AppLogic.GetString("createaccount.aspx.5", 1, Localization.GetDefaultLocale()) + ""; } foreach (IValidator aValidator in this.Validators) { if (!aValidator.IsValid) { ErrorMsgLabel.Text += "• " + aValidator.ErrorMessage + ""; } } ErrorMsgLabel.Text += ""; ResetScrollPosition(); } pnlErrorMsg.Visible = (ErrorMsgLabel.Text.Length > 5); }
private void CreateAccount() { ThisCustomer.RequireCustomerRecord(); GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon(); if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut && checkoutByAmazon.GetDefaultShippingAddress() == null) { lblErrorMessage.Text = "gw.checkoutbyamazon.display.3".StringResource(); pnlErrorMsg.Visible = true; return; } if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut && ThisCustomer.IsRegistered) { checkoutByAmazon.BeginCheckout(new Guid(ThisCustomer.CustomerGUID), false, false); Response.Redirect("checkoutshipping.aspx"); } else if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut) { checkoutByAmazon.BeginCheckout(new Guid(ThisCustomer.CustomerGUID), false, false); } SetPasswordFields(); string AccountName = (ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim()).Trim(); if (SkipRegistration) { AccountName = String.Format("{0} {1}", ctrlBillingAddress.FirstName.Trim(), ctrlBillingAddress.LastName.Trim()).Trim(); if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut) { AccountName = "Anonymous Amazon Customer"; } } if (SkipRegistration) { Page.Validate("skipreg"); } else { if (ctrlAccount.Password.Contains('\xFF') || ctrlAccount.Password.Length == 0) { ctrlAccount.PasswordValidate = ViewState["custpwd"].ToString(); } else { ctrlAccount.PasswordValidate = ctrlAccount.Password; } if (ctrlAccount.PasswordConfirm.Contains('\xFF') || ctrlAccount.PasswordConfirm.Length == 0) { ctrlAccount.PasswordConfirmValidate = ViewState["custpwd2"].ToString(); } else { ctrlAccount.PasswordConfirmValidate = ctrlAccount.PasswordConfirm; } ctrlAccount.Over13 = ctrlAccount.Over13; if ((!ThisCustomer.IsRegistered) && !checkoutByAmazon.IsCheckingOut && (ctrlAccount.Password.Length == 0 || ctrlAccount.PasswordConfirm.Length == 0)) { lblErrorMessage.Text = "createaccount.aspx.6".StringResource(); ResetScrollPosition(); pnlErrorMsg.Visible = true; return; } ctrlBillingAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlBillingAddress.Country); ctrlShippingAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlShippingAddress.Country); Page.Validate("registration"); if (RequireSecurityCode) { if (Session["SecurityCode"] != null) { String sCode = Session["SecurityCode"].ToString(); String fCode = ctrlAccount.txtSecurityCode.Text; Boolean codeMatch = false; if (AppLogic.AppConfigBool("Captcha.CaseSensitive")) { if (fCode.Equals(sCode)) { codeMatch = true; } } else { if (fCode.Equals(sCode, StringComparison.InvariantCultureIgnoreCase)) { codeMatch = true; } } if (!codeMatch) { lblErrorMessage.Text = string.Format(AppLogic.GetString("lat_signin_process.aspx.5", SkinID, ThisCustomer.LocaleSetting), sCode, fCode); ctrlAccount.txtSecurityCode.Text = String.Empty; ctrlAccount.imgAccountSecurityImage.ImageUrl = "~/Captcha.ashx?id=1"; ResetScrollPosition(); pnlErrorMsg.Visible = true; return; } } else { lblErrorMessage.Text = string.Format(AppLogic.GetString("lat_signin_process.aspx.5", SkinID, ThisCustomer.LocaleSetting), "", ctrlAccount.txtSecurityCode.Text); ctrlAccount.txtSecurityCode.Text = String.Empty; ctrlAccount.imgAccountSecurityImage.ImageUrl = "~/Captcha.ashx?id=1"; ResetScrollPosition(); pnlErrorMsg.Visible = true; return; } } if (!Page.IsValid && RequireSecurityCode) { Session["SecurityCode"] = CommonLogic.GenerateRandomCode(6); } } Page.Validate("createacccount"); if (Page.IsValid && AccountName.Length > 0) { String EMailField = CommonLogic.IIF(SkipRegistration, txtSkipRegEmail.Text.ToLowerInvariant().Trim(), ctrlAccount.Email.ToLowerInvariant().Trim()); bool NewEmailAllowed = Customer.NewEmailPassesDuplicationRules(EMailField, ThisCustomer.CustomerID, SkipRegistration); String PWD = ViewState["custpwd"].ToString(); Password p = new Password(PWD); String newpwd = p.SaltedPassword; System.Nullable <int> newsaltkey = p.Salt; Password blankpwd = new Password("", ThisCustomer.SaltKey); if (!(ThisCustomer.Password == "" || ThisCustomer.Password == blankpwd.SaltedPassword)) { // do NOT allow passwords to be changed on this page. this is only for creating an account. // if they want to change their password, they must use their account page newpwd = null; newsaltkey = null; } if (NewEmailAllowed) { AppLogic.eventHandler("CreateAccount").CallEvent("&CreateAccount=true"); string strDOB = null; if (AppLogic.AppConfigBool("Account.ShowBirthDateField")) { strDOB = ctrlAccount.DOBMonth + "/" + ctrlAccount.DOBDay + "/" + ctrlAccount.DOBYear; //DOB defaults to 0/0/0 when doing anonymous checkout and blows up dbo.aspdnsf_updCustomer, preventing checkout strDOB = (strDOB.Equals("0/0/0", StringComparison.Ordinal)) ? null : strDOB; } var defaultCustomerLevel_Public = (int)UserType.PUBLIC; ThisCustomer.UpdateCustomer( /*CustomerLevelID*/ defaultCustomerLevel_Public, /*EMail*/ EMailField, /*SaltedAndHashedPassword*/ newpwd, /*SaltKey*/ newsaltkey, /*DateOfBirth*/ strDOB, /*Gender*/ null, /*FirstName*/ ctrlAccount.FirstName, /*LastName*/ ctrlAccount.LastName, /*Notes*/ null, /*SkinID*/ null, /*Phone*/ ctrlAccount.Phone, /*AffiliateID*/ null, /*Referrer*/ null, /*CouponCode*/ null, /*OkToEmail*/ CommonLogic.IIF(ctrlAccount.OKToEmailYes, 1, 0), /*IsAdmin*/ null, /*BillingEqualsShipping*/ CommonLogic.IIF(AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo"), 0, 1), /*LastIPAddress*/ null, /*OrderNotes*/ null, /*SubscriptionExpiresOn*/ null, /*RTShipRequest*/ null, /*RTShipResponse*/ null, /*OrderOptions*/ null, /*LocaleSetting*/ null, /*MicroPayBalance*/ null, /*RecurringShippingMethodID*/ null, /*RecurringShippingMethod*/ null, /*BillingAddressID*/ null, /*ShippingAddressID*/ null, /*GiftRegistryGUID*/ null, /*GiftRegistryIsAnonymous*/ null, /*GiftRegistryAllowSearchByOthers*/ null, /*GiftRegistryNickName*/ null, /*GiftRegistryHideShippingAddresses*/ null, /*CODCompanyCheckAllowed*/ null, /*CODNet30Allowed*/ null, /*ExtensionData*/ null, /*FinalizationData*/ null, /*Deleted*/ null, /*Over13Checked*/ 1, //CommonLogic.IIF(ctrlAccount.Over13 || SkipRegOver13.Checked, 1, 0), /*CurrencySetting*/ null, /*VATSetting*/ null, /*VATRegistrationID*/ null, /*StoreCCInDB*/ CommonLogic.IIF(ctrlAccount.ShowSaveCC, ctrlAccount.SaveCC, true), /*IsRegistered*/ CommonLogic.IIF(SkipRegistration, 0, 1), /*LockedUntil*/ null, /*AdminCanViewCC*/ null, /*BadLogin*/ null, /*Active*/ null, /*PwdChangeRequired*/ null, /*RegisterDate*/ null, /*StoreId*/ AppLogic.StoreID() ); if (ctrlAccount.OKToEmailYes) { AddToNewsletterList(ctrlAccount.FirstName, ctrlAccount.LastName, EMailField); } BillingAddress = ThisCustomer.PrimaryBillingAddress; if (BillingAddress.AddressID == 0 && !checkoutByAmazon.IsCheckingOut) { if (pnlBillingInfo.Visible) { BillingAddress.NickName = ctrlBillingAddress.NickName; BillingAddress.LastName = ctrlBillingAddress.LastName; BillingAddress.FirstName = ctrlBillingAddress.FirstName; BillingAddress.Phone = ctrlBillingAddress.PhoneNumber; BillingAddress.Company = ctrlBillingAddress.Company; BillingAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlBillingAddress.ResidenceType); BillingAddress.Address1 = ctrlBillingAddress.Address1; BillingAddress.Address2 = ctrlBillingAddress.Address2; BillingAddress.Suite = ctrlBillingAddress.Suite; BillingAddress.City = ctrlBillingAddress.City; BillingAddress.State = ctrlBillingAddress.State; BillingAddress.Zip = ctrlBillingAddress.ZipCode; BillingAddress.Country = ctrlBillingAddress.Country; BillingAddress.InsertDB(ThisCustomer.CustomerID); BillingAddress.MakeCustomersPrimaryAddress(AddressTypes.Billing); } } else { BillingAddress.NickName = String.Format("{0} {1}", ctrlAccount.FirstName, ctrlAccount.LastName); BillingAddress.LastName = ctrlAccount.FirstName; BillingAddress.FirstName = ctrlAccount.LastName; BillingAddress.Phone = ctrlAccount.Phone; } ShippingAddress = ThisCustomer.PrimaryShippingAddress; if (ShippingAddress.AddressID == 0 && !checkoutByAmazon.IsCheckingOut) { if (AllowShipToDifferentThanBillTo) { if (ctrlShippingAddress.Visible) { ShippingAddress.NickName = ctrlBillingAddress.NickName; ShippingAddress.LastName = ctrlShippingAddress.LastName; ShippingAddress.FirstName = ctrlShippingAddress.FirstName; ShippingAddress.Phone = ctrlShippingAddress.PhoneNumber; ShippingAddress.Company = ctrlShippingAddress.Company; ShippingAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlShippingAddress.ResidenceType); ShippingAddress.Address1 = ctrlShippingAddress.Address1; ShippingAddress.Address2 = ctrlShippingAddress.Address2; ShippingAddress.Suite = ctrlShippingAddress.Suite; ShippingAddress.City = ctrlShippingAddress.City; ShippingAddress.State = ctrlShippingAddress.State; ShippingAddress.Zip = ctrlShippingAddress.ZipCode; ShippingAddress.Country = ctrlShippingAddress.Country; ShippingAddress.InsertDB(ThisCustomer.CustomerID); if (!String.IsNullOrEmpty(VerifyAddressesProvider)) { VerifyResult = AddressValidation.RunValidate(ShippingAddress, out StandardizedAddress); VerifyAddressPrompt = (VerifyResult != AppLogic.ro_OK); if (VerifyAddressPrompt) { ShippingAddress = StandardizedAddress; ShippingAddress.UpdateDB(); } } ShippingAddress.MakeCustomersPrimaryAddress(AddressTypes.Shipping); } } else { if (!String.IsNullOrEmpty(VerifyAddressesProvider)) { VerifyResult = AddressValidation.RunValidate(BillingAddress, out StandardizedAddress); VerifyAddressPrompt = (VerifyResult != AppLogic.ro_OK); if (VerifyAddressPrompt) { BillingAddress = StandardizedAddress; BillingAddress.UpdateDB(); } } BillingAddress.MakeCustomersPrimaryAddress(AddressTypes.Shipping); } } else { ShippingAddress.NickName = String.Format("{0} {1}", ctrlAccount.FirstName, ctrlAccount.LastName); ShippingAddress.LastName = ctrlAccount.FirstName; ShippingAddress.FirstName = ctrlAccount.LastName; ShippingAddress.Phone = ctrlAccount.Phone; } if (AppLogic.AppConfigBool("Vat.Enabled") && ctrlAccount.VATRegistrationID.Length > 0) { String vtr = ctrlAccount.VATRegistrationID.Trim(); Exception vatServiceException = null; if (AppLogic.VATRegistrationIDIsValid(ctrlBillingAddress.Country, vtr, out vatServiceException)) { ThisCustomer.SetVATRegistrationID(vtr); } else { vtr = String.Empty; if (vatServiceException != null && !String.IsNullOrEmpty(vatServiceException.Message)) { if (vatServiceException.Message.Length > 255) { lblErrorMessage.Text = Server.HtmlEncode(vatServiceException.Message.Substring(0, 255)); } else { lblErrorMessage.Text = Server.HtmlEncode(vatServiceException.Message); } } else { lblErrorMessage.Text = "account.aspx.91".StringResource(); } pnlErrorMsg.Visible = true; return; } } if (AppLogic.AppConfigBool("DynamicRelatedProducts.Enabled") || AppLogic.AppConfigBool("RecentlyViewedProducts.Enabled")) { ThisCustomer.ReplaceProductViewFromAnonymous(); } } if (Checkout) { if (!NewEmailAllowed) { lblErrorMessage.Text = AppLogic.GetString("createaccount_process.aspx.1", 1, Localization.GetDefaultLocale()); InitializePageContent(); } else { if (AppLogic.AppConfigBool("SendWelcomeEmail") && EMailField.IndexOf("@") != -1 && ThisCustomer.IsRegistered == true) { // don't let a simple welcome stop checkout! try { string body = AppLogic.RunXmlPackage(AppLogic.AppConfig("XmlPackage.WelcomeEmail"), null, ThisCustomer, this.SkinID, "", "fullname=" + ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim(), false, false, this.EntityHelpers); AppLogic.SendMail(AppLogic.GetString("createaccount.aspx.79", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), body, true, AppLogic.AppConfig("MailMe_FromAddress"), AppLogic.AppConfig("MailMe_FromName"), EMailField, ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim(), "", AppLogic.MailServer()); } catch { } } if (VerifyAddressPrompt) { if (AllowShipToDifferentThanBillTo) { Response.Redirect("address.aspx?Checkout=True&AddressType=Shipping&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult + "&skipreg=" + SkipRegistration + "&returnURL=checkoutshipping.aspx?checkout=true"); } else { Response.Redirect("address.aspx?Checkout=True&AddressType=Billing&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult + "&skipreg=" + SkipRegistration + "&returnURL=checkoutshipping.aspx?checkout=true"); } } else { if (checkouttype == "ppec" || checkouttype == "ppbml" || checkouttype == "gc") { Response.Redirect("shoppingcart.aspx"); } else { Response.Redirect("account.aspx?checkout=true");//checkoutshipping } } } } else { if (!NewEmailAllowed) { DB.ExecuteSQL("update customer set EMail='', IsRegistered = 0 where CustomerID=" + ThisCustomer.CustomerID); lblErrorMessage.Text = AppLogic.GetString("createaccount_process.aspx.1", 1, Localization.GetDefaultLocale()); InitializePageContent(); } else { if (AppLogic.AppConfigBool("SendWelcomeEmail") && EMailField.IndexOf("@") != -1 && ThisCustomer.IsRegistered == true) { // don't let a simple welcome stop checkout! try { string body = AppLogic.RunXmlPackage(AppLogic.AppConfig("XmlPackage.WelcomeEmail"), null, ThisCustomer, this.SkinID, "", "", false, false, this.EntityHelpers); AppLogic.SendMail(AppLogic.GetString("createaccount.aspx.79", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), body, true, AppLogic.AppConfig("MailMe_FromAddress"), AppLogic.AppConfig("MailMe_FromName"), EMailField, ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim(), "", AppLogic.MailServer()); } catch { } } if (VerifyAddressPrompt) { if (AllowShipToDifferentThanBillTo) { Response.Redirect("address.aspx?Checkout=False&AddressType=Shipping&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult + "&skipreg=" + SkipRegistration); } else { Response.Redirect("address.aspx?Checkout=False&AddressType=Billing&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult + "&skipreg=" + SkipRegistration); } } else { Response.Redirect("JWMyAccount.aspx"); } } } } else { foreach (IValidator aValidator in this.Validators) { if (!aValidator.IsValid) { lblErrorMessage.Text = aValidator.ErrorMessage; break; } } ResetScrollPosition(); } pnlErrorMsg.Visible = lblErrorMessage.Text.Length > 0; }
protected override void OnPreInit(EventArgs e) { if (HttpContext.Current != null) { //Have to call GetPropertyValue once before you actually need it to initialize the PropertyValues collection if (HttpContext.Current.Profile != null) { HttpContext.Current.Profile.GetPropertyValue("SkinID"); } //SkinId querystring overrides everything but mobile if (CommonLogic.QueryStringUSInt("skinid") > 0) { SkinID = CommonLogic.QueryStringUSInt("skinid"); //Customer has a querystring so save this to the profile. if (HttpContext.Current.Profile != null) { HttpContext.Current.Profile.SetPropertyValue("SkinID", SkinID.ToString()); } } //Check to see if we are previewing the skin else if (CommonLogic.QueryStringUSInt("previewskinid") > 0) { SkinID = CommonLogic.QueryStringUSInt("previewskinid"); //Customer has a preview querystring so save this to the profile. if (HttpContext.Current.Profile != null) { HttpContext.Current.Profile.SetPropertyValue("PreviewSkinID", SkinID.ToString()); } } //Use the preview profile value if we have one else if (HttpContext.Current.Profile != null && HttpContext.Current.Profile.PropertyValues["PreviewSkinID"] != null && CommonLogic.IsInteger(HttpContext.Current.Profile.GetPropertyValue("PreviewSkinID").ToString())) { int skinFromProfile = int.Parse(HttpContext.Current.Profile.GetPropertyValue("PreviewSkinID").ToString()); if (skinFromProfile > 0) { SkinID = skinFromProfile; } } //Pull the skinid from the current profile else if (HttpContext.Current.Profile != null && CommonLogic.IsInteger(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString())) { int skinFromProfile = int.Parse(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString()); if (skinFromProfile > 0) { SkinID = skinFromProfile; } } //Now save the skinID to the customer record. This is not used OOB. if (ThisCustomer.SkinID != SkinID) { ThisCustomer.SkinID = SkinID; ThisCustomer.UpdateCustomer(new SqlParameter[] { new SqlParameter("SkinID", SkinID) }); } if (CommonLogic.QueryStringUSInt("affiliateid") > 0) { var affiliateId = CommonLogic.QueryStringUSInt("affiliateid"); var affiliate = new Affiliate(affiliateId); if (!AppLogic.GlobalConfigBool("AllowAffiliateFiltering") || affiliate.StoreID == AppLogic.StoreID()) { HttpContext.Current.Profile.SetPropertyValue("AffiliateID", affiliateId.ToString()); } } if (HttpContext.Current.Request.UrlReferrer != null && HttpContext.Current.Request.UrlReferrer.Authority != HttpContext.Current.Request.Url.Authority) { HttpContext.Current.Profile.SetPropertyValue("Referrer", HttpContext.Current.Request.UrlReferrer.ToString()); } Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Localization.GetDefaultLocale()); Thread.CurrentThread.CurrentUICulture = new CultureInfo(ThisCustomer.LocaleSetting); m_TemplateName = GetTemplateName(); m_Parser = new Parser(); string SkinDirectory = string.Empty; string PageTheme = string.Empty; SkinDirectory = "Skin_" + SkinID.ToString(); PageTheme = "Skin_" + SkinID.ToString(); if (!m_TemplateName.EndsWith(".master", StringComparison.OrdinalIgnoreCase)) { m_TemplateName = m_TemplateName + ".master"; } MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName; Theme = PageTheme; if (!CommonLogic.FileExists(MasterPageFile)) { SkinID = AppLogic.DefaultSkinID(); m_TemplateName = "template.master"; SkinDirectory = "Skin_" + SkinID.ToString(); PageTheme = "Skin_" + SkinID.ToString(); MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName; Theme = PageTheme; } } base.OnPreInit(e); }
protected override void OnPreInit(EventArgs e) { if (HttpContext.Current != null) { m_ThisCustomer = ((AspDotNetStorefrontPrincipal)Context.User).ThisCustomer; int StoreID = AppLogic.StoreID(); m_SkinID = AppLogic.GetStoreSkinID(StoreID); //TODO: review this if (CommonLogic.IsInteger(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString())) { int skinFromProfile = int.Parse(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString()); if (skinFromProfile > 0) { m_SkinID = skinFromProfile; } } else if (AppLogic.AppConfig("Signin.SkinMaster").EqualsIgnoreCase("session")) { m_SkinID = m_ThisCustomer.DBSkinID; } if (CommonLogic.QueryStringUSInt("skinid") > 0) { m_SkinID = CommonLogic.QueryStringUSInt("skinid"); } if (CommonLogic.QueryStringUSInt("affiliateid") > 0) { HttpContext.Current.Profile.SetPropertyValue("AffiliateID", CommonLogic.QueryStringUSInt("affiliateid").ToString()); } if (HttpContext.Current.Request.UrlReferrer != null && HttpContext.Current.Request.UrlReferrer.Authority != HttpContext.Current.Request.Url.Authority) { HttpContext.Current.Profile.SetPropertyValue("Referrer", HttpContext.Current.Request.UrlReferrer.ToString()); } if (AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("GoogleCheckout.ShowOnCartPage")) { String s = (String)HttpContext.Current.Cache.Get("GCCallbackLoadCheck"); if (s == null) { String notused = CommonLogic.AspHTTP(AppLogic.GetStoreHTTPLocation(false) + "gccallback.aspx?loadcheck=1", 10); HttpContext.Current.Cache.Insert("GCCallbackLoadCheck", "true", null, System.DateTime.Now.AddMinutes(5), TimeSpan.Zero); } } // don't fire disclaimer logic on admin pages if (!AppLogic.IsAdminSite && CommonLogic.QueryStringCanBeDangerousContent("ReturnURL").IndexOf(AppLogic.AppConfig("AdminDir")) == -1 && (AppLogic.AppConfigBool("SiteDisclaimerRequired") && CommonLogic.CookieCanBeDangerousContent("SiteDisclaimerAccepted", true).Length == 0)) { String ThisPageURL = CommonLogic.GetThisPageName(true) + "?" + CommonLogic.ServerVariables("QUERY_STRING"); Response.Redirect("disclaimer.aspx?returnURL=" + Server.UrlEncode(ThisPageURL)); } bool IGDQueryClear = false; m_IGD = CommonLogic.QueryStringCanBeDangerousContent("IGD").Trim(); if (m_IGD.Length == 0 && CommonLogic.ServerVariables("QUERY_STRING").IndexOf("IGD=") != -1) { m_IGD = String.Empty; // there was IGD={blank} in the query string, so forcefully clear IGD! IGDQueryClear = true; } bool IsStartOfImpersonation = m_IGD.Length != 0; // the url invocation starts the impersonation only! if (!IGDQueryClear && m_IGD.Length == 0) { if (m_ThisCustomer.IsAdminUser) { // pull out the impersonation IGD from the customer session, if any m_IGD = m_ThisCustomer.ThisCustomerSession["IGD"]; } } if (IGDQueryClear) { // forcefully clear any IGD for this customer, just to be safe! m_ThisCustomer.ThisCustomerSession["IGD"] = ""; m_ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = ""; } Customer PhoneCustomer = null; if (m_IGD.Length != 0) { if (m_ThisCustomer.IsAdminUser) { try { Guid IGD = new Guid(m_IGD); PhoneCustomer = new Customer(IGD); PhoneCustomer.IsImpersonated = true; } catch { m_ThisCustomer.ThisCustomerSession["IGD"] = ""; m_ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = ""; m_IGD = string.Empty; } } if (PhoneCustomer != null && PhoneCustomer.HasCustomerRecord) { int ImpersonationTimeoutInMinutes = AppLogic.AppConfigUSInt("ImpersonationTimeoutInMinutes"); if (ImpersonationTimeoutInMinutes == 0) { ImpersonationTimeoutInMinutes = 20; } if (PhoneCustomer.ThisCustomerSession.LastActivity >= DateTime.Now.AddMinutes(-ImpersonationTimeoutInMinutes)) { m_ThisCustomer.ThisCustomerSession["IGD"] = IGD; m_AdminCustomer = m_ThisCustomer; // save the owning admin user doing the impersonation here m_ThisCustomer = PhoneCustomer; // build the impersonation customer the phone order customer bool IsAdmin = CommonLogic.ApplicationBool("IsAdminSite"); if (!HttpContext.Current.Items.Contains("IsBeingImpersonated")) { HttpContext.Current.Items.Add("IsBeingImpersonated", "true"); } } else { if (HttpContext.Current.Items.Contains("IsBeingImpersonated")) { HttpContext.Current.Items["IsBeingImpersonated"] = "false"; } m_ThisCustomer.ThisCustomerSession["IGD"] = ""; m_ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = ""; m_IGD = string.Empty; //Response.Redirect("t-phoneordertimeout.aspx"); Response.Redirect(SE.MakeDriverLink("phoneordertimeout")); } } } Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Localization.GetDefaultLocale()); Thread.CurrentThread.CurrentUICulture = new CultureInfo(ThisCustomer.LocaleSetting); m_Parser = new Parser(m_EntityHelpers, m_SkinID, m_ThisCustomer); m_TemplateName = GetTemplateName(); #region Vortx Mobile Modification if (!AppLogic.IsAdminSite) { m_ThisCustomer = MobileRedirectController.SkinBaseHook(SkinID, ThisCustomer); SkinID = ThisCustomer.SkinID; if (SkinID == Vortx.Data.Config.MobilePlatform.SkinId && MobileHelper.isMobile()) { m_TemplateName = "template.master"; } } #endregion String SkinDirectory = String.Empty; String PageTheme = String.Empty; SkinDirectory = "Skin_" + this.SkinID.ToString(); PageTheme = "Skin_" + this.SkinID.ToString(); if (!m_TemplateName.EndsWith(".master", StringComparison.OrdinalIgnoreCase)) { m_TemplateName = m_TemplateName + ".master"; } this.MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName; this.Theme = PageTheme; if (!CommonLogic.FileExists(this.MasterPageFile)) { this.SkinID = AppLogic.DefaultSkinID(); m_TemplateName = "template.master"; SkinDirectory = "Skin_" + this.SkinID.ToString(); PageTheme = "Skin_" + this.SkinID.ToString(); this.MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName; this.Theme = PageTheme; } HttpContext.Current.Profile.SetPropertyValue("SkinID", this.SkinID.ToString()); if (ThisCustomer.SkinID != this.SkinID) { ThisCustomer.SkinID = this.SkinID; ThisCustomer.UpdateCustomer(new SqlParameter[] { new SqlParameter("SkinID", this.SkinID) }); } } base.OnPreInit(e); }