Esempio n. 1
0
        /// <summary>
        /// Creates child controls.
        /// </summary>
        protected override void CreateChildControls()
        {
            UserContext user = UserContext.Current;

            m_HelloNote    = new HtmlGenericControl("div");
            m_HelloNote.ID = "HelloNoteLabel";
            m_HelloNote.Style.Add(HtmlTextWriterStyle.FontSize, "12px");
            m_HelloNote.InnerHtml = Resources.Hello_HelloNoteLabel_Text + "&nbsp;";
            if (user == null)
            {
                m_HelloNote.Style.Add(HtmlTextWriterStyle.PaddingBottom, "7px");
                m_HelloNote.InnerHtml += Resources.Hello_VisitorText;
            }
            else
            {
                m_HelloNote.Style.Add(HtmlTextWriterStyle.Display, "inline");
            }

            this.Controls.Add(m_HelloNote);

            if (user != null)
            {
                m_HelloNote.Style.Add(HtmlTextWriterStyle.Display, "inline");

                m_ProfileLink           = new HyperLink();
                m_ProfileLink.ID        = "ProfileLink";
                m_ProfileLink.Font.Size = new FontUnit(12, UnitType.Pixel);
                m_ProfileLink.Text      = user.FirstName;

                Action action = ActionProvider.GlobalNavigationLinks.FindByActionId(ActionProvider.MyAccountGlobalNavigationLinkActionId);
                if (action != null)
                {
                    m_ProfileLink.NavigateUrl = action.AbsoluteNavigateUrl;
                }

                this.Controls.Add(m_ProfileLink);

                string name = string.Empty;
                if (user.InstanceId != System.Guid.Empty)
                {
                    name = user.Instance.Name;
                }
                else if (user.OrganizationId != System.Guid.Empty)
                {
                    name = user.Organization.Name;
                }

                m_RoleLabel    = new HtmlGenericControl("div");
                m_RoleLabel.ID = "RoleLabel";
                m_RoleLabel.Style.Add(HtmlTextWriterStyle.Padding, "7px 0 7px 0");
                m_RoleLabel.Style.Add(HtmlTextWriterStyle.FontSize, "12px");
                m_RoleLabel.InnerHtml = string.Format(CultureInfo.CurrentCulture, Resources.Hello_RoleLabel_Text, name, RoleProvider.GetRoleName(user.RoleId));

                this.Controls.Add(m_RoleLabel);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates child controls.
        /// </summary>
        protected override void CreateChildControls()
        {
            this.Controls.Clear();

            HtmlGenericControl footerDiv    = null;
            HtmlGenericControl leftDiv      = null;
            HtmlGenericControl copyrightDiv = null;

            try
            {
                copyrightDiv = new HtmlGenericControl("div");
                footerDiv    = new HtmlGenericControl("div");

                WebApplicationElement webAppSettings = FrameworkConfiguration.Current.WebApplication;

                if (m_UserContext != null)
                {
                    leftDiv = new HtmlGenericControl("div");
                    StringBuilder sb = new StringBuilder();

                    if (m_UserContext.OrganizationId != Guid.Empty)
                    {
                        sb.Append(m_UserContext.Organization.Name);
                    }

                    if (webAppSettings.EnableMultipleInstances && (m_UserContext.InstanceId != Guid.Empty))
                    {
                        if (sb.Length > 0)
                        {
                            sb.Append("<br />");
                        }
                        sb.Append(m_UserContext.Instance.Name);
                    }

                    string roleName = RoleProvider.GetRoleName(m_UserContext.RoleId);
                    if (!string.IsNullOrEmpty(roleName))
                    {
                        if (sb.Length > 0)
                        {
                            sb.Append("<br />");
                        }
                        sb.Append(roleName);
                    }

                    leftDiv.Attributes["class"] = "L";
                    leftDiv.InnerHtml           = sb.ToString();
                }

                copyrightDiv.InnerHtml = string.Format(CultureInfo.InvariantCulture, Resources.Footer_CopyrightInformationFormatString, DateTime.UtcNow.Year, GetCompanyName(webAppSettings.Copyright));
                if (webAppSettings.MasterPage.Footer.VisibleEngineeredBy)
                {
                    copyrightDiv.InnerHtml += "<br />" + string.Format(CultureInfo.InvariantCulture, Resources.Footer_EngineeredByFormatString, BaseControl.GetHyperlink("http://www.micajah.com", Resources.Footer_MicajahCompanyName));
                }

                if (leftDiv != null)
                {
                    footerDiv.Controls.Add(leftDiv);
                }
                footerDiv.Controls.Add(copyrightDiv);

                footerDiv.Attributes["class"] = "Mp_Ftr";

                this.Controls.Add(footerDiv);
            }
            finally
            {
                if (leftDiv != null)
                {
                    leftDiv.Dispose();
                }
                if (copyrightDiv != null)
                {
                    copyrightDiv.Dispose();
                }
                if (footerDiv != null)
                {
                    footerDiv.Dispose();
                }
            }
        }