protected override PageContent getContent()
        {
            var content = new UiPageContent();

            var staticFil = FormItemList.CreateStack(generalSetup: new FormItemListSetup(buttonSetup: new ButtonSetup("Submit")));

            staticFil.AddFormItems(
                new TextControl("Values here will be retained across post-backs", true).ToFormItem(label: "Static Field".ToComponents()),
                new TextControl("", true).ToFormItem(label: "Static Field".ToComponents()),
                new TextControl(
                    "Edit this one to get a validation error",
                    true,
                    setup: TextControlSetup.Create(validationPredicate: valueChangedOnPostBack => valueChangedOnPostBack),
                    validationMethod: (postBackValue, validator) => validator.NoteErrorAndAddMessage("You can't change the value in this box!")).ToFormItem(
                    label: "Static Field".ToComponents()));
            content.Add(staticFil);

            content.Add(getBasicRegionComponents().Materialize());

            var listTable = EwfTable.Create(
                style: EwfTableStyle.StandardLayoutOnly,
                fields: new[] { 10, 1, 10 }.Select(i => new EwfTableField(size: i.ToPercentage())).Materialize());

            listTable.AddItem(
                EwfTableItem.Create(
                    EwfTableItemSetup.Create(verticalAlignment: TableCellVerticalAlignment.Top),
                    getNonIdListRegionComponents().ToCell(),
                    "".ToCell(),
                    getIdListRegionComponents().ToCell()));
            content.Add(listTable);

            return(content);
        }
        protected override PageContent getContent()
        {
            var content = new UiPageContent(isAutoDataUpdater: true);

            var omni = FormItemList.CreateGrid(numberOfColumns: 7);

            var boxId = new ModalBoxId();

            omni.AddFormItems(
                new TextControl("", true).ToFormItem(
                    setup: new FormItemSetup(columnSpan: 2),
                    label: "Model number ".ToComponents()
                    .Append(
                        new EwfButton(
                            new StandardButtonStyle("(popup)", buttonSize: ButtonSize.ShrinkWrap),
                            behavior: new OpenModalBehavior(boxId, etherealChildren: new ModalBox(boxId, true, "More information...".ToComponents()).ToCollection())))
                    .Materialize()),
                "".ToComponents().ToFormItem(label: "Normal price".ToComponents()),
                new TextControl("", true).ToFormItem(label: "Actual price".ToComponents()),
                new TextControl("", true).ToFormItem(label: "Quantity".ToComponents()),
                "".ToComponents().ToFormItem(label: "Inventory".ToComponents()),
                "".ToComponents().ToFormItem(label: "Bill Number".ToComponents()));
            content.Add(omni);

            return(content);
        }
        protected override PageContent getContent()
        {
            var content = new UiPageContent(omitContentBox: true);

            if (UserManagementStatics.IdentityProviders.OfType <SamlIdentityProvider>().Any())
            {
                var certificate = UserManagementStatics.GetCertificate();
                content.Add(
                    new Section(
                        "Identity providers",
                        FormItemList.CreateStack(
                            items:
                            (certificate.Any()
                                                                          ? "Certificate valid until {0}.".FormatWith(
                                 new X509Certificate2(Convert.FromBase64String(certificate), UserManagementStatics.CertificatePassword).NotAfter
                                 .ToDayMonthYearString(
                                     false))
                             .ToComponents()
                                                                          : "No certificate.".ToComponents()).Concat(" ".ToComponents())
                            .Append(
                                new EwfButton(
                                    new StandardButtonStyle("Regenerate", buttonSize: ButtonSize.ShrinkWrap),
                                    behavior: new ConfirmationButtonBehavior(
                                        "Are you sure?".ToComponents(),
                                        postBack: PostBack.CreateFull(
                                            "certificate",
                                            modificationMethod: () => UserManagementStatics.UpdateCertificate(generateCertificate(DateTimeOffset.UtcNow))))))
                            .Materialize()
                            .ToFormItem(label: "System self-signed certificate".ToComponents())
                            .Concat(
                                AuthenticationStatics.SamlIdentityProviders.Any()
                                                                                ? new EwfHyperlink(EnterpriseWebFramework.UserManagement.SamlResources.Metadata.GetInfo(), new StandardHyperlinkStyle(""))
                                .ToFormItem(label: "Application SAML metadata".ToComponents())
                                .ToCollection()
                                                                                : Enumerable.Empty <FormItem>())
                            .Materialize())
                        .ToCollection(),
                        style: SectionStyle.Box));
            }
            content.Add(
                new Section(
                    "System users",
                    EwfTable.Create(
                        tableActions: new HyperlinkSetup(new SystemUser(Es, null), "Create User").ToCollection(),
                        headItems: EwfTableItem.Create("Email".ToCell().Append("Role".ToCell()).Materialize()).ToCollection())
                    .AddData(
                        UserManagementStatics.SystemProvider.GetUsers(),
                        user => EwfTableItem.Create(
                            user.Email.ToCell().Append(user.Role.Name.ToCell()).Materialize(),
                            setup: EwfTableItemSetup.Create(activationBehavior: ElementActivationBehavior.CreateHyperlink(new SystemUser(Es, user.UserId)))))
                    .ToCollection(),
                    style: SectionStyle.Box));
            return(content);
        }
Beispiel #4
0
        protected override PageContent getContent()
        {
            var content = new UiPageContent(omitContentBox: true);

            content.Add(
                getChart(
                    "Line",
                    new Chart(
                        new ChartSetup(ChartType.Line, 4, new[] { "Three", "One", "Two", "Four", "Five" }, postBackIdBase: "1"),
                        new ChartDataSet("Value", new[] { 3, 1, 2, 4, 5 }))));

            var random    = new Random();
            var floatData = Enumerable.Range(0, 20).Select(i => random.NextDouble() * 100).ToArray();

            content.Add(
                getChart(
                    "Line of floating point numbers",
                    new Chart(
                        new ChartSetup(ChartType.Line, 4, floatData.Select((f, i) => "" + i), postBackIdBase: "2"),
                        new ChartDataSet("Value", floatData))));

            var floatData1 = Enumerable.Range(0, 20).Select(i => random.NextDouble() * 100).ToArray();
            var floatData2 = Enumerable.Range(0, 20).Select(i => random.NextDouble() * 100).ToArray();

            content.Add(
                getChart(
                    "Two lines of floating point numbers",
                    new Chart(
                        new ChartSetup(ChartType.Line, 4, floatData1.Select((f, i) => "" + i), postBackIdBase: "3"),
                        new[] { new ChartDataSet("First value", floatData1), new ChartDataSet("Second value", floatData2) })));

            var floatData3 = Enumerable.Range(0, 10).Select(i => random.NextDouble() * 50).ToArray();

            content.Add(
                getChart(
                    "Bar",
                    new Chart(
                        new ChartSetup(ChartType.Bar, 4, floatData3.Select((f, i) => "" + i), postBackIdBase: "4"),
                        new ChartDataSet("Value", floatData3))));


            var floatData4 = Enumerable.Range(0, 20).Select(i => random.NextDouble() * 100).ToArray();
            var floatData5 = Enumerable.Range(0, 20).Select(i => random.NextDouble() * 100).ToArray();

            content.Add(
                getChart(
                    "Two bars of floating point numbers",
                    new Chart(
                        new ChartSetup(ChartType.Bar, 4, floatData4.Select((f, i) => "" + i), postBackIdBase: "5"),
                        new[] { new ChartDataSet("First value", floatData4), new ChartDataSet("Second value", floatData5) })));

            return(content);
        }
Beispiel #5
0
        protected override PageContent getContent()
        {
            var mod      = getMod();
            var password = new DataValue <string> {
                Value = ""
            };
            Tuple <IReadOnlyCollection <EtherealComponent>, Action <int> > logInHiddenFieldsAndMethod = null;

            return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                       PostBack.CreateFull(
                           modificationMethod: () => {
                if (AppTools.User == null)
                {
                    mod.UserId = MainSequence.GetNextValue();
                }
                if (password.Value.Any())
                {
                    var passwordSalter = new Password(password.Value);
                    mod.Salt = passwordSalter.Salt;
                    mod.SaltedPassword = passwordSalter.ComputeSaltedHash();
                }
                mod.Execute();

                logInHiddenFieldsAndMethod?.Item2(mod.UserId);
            },
                           actionGetter: () => new PostBackAction(logInHiddenFieldsAndMethod != null ? (PageBase)Home.GetInfo() : Profile.GetInfo(AppTools.User.UserId)))
                       .ToCollection(),
                       () => {
                var content = new UiPageContent(contentFootActions: new ButtonSetup(AppTools.User != null ? "Update Settings" : "Sign up").ToCollection());

                if (AppTools.User == null)
                {
                    content.Add(
                        new EwfHyperlink(
                            EnterpriseWebLibrary.EnterpriseWebFramework.UserManagement.Pages.LogIn.GetInfo(Home.GetInfo().GetUrl()),
                            new StandardHyperlinkStyle("Have an account?")));
                }

                content.Add(getFormItemStack(mod, password));

                if (AppTools.User == null)
                {
                    logInHiddenFieldsAndMethod = FormsAuthStatics.GetLogInHiddenFieldsAndSpecifiedUserLogInMethod();
                    content.Add(logInHiddenFieldsAndMethod.Item1);
                }

                return content;
            }));
        }
Beispiel #6
0
        protected override PageContent getContent()
        {
            var content = new UiPageContent();

            var updateRegionSet = new UpdateRegionSet();

            content.Add(
                EwfTable.Create(
                    caption: "Caption",
                    subCaption: "Sub caption",
                    allowExportToExcel: true,
                    tableActions: new ButtonSetup(
                        "Remove Last Group",
                        behavior: new PostBackBehavior(
                            postBack: PostBack.CreateIntermediate(
                                updateRegionSet.ToCollection(),
                                id: "removeLastGroup",
                                modificationMethod: () => {
                if (GroupCount <= 0)
                {
                    throw new DataModificationException("No groups to remove.");
                }
                parametersModification.GroupCount -= 1;
            }))).ToCollection(),
                    selectedItemActions: SelectedItemAction
                    .CreateWithIntermediatePostBackBehavior <int>(
                        "Echo IDs",
                        null,
                        ids => AddStatusMessage(StatusMessageType.Info, StringTools.GetEnglishListPhrase(ids.Select(i => i.ToString()), true)))
                    .Append(
                        SelectedItemAction.CreateWithIntermediatePostBackBehavior <int>(
                            "With confirmation",
                            null,
                            ids => AddStatusMessage(StatusMessageType.Info, StringTools.GetEnglishListPhrase(ids.Select(i => i.ToString()), true)),
                            confirmationDialogContent: "Are you sure?".ToComponents()))
                    .Materialize(),
                    fields: new[] { new EwfTableField(size: 1.ToPercentage()), new EwfTableField(size: 2.ToPercentage()) },
                    headItems: EwfTableItem.Create("First Column".ToCell(), "Second Column".ToCell()).ToCollection(),
                    defaultItemLimit: DataRowLimit.Fifty,
                    tailUpdateRegions: new TailUpdateRegion(updateRegionSet.ToCollection(), 1).ToCollection())
                .AddItemGroups(Enumerable.Range(1, GroupCount).Select(getItemGroup).Materialize()));

            return(content);
        }
        protected override PageContent getContent()
        {
            var clientTime = new DataValue <string>();
            var content    = new UiPageContent(
                contentFootActions: verificationFailed()
                                                            ? new ButtonSetup(
                    "Proceed Anyway",
                    behavior: new PostBackBehavior(
                        postBack: PostBack.CreateFull(actionGetter: () => new PostBackAction(new ExternalResource(ReturnUrl)))))
                .ToCollection()
                                                            : Enumerable.Empty <ButtonSetup>().Materialize(),
                pageLoadPostBack: verificationFailed()
                                                          ? null
                                                          : PostBack.CreateFull(
                    modificationMethod: () => {
                if (AuthenticationStatics.TestCookieMissing())
                {
                    parametersModification.CookiesDisabled = true;
                }
                if (AuthenticationStatics.ClockNotSynchronized(clientTime))
                {
                    parametersModification.ClockWrong = true;
                }
            },
                    actionGetter: () => new PostBackAction(verificationFailed() ? null : new ExternalResource(ReturnUrl))));

            if (verificationFailed())
            {
                if (CookiesDisabled)
                {
                    content.Add(new Paragraph(Translation.YourBrowserHasCookiesDisabled.ToComponents()));
                }
                if (ClockWrong)
                {
                    content.Add(new Paragraph(AuthenticationStatics.GetClockWrongMessage().ToComponents()));
                }
            }
            else
            {
                content.Add(new Paragraph("Please wait.".ToComponents())).Add(AuthenticationStatics.GetLogInHiddenFieldsAndSetUpClientSideLogic(clientTime));
            }
            return(content);
        }
        protected override PageContent getContent()
        {
            var content = new UiPageContent();

            var modalBoxId = new ModalBoxId();

            content.Add(
                new WrappingList(
                    new EwfButton(
                        new StandardButtonStyle("Open standard"),
                        behavior: new OpenModalBehavior(
                            modalBoxId,
                            etherealChildren: new ModalBox(
                                modalBoxId,
                                true,
                                new[]
            {
                "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi scelerisque venenatis mi id vehicula. Mauris iaculis tincidunt erat, sit amet fringilla magna porttitor a. Fusce a commodo felis. Phasellus sit amet augue quis dolor tincidunt tincidunt. Sed cursus vitae odio nec malesuada. Vestibulum odio lacus, auctor in facilisis ut, egestas eget lorem. Nam rutrum consequat orci, ac blandit purus interdum id. Aliquam sagittis massa sit amet nisl vestibulum fringilla.",
                "Suspendisse ut sagittis nunc. Maecenas tincidunt quam semper blandit sagittis. Sed consequat sollicitudin elementum. Curabitur pellentesque massa euismod, vestibulum mauris a, blandit leo. Aliquam fringilla lacinia diam, a commodo massa ultricies sit amet. Nullam et tincidunt ex, eget mattis quam. Nunc venenatis arcu a velit congue, nec tempus arcu egestas. Quisque magna dui, dignissim et libero id, efficitur convallis urna. Cras volutpat eget sapien sit amet rhoncus. Praesent eu metus eget urna imperdiet pretium. Nulla feugiat condimentum efficitur. Mauris aliquam scelerisque ex, ut blandit sem porttitor vitae.",
                "Vivamus dignissim quam eget hendrerit malesuada. Aenean aliquam risus at dui consequat luctus. Donec sollicitudin, elit quis pulvinar bibendum, urna magna facilisis nisi, ac tempor sem magna non enim. Vivamus porttitor dolor nulla, facilisis elementum neque euismod nec. Fusce sodales vitae enim at vulputate. Sed ut turpis pellentesque, iaculis turpis vitae, hendrerit metus. Sed posuere massa id quam gravida iaculis ac facilisis erat. Nullam ac risus at orci dictum bibendum. Nullam malesuada dui ut turpis volutpat, quis mollis orci iaculis. Quisque at eleifend urna, eget laoreet libero. Donec fringilla felis et ex rhoncus interdum. Cras semper semper eros, in gravida justo. Nullam vulputate, nulla et gravida fermentum, dui massa sodales leo, et ultricies purus quam et ex. Aliquam augue justo, ultricies ac nulla non, tristique convallis orci. Quisque feugiat eu quam quis feugiat.",
                "Fusce ornare ornare massa ut ullamcorper. Nunc commodo malesuada ante sed vulputate. Nam nec nulla sem. Quisque et cursus diam. Nullam vitae leo sed felis interdum pellentesque quis vel nisl. Sed cursus, tellus et ultrices pellentesque, lorem sem accumsan magna, eget imperdiet quam diam at sem. Ut diam ipsum, tristique non mauris et, aliquet accumsan justo. Pellentesque viverra tortor non eros consectetur pulvinar.",
                "Praesent suscipit nulla vitae fermentum elementum. Cras eu vehicula lectus, a luctus neque. In euismod congue sollicitudin. Ut fringilla massa ac orci blandit egestas. Aenean hendrerit ac leo ac interdum. Cras urna elit, rhoncus sit amet convallis sed, vulputate sed nisl. Nunc rutrum nunc quis dolor cursus pharetra. Mauris enim turpis, porttitor in mauris eu, consequat suscipit dolor. Donec tincidunt nisi et justo maximus, porttitor posuere odio placerat. Ut tempor justo eget lacus auctor, ut pharetra velit ullamcorper.",
                "Vivamus dignissim quam eget hendrerit malesuada. Aenean aliquam risus at dui consequat luctus. Donec sollicitudin, elit quis pulvinar bibendum, urna magna facilisis nisi, ac tempor sem magna non enim. Vivamus porttitor dolor nulla, facilisis elementum neque euismod nec. Fusce sodales vitae enim at vulputate. Sed ut turpis pellentesque, iaculis turpis vitae, hendrerit metus. Sed posuere massa id quam gravida iaculis ac facilisis erat. Nullam ac risus at orci dictum bibendum. Nullam malesuada dui ut turpis volutpat, quis mollis orci iaculis. Quisque at eleifend urna, eget laoreet libero. Donec fringilla felis et ex rhoncus interdum. Cras semper semper eros, in gravida justo. Nullam vulputate, nulla et gravida fermentum, dui massa sodales leo, et ultricies purus quam et ex. Aliquam augue justo, ultricies ac nulla non, tristique convallis orci. Quisque feugiat eu quam quis feugiat.",
                "Fusce ornare ornare massa ut ullamcorper. Nunc commodo malesuada ante sed vulputate. Nam nec nulla sem. Quisque et cursus diam. Nullam vitae leo sed felis interdum pellentesque quis vel nisl. Sed cursus, tellus et ultrices pellentesque, lorem sem accumsan magna, eget imperdiet quam diam at sem. Ut diam ipsum, tristique non mauris et, aliquet accumsan justo. Pellentesque viverra tortor non eros consectetur pulvinar.",
                "Praesent suscipit nulla vitae fermentum elementum. Cras eu vehicula lectus, a luctus neque. In euismod congue sollicitudin. Ut fringilla massa ac orci blandit egestas. Aenean hendrerit ac leo ac interdum. Cras urna elit, rhoncus sit amet convallis sed, vulputate sed nisl. Nunc rutrum nunc quis dolor cursus pharetra. Mauris enim turpis, porttitor in mauris eu, consequat suscipit dolor. Donec tincidunt nisi et justo maximus, porttitor posuere odio placerat. Ut tempor justo eget lacus auctor, ut pharetra velit ullamcorper."
            }.Select(i => new Paragraph(i.ToComponents()))
                                .Materialize()).ToCollection())).ToCollection <FlowComponent>()
                    .Append(new EwfHyperlink(Basic.ModalContent.GetInfo().ToHyperlinkModalBoxBehavior(), new ButtonHyperlinkStyle("Open browsing")))
                    .Append(
                        new EwfButton(
                            new StandardButtonStyle("Perform action with confirmation"),
                            behavior: new ConfirmationButtonBehavior(
                                new Paragraph(
                                    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur lacinia et quam vel aliquam. Aliquam vel metus est. Donec finibus."
                                    .ToComponents()).ToCollection(),
                                postBack: PostBack.CreateFull(
                                    id: "action1",
                                    modificationMethod: () => AddStatusMessage(StatusMessageType.Info, "Action performed.")))))
                    .Select(i => i.ToCollection().ToComponentListItem().ToWrappingListItem())));

            return(content);
        }
        protected override PageContent getContent()
        {
            var content = new UiPageContent();

            var userIsProfiling = AppMemoryCache.UserIsProfilingRequests(AppRequestState.Instance.ProfilingUserId);

            content.Add(
                new Paragraph("Profiling is currently {0}.".FormatWith(userIsProfiling ? "ON" : "OFF").ToComponents()).Append(
                    new Paragraph(
                        new EwfButton(
                            new StandardButtonStyle(userIsProfiling ? "Turn Profiling OFF" : "Turn Profiling ON"),
                            behavior: new PostBackBehavior(
                                postBack: PostBack.CreateFull(
                                    id: "toggle",
                                    modificationMethod: () => AppRequestState.AddNonTransactionalModificationMethod(
                                        () => AppMemoryCache.SetRequestProfilingForUser(
                                            AppRequestState.Instance.ProfilingUserId,
                                            userIsProfiling ? TimeSpan.Zero : TimeSpan.FromHours(1)))))).ToCollection()))
                .Materialize());

            return(content);
        }
        protected override PageContent getContent()
        {
            var content = new UiPageContent();

            if (AppTools.User == null)
            {
                content.Add(
                    new GenericFlowContainer(
                        new GenericFlowContainer("Conduit".ToComponents()).Append <FlowComponent>(new Paragraph("A place to share your knowledge.".ToComponents()))
                        .Materialize(),
                        classes: ElementClasses.Banner));
            }

            var filter = ComponentStateItem.Create("filter", AppTools.User != null ? "user" : "global", v => true, false);
            var resultUpdateRegions = new UpdateRegionSet();

            content.Add(
                new GenericFlowContainer(
                    getArticleSection(filter.Value, resultUpdateRegions).Append(getTagSection(filter.Value, resultUpdateRegions)).Materialize(),
                    classes: ElementClasses.HomeContainer,
                    etherealContent: filter.ToCollection()));

            return(content);
        }
Beispiel #11
0
        protected override PageContent getContent()
        {
            var content = new UiPageContent();

            // NOTE: This was the markup:
            //<ewf:ControlStack runat="server" IsStandard="true">
            //  <p>This page can be used to help develop and test regular expressions.</p>
            //  <ewf:EwfTextBox runat="server" ID="regexBox" />
            //  <ewf:Checklist runat="server" ID="regexOptions" Caption="Regular Expression Options" NumberOfColumns="5" />
            //  <ewf:LabeledControl runat="server" Label="Input"><ewf:EwfTextBox runat="server" Rows="6" ID="input" /></ewf:LabeledControl>
            //  <ewf:BlockCheckBox runat="server" ID="replace" Text="Find - Replace">
            //    <ewf:LabeledControl runat="server" Label="Replacement Text"><ewf:EwfTextBox runat="server" ID="replacementText" /></ewf:LabeledControl>
            //    <ewf:LabeledControl runat="server" Label="Output"><ewf:EwfTextBox runat="server" ID="outputText" Rows="13" /></ewf:LabeledControl>
            //  </ewf:BlockCheckBox><asp:PlaceHolder runat="server" ID="goPlace" />
            //  <ewf:DynamicTable runat="server" IsStandard="true" ID="output" Caption="Results" />
            //</ewf:ControlStack>

            //goPlace.AddControlsReturnThis( new PostBackButton( new DataModification(), null, new TextActionControlStyle( "Test" ) ) );

            //var regexOptionsDic = new Dictionary<string, RegexOptions>
            //  {
            //    { RegexOptions.Compiled.ToString(), RegexOptions.Compiled },
            //    { RegexOptions.CultureInvariant.ToString(), RegexOptions.CultureInvariant },
            //    { RegexOptions.ECMAScript.ToString(), RegexOptions.ECMAScript },
            //    { RegexOptions.ExplicitCapture.ToString(), RegexOptions.ExplicitCapture },
            //    { RegexOptions.IgnoreCase.ToString(), RegexOptions.IgnoreCase },
            //    { RegexOptions.IgnorePatternWhitespace.ToString(), RegexOptions.IgnorePatternWhitespace },
            //    { RegexOptions.Multiline.ToString(), RegexOptions.Multiline },
            //    { RegexOptions.RightToLeft.ToString(), RegexOptions.RightToLeft },
            //    { RegexOptions.Singleline.ToString(), RegexOptions.Singleline }
            //  };

            //foreach( var regexOption in regexOptionsDic )
            //  regexOptions.AddItem( regexOption.Value.ToString(), regexOption.Key );
            ////WireUpControlsToPageState( regexOptions, regexBox, input, replace, replacementText );

            //try {
            //  var regexObj = new Regex( regexBox.Value,
            //                            regexOptions.SelectedValues.Aggregate( new RegexOptions(), ( current, option ) => current | option.ToEnum<RegexOptions>() ) );

            //  if( replace.Checked )
            //    outputText.Value = regexObj.Replace( input.Value, replacementText.Value );

            //  output.SetUpColumns( new ColumnSetup { Width = Unit.Percentage( 17 ) }, new ColumnSetup { Width = Unit.Percentage( 83 ) } );
            //  var matches = regexObj.Matches( input.Value );

            //  for( var i = 1; i <= matches.Count; i++ ) {
            //    var match = matches[ i - 1 ];
            //    output.AddTextRow( "Match " + i, match.ToString() );
            //    foreach( var groupName in regexObj.GetGroupNames() ) {
            //      var group = match.Groups[ groupName ];
            //      output.AddTextRow( "Group " + groupName, group.Value );
            //    }
            //  }
            //}
            //catch( Exception e ) {
            //  if( IsPostBack )
            //    StandardLibrarySessionState.AddStatusMessage( StatusMessageType.Warning, e.Message );
            //}

            return(content);
        }
        protected override PageContent getContent()
        {
            AuthenticationStatics.CodeLoginModificationMethod codeLoginMethod = null;
            string destinationUrl = null;

            if (User.Any())
            {
                var postBack = PostBack.CreateFull(
                    modificationMethod: () => destinationUrl = codeLoginMethod(
                        User,
                        Code,
                        errorMessage:
                        "The login link you just used has expired. Please return to the page you were trying to access and send yourself another login email.")
                                                               .destinationUrl,
                    actionGetter: () => new PostBackAction(new ExternalResource(destinationUrl)));
                return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                           postBack.ToCollection(),
                           () => {
                    var logInHiddenFieldsAndMethods = AuthenticationStatics.GetLogInHiddenFieldsAndMethods();
                    codeLoginMethod = logInHiddenFieldsAndMethods.modificationMethods.codeLoginMethod;
                    return new UiPageContent(pageLoadPostBack: postBack).Add(new Paragraph("Please wait.".ToComponents()))
                    .Add(logInHiddenFieldsAndMethods.hiddenFields);
                }));
            }

            var content = new UiPageContent(omitContentBox: true);

            var codeEntryIsForPasswordReset = ComponentStateItem.Create <bool?>("codeEntryIsForPasswordReset", null, value => true, false);

            var emailAddress = new DataValue <string>();
            var password     = new DataValue <string>();
            var loginCode    = new DataValue <string>();

            AuthenticationStatics.PasswordLoginModificationMethod passwordLoginMethod = null;
            AuthenticationStatics.LoginCodeSenderMethod           loginCodeSender     = null;

            var logInPb = PostBack.CreateFull(
                modificationMethod: () => {
                if (codeEntryIsForPasswordReset.Value.Value.HasValue)
                {
                    destinationUrl = codeLoginMethod(emailAddress.Value, loginCode.Value).destinationUrl;
                }
                else
                {
                    passwordLoginMethod(emailAddress, password);
                }
            },
                actionGetter: () => new PostBackAction(new ExternalResource(codeEntryIsForPasswordReset.Value.Value.HasValue ? destinationUrl : ReturnUrl)));

            var          authenticationModeUpdateRegion = new UpdateRegionSet();
            const string passwordOrCodeFocusKey         = "code";
            var          sendCodePb = codeEntryIsForPasswordReset.Value.Value != true
                                                 ? PostBack.CreateIntermediate(
                authenticationModeUpdateRegion.ToCollection(),
                id : "sendCode",
                modificationMethod : () => {
                loginCodeSender(emailAddress, false, ReturnUrl);
                codeEntryIsForPasswordReset.Value.Value = false;
            },
                reloadBehaviorGetter : () => new PageReloadBehavior(focusKey: passwordOrCodeFocusKey))
                                                 : null;

            var newPasswordPb = codeEntryIsForPasswordReset.Value.Value != false
                                                    ? PostBack.CreateIntermediate(
                authenticationModeUpdateRegion.ToCollection(),
                id : "newPw",
                modificationMethod : () => {
                loginCodeSender(emailAddress, true, ReturnUrl);
                codeEntryIsForPasswordReset.Value.Value = true;
            },
                reloadBehaviorGetter : () => new PageReloadBehavior(focusKey: passwordOrCodeFocusKey))
                                                    : null;

            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(UserManagementStatics.LocalIdentityProvider.AdministratingOrganizationName)
                        .ToComponents()));

                registeredComponents.Add(
                    FormItemList.CreateStack(
                        generalSetup: new FormItemListSetup(buttonSetup: new ButtonSetup("Log In"), enableSubmitButton: true),
                        items: FormState
                        .ExecuteWithDataModificationsAndDefaultAction(
                            new[] { logInPb, sendCodePb, newPasswordPb }.Where(i => i != null),
                            () => emailAddress.GetEmailAddressFormItem("Email address".ToComponents()))
                        .Append(
                            codeEntryIsForPasswordReset.Value.Value.HasValue
                                                                                ? getLoginCodeFormItem(authenticationModeUpdateRegion.ToCollection(), AutofocusCondition.PostBack(passwordOrCodeFocusKey), loginCode)
                                                                                : getPasswordFormItem(
                                authenticationModeUpdateRegion.ToCollection(),
                                AutofocusCondition.PostBack(passwordOrCodeFocusKey),
                                password,
                                new PostBackBehavior(postBack: sendCodePb)))
                        .Materialize()));

                registeredComponents.Add(
                    new Paragraph(
                        new PhrasingIdContainer(
                            codeEntryIsForPasswordReset.Value.Value.HasValue
                                                                        ? new ImportantContent("Having trouble?".ToComponents()).ToCollection()
                            .Concat(" ".ToComponents())
                            .Append(
                                new EwfButton(
                                    new StandardButtonStyle("Send me another code", buttonSize: ButtonSize.ShrinkWrap),
                                    behavior: new PostBackBehavior(postBack: codeEntryIsForPasswordReset.Value.Value.Value ? newPasswordPb : sendCodePb)))
                            .Concat(" ".ToComponents())
                            .Append(
                                new EwfButton(
                                    new StandardButtonStyle(
                                        codeEntryIsForPasswordReset.Value.Value.Value ? "Try password again" : "Log in with password",
                                        buttonSize: ButtonSize.ShrinkWrap),
                                    behavior: new PostBackBehavior(
                                        postBack: PostBack.CreateIntermediate(
                                            authenticationModeUpdateRegion.ToCollection(),
                                            id: "revertToPasswordEntry",
                                            modificationMethod: () => codeEntryIsForPasswordReset.Value.Value = null,
                                            reloadBehaviorGetter: () => new PageReloadBehavior(focusKey: passwordOrCodeFocusKey)))))
                                                                        : new ImportantContent("Forgot password?".ToComponents()).ToCollection()
                            .Concat(" ".ToComponents())
                            .Append(
                                new EwfButton(
                                    new StandardButtonStyle("Set a new password", buttonSize: ButtonSize.ShrinkWrap),
                                    behavior: new ConfirmationButtonBehavior(
                                        new Paragraph("Are you sure you want to set a new password?".ToComponents()).Append(
                                            new Paragraph(
                                                StringTools.ConcatenateWithDelimiter(
                                                    " ",
                                                    "Click \"Continue\" to email yourself a login code.",
                                                    "After logging in, you will be prompted to change your password to something you will remember, which you may use to log in from that point forward.")
                                                .ToComponents()))
                                        .Materialize(),
                                        postBack: newPasswordPb))),
                            updateRegionSets: authenticationModeUpdateRegion.ToCollection()).ToCollection()));

                var logInHiddenFieldsAndMethods = FormState.ExecuteWithDataModificationsAndDefaultAction(
                    new[] { logInPb, sendCodePb, newPasswordPb }.Where(i => i != null),
                    AuthenticationStatics.GetLogInHiddenFieldsAndMethods);

                content.Add(
                    new FlowAutofocusRegion(
                        AutofocusCondition.InitialRequest(),
                        new Section(
                            "Registered users",
                            registeredComponents,
                            style: SectionStyle.Box,
                            etherealContent: logInHiddenFieldsAndMethods.hiddenFields.Append(codeEntryIsForPasswordReset).Materialize()).ToCollection()));

                passwordLoginMethod = logInHiddenFieldsAndMethods.modificationMethods.passwordLoginMethod;
                loginCodeSender     = logInHiddenFieldsAndMethods.modificationMethods.loginCodeSender;
                codeLoginMethod     = logInHiddenFieldsAndMethods.modificationMethods.codeLoginMethod;
            });

            var specialInstructions = EwfUiStatics.AppProvider.GetSpecialInstructionsForLogInPage();

            if (specialInstructions.Any())
            {
                content.Add(specialInstructions);
            }
            else
            {
                var unregisteredComponents = new List <FlowComponent>();
                unregisteredComponents.Add(
                    new Paragraph(
                        "If you have difficulty logging in, please {0}".FormatWith(UserManagementStatics.LocalIdentityProvider.LogInHelpInstructions).ToComponents()));
                content.Add(new Section("Unregistered users", unregisteredComponents, style: SectionStyle.Box));
            }

            return(content);
        }
Beispiel #13
0
        protected override PageContent getContent()
        {
            var content = new UiPageContent(isAutoDataUpdater: true);

            var fil = FormItemList.CreateStack();

            fil.AddFormItems(parametersModification.GetField1TextControlFormItem(true), parametersModification.GetField2TextControlFormItem(true));
            content.Add(fil);

            content.Add(
                new EwfButton(
                    new StandardButtonStyle("Navigate and change Field 2"),
                    behavior: new PostBackBehavior(
                        postBack: PostBack.CreateFull(
                            actionGetter: () => new PostBackAction(
                                new OptionalParametersDemo(Es, optionalParameterSetter: (specifier, entitySetup, parameters) => { specifier.Field2 = "bob"; }))))));

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

            content.Add(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);
                }
            }

            return(content);
        }