コード例 #1
0
ファイル: EditAccount.cs プロジェクト: vsrathore2/SES-8.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>
        /// Renders the control.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public override void RenderControl(HtmlTextWriter writer)
        {
            var innerWriter = this.IsWffm22OrLater() ? new HtmlTextWriter(new System.IO.StringWriter()) : writer;

            innerWriter.Write("<div class='scfForm' id=\"" + this.ID + "\"");
            this.Attributes.Render(innerWriter);
            innerWriter.Write(">");

            this.RenderControl(innerWriter, this.Adapter);

            innerWriter.Write("</div>");

            if (!this.IsWffm22OrLater())
            {
                return;
            }

            var args = new RenderFormArgs(this.FormItem.InnerItem)
            {
                Parameters     = WebUtil.ParseQueryString(this.Parameters),
                DisableWebEdit = this.DisableWebEditing
            };

            args.Result.FirstPart = args.Result.FirstPart + innerWriter.InnerWriter;
            using (new LongRunningOperationWatcher(Settings.Profiling.RenderFieldThreshold, "postRenderForm pipeline[id={0}]", this.FormID.ToString()))
            {
                CorePipeline.Run("postRenderForm", args);
            }

            writer.Write(args.Result);
        }
コード例 #3
0
        /// <summary>
        /// Renders the control.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public override void RenderControl(HtmlTextWriter writer)
        {
            var innerWriter = this.IsWffm22OrLater() ? new HtmlTextWriter(new System.IO.StringWriter()) : writer;
              innerWriter.Write("<div class='scfForm' id=\"" + this.ID + "\"");
              this.Attributes.Render(innerWriter);
              innerWriter.Write(">");

              this.RenderControl(innerWriter, this.Adapter);

              innerWriter.Write("</div>");

              if (!this.IsWffm22OrLater())
              {
            return;
              }

              var args = new RenderFormArgs(this.FormItem.InnerItem)
              {
            Parameters = WebUtil.ParseQueryString(this.Parameters),
            DisableWebEdit = this.DisableWebEditing
              };
              args.Result.FirstPart = args.Result.FirstPart + innerWriter.InnerWriter;
              using (new LongRunningOperationWatcher(Settings.Profiling.RenderFieldThreshold, "postRenderForm pipeline[id={0}]", this.FormID.ToString()))
              {
            CorePipeline.Run("postRenderForm", args);
              }

              writer.Write(args.Result);
        }
コード例 #4
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]);
              }
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HtmlFormModifier"/> class.
        /// </summary>
        /// <param name="args">The render form arguments.</param>
        public HtmlFormModifier(RenderFormArgs args)
        {
            this.formItem = args.Item;
              this.args = args;

              var firstPartDoc = new HtmlDocument();
              firstPartDoc.LoadHtml(args.Result.FirstPart);
              this.firstPart = ToXDocument(firstPartDoc);
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HtmlFormModifier"/> class.
        /// </summary>
        /// <param name="args">The render form arguments.</param>
        public HtmlFormModifier(RenderFormArgs args)
        {
            this.formItem = args.Item;
            this.args     = args;

            var firstPartDoc = new HtmlDocument();

            firstPartDoc.LoadHtml(args.Result.FirstPart);
            this.firstPart = ToXDocument(firstPartDoc);
        }
コード例 #7
0
ファイル: PostRenderForm.cs プロジェクト: vsrathore2/SES-8.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);
                    }
                }
            }
        }
コード例 #8
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);
              }
            }
              }
        }
コード例 #9
0
ファイル: LogIn.cs プロジェクト: vsrathore2/SES-8.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");
            }
        }
コード例 #10
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");
              }
        }
コード例 #11
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.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);
              }
            }
              }
        }
コード例 #12
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");
        }
コード例 #13
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)
 {
 }
コード例 #14
0
ファイル: ChangePassword.cs プロジェクト: vsrathore2/SES-8.0
 /// <summary>
 /// The on load. </summary>
 /// <param name="isPostback">Is PostBack </param>
 /// <param name="args">Render form args </param>
 protected void OnLoad(bool isPostback, RenderFormArgs args)
 {
 }
コード例 #15
0
 /// <summary>
 /// The on load. </summary>
 /// <param name="isPostback">Is PostBack </param>
 /// <param name="args">Render form args </param>
 protected void OnLoad(bool isPostback, RenderFormArgs args)
 {
 }
コード例 #16
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");
        }
コード例 #17
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]);
              }
        }
コード例 #18
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]);
            }
        }
コード例 #19
0
ファイル: NewPassword.cs プロジェクト: vsrathore2/SES-8.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)
 {
 }