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)));
        }
        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)));
        }
        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);
        }
Esempio n. 4
0
        protected override void loadData()
        {
            var updateRegionSet = new UpdateRegionSet();

            EwfUiStatics.SetPageActions(
                new ActionButtonSetup(
                    "Remove Last Group",
                    new PostBackButton(
                        PostBack.CreateIntermediate(
                            updateRegionSet.ToCollection(),
                            id: "removeLastGroup",
                            firstModificationMethod: () => {
                if (info.GroupCount <= 0)
                {
                    throw new DataModificationException("No groups to remove.");
                }
                parametersModification.GroupCount -= 1;
            }))));

            place.Controls.Add(
                EwfTable.CreateWithItemGroups(
                    Enumerable.Range(1, info.GroupCount).Select(getItemGroup),
                    defaultItemLimit: DataRowLimit.Fifty,
                    caption: "Caption",
                    subCaption: "Sub caption",
                    fields:
                    new[]
                    { new EwfTableField(size: Unit.Percentage(1), toolTip: "First column!"), new EwfTableField(size: Unit.Percentage(2), toolTip: "Second column!") },
                    headItems: new EwfTableItem("First Column", "Second Column").ToCollection(),
                    tailUpdateRegions: new TailUpdateRegion(updateRegionSet.ToCollection(), 1).ToCollection()));
        }
        protected override void loadData()
        {
            EwfUiStatics.OmitContentBox();

            ph.AddControlsReturnThis(
                new Section(new Paragraph("This is a basic box.".ToComponents()).ToCollection(), style: SectionStyle.Box).ToCollection()
                .Append(new Section("Heading Box", new Paragraph("This is a box with heading.".ToComponents()).ToCollection(), style: SectionStyle.Box))
                .Append(
                    new Section(
                        "Expandable Box",
                        new Paragraph("This is an expandable box.".ToComponents()).ToCollection(),
                        style: SectionStyle.Box,
                        expanded: false))
                .Append(
                    new Section(
                        "Heading Box",
                        new Paragraph("This is a box with heading.".ToComponents()).ToCollection(),
                        style: SectionStyle.Box,
                        postHeadingComponents: new Paragraph("Post-heading components.".ToComponents()).ToCollection()))
                .Append(
                    new Section(
                        "Expandable Box",
                        new Paragraph("This is an expandable box.".ToComponents()).ToCollection(),
                        style: SectionStyle.Box,
                        postHeadingComponents: new Paragraph("Post-heading components.".ToComponents()).ToCollection(),
                        expanded: false))
                .GetControls());
        }
Esempio n. 6
0
        protected override void loadData()
        {
            ph.AddControlsReturnThis(new LegacyParagraph("You may report any problems, make suggestions, or ask for help here."));

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull(firstModificationMethod: modifyData, actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl)))
                .ToCollection(),
                () => {
                var list = FormItemList.CreateStack();
                list.AddFormItems(
                    new EmailAddress(AppTools.User.Email, AppTools.User.FriendlyName).ToMailAddress()
                    .ToString()
                    .ToComponents()
                    .ToFormItem(label: "From".ToComponents()),
                    "{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()
                    .ToFormItem(label: "To".ToComponents()),
                    body.ToTextControl(false, setup: TextControlSetup.Create(numberOfRows: 10), value: "").ToFormItem(label: "Message".ToComponents()));
                ph.AddControlsReturnThis(list.ToCollection().GetControls());

                EwfUiStatics.SetContentFootActions(new ButtonSetup("Send Message").ToCollection());
            });
        }
        protected override void loadData()
        {
            var pb = PostBack.CreateFull(actionGetter: () => new PostBackAction(new ExternalResourceInfo(es.info.DestinationUrl)));

            EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Reset Password", new PostBackButton(pb)));

            pb.AddModificationMethod(modifyData);
        }
Esempio n. 8
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)));
        }
Esempio n. 9
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)));
 }
        protected override void loadData()
        {
            HtmlBlockEditorModification mod;

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull().ToCollection(),
                () => {
                ph.AddControlsReturnThis(new HtmlBlockEditor(null, id => { }, out mod).ToFormItem("").ToControl());
                EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Post Back", new PostBackButton()));
            });
        }
 protected override void loadData()
 {
     FormState.ExecuteWithDataModificationsAndDefaultAction(
         PostBack.CreateFull().ToCollection(),
         () => {
         ph.AddControlsReturnThis(
             new HtmlBlockEditor(null, id => {}, out var mod).ToFormItem(label: Enumerable.Empty <PhrasingComponent>().Materialize())
             .ToComponentCollection()
             .GetControls());
         EwfUiStatics.SetContentFootActions(new ButtonSetup("Post Back").ToCollection());
     });
 }
        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);
                }))));
            });
        }
        protected override void loadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull().ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    new Section("Radio Button List, Vertical", FormItemList.CreateStack(items: getRadioItems(false).Materialize()).ToCollection())
                    .ToCollection <FlowComponent>()
                    .Append(new Section("Radio Button List, Horizontal", FormItemList.CreateStack(items: getRadioItems(true).Materialize()).ToCollection()))
                    .Append(getChosenUpgradeTestingInfo())
                    .Append(new Section("Drop-Down List", FormItemList.CreateStack(items: getDropDownItems().Materialize()).ToCollection()))
                    .GetControls());

                EwfUiStatics.SetContentFootActions(new ButtonSetup("Submit").ToCollection());
            });
        }
        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()));
            });
        }
Esempio n. 15
0
        protected override void loadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull(
                    actionGetter: () => new PostBackAction(
                        new PageReloadBehavior(
                            secondaryResponse: new SecondaryResponse(
                                () => EwfResponse.Create(
                                    ContentTypes.ApplicationZip,
                                    new EwfResponseBodyCreator(createAndZipSystem),
                                    fileNameCreator: () => "{0}.zip".FormatWith(systemShortName.Value))))))
                .ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    FormItemList.CreateStack(
                        items: new[]
                {
                    systemName.ToTextControl(
                        false,
                        value: "",
                        maxLength: 50,
                        additionalValidationMethod: validator => {
                        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();
                    })
                    .ToFormItem(label: "System name".ToComponents()),
                    baseNamespace.ToTextControl(
                        false,
                        value: "",
                        maxLength: 50,
                        additionalValidationMethod: validator => {
                        if (baseNamespace.Value != EwlStatics.GetCSharpIdentifier(baseNamespace.Value))
                        {
                            validator.NoteErrorAndAddMessage("The base namespace must be a valid C# identifier.");
                        }
                    })
                    .ToFormItem(label: "Base namespace".ToComponents())
                })
                    .ToCollection()
                    .GetControls());

                EwfUiStatics.SetContentFootActions(new ButtonSetup("Create System").ToCollection());
            });
        }
Esempio n. 16
0
        protected override void loadData()
        {
            var pb = PostBack.CreateFull(actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl)));

            ph.AddControlsReturnThis(
                FormItem.Create(
                    "You may report any problems, make suggestions, or ask for help here.",
                    new EwfTextBox("", rows: 20),
                    validationGetter:
                    control =>
                    new EwfValidation(
                        (pbv, validator) => emailText = validator.GetString(new ValidationErrorHandler("text"), control.GetPostBackValue(pbv), false),
                        pb)).ToControl());

            EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Send", new PostBackButton(pb)));

            pb.AddModificationMethod(modifyData);
        }
        protected override void loadData()
        {
            if (info.UserId.HasValue)
            {
                EwfUiStatics.SetPageActions(
                    new ActionButtonSetup(
                        "Delete User",
                        new PostBackButton(
                            PostBack.CreateFull(id: "delete", firstModificationMethod: deleteUser, actionGetter: () => new PostBackAction(new SystemUsers.Info(es.info))))));
            }

            var pb = PostBack.CreateFull(actionGetter: () => new PostBackAction(es.info.ParentResource));

            userFieldTable = new UserFieldTable();
            userFieldTable.LoadData(info.UserId, pb);
            ph.AddControlsReturnThis(userFieldTable);
            EwfUiStatics.SetContentFootActions(new ActionButtonSetup("OK", new PostBackButton(pb)));

            pb.AddModificationMethod(modifyData);
        }
        protected override void loadData()
        {
            if (info.Password.Any())
            {
                if (!pageViewDataModificationsExecuted)
                {
                    throw new ApplicationException("Page-view data modifications did not execute.");
                }

                ph.AddControlsReturnThis(new Paragraph("Please wait.".ToComponents()).ToCollection().GetControls());
                StandardLibrarySessionState.Instance.SetInstantClientSideNavigation(new ExternalResourceInfo(info.ReturnUrl).GetUrl());
                return;
            }

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull(
                    firstModificationMethod: () => logIn(false),
                    actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl)))
                .ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    FormItemList.CreateStack(
                        items: new TextControl(
                            "",
                            true,
                            setup: TextControlSetup.CreateObscured(),
                            validationMethod: (postBackValue, 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 = postBackValue == ConfigurationStatics.SystemGeneralProvider.IntermediateLogInPassword;
                    if (!passwordMatch)
                    {
                        validator.NoteErrorAndAddMessage("Incorrect password.");
                    }
                }).ToFormItem(label: "Enter your password for this non-live installation".ToComponents())
                        .ToCollection())
                    .ToCollection()
                    .GetControls());

                EwfUiStatics.SetContentFootActions(new ButtonSetup("Log In").ToCollection());
            });
        }
Esempio n. 19
0
        protected override void loadData()
        {
            ph.AddControlsReturnThis(
                new Paragraph(
                    StringTools.ConcatenateWithDelimiter(
                        " ",
                        "Click \"Reset Password\" to email yourself a new password.",
                        "Upon receiving your new password, you may immediately use it to log in.",
                        "You will then be prompted to change your password to something you will remember, which you may use to log in from that point forward.")));

            EwfUiStatics.SetContentFootActions(
                new ActionButtonSetup(
                    "Reset Password",
                    new PostBackButton(
                        PostBack.CreateFull(
                            firstModificationMethod: () => {
                FormsAuthStatics.ResetAndSendPassword(info.User.UserId);
                AddStatusMessage(StatusMessageType.Info, "Your new password has been sent to your email address.");
            },
                            actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl))))));
        }
Esempio n. 20
0
        protected override void loadData()
        {
            if (info.UserId.HasValue)
            {
                EwfUiStatics.SetPageActions(
                    new ButtonSetup(
                        "Delete User",
                        behavior: new PostBackBehavior(
                            postBack: PostBack.CreateFull(
                                id: "delete",
                                firstModificationMethod: deleteUser,
                                actionGetter: () => new PostBackAction(new SystemUsers.Info(es.info))))).ToCollection());
            }

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull(firstModificationMethod: modifyData, actionGetter: () => new PostBackAction(info.ParentResource)).ToCollection(),
                () => {
                userFieldTable = new UserFieldTable();
                userFieldTable.LoadData(info.UserId);
                ph.AddControlsReturnThis(userFieldTable);

                EwfUiStatics.SetContentFootActions(new ButtonSetup("OK").ToCollection());
            });
        }
        protected override void loadData()
        {
            EwfUiStatics.OmitContentBox();

            ph.AddControlsReturnThis(
                getBox(
                    new EwfButton(
                        new StandardButtonStyle("Tiny Post Back Button", buttonSize: ButtonSize.ShrinkWrap),
                        behavior: new PostBackBehavior(postBack: PostBack.CreateFull(id: "tiny")))));
            ph.AddControlsReturnThis(
                getBox(new EwfHyperlink(SubFolder.General.GetInfo(), new ButtonHyperlinkStyle("Tiny EWF Link", buttonSize: ButtonSize.ShrinkWrap))));

            ph.AddControlsReturnThis(
                getBox(
                    new EwfButton(new StandardButtonStyle("Post Back Button"), behavior: new PostBackBehavior(postBack: PostBack.CreateFull(id: "normal")))));
            ph.AddControlsReturnThis(getBox(new EwfHyperlink(EwfTableDemo.GetInfo(), new ButtonHyperlinkStyle("EWF Link"))));

            ph.AddControlsReturnThis(
                getBox(
                    new EwfButton(
                        new StandardButtonStyle("Large Post Back Button", buttonSize: ButtonSize.Large),
                        behavior: new PostBackBehavior(postBack: PostBack.CreateFull(id: "large")))));
            ph.AddControlsReturnThis(getBox(new EwfHyperlink(EwfTableDemo.GetInfo(), new ButtonHyperlinkStyle("Large EWF Link", ButtonSize.Large))));
        }
        protected override void loadData()
        {
            EwfUiStatics.OmitContentBox();

            Tuple <IReadOnlyCollection <EtherealComponent>, Func <FormsAuthCapableUser> > logInHiddenFieldsAndMethod = null;
            var logInPb = PostBack.CreateFull(
                firstModificationMethod: () => user = logInHiddenFieldsAndMethod.Item2(),
                actionGetter: () => new PostBackAction(
                    user.MustChangePassword ? ChangePassword.Page.GetInfo(info.ReturnUrl) as ResourceInfo : new ExternalResourceInfo(info.ReturnUrl)));
            var newPasswordPb = PostBack.CreateFull(id: "newPw", actionGetter: getSendNewPasswordAction);

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                logInPb.ToCollection(),
                () => {
                var registeredComponents = new List <FlowComponent>();
                registeredComponents.Add(
                    new Paragraph(
                        "You may log in to this system if you have registered your email address with {0}"
                        .FormatWith(FormsAuthStatics.SystemProvider.AdministratingCompanyName)
                        .ToComponents()));

                emailAddress = new DataValue <string>();
                var password = new DataValue <string>();
                registeredComponents.Add(
                    FormItemList.CreateStack(
                        generalSetup: new FormItemListSetup(buttonSetup: new ButtonSetup("Log In"), enableSubmitButton: true),
                        items: FormState
                        .ExecuteWithDataModificationsAndDefaultAction(
                            new[] { logInPb, newPasswordPb },
                            () => emailAddress.GetEmailAddressFormItem("Email address".ToComponents()))
                        .Append(
                            password.ToTextControl(true, setup: TextControlSetup.CreateObscured(autoFillTokens: "current-password"), value: "")
                            .ToFormItem(label: "Password".ToComponents()))
                        .Materialize()));

                if (FormsAuthStatics.PasswordResetEnabled)
                {
                    registeredComponents.Add(
                        new Paragraph(
                            new ImportantContent("Forgot password?".ToComponents()).ToCollection()
                            .Concat(" ".ToComponents())
                            .Append(
                                new EwfButton(
                                    new StandardButtonStyle("Send me a new password", buttonSize: ButtonSize.ShrinkWrap),
                                    behavior: new PostBackBehavior(postBack: newPasswordPb)))
                            .Materialize()));
                }

                ph.AddControlsReturnThis(
                    new FlowAutofocusRegion(
                        AutofocusCondition.InitialRequest(),
                        new Section("Registered users", registeredComponents, style: SectionStyle.Box).ToCollection()).ToCollection()
                    .GetControls());

                logInHiddenFieldsAndMethod = FormsAuthStatics.GetLogInHiddenFieldsAndMethod(
                    emailAddress,
                    password,
                    getUnregisteredEmailMessage(),
                    "Incorrect password. If you do not know your password, enter your email address and send yourself a new password using the link below.");
                logInHiddenFieldsAndMethod.Item1.AddEtherealControls(this);
            });

            var specialInstructions = EwfUiStatics.AppProvider.GetSpecialInstructionsForLogInPage();

            if (specialInstructions != null)
            {
                ph.AddControlsReturnThis(specialInstructions);
            }
            else
            {
                var unregisteredComponents = new List <FlowComponent>();
                unregisteredComponents.Add(
                    new Paragraph("If you have difficulty logging in, please {0}".FormatWith(FormsAuthStatics.SystemProvider.LogInHelpInstructions).ToComponents()));
                ph.AddControlsReturnThis(new Section("Unregistered users", unregisteredComponents, style: SectionStyle.Box).ToCollection().GetControls());
            }
        }
        /// <summary>
        /// Call this from Application_Start in your Global.asax.cs file. Besides this call, there should be no other code in the method.
        /// </summary>
        /// <param name="globalInitializer">The system's global initializer. Do not pass null.</param>
        /// <param name="appInitializer">The application initializer, which performs web-site specific initialization and cleanup. If you have one of these you
        /// should name the class AppInitializer.</param>
        public static void InitStatics(SystemInitializer globalInitializer, SystemInitializer appInitializer = null)
        {
            // This is a hack to support data-access state in WCF services.
            var wcfDataAccessState = new ThreadLocal <DataAccessState>(() => new DataAccessState());

            // Initialize system.
            var initTimeDataAccessState = new ThreadLocal <DataAccessState>(() => new DataAccessState());

            try {
                GlobalInitializationOps.InitStatics(
                    globalInitializer,
                    Path.GetFileName(Path.GetDirectoryName(HttpRuntime.AppDomainAppPath)),
                    false,
                    mainDataAccessStateGetter: () => {
                    return(EwfApp.Instance != null ? EwfApp.Instance.RequestState != null ? EwfApp.Instance.RequestState.DataAccessState :
                           initTimeDataAccessState.Value :
                           System.ServiceModel.OperationContext.Current != null ? wcfDataAccessState.Value : null);
                });
            }
            catch {
                // Suppress all exceptions since there is no way to report them.
                return;
            }
            ewlInitialized = true;

            // Initialize web application.
            if (!GlobalInitializationOps.SecondaryInitFailed)
            {
                EwfApp.ExecuteWithBasicExceptionHandling(
                    () => {
                    EwfConfigurationStatics.Init();

                    GlobalConfiguration.Configure(WebApiStatics.ConfigureWebApi);

                    // Prevent MiniProfiler JSON exceptions caused by pages with hundreds of database queries.
                    MiniProfiler.Settings.MaxJsonResponseSize = int.MaxValue;

                    var globalType = BuildManager.GetGlobalAsaxType().BaseType;
                    if (!(globalType.Assembly.CreateInstance("EnterpriseWebLibrary.EnterpriseWebFramework." + globalType.Namespace + ".MetaLogicFactory") is
                          AppMetaLogicFactory metaLogicFactory))
                    {
                        throw new ApplicationException("Meta logic factory not found.");
                    }
                    EwfApp.Init(globalType, metaLogicFactory);

                    EwfPage.Init(
                        ModalBox.CreateBrowsingModalBox,
                        () => {
                        var cssInfos = new List <ResourceInfo>();
                        cssInfos.AddRange(EwfApp.MetaLogicFactory.CreateBasicCssInfos());
                        if (EwfUiStatics.AppMasterPage != null)
                        {
                            cssInfos.AddRange(EwfApp.MetaLogicFactory.CreateEwfUiCssInfos());
                        }
                        cssInfos.AddRange(EwfApp.Instance.GetStyleSheets());
                        if (EwfUiStatics.AppMasterPage != null)
                        {
                            cssInfos.AddRange(EwfUiStatics.AppProvider.GetStyleSheets());
                        }
                        return(cssInfos);
                    });
                    CssPreprocessingStatics.Init(globalInitializer.GetType().Assembly, globalType.Assembly);
                    HyperlinkBehaviorExtensionCreators.Init(ModalBox.GetBrowsingModalBoxOpenStatements);
                    EwfUiStatics.Init(globalType);

                    EwfInitializationOps.appInitializer = appInitializer;
                    appInitializer?.InitStatics();

                    initTimeDataAccessState     = null;
                    EwfApp.FrameworkInitialized = true;
                },
                    false,
                    false);
            }

            // If initialization failed, unload and restart the application after a reasonable delay.
            if (!EwfApp.FrameworkInitialized)
            {
                const int unloadDelay = 60000;                 // milliseconds
                initFailureUnloadTimer = new Timer(
                    state => EwfApp.ExecuteWithBasicExceptionHandling(
                        () => {
                    if (ConfigurationStatics.IsDevelopmentInstallation)
                    {
                        return;
                    }
                    HttpRuntime.UnloadAppDomain();

                    // Restart the application by making a request. Idea from Rick Strahl:
                    // http://weblog.west-wind.com/posts/2013/Oct/02/Use-IIS-Application-Initialization-for-keeping-ASPNET-Apps-alive.
                    //
                    // Disable server certificate validation so that this request gets through even for web sites that don't use a certificate that is trusted by
                    // default. There is no security risk since we're not sending any sensitive information and we're not using the response.
                    Tewl.Tools.NetTools.ExecuteWithResponse(
                        IisConfigurationStatics.GetFirstBaseUrlForCurrentSite(false),
                        response => {},
                        disableCertificateValidation: true);
                },
                        false,
                        false),
                    null,
                    unloadDelay,
                    Timeout.Infinite);
            }
        }
 protected override void loadData()
 {
     addHtmlEditor();
     EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Post back", new PostBackButton(PostBack.CreateFull())));
 }
 protected override void loadData()
 {
     calendar.SetParameters(info.Date, date => parametersModification.Date = date);
     EwfUiStatics.SetContentFootActions(
         ActionButtonSetup.CreateWithUrl("OK", info.ReturnUrl.Any() ? (ResourceInfo) new ExternalResourceInfo(info.ReturnUrl) : ActionControls.GetInfo()));
 }
        /// <summary>
        /// Call this from Application_Start in your Global.asax.cs file. Besides this call, there should be no other code in the method.
        /// </summary>
        /// <param name="globalInitializer">The system's global initializer. Do not pass null.</param>
        /// <param name="appInitializer">The application initializer, which performs web-site specific initialization and cleanup. If you have one of these you
        /// should name the class AppInitializer.</param>
        public static void InitStatics(SystemInitializer globalInitializer, SystemInitializer appInitializer = null)
        {
            // This is a hack to support data-access state in WCF services.
            var wcfDataAccessState = new ThreadLocal <DataAccessState>(() => new DataAccessState());

            // Initialize system.
            var initTimeDataAccessState = new ThreadLocal <DataAccessState>(() => new DataAccessState());

            try {
                GlobalInitializationOps.InitStatics(
                    globalInitializer,
                    Path.GetFileName(Path.GetDirectoryName(HttpRuntime.AppDomainAppPath)),
                    false,
                    mainDataAccessStateGetter: () => {
                    return(EwfApp.Instance != null ? EwfApp.Instance.RequestState != null ? EwfApp.Instance.RequestState.DataAccessState :
                           initTimeDataAccessState.Value :
                           System.ServiceModel.OperationContext.Current != null ? wcfDataAccessState.Value : null);
                });
            }
            catch {
                // Suppress all exceptions since there is no way to report them.
                return;
            }
            ewlInitialized = true;

            // Initialize web application.
            if (!GlobalInitializationOps.SecondaryInitFailed)
            {
                EwfApp.ExecuteWithBasicExceptionHandling(
                    () => {
                    EwfConfigurationStatics.Init();

                    GlobalConfiguration.Configure(WebApiStatics.ConfigureWebApi);

                    var miniProfilerOptions = new MiniProfilerOptions();
                    miniProfilerOptions.IgnoredPaths.Clear();
                    MiniProfiler.Configure(miniProfilerOptions);

                    var globalType     = BuildManager.GetGlobalAsaxType().BaseType;
                    var providerGetter = new SystemProviderGetter(
                        globalType.Assembly,
                        globalType.Namespace + ".Providers",
                        providerName =>
                        @"{0} provider not found in application. To implement, create a class named {0} in ""Your Web Site\Providers"" that derives from App{0}Provider."
                        .FormatWith(providerName));

                    if (ExternalFunctionalityStatics.SamlFunctionalityEnabled)
                    {
                        ExternalFunctionalityStatics.ExternalSamlProvider.InitAppStatics(
                            providerGetter,
                            () => AuthenticationStatics.SamlIdentityProviders.Select(
                                identityProvider => {
                            using (var client = new HttpClient()) {
                                client.Timeout = new TimeSpan(0, 0, 10);
                                var metadata   = Task.Run(
                                    async() => {
                                    using (var response = await client.GetAsync(identityProvider.MetadataUrl, HttpCompletionOption.ResponseHeadersRead)) {
                                        response.EnsureSuccessStatusCode();
                                        var document = new XmlDocument();
                                        using (var stream = await response.Content.ReadAsStreamAsync())
                                            using (var reader = XmlReader.Create(stream))
                                                document.Load(reader);
                                        return(document.DocumentElement);
                                    }
                                })
                                                 .Result;
                                return(metadata, identityProvider.EntityId);
                            }
                        })
                            .Materialize());
                    }

                    UrlHandlingStatics.Init(
                        (baseUrlString, appRelativeUrl) =>
                        AppRequestState.ExecuteWithUrlHandlerStateDisabled(() => UrlHandlingStatics.ResolveUrl(baseUrlString, appRelativeUrl)?.Last()));
                    CssPreprocessingStatics.Init(globalInitializer.GetType().Assembly, globalType.Assembly);
                    ResourceBase.Init(
                        (requestTransferred, resource) => {
                        if (requestTransferred)
                        {
                            var urlHandlers       = new List <BasicUrlHandler>();
                            UrlHandler urlHandler = resource;
                            do
                            {
                                urlHandlers.Add(urlHandler);
                            }while((urlHandler = urlHandler.GetParent()) != null);
                            AppRequestState.Instance.SetUrlHandlers(urlHandlers);

                            AppRequestState.Instance.SetNewUrlParameterValuesEffective(false);
                            AppRequestState.Instance.SetResource(resource);
                        }
                        else
                        {
                            AppRequestState.Instance.SetResource(resource);
                        }
                    },
                        () => AppRequestState.Instance.Resource);
                    PageBase.Init(
                        (() => BasePageStatics.AppProvider.GetPageViewDataModificationMethod(), () => BasePageStatics.AppProvider.JavaScriptDocumentReadyFunctionCall),
                        BasicPageContent.GetContent);
                    HyperlinkBehaviorExtensionCreators.Init(ModalBox.GetBrowsingModalBoxOpenStatements);
                    FileUpload.Init(() => ((BasicPageContent)PageBase.Current.BasicContent).FormUsesMultipartEncoding = true);
                    ModalBox.Init(() => ((BasicPageContent)PageBase.Current.BasicContent).BrowsingModalBoxId);
                    CreditCardCollector.Init(() => ((BasicPageContent)PageBase.Current.BasicContent).IncludesStripeCheckout = true);
                    BasePageStatics.Init(providerGetter.GetProvider <AppStandardPageLogicProvider>("StandardPageLogic"));
                    BasicPageContent.Init(
                        contentObjects => {
                        var contentUsesUi = contentObjects.Any(i => i is UiPageContent);

                        var cssInfos = new List <ResourceInfo>();
                        cssInfos.Add(
                            new ExternalResource(
                                "//fonts.googleapis.com/css2?family=Libre+Franklin:wght@500;600;700&family=Open+Sans:ital,wght@0,400;0,600;0,700;1,400&display=fallback"));
                        cssInfos.Add(new ExternalResource("//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"));
                        cssInfos.Add(new StaticFiles.Versioned.Third_party.Jquery_ui.Jquery_ui_1114custom_v2.Jquery_uiminCss());
                        cssInfos.Add(new StaticFiles.Third_party.Select_cssCss());
                        cssInfos.Add(new StaticFiles.Versioned.Third_party.Chosen.Chosen_v187.ChosenminCss());
                        cssInfos.Add(new StaticFiles.Third_party.Time_picker.StylesCss());
                        cssInfos.Add(new ExternalResource("//cdn.jsdelivr.net/qtip2/2.2.1/jquery.qtip.min.css"));
                        cssInfos.Add(new ExternalResource("//cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.4.9/dialog-polyfill.min.css"));
                        cssInfos.Add(new StaticFiles.Styles.BasicCss());
                        if (contentUsesUi)
                        {
                            cssInfos.AddRange(
                                new ResourceInfo[]
                            {
                                new StaticFiles.Styles.Ui.ColorsCss(), new StaticFiles.Styles.Ui.FontsCss(), new StaticFiles.Styles.Ui.LayoutCss(),
                                new StaticFiles.Styles.Ui.TransitionsCss()
                            });
                        }
                        foreach (var resource in BasePageStatics.AppProvider.GetStyleSheets())
                        {
                            assertResourceIsIntermediateInstallationPublicResourceWhenNecessary(resource);
                            cssInfos.Add(resource);
                        }
                        if (contentUsesUi)
                        {
                            foreach (var resource in EwfUiStatics.AppProvider.GetStyleSheets())
                            {
                                assertResourceIsIntermediateInstallationPublicResourceWhenNecessary(resource);
                                cssInfos.Add(resource);
                            }
                        }
                        else
                        {
                            foreach (var resource in BasePageStatics.AppProvider.GetCustomUiStyleSheets())
                            {
                                assertResourceIsIntermediateInstallationPublicResourceWhenNecessary(resource);
                                cssInfos.Add(resource);
                            }
                        }
                        return(cssInfos);
                    },
                        (markup, includeStripeCheckout) => {
                        string getElement(ResourceInfo resource) => "<script src=\"{0}\" defer></script>".FormatWith(resource.GetUrl());

                        var infos = new List <ResourceInfo>();
                        infos.Add(new ExternalResource("//code.jquery.com/jquery-1.12.3.min.js"));
                        infos.Add(new StaticFiles.Versioned.Third_party.Jquery_ui.Jquery_ui_1114custom_v2.Jquery_uiminJs());
                        infos.Add(new StaticFiles.Versioned.Third_party.Chosen.Chosen_v187.ChosenjqueryminJs());
                        infos.Add(new StaticFiles.Third_party.Time_picker.CodeJs());
                        infos.Add(new ExternalResource("//cdn.jsdelivr.net/qtip2/2.2.1/jquery.qtip.min.js"));
                        infos.Add(new ExternalResource("//cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.4.9/dialog-polyfill.min.js"));
                        infos.Add(new StaticFiles.Third_party.Spin_js.SpinminJs());
                        infos.Add(new ExternalResource("//cdn.ckeditor.com/4.5.8/full/ckeditor.js"));
                        infos.Add(new ExternalResource("https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js"));
                        infos.Add(new ExternalResource("https://instant.page/5.1.0"));
                        if (includeStripeCheckout)
                        {
                            infos.Add(new ExternalResource("https://checkout.stripe.com/checkout.js"));
                        }
                        infos.Add(new StaticFiles.CodeJs());
                        foreach (var i in infos.Select(getElement))
                        {
                            markup.Append(i);
                        }
                        markup.Append(MiniProfiler.Current.RenderIncludes().ToHtmlString());
                        foreach (var resource in BasePageStatics.AppProvider.GetJavaScriptFiles())
                        {
                            assertResourceIsIntermediateInstallationPublicResourceWhenNecessary(resource);
                            markup.Append(getElement(resource));
                        }
                    },
                        () => {
                        var icons = new List <(ResourceInfo, string, string)>();

                        var faviconPng48X48 = BasePageStatics.AppProvider.FaviconPng48X48;
                        if (faviconPng48X48 != null)
                        {
                            assertResourceIsIntermediateInstallationPublicResourceWhenNecessary(faviconPng48X48);
                            icons.Add((faviconPng48X48, "icon", "48x48"));
                        }

                        var favicon = BasePageStatics.AppProvider.Favicon;
                        if (favicon != null)
                        {
                            assertResourceIsIntermediateInstallationPublicResourceWhenNecessary(favicon);
                            icons.Add((favicon, "icon", ""));
                        }

                        return(icons);
                    },
                        hideWarnings => {
                        var url = AppRequestState.Instance.Url;
                        if (AppRequestState.Instance.UserAccessible && AppRequestState.Instance.ImpersonatorExists)
                        {
                            url = new UserManagement.Pages.Impersonate(
                                url,
                                optionalParameterSetter: (specifier, parameters) =>
                                specifier.User = AppTools.User != null ? AppTools.User.Email : UserManagement.Pages.Impersonate.AnonymousUser).GetUrl();
                        }
                        return(new NonLiveLogIn(
                                   url,
                                   optionalParameterSetter: (specifier, parameters) => {
                            specifier.Password = ConfigurationStatics.SystemGeneralProvider.IntermediateLogInPassword;
                            specifier.HideWarnings = hideWarnings;
                        }).GetUrl());
                    },
                        () => {
                        if (!AppRequestState.Instance.UserAccessible || !AppRequestState.Instance.ImpersonatorExists ||
                            (ConfigurationStatics.IsIntermediateInstallation && !AppRequestState.Instance.IntermediateUserExists))
                        {
                            return(null);
                        }
                        return("User impersonation is in effect.",
                               new HyperlinkSetup(new UserManagement.Pages.Impersonate(AppRequestState.Instance.Url), "Change user").Append <ActionComponentSetup>(
                                   new ButtonSetup(
                                       "End impersonation",
                                       behavior: new PostBackBehavior(
                                           postBack: PostBack.CreateFull(
                                               id: "ewfEndImpersonation",
                                               modificationMethod: UserImpersonationStatics.EndImpersonation,
                                               actionGetter: () => new PostBackAction(
                                                   new ExternalResource(
                                                       EwfConfigurationStatics.AppConfiguration.DefaultBaseUrl.GetUrlString(
                                                           EwfConfigurationStatics.AppSupportsSecureConnections)))))))
                               .Materialize());
                    });
                    EwfUiStatics.Init(providerGetter.GetProvider <AppEwfUiProvider>("EwfUi"));
                    AuthenticationStatics.Init(
                        providerGetter.GetProvider <AppAuthenticationProvider>("Authentication"),
                        (user, code) => new UserManagement.Pages.LogIn(
                            "",
                            optionalParameterSetter: (specifier, parameters) => {
                        specifier.User = user;
                        specifier.Code = code;
                    }).GetUrl(),
                        destinationUrl => new UserManagement.Pages.ChangePassword(destinationUrl).GetUrl(disableAuthorizationCheck: true));
                    Admin.EntitySetup.Init(() => RequestDispatchingStatics.AppProvider.GetFrameworkUrlParent());
                    RequestDispatchingStatics.Init(providerGetter.GetProvider <AppRequestDispatchingProvider>("RequestDispatching"));

                    EwfInitializationOps.appInitializer = appInitializer;
                    appInitializer?.InitStatics();

                    executeWithAutomaticDatabaseConnections(AuthenticationStatics.InitAppSpecificLogicDependencies);
                    if (AuthenticationStatics.SamlIdentityProviders.Any() || ExternalFunctionalityStatics.SamlFunctionalityEnabled)
                    {
                        executeWithAutomaticDatabaseConnections(ExternalFunctionalityStatics.ExternalSamlProvider.InitAppSpecificLogicDependencies);
                    }

                    initTimeDataAccessState     = null;
                    EwfApp.FrameworkInitialized = true;
                },
Esempio n. 27
0
        /// <summary>
        /// Call this from Application_Start in your Global.asax.cs file. Besides this call, there should be no other code in the method.
        /// </summary>
        // We could save people the effort of calling this by using trick #1 in
        // http://www.paraesthesia.com/archive/2011/02/08/dynamic-httpmodule-registration-in-asp-net-4-0.aspx, but that would probably require making this a static
        // method and would probably also cause this method to run at start up time in *all* web applications that reference the Standard Library, even the ones
        // that don't want to use EWF.
        protected void ewfApplicationStart(SystemLogic systemLogic)
        {
            // This is a hack to support data-access state in WCF services.
            var wcfDataAccessState = new ThreadLocal <DataAccessState>(() => new DataAccessState());

            // Initialize system.
            var initTimeDataAccessState = new ThreadLocal <DataAccessState>(() => new DataAccessState());

            try {
                AppTools.Init(
                    Path.GetFileName(Path.GetDirectoryName(HttpRuntime.AppDomainAppPath)),
                    false,
                    systemLogic,
                    mainDataAccessStateGetter: () => {
                    // We must use the Instance property here to prevent this logic from always returning the request state of the *first* EwfApp instance.
                    return(Instance != null
                                                               ? Instance.RequestState != null ? Instance.RequestState.DataAccessState : initTimeDataAccessState.Value
                                                               : System.ServiceModel.OperationContext.Current != null ? wcfDataAccessState.Value : null);
                });
            }
            catch {
                // Suppress all exceptions since there is no way to report them.
                return;
            }
            ewlInitialized = true;

            // Initialize web application.
            if (!AppTools.SecondaryInitFailed)
            {
                executeWithBasicExceptionHandling(
                    () => {
                    EwfConfigurationStatics.Init();

                    // Prevent MiniProfiler JSON exceptions caused by pages with hundreds of database queries.
                    MiniProfiler.Settings.MaxJsonResponseSize = int.MaxValue;

                    GlobalType       = GetType().BaseType;
                    MetaLogicFactory =
                        GlobalType.Assembly.CreateInstance("RedStapler.StandardLibrary.EnterpriseWebFramework." + GlobalType.Namespace + ".MetaLogicFactory") as
                        AppMetaLogicFactory;
                    if (MetaLogicFactory == null)
                    {
                        throw new ApplicationException("Meta logic factory not found.");
                    }

                    // This initialization could be performed using reflection. There is no need for EwfApp to have a dependency on these classes.
                    if (systemLogic != null)
                    {
                        CssPreprocessingStatics.Init(systemLogic.GetType().Assembly, GlobalType.Assembly);
                    }
                    else
                    {
                        CssPreprocessingStatics.Init(GlobalType.Assembly);
                    }
                    EwfUiStatics.Init(GlobalType);

                    initializeWebApp();

                    initTimeDataAccessState = null;
                    initialized             = true;
                },
                    false,
                    false);
            }

            // If initialization failed, unload and restart the application after a reasonable delay.
            if (!initialized)
            {
                const int unloadDelay = 60000;                 // milliseconds
                initFailureUnloadTimer = new Timer(
                    state => executeWithBasicExceptionHandling(
                        () => {
                    if (AppTools.IsDevelopmentInstallation)
                    {
                        return;
                    }
                    HttpRuntime.UnloadAppDomain();

                    // Restart the application by making a request. Idea from Rick Strahl:
                    // http://weblog.west-wind.com/posts/2013/Oct/02/Use-IIS-Application-Initialization-for-keeping-ASPNET-Apps-alive.
                    //
                    // Disable server certificate validation so that this request gets through even for web sites that don't use a certificate that is trusted by
                    // default. There is no security risk since we're not sending any sensitive information and we're not using the response.
                    NetTools.ExecuteWithResponse(IisConfigurationStatics.GetFirstBaseUrlForCurrentSite(false), response => { }, disableCertificateValidation: true);
                },
                        false,
                        false),
                    null,
                    unloadDelay,
                    Timeout.Infinite);
            }
        }
Esempio n. 28
0
        protected override void loadData()
        {
            var logInPb =
                PostBack.CreateFull(
                    actionGetter:
                    () =>
                    new PostBackAction(user.MustChangePassword ? ChangePassword.Page.GetInfo(info.ReturnUrl) as ResourceInfo : new ExternalResourceInfo(info.ReturnUrl)));
            var newPasswordPb = PostBack.CreateFull(id: "newPw", actionGetter: getSendNewPasswordAction);

            var registeredTable = EwfTable.Create(caption: "Registered users");

            registeredTable.AddItem(
                new EwfTableItem(
                    ("You may log in to this system if you have registered your email address with " + FormsAuthStatics.SystemProvider.AdministratingCompanyName).ToCell(
                        new TableCellSetup(fieldSpan: 2))));

            emailAddress = new DataValue <string>();
            var emailVl = new BasicValidationList();

            registeredTable.AddItem(
                new EwfTableItem("Email address", emailAddress.GetEmailAddressFormItem("", "Please enter a valid email address.", emailVl).ToControl()));
            logInPb.AddValidations(emailVl);
            newPasswordPb.AddValidations(emailVl);

            var password = new DataValue <string>();

            registeredTable.AddItem(
                new EwfTableItem(
                    "Password",
                    FormItem.Create(
                        "",
                        new EwfTextBox("", masksCharacters: true),
                        validationGetter: control => new EwfValidation((pbv, v) => password.Value = control.GetPostBackValue(pbv), logInPb)).ToControl()));

            if (FormsAuthStatics.PasswordResetEnabled)
            {
                registeredTable.AddItem(
                    new EwfTableItem(
                        new PlaceHolder().AddControlsReturnThis(
                            "If you are a first-time user and do not know your password, or if you have forgotten your password, ".GetLiteralControl(),
                            new PostBackButton(newPasswordPb, new TextActionControlStyle("click here to immediately send yourself a new password."), usesSubmitBehavior: false))
                        .ToCell(new TableCellSetup(fieldSpan: 2))));
            }

            ph.AddControlsReturnThis(registeredTable);

            var specialInstructions = EwfUiStatics.AppProvider.GetSpecialInstructionsForLogInPage();

            if (specialInstructions != null)
            {
                ph.AddControlsReturnThis(specialInstructions);
            }
            else
            {
                var unregisteredTable = EwfTable.Create(caption: "Unregistered users");
                unregisteredTable.AddItem(new EwfTableItem("If you have difficulty logging in, please " + FormsAuthStatics.SystemProvider.LogInHelpInstructions));
                ph.AddControlsReturnThis(unregisteredTable);
            }

            EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Log In", new PostBackButton(logInPb)));

            var logInMethod = FormsAuthStatics.GetLogInMethod(
                this,
                emailAddress,
                password,
                getUnregisteredEmailMessage(),
                "Incorrect password. If you do not know your password, enter your email address and send yourself a new password using the link below.",
                logInPb);

            logInPb.AddModificationMethod(() => user = logInMethod());
        }