Пример #1
0
        /// <summary>
        /// The form load event handler. Retrieves the current user information from Sitecore. The fieldnames are defined in the belonging webform.
        /// </summary>
        /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param>
        /// <param name="args">The render form arguments.</param>
        public void Load(bool isPostback, RenderFormArgs args)
        {
            HtmlFormModifier form = new HtmlFormModifier(args);

              if (isPostback)
              {
            return;
              }

              ICustomerManager<CustomerInfo> customerManager = Context.Entity.Resolve<ICustomerManager<CustomerInfo>>();

              // Sets the Billing and Shipping Address from the user object.
              form.SetInputValue("Name", customerManager.CurrentUser.BillingAddress.Name);
              form.SetInputValue("Address", customerManager.CurrentUser.BillingAddress.Address);
              form.SetInputValue("Zip", customerManager.CurrentUser.BillingAddress.Zip);
              form.SetInputValue("City", customerManager.CurrentUser.BillingAddress.City);

              form.SetSelectedDropListValue("State", customerManager.CurrentUser.BillingAddress.State);
              form.SetSelectedDropListValue("Country", customerManager.CurrentUser.BillingAddress.Country.Title);

              foreach (string key in customerManager.CurrentUser.CustomProperties.AllKeys)
              {
            form.SetInputValue(key, customerManager.CurrentUser.CustomProperties[key]);
              }
        }
Пример #2
0
        /// <summary>
        /// The form load event handler. Retrieves the current user information from Sitecore. The fieldnames are defined in the belonging webform.
        /// </summary>
        /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param>
        /// <param name="args">The render form arguments.</param>
        public void Load(bool isPostback, RenderFormArgs args)
        {
            HtmlFormModifier form = new HtmlFormModifier(args);

            if (isPostback)
            {
                return;
            }

            ICustomerManager <CustomerInfo> customerManager = Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            // Sets the Billing and Shipping Address from the user object.
            form.SetInputValue("Name", customerManager.CurrentUser.BillingAddress.Name);
            form.SetInputValue("Address", customerManager.CurrentUser.BillingAddress.Address);
            form.SetInputValue("Zip", customerManager.CurrentUser.BillingAddress.Zip);
            form.SetInputValue("City", customerManager.CurrentUser.BillingAddress.City);

            form.SetSelectedDropListValue("State", customerManager.CurrentUser.BillingAddress.State);
            form.SetSelectedDropListValue("Country", customerManager.CurrentUser.BillingAddress.Country.Title);

            foreach (string key in customerManager.CurrentUser.CustomProperties.AllKeys)
            {
                form.SetInputValue(key, customerManager.CurrentUser.CustomProperties[key]);
            }
        }
Пример #3
0
        /// <summary>
        /// Processes the specified args.
        /// </summary>
        /// <param name="args">The render form args.</param>
        public void Process(RenderFormArgs args)
        {
            // replaces legends with div tags
            var form = new HtmlFormModifier(args);

            form.ReplaceLegendWithDiv();
            form.RemoveEmptyTags("div", "scfSectionUsefulInfo");
            form.RemoveEmptyTags("div", "scfTitleBorder");
            form.RemoveEmptyTags("div", "scfIntroBorder");
            form.RemoveEmptyTags("span", "scfError");
            form.SurroundContentWithUlLi("scfError");

            form.RemoveNbsp();

            var saveActions = args.Item["Save Actions"];

            if (!string.IsNullOrEmpty(saveActions))
            {
                var commands  = XDocument.Parse(saveActions);
                var actionIds = (from c in commands.Descendants()
                                 where c.Name.LocalName == "li" &&
                                 (c.Attribute(XName.Get("id")) != null)
                                 select c.Attribute(XName.Get("id")).Value).ToList();

                foreach (var actionId in actionIds)
                {
                    var actionItem = args.Item.Database.GetItem(actionId);
                    if (null == actionItem)
                    {
                        continue;
                    }

                    var assembly  = actionItem["assembly"];
                    var className = actionItem["Class"];

                    if (string.IsNullOrEmpty(assembly) || string.IsNullOrEmpty(className))
                    {
                        continue;
                    }

                    var obj = ReflectionUtil.CreateObject(assembly, className, new object[] { });
                    if (obj == null)
                    {
                        throw new ConfigurationException("Could not load " + className + " from " + assembly);
                    }

                    var method = ReflectionUtil.GetMethod(obj, "Load", new object[] { IsPostback, args });
                    if (method != null)
                    {
                        ReflectionUtil.InvokeMethod(method, new object[] { IsPostback, args }, obj);
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Processes the specified args.
        /// </summary>
        /// <param name="args">The render form args.</param>
        public void Process(RenderFormArgs args)
        {
            // replaces legends with div tags
              var form = new HtmlFormModifier(args);
              form.ReplaceLegendWithDiv();
              form.RemoveEmptyTags("div", "scfSectionUsefulInfo");
              form.RemoveEmptyTags("div", "scfTitleBorder");
              form.RemoveEmptyTags("div", "scfIntroBorder");
              form.RemoveEmptyTags("span", "scfError");
              form.SurroundContentWithUlLi("scfError");

              form.RemoveNbsp();

              var saveActions = args.Item["Save Actions"];
              if (!string.IsNullOrEmpty(saveActions))
              {
            var commands = XDocument.Parse(saveActions);
            var actionIds = (from c in commands.Descendants()
                                  where c.Name.LocalName == "li"
                                        && (c.Attribute(XName.Get("id")) != null)
                                  select c.Attribute(XName.Get("id")).Value).ToList();

            foreach (var actionId in actionIds)
            {
              var actionItem = args.Item.Database.GetItem(actionId);
              if (null == actionItem)
              {
            continue;
              }

              var assembly = actionItem["assembly"];
              var className = actionItem["Class"];

              if (string.IsNullOrEmpty(assembly) || string.IsNullOrEmpty(className))
              {
            continue;
              }

              var obj = ReflectionUtil.CreateObject(assembly, className, new object[] { });
              if (obj == null)
              {
            throw new ConfigurationException("Could not load " + className + " from " + assembly);
              }

              var method = ReflectionUtil.GetMethod(obj, "Load", new object[] { IsPostback, args });
              if (method != null)
              {
            ReflectionUtil.InvokeMethod(method, new object[] { IsPostback, args }, obj);
              }
            }
              }
        }
Пример #5
0
        /// <summary>
        /// The form load event handler.
        /// </summary>
        /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param>
        /// <param name="args">The Render Form arguments.</param>
        public void Load(bool isPostback, RenderFormArgs args)
        {
            HtmlFormModifier form = new HtmlFormModifier(args);

            if (!MainUtil.IsLoggedIn())
            {
                form.ChangeFormIntroduction(string.Empty);
            }
            else
            {
                ICustomerManager <CustomerInfo> customerManager = Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();
                string name = customerManager.CurrentUser.BillingAddress.Name;
                form.ChangeFormTitle(string.Format("{0} {1}.", Translate.Text(Examples.Texts.Welcome), name));
                form.HideSectionByField("Returning customer", "UserName");
                //Note: hiding of submit form button :)
                form.HideElement("div", "class", "scfSubmitButtonBorder");
            }
        }
Пример #6
0
        /// <summary>
        /// The form load event handler.
        /// </summary>
        /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param>
        /// <param name="args">The Render Form arguments.</param>
        public void Load(bool isPostback, RenderFormArgs args)
        {
            HtmlFormModifier form = new HtmlFormModifier(args);

              if (!MainUtil.IsLoggedIn())
              {
            form.ChangeFormIntroduction(string.Empty);
              }
              else
              {
            ICustomerManager<CustomerInfo> customerManager = Context.Entity.Resolve<ICustomerManager<CustomerInfo>>();
            string name = customerManager.CurrentUser.BillingAddress.Name;
            form.ChangeFormTitle(string.Format("{0} {1}.", Translate.Text(Examples.Texts.Welcome), name));
            form.HideSectionByField("Returning customer", "UserName");
            //Note: hiding of submit form button :)
            form.HideElement("div", "class", "scfSubmitButtonBorder");
              }
        }
        /// <summary>
        /// Processes the specified args.
        /// </summary>
        /// <param name="args">The render form args.</param>
        public void Process(RenderFormArgs args)
        {
            // replaces legends with div tags
              var form = new HtmlFormModifier(args);
              form.ReplaceLegendWithDiv();
              form.RemoveEmptyTags("div", "scfSectionUsefulInfo");
              form.RemoveEmptyTags("div", "scfTitleBorder");
              form.RemoveEmptyTags("div", "scfIntroBorder");
              form.RemoveEmptyTags("span", "scfError");
              form.SorundContentWithUlLi("scfError");

              // TODO: remove this line after web forms fixed bug with unnecessary nbsp symbols
              form.RemoveNbsp();

              string saveActions = args.Item["Save Actions"];
              if (!string.IsNullOrEmpty(saveActions))
              {
            XDocument commands = XDocument.Parse(saveActions);
            List<string> actionIds = (from c in commands.Descendants()
                                  where c.Name.LocalName == "li"
                                        && (c.Attribute(XName.Get("id")) != null
                                        && c.Attribute(XName.Get("id")).Value != null)
                                  select c.Attribute(XName.Get("id")).Value).ToList();

            foreach (string actionId in actionIds)
            {
              Item actionItem = args.Item.Database.GetItem(actionId);
              string assembly = actionItem["assembly"];
              string className = actionItem["Class"];

              object obj = ReflectionUtil.CreateObject(assembly, className, new object[] { });
              if (obj == null)
              {
            throw new ConfigurationException("Could not load " + className + " from " + assembly);
              }

              MethodInfo method = ReflectionUtil.GetMethod(obj, "Load", new object[] { IsPostback, args });
              if (method != null)
              {
            ReflectionUtil.InvokeMethod(method, new object[] { IsPostback, args }, obj);
              }
            }
              }
        }
Пример #8
0
        /// <summary>
        /// Gets the most recent set options from the ShoppingCart and customerInfo instance
        /// and displays the options in the web form.
        /// If there are no items in the ShoppingCart, the user will be redirected to the
        /// home page.
        /// </summary>
        /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param>
        /// <param name="args">The render form arguments.</param>
        public void Load(bool isPostback, RenderFormArgs args)
        {
            // Checks if the user has appropiate access.
              ICheckOut checkOut = Context.Entity.GetInstance<ICheckOut>();
              if (checkOut != null && checkOut is CheckOut)
              {
            if (!((CheckOut)checkOut).BeginCheckOut || !((CheckOut)checkOut).DeliveryDone)
            {
              HttpContext.Current.Response.Redirect("/");
            }
              }

              HtmlFormModifier form = new HtmlFormModifier(args);

              form.DisableInputField("UserName");

              /*
              Item navigationLinkItem = Utils.ItemUtil.GetNavigationLinkItem("Previous");
              if (navigationLinkItem != null)
              {
            form.AddButtonFromNavigationLink(navigationLinkItem, true);
              }
              */

              // If the user is logged in we hide the Create User boks.
              if (MainUtil.IsLoggedIn())
              {
            form.HideSectionByField("Create Username", "HideCreateUserSection");
              }

              ICustomerManager<CustomerInfo> customerManager = Context.Entity.Resolve<ICustomerManager<CustomerInfo>>();
              form.SetInputValue("UserName", customerManager.CurrentUser.Email);

              if (isPostback)
              {
            return;
              }

              ShoppingCart shoppingCart = Context.Entity.GetInstance<ShoppingCart>();
              shoppingCart.CustomerInfo = customerManager.CurrentUser;

              Context.Entity.SetInstance(shoppingCart);

              // Checks the Use other shipping address checkbox.
              // form.SetCheckboxSelected("HideThisSection", true);

              form.SetInputValue("Name", customerManager.CurrentUser.BillingAddress.Name);
              form.SetInputValue("Address", customerManager.CurrentUser.BillingAddress.Address);
              form.SetInputValue("Zip", customerManager.CurrentUser.BillingAddress.Zip);
              form.SetInputValue("City", customerManager.CurrentUser.BillingAddress.City);
              form.SetInputValue("Email", customerManager.CurrentUser.Email);

              if (customerManager.CurrentUser.BillingAddress.Country.Code != "US")
              {
            form.HideField("State");
              }
              else
              {
            form.SetSelectedDropListValue("State", customerManager.CurrentUser.BillingAddress.State);
              }

              if (customerManager.CurrentUser.ShippingAddress.Country.Code != "US")
              {
            form.HideField("ShippingState");
              }
              else
              {
            form.SetSelectedDropListValue("ShippingState", customerManager.CurrentUser.ShippingAddress.State);
              }

              form.SetSelectedDropListValue("Country", customerManager.CurrentUser.BillingAddress.Country.Name);

              /*
              // Only field out shipping address if it was checked before.
              if (checkOut is CheckOut)
              {
            if (!((CheckOut)checkOut).HasOtherShippingAddressBeenChecked)
            {
              return;
            }
              }
              */
              form.SetInputValue("ShippingName", customerManager.CurrentUser.ShippingAddress.Name);
              form.SetInputValue("ShippingAddress", customerManager.CurrentUser.ShippingAddress.Address);
              form.SetInputValue("ShippingZip", customerManager.CurrentUser.ShippingAddress.Zip);
              form.SetInputValue("ShippingCity", customerManager.CurrentUser.ShippingAddress.City);

              form.SetSelectedDropListValue("ShippingCountry", customerManager.CurrentUser.ShippingAddress.Country.Title);

              foreach (string key in customerManager.CurrentUser.CustomProperties.AllKeys)
              {
            form.SetInputValue(key, customerManager.CurrentUser.CustomProperties[key]);
              }
        }
        /// <summary>
        /// The form load event handler.
        /// </summary>
        /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param>
        /// <param name="args">The render form arguments.</param>
        public void Load(bool isPostback, RenderFormArgs args)
        {
            HtmlFormModifier form = new HtmlFormModifier(args);

              form.DisableInputField("UserName");
        }
Пример #10
0
        /// <summary>
        /// Gets the most recent set options from the ShoppingCart and customerInfo instance
        /// and displays the options in the web form.
        /// If there are no items in the ShoppingCart, the user will be redirected to the
        /// home page.
        /// </summary>
        /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param>
        /// <param name="args">The render form arguments.</param>
        public void Load(bool isPostback, RenderFormArgs args)
        {
            // Checks if the user has appropiate access.
            ICheckOut checkOut = Context.Entity.GetInstance <ICheckOut>();

            if (checkOut != null && checkOut is CheckOut)
            {
                if (!((CheckOut)checkOut).BeginCheckOut || !((CheckOut)checkOut).DeliveryDone)
                {
                    HttpContext.Current.Response.Redirect("/");
                }
            }

            HtmlFormModifier form = new HtmlFormModifier(args);

            form.DisableInputField("UserName");

            /*
             * Item navigationLinkItem = Utils.ItemUtil.GetNavigationLinkItem("Previous");
             * if (navigationLinkItem != null)
             * {
             * form.AddButtonFromNavigationLink(navigationLinkItem, true);
             * }
             */

            // If the user is logged in we hide the Create User boks.
            if (MainUtil.IsLoggedIn())
            {
                form.HideSectionByField("Create Username", "HideCreateUserSection");
            }

            ICustomerManager <CustomerInfo> customerManager = Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            form.SetInputValue("UserName", customerManager.CurrentUser.Email);

            if (isPostback)
            {
                return;
            }

            ShoppingCart shoppingCart = Context.Entity.GetInstance <ShoppingCart>();

            shoppingCart.CustomerInfo = customerManager.CurrentUser;

            Context.Entity.SetInstance(shoppingCart);

            // Checks the Use other shipping address checkbox.
            // form.SetCheckboxSelected("HideThisSection", true);

            form.SetInputValue("Name", customerManager.CurrentUser.BillingAddress.Name);
            form.SetInputValue("Address", customerManager.CurrentUser.BillingAddress.Address);
            form.SetInputValue("Zip", customerManager.CurrentUser.BillingAddress.Zip);
            form.SetInputValue("City", customerManager.CurrentUser.BillingAddress.City);
            form.SetInputValue("Email", customerManager.CurrentUser.Email);

            if (customerManager.CurrentUser.BillingAddress.Country.Code != "US")
            {
                form.HideField("State");
            }
            else
            {
                form.SetSelectedDropListValue("State", customerManager.CurrentUser.BillingAddress.State);
            }

            if (customerManager.CurrentUser.ShippingAddress.Country.Code != "US")
            {
                form.HideField("ShippingState");
            }
            else
            {
                form.SetSelectedDropListValue("ShippingState", customerManager.CurrentUser.ShippingAddress.State);
            }

            form.SetSelectedDropListValue("Country", customerManager.CurrentUser.BillingAddress.Country.Name);

            /*
             * // Only field out shipping address if it was checked before.
             * if (checkOut is CheckOut)
             * {
             * if (!((CheckOut)checkOut).HasOtherShippingAddressBeenChecked)
             * {
             *  return;
             * }
             * }
             */
            form.SetInputValue("ShippingName", customerManager.CurrentUser.ShippingAddress.Name);
            form.SetInputValue("ShippingAddress", customerManager.CurrentUser.ShippingAddress.Address);
            form.SetInputValue("ShippingZip", customerManager.CurrentUser.ShippingAddress.Zip);
            form.SetInputValue("ShippingCity", customerManager.CurrentUser.ShippingAddress.City);

            form.SetSelectedDropListValue("ShippingCountry", customerManager.CurrentUser.ShippingAddress.Country.Title);

            foreach (string key in customerManager.CurrentUser.CustomProperties.AllKeys)
            {
                form.SetInputValue(key, customerManager.CurrentUser.CustomProperties[key]);
            }
        }
Пример #11
0
        /// <summary>
        /// The form load event handler.
        /// </summary>
        /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param>
        /// <param name="args">The render form arguments.</param>
        public void Load(bool isPostback, RenderFormArgs args)
        {
            HtmlFormModifier form = new HtmlFormModifier(args);

            form.DisableInputField("UserName");
        }