Example #1
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(string model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            if (!string.IsNullOrWhiteSpace(model))
            {
                hb.Append(@"<div class='yt_ipaddress t_display'>");
                hb.Append(HE(model));

                bool lookup = PropData.GetAdditionalAttributeValue("Lookup", true);
                if (lookup)
                {
                    ModuleDefinition modDisplay = await ModuleDefinition.LoadAsync(new Guid("{ad95564e-8eb7-4bcb-be64-dc6f1cd6b55d}"), AllowNone : true);

                    if (modDisplay != null)
                    {
                        ModuleAction actionDisplay = await modDisplay.GetModuleActionAsync("DisplayHostName", null, model);

                        if (modDisplay != null)
                        {
                            hb.Append(await actionDisplay.RenderAsync(ModuleAction.RenderModeEnum.IconsOnly));
                        }
                        actionDisplay = await modDisplay.GetModuleActionAsync("DisplayGeoData", null, model);

                        if (modDisplay != null)
                        {
                            hb.Append(await actionDisplay.RenderAsync(ModuleAction.RenderModeEnum.IconsOnly));
                        }
                    }
                }
                hb.Append(@"</div>");
            }
            return(hb.ToString());
        }
Example #2
0
        public async Task <string> RenderAsync(string model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            YTagBuilder tag = new YTagBuilder("span");

            FieldSetup(tag, FieldType.Anonymous);

            ModuleAction actionDisplay = null;
            ModuleAction actionLoginAs = null;

            using (UserDefinitionDataProvider userDefDP = new UserDefinitionDataProvider()) {
                UserDefinition user     = null;
                string         userName = "";
                if (!string.IsNullOrWhiteSpace(model))
                {
                    user = await userDefDP.GetItemByEmailAsync(model);

                    if (user == null)
                    {
                        userName = model;
                    }
                    else
                    {
                        userName = user.Email;
                        UsersDisplayModule modDisp = new UsersDisplayModule();
                        actionDisplay = modDisp.GetAction_Display(null, user.UserName);
                        LoginModule modLogin = (LoginModule)await ModuleDefinition.CreateUniqueModuleAsync(typeof(LoginModule));

                        actionLoginAs = await modLogin.GetAction_LoginAsAsync(user.UserId, user.UserName);
                    }
                }
                else
                {
                    userName = __ResStr("noEmail", "(not specified)");
                }
                tag.SetInnerText(userName);
            }
            hb.Append(tag.ToString(YTagRenderMode.Normal));
            if (actionDisplay != null)
            {
                hb.Append(await actionDisplay.RenderAsync(ModuleAction.RenderModeEnum.IconsOnly));
            }
            if (actionLoginAs != null)
            {
                hb.Append(await actionLoginAs.RenderAsync(ModuleAction.RenderModeEnum.IconsOnly));
            }
            return(hb.ToString());
        }
Example #3
0
        public async Task <string> RenderAsync(int model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            YTagBuilder tag = new YTagBuilder("span");

            tag.AddCssClass("yt_yetawf_identity_userid");
            tag.AddCssClass("t_display");
            FieldSetup(tag, FieldType.Anonymous);

            ModuleAction actionDisplay = null;
            ModuleAction actionLoginAs = null;

            using (UserDefinitionDataProvider dataProvider = new UserDefinitionDataProvider()) {
                UserDefinition user = await dataProvider.GetItemByUserIdAsync(model);

                string userName = "";
                if (user == null)
                {
                    if (model != 0)
                    {
                        userName = string.Format("({0})", model);
                    }
                }
                else
                {
                    userName = user.UserName;
                    Modules.UsersDisplayModule modDisp = new Modules.UsersDisplayModule();
                    actionDisplay = modDisp.GetAction_Display(null, userName);
                    Modules.LoginModule modLogin = (Modules.LoginModule) await ModuleDefinition.CreateUniqueModuleAsync(typeof(Modules.LoginModule));

                    actionLoginAs = await modLogin.GetAction_LoginAsAsync(model, userName);
                }
                tag.SetInnerText(userName);
            }

            hb.Append(tag.ToString(YTagRenderMode.Normal));
            if (actionDisplay != null)
            {
                hb.Append(await actionDisplay.RenderAsync(ModuleAction.RenderModeEnum.IconsOnly));
            }
            if (actionLoginAs != null)
            {
                hb.Append(await actionLoginAs.RenderAsync(ModuleAction.RenderModeEnum.IconsOnly));
            }

            return(hb.ToString());
        }
Example #4
0
        public async Task <string> RenderViewAsync(TinyLoginModule module, TinyLoginModuleController.TinyLoginModel model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            if (model.LoggedOn)
            {
                ModuleAction logoffAction = await module.GetAction_LogoffAsync(model.LogoffUrl);

                ModuleAction userNameAction = await module.GetAction_UserNameAsync(model.UserUrl, model.UserName, model.UserTooltip);

                hb.Append($@"
<div class='t_haveuser t_link'>
    {await logoffAction.RenderAsync(ModuleAction.RenderModeEnum.NormalLinks)}
</div>
<div class='t_haveuser t_user'>
    {await userNameAction.RenderAsync(ModuleAction.RenderModeEnum.NormalLinks)}
</div>");
            }
            else
            {
                ModuleAction loginAction = await module.GetAction_LoginAsync(model.LogonUrl);

                ModuleAction registerAction = await module.GetAction_RegisterAsync(model.RegisterUrl);

                hb.Append($@"
<div class='t_nouser t_logon'>
    {await loginAction.RenderAsync(ModuleAction.RenderModeEnum.NormalLinks)}
</div>
<div class='t_nouser t_register'>");

                if (registerAction != null)
                {
                    hb.Append($@"
                    {await registerAction.RenderAsync(ModuleAction.RenderModeEnum.NormalLinks)}");
                }
                hb.Append($@"
</div>");
            }

            return(hb.ToString());
        }