コード例 #1
0
        protected override void loadData()
        {
            var pb  = PostBack.CreateFull(actionGetter: () => new PostBackAction(new ExternalResourceInfo(es.info.ReturnAndDestinationUrl)));
            var fib = FormItemBlock.CreateFormItemTable();

            newPassword = new DataValue <string>();
            fib.AddFormItems(
                FormItem.Create(
                    "New password",
                    new EwfTextBox("", masksCharacters: true),
                    validationGetter: control => new Validation((pbv, v) => newPassword.Value = control.GetPostBackValue(pbv), pb)));
            var newPasswordConfirm = new DataValue <string>();

            fib.AddFormItems(
                FormItem.Create(
                    "Re-type new password",
                    new EwfTextBox("", masksCharacters: true),
                    validationGetter: control => new Validation((pbv, v) => newPasswordConfirm.Value = control.GetPostBackValue(pbv), pb)));
            pb.AddTopValidationMethod((pbv, validator) => FormsAuthStatics.ValidatePassword(validator, newPassword, newPasswordConfirm));

            ph.AddControlsReturnThis(fib);
            EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Change Password", new PostBackButton(pb)));

            pb.AddModificationMethod(modifyData);
        }
        protected override void loadData()
        {
            var pb = PostBack.CreateFull(
                firstModificationMethod: () => {
                IntermediateAuthenticationMethods.SetCookie();
                AppRequestState.Instance.IntermediateUserExists = true;
            },
                actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl)));

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                pb.ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    FormItemBlock.CreateFormItemTable(
                        formItems:
                        FormItem.Create(
                            "Enter your password for this non-live installation",
                            new EwfTextBox("", masksCharacters: true),
                            validationGetter: control => new EwfValidation(
                                (pbv, validator) => {
                    // NOTE: Using a single password here is a hack. The real solution is being able to use RSIS credentials, which is a goal.
                    var passwordMatch = control.GetPostBackValue(pbv) ==
                                        ConfigurationStatics.SystemGeneralProvider.IntermediateLogInPassword;
                    if (!passwordMatch)
                    {
                        validator.NoteErrorAndAddMessage("Incorrect password.");
                    }
                })).ToCollection()));
            });

            EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Log In", new PostBackButton(pb)));
        }
コード例 #3
0
        protected override void loadData()
        {
            var staticTable = FormItemBlock.CreateFormItemTable();

            staticTable.AddFormItems(
                FormItem.Create("Static Field", new EwfTextBox("Values here will be retained across post-backs")),
                FormItem.Create("Static Field", new EwfTextBox("")),
                FormItem.Create(
                    "Static Field",
                    new EwfTextBox("Edit this one to get a validation error"),
                    validationGetter: control => new EwfValidation(
                        (pbv, validator) => {
                if (control.ValueChangedOnPostBack(pbv))
                {
                    validator.NoteErrorAndAddMessage("You can't change the value in this box!");
                }
            },
                        DataUpdate)));
            staticTable.IncludeButtonWithThisText = "Submit";
            ph.AddControlsReturnThis(staticTable);

            ph.AddControlsReturnThis(getBasicRegionBlocks());

            var listTable = EwfTable.Create(
                style: EwfTableStyle.StandardLayoutOnly,
                fields: from i in new[] { 10, 1, 10 } select new EwfTableField(size: Unit.Percentage(i)));

            listTable.AddItem(
                new EwfTableItem(
                    new EwfTableItemSetup(verticalAlignment: TableCellVerticalAlignment.Top),
                    getNonIdListRegionBlocks().ToCell(),
                    "",
                    getIdListRegionBlocks().ToCell()));
            ph.AddControlsReturnThis(listTable);
        }
コード例 #4
0
        protected override void loadData()
        {
            ph.AddControlsReturnThis(new LegacyParagraph("You may report any problems, make suggestions, or ask for help here."));

            var pb = PostBack.CreateFull(firstModificationMethod: modifyData, actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl)));

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                pb.ToCollection(),
                () => {
                var table = FormItemBlock.CreateFormItemTable();
                table.AddFormItems(
                    FormItem.Create(
                        "From",
                        new PlaceHolder().AddControlsReturnThis(
                            new EmailAddress(AppTools.User.Email, AppTools.User.FriendlyName).ToMailAddress().ToString().ToComponents().GetControls())),
                    FormItem.Create(
                        "To",
                        new PlaceHolder().AddControlsReturnThis(
                            "{0} ({1} for this system)".FormatWith(
                                StringTools.GetEnglishListPhrase(EmailStatics.GetAdministratorEmailAddresses().Select(i => i.DisplayName), true),
                                "support contacts".ToQuantity(EmailStatics.GetAdministratorEmailAddresses().Count(), showQuantityAs: ShowQuantityAs.None))
                            .ToComponents()
                            .GetControls())),
                    FormItem.Create(
                        "Message",
                        new EwfTextBox("", rows: 10),
                        validationGetter:
                        control =>
                        new EwfValidation(
                            (pbv, validator) => body.Value = validator.GetString(new ValidationErrorHandler("message"), control.GetPostBackValue(pbv), false))));
                ph.AddControlsReturnThis(table);
            });

            EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Send Message", new PostBackButton(pb)));
        }
コード例 #5
0
        protected override void loadData()
        {
            var pb =
                PostBack.CreateFull(
                    actionGetter:
                    () =>
                    new PostBackAction(
                        new SecondaryResponse(
                            () =>
                            EwfResponse.Create(
                                ContentTypes.ApplicationZip,
                                new EwfResponseBodyCreator(createAndZipSystem),
                                fileNameCreator: () => "{0}.zip".FormatWith(systemShortName.Value)))));

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                pb.ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    FormItemBlock.CreateFormItemTable(
                        formItems: new[]
                {
                    FormItem.Create(
                        "System name",
                        new EwfTextBox(""),
                        validationGetter: control => new EwfValidation(
                            (pbv, validator) => {
                        systemName.Value = validator.GetString(
                            new ValidationErrorHandler("system name"),
                            control.GetPostBackValue(pbv),
                            false,
                            50);
                        if (systemName.Value != systemName.Value.RemoveNonAlphanumericCharacters(preserveWhiteSpace: true))
                        {
                            validator.NoteErrorAndAddMessage("The system name must consist of only alphanumeric characters and white space.");
                        }
                        systemShortName.Value = systemName.Value.EnglishToPascal();
                    })),
                    FormItem.Create(
                        "Base namespace",
                        new EwfTextBox(""),
                        validationGetter: control => new EwfValidation(
                            (pbv, validator) => {
                        baseNamespace.Value = validator.GetString(
                            new ValidationErrorHandler("base namespace"),
                            control.GetPostBackValue(pbv),
                            false,
                            50);
                        if (baseNamespace.Value != EwlStatics.GetCSharpIdentifier(baseNamespace.Value))
                        {
                            validator.NoteErrorAndAddMessage("The base namespace must be a valid C# identifier.");
                        }
                    }))
                }));
            });

            EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Create System", new PostBackButton(pb)));
        }
コード例 #6
0
 protected override void loadData()
 {
     pb = PostBack.CreateFull();
     ph.AddControlsReturnThis(
         FormItemBlock.CreateFormItemTable(heading: "Radio Button List, Vertical", formItems: getRadioItems(false)),
         FormItemBlock.CreateFormItemTable(heading: "Radio Button List, Horizontal", formItems: getRadioItems(true)),
         getSelect2UpgradeTestingInfo(),
         FormItemBlock.CreateFormItemTable(heading: "Drop-Down List", formItems: getDropDownItems()));
     EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Submit", new PostBackButton(pb)));
 }
コード例 #7
0
        protected override void loadData()
        {
            var table = FormItemBlock.CreateFormItemTable();

            table.AddFormItems(
                FormItem.Create("Date Picker", new DatePicker(null)),
                FormItem.Create("Time Picker", new TimePicker(null)),
                FormItem.Create("Date/Time Picker", new DateTimePicker(null)),
                FormItem.Create("Duration Picker", new DurationPicker(TimeSpan.Zero)));
            ph.AddControlsReturnThis(table);
        }
コード例 #8
0
        protected override void loadData()
        {
            // NOTE: The attributes need to have a value...
            ph.AddControlsReturnThis(new FancyFileManager("first one!", "a"));
            var postBack = PostBack.CreateFull(firstTopValidationMethod: (pbv, v) => v.NoteErrorAndAddMessage("error"));

            ph.AddControlsReturnThis(
                FormItemBlock.CreateFormItemTable(heading: "woo", formItems: new FormItem[] { FormItem.Create("Files", new FancyFileManager("second one!", "")) }));

            ph.AddControlsReturnThis(new PostBackButton(postBack));
        }
コード例 #9
0
        protected override void loadData()
        {
            var pb = PostBack.CreateFull();

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                pb.ToCollection(),
                () => {
                addMessageIfNotNull(ph, getTest1(null));
                ph.AddControlsReturnThis(test1(setTest1));

                addMessageIfNotNull(ph, getTest2(null));
                ph.AddControlsReturnThis(test2(setTest2));

                addMessageIfNotNull(ph, getTest3(null));
                ph.AddControlsReturnThis(test3(setTest3));

                addMessageIfNotNull(ph, getTest4(null));
                ph.AddControlsReturnThis(test4(setTest4));

                addMessageIfNotNull(ph, getTest5(null));
                ph.AddControlsReturnThis(test5(setTest5));

                addMessageIfNotNull(ph, getTest6(null));
                ph.AddControlsReturnThis(test6(setTest6));

                var table = FormItemBlock.CreateFormItemTable();
                table.AddFormItems(
                    FormItem.Create("Textarea", new EwfTextBox("This is a paragraph.", rows: 4)),
                    FormItem.Create("Masked Input", new EwfTextBox("This should not appear in the markup!", masksCharacters: true)));
                ph.AddControlsReturnThis(table);

                EwfUiStatics.SetContentFootActions(
                    new ActionButtonSetup("OK", new PostBackButton()),
                    new ActionButtonSetup(
                        "Reset Values",
                        new PostBackButton(
                            PostBack.CreateFull(
                                id: "reset",
                                firstModificationMethod: () => {
                    setTest1(null);
                    setTest2(null);
                    setTest3(null);
                    setTest4(null);
                    setTest5(null);
                    setTest6(null);
                }))));
            });
        }
コード例 #10
0
        protected override void loadData()
        {
            var pb = PostBack.CreateFull(
                firstModificationMethod: modifyData,
                actionGetter: () => new PostBackAction(new ExternalResourceInfo(es.info.ReturnAndDestinationUrl)));

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                pb.ToCollection(),
                () => {
                newPassword = new DataValue <string>();
                ph.AddControlsReturnThis(
                    FormItemBlock.CreateFormItemTable(
                        formItems: newPassword.GetPasswordModificationFormItems(firstLabel: "New password", secondLabel: "Re-type new password")));
                EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Change Password", new PostBackButton()));
            });
        }
コード例 #11
0
        protected override void loadData()
        {
            var omni         = FormItemBlock.CreateFormItemList(numberOfColumns: 7);
            var complexLabel = new Panel();

            complexLabel.AddControlsReturnThis("Model number".ToComponents().GetControls());
            complexLabel.AddControlsReturnThis(
                new LaunchWindowLink(new ModalWindow(this, new PlaceHolder().AddControlsReturnThis("More information...".ToComponents().GetControls())))
            {
                ActionControlStyle = new TextActionControlStyle(" (popup)")
            });
            omni.AddFormItems(
                FormItem.Create(complexLabel, new EwfTextBox(""), cellSpan: 2),
                FormItem.Create("Normal price", new PlaceHolder().AddControlsReturnThis("".ToComponents().GetControls())),
                FormItem.Create("Actual price", new EwfTextBox("")),
                FormItem.Create("Quantity", new EwfTextBox("")),
                FormItem.Create("Inventory", new PlaceHolder().AddControlsReturnThis("".ToComponents().GetControls())),
                FormItem.Create("Bill Number", new PlaceHolder().AddControlsReturnThis("".ToComponents().GetControls())));
            ph.AddControlsReturnThis(omni);
        }
        protected override void loadData()
        {
            var fib = FormItemBlock.CreateFormItemTable();

            fib.AddFormItems(parametersModification.GetField1TextFormItem(true), parametersModification.GetField2TextFormItem(true));
            ph.AddControlsReturnThis(fib);

            ph.AddControlsReturnThis(
                new PostBackButton(
                    new ButtonActionControlStyle("Navigate and change Field 2"),
                    usesSubmitBehavior: false,
                    postBack: PostBack.CreateFull(actionGetter: () => new PostBackAction(new Info(es.info, new OptionalParameterPackage {
                Field2 = "bob"
            })))));

            var table = EwfTable.Create(headItems: new[] { new EwfTableItem("Url", "Valid?") });

            ph.AddControlsReturnThis(table);

            foreach (var scheme in new[] { "http://", "ftp://", "file://" })
            {
                foreach (var userinfo in new[] { "", "user:pass@" })
                {
                    foreach (var subdomain in new[] { "", "subdomain." })
                    {
                        foreach (var domain in new[] { "domain", "localhost" })
                        {
                            foreach (var tld in new[] { "", ".com" })
                            {
                                foreach (var port in new[] { "", ":80" })
                                {
                                    foreach (var folder in new[] { "", "/", "/folder/" })
                                    {
                                        foreach (var file in new[] { "", "file.asp" })
                                        {
                                            foreach (var query in new[] { "", "?here=go&there=yup" })
                                            {
                                                foreach (var frag in new[] { "", "#fragment" })
                                                {
                                                    testUrl(table, scheme + userinfo + subdomain + domain + tld + port + folder + file + query + frag);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                foreach (var additionalUrl in
                         new[]
                {
                    "//example.org/scheme-relative/URI/with/absolute/path/to/resource.txt", "/relative/URI/with/absolute/path/to/resource.txt",
                    "relative/path/to/resource.txt", "../../../resource.txt", "./resource.txt#frag01", "resource.txt", "#frag01", "www.world.com"
                })
                {
                    testUrl(table, additionalUrl);
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// Call this during LoadData.
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="vl"></param>
        /// <param name="availableRoles">Pass a restricted list of <see cref="Role"/>s the user may select. Otherwise, Roles available
        /// in the System Provider are used.</param>
        /// <param name="validationPredicate">If the function returns true, validation continues.</param>
        public void LoadData(int?userId, ValidationList vl, List <Role> availableRoles = null, Func <bool> validationPredicate = null)
        {
            availableRoles = (availableRoles != null ? availableRoles.OrderBy(r => r.Name) : UserManagementStatics.SystemProvider.GetRoles()).ToList();

            user = userId.HasValue ? UserManagementStatics.GetUser(userId.Value, true) : null;
            if (includePasswordControls() && user != null)
            {
                facUser = FormsAuthStatics.GetUser(user.UserId, true);
            }

            Func <bool> validationShouldRun = () => validationPredicate == null || validationPredicate();

            var b = FormItemBlock.CreateFormItemTable(heading: "Security Information");

            b.AddFormItems(
                FormItem.Create(
                    "Email address",
                    new EwfTextBox(user != null ? user.Email : ""),
                    validationGetter: control => new Validation(
                        (pbv, validator) => {
                if (validationShouldRun())
                {
                    Email = validator.GetEmailAddress(new ValidationErrorHandler("email address"), control.GetPostBackValue(pbv), false);
                }
            },
                        vl)));

            if (includePasswordControls())
            {
                var group = new RadioButtonGroup(false);

                var keepPassword = FormItem.Create(
                    "",
                    group.CreateInlineRadioButton(true, label: userId.HasValue ? "Keep the current password" : "Do not create a password"),
                    validationGetter: control => new Validation(
                        (pbv, validator) => {
                    if (!validationShouldRun() || !control.IsCheckedInPostBack(pbv))
                    {
                        return;
                    }
                    if (user != null)
                    {
                        Salt               = facUser.Salt;
                        SaltedPassword     = facUser.SaltedPassword;
                        MustChangePassword = facUser.MustChangePassword;
                    }
                    else
                    {
                        genPassword(false);
                    }
                },
                        vl));

                var generatePassword = FormItem.Create(
                    "",
                    group.CreateInlineRadioButton(false, label: "Generate a " + (userId.HasValue ? "new, " : "") + "random password and email it to the user"),
                    validationGetter: control => new Validation(
                        (pbv, validator) => {
                    if (validationShouldRun() && control.IsCheckedInPostBack(pbv))
                    {
                        genPassword(true);
                    }
                },
                        vl));

                var newPassword      = new DataValue <string>();
                var confirmPassword  = new DataValue <string>();
                var newPasswordTable = EwfTable.Create(style: EwfTableStyle.StandardExceptLayout);
                newPasswordTable.AddItem(
                    new EwfTableItem(
                        "Password",
                        FormItem.Create(
                            "",
                            new EwfTextBox("", masksCharacters: true, disableBrowserAutoComplete: true)
                {
                    Width = Unit.Pixel(200)
                },
                            validationGetter: control => new Validation((pbv, v) => newPassword.Value = control.GetPostBackValue(pbv), vl)).ToControl()));
                newPasswordTable.AddItem(
                    new EwfTableItem(
                        "Password again",
                        FormItem.Create(
                            "",
                            new EwfTextBox("", masksCharacters: true, disableBrowserAutoComplete: true)
                {
                    Width = Unit.Pixel(200)
                },
                            validationGetter: control => new Validation((pbv, v) => confirmPassword.Value = control.GetPostBackValue(pbv), vl)).ToControl()));

                var providePasswordRadio = group.CreateBlockRadioButton(false, label: "Provide a " + (userId.HasValue ? "new " : "") + "password");
                providePasswordRadio.NestedControls.Add(newPasswordTable);
                var providePassword = FormItem.Create(
                    "",
                    providePasswordRadio,
                    validationGetter: control => new Validation(
                        (pbv, validator) => {
                    if (!validationShouldRun() || !control.IsCheckedInPostBack(pbv))
                    {
                        return;
                    }
                    FormsAuthStatics.ValidatePassword(validator, newPassword, confirmPassword);
                    var p              = new Password(newPassword.Value);
                    Salt               = p.Salt;
                    SaltedPassword     = p.ComputeSaltedHash();
                    MustChangePassword = false;
                },
                        vl));

                b.AddFormItems(
                    FormItem.Create("Password", ControlStack.CreateWithControls(true, keepPassword.ToControl(), generatePassword.ToControl(), providePassword.ToControl())));
            }

            b.AddFormItems(
                FormItem.Create(
                    "Role",
                    SelectList.CreateDropDown(
                        from i in availableRoles select SelectListItem.Create(i.RoleId as int?, i.Name),
                        user != null ? user.Role.RoleId as int? : null),
                    validationGetter: control => new Validation(
                        (pbv, validator) => {
                if (validationShouldRun())
                {
                    RoleId = control.ValidateAndGetSelectedItemIdInPostBack(pbv, validator) ?? default(int);
                }
            },
                        vl)));

            Controls.Add(b);
        }
コード例 #14
0
        /// <summary>
        /// Call this during LoadData.
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="availableRoles">Pass a restricted list of <see cref="Role"/>s the user may select. Otherwise, Roles available
        /// in the System Provider are used.</param>
        /// <param name="validationPredicate">If the function returns true, validation continues.</param>
        public void LoadData(int?userId, List <Role> availableRoles = null, Func <bool> validationPredicate = null)
        {
            availableRoles = (availableRoles != null ? availableRoles.OrderBy(r => r.Name) : UserManagementStatics.SystemProvider.GetRoles()).ToList();

            user = userId.HasValue ? UserManagementStatics.GetUser(userId.Value, true) : null;
            if (includePasswordControls() && user != null)
            {
                facUser = FormsAuthStatics.GetUser(user.UserId, true);
            }

            Func <bool> validationShouldRun = () => validationPredicate == null || validationPredicate();

            var b = FormItemBlock.CreateFormItemTable(heading: "Security Information");

            b.AddFormItems(
                FormItem.Create(
                    "Email address",
                    new EwfTextBox(user != null ? user.Email : ""),
                    validationGetter: control => new EwfValidation(
                        (pbv, validator) => {
                if (validationShouldRun())
                {
                    Email = validator.GetEmailAddress(new ValidationErrorHandler("email address"), control.GetPostBackValue(pbv), false);
                }
            })));

            if (includePasswordControls())
            {
                var group = new RadioButtonGroup(false);

                var keepPassword = FormItem.Create(
                    "",
                    group.CreateInlineRadioButton(true, label: userId.HasValue ? "Keep the current password" : "Do not create a password"),
                    validationGetter: control => new EwfValidation(
                        (pbv, validator) => {
                    if (!validationShouldRun() || !control.IsCheckedInPostBack(pbv))
                    {
                        return;
                    }
                    if (user != null)
                    {
                        Salt               = facUser.Salt;
                        SaltedPassword     = facUser.SaltedPassword;
                        MustChangePassword = facUser.MustChangePassword;
                    }
                    else
                    {
                        genPassword(false);
                    }
                }));

                var generatePassword = FormItem.Create(
                    "",
                    group.CreateInlineRadioButton(false, label: "Generate a " + (userId.HasValue ? "new, " : "") + "random password and email it to the user"),
                    validationGetter: control => new EwfValidation(
                        (pbv, validator) => {
                    if (validationShouldRun() && control.IsCheckedInPostBack(pbv))
                    {
                        genPassword(true);
                    }
                }));

                var providePassword = FormState.ExecuteWithValidationPredicate(
                    validationShouldRun,
                    () => {
                    var providePasswordSelected = new DataValue <bool>();
                    return(FormItem.Create(
                               "",
                               group.CreateBlockRadioButton(
                                   false,
                                   (postBackValue, validator) => providePasswordSelected.Value = postBackValue.Value,
                                   label: "Provide a {0}".FormatWith(userId.HasValue ? "new password" : "password"),
                                   nestedControlListGetter: () => {
                        return FormState.ExecuteWithValidationPredicate(
                            () => providePasswordSelected.Value,
                            () => {
                            var password = new DataValue <string>();
                            var newPasswordTable = EwfTable.Create(style: EwfTableStyle.StandardExceptLayout);
                            foreach (var i in password.GetPasswordModificationFormItems(textBoxWidth: Unit.Pixel(200)))
                            {
                                newPasswordTable.AddItem(new EwfTableItem(i.Label, i.ToControl(omitLabel: true)));
                            }

                            new EwfValidation(
                                validator => {
                                var p = new Password(password.Value);
                                Salt = p.Salt;
                                SaltedPassword = p.ComputeSaltedHash();
                                MustChangePassword = false;
                            });

                            return newPasswordTable.ToCollection();
                        });
                    }),
                               validationGetter: control => control.Validation));
                });

                b.AddFormItems(
                    FormItem.Create("Password", ControlStack.CreateWithControls(true, keepPassword.ToControl(), generatePassword.ToControl(), providePassword.ToControl())));
            }

            b.AddFormItems(
                FormItem.Create(
                    "Role",
                    SelectList.CreateDropDown(
                        from i in availableRoles select SelectListItem.Create(i.RoleId as int?, i.Name),
                        user != null ? user.Role.RoleId as int? : null),
                    validationGetter: control => new EwfValidation(
                        (pbv, validator) => {
                if (validationShouldRun())
                {
                    RoleId = control.ValidateAndGetSelectedItemIdInPostBack(pbv, validator) ?? default(int);
                }
            })));

            Controls.Add(b);
        }