private void Page_Load(object sender, System.EventArgs e)
        {
            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            // Dynamically Populate the Portal Site Name
            siteName.Text = portalSettings.PortalName;

            // If user logged in, customize welcome message
            if (Request.IsAuthenticated == true)
            {
                WelcomeMessage.Text = "Welcome " + Context.User.Identity.Name + "! <" + "span class=Accent" + ">|<" + "/span" + ">";

                // if authentication mode is Cookie, provide a logoff link
                if (Context.User.Identity.AuthenticationType == "Forms")
                {
                    LogoffLink = "<" + "span class=\"Accent\">|</span>\n" + "<" + "a href=" + Request.ApplicationPath + "/Admin/Logoff.aspx class=SiteLink> Logoff" + "<" + "/a>";
                }
            }

            // Dynamically render portal tab strip
            if (ShowTabs == true)
            {
                tabIndex = portalSettings.ActiveTab.TabIndex;

                // Build list of tabs to be shown to user
                ArrayList authorizedTabs = new ArrayList();
                int       addedTabs      = 0;

                for (int i = 0; i < portalSettings.DesktopTabs.Count; i++)
                {
                    TabStripDetails tab = (TabStripDetails)portalSettings.DesktopTabs[i];

                    if (PortalSecurity.IsInRoles(tab.AuthorizedRoles))
                    {
                        authorizedTabs.Add(tab);
                    }

                    if (addedTabs == tabIndex)
                    {
                        tabs.SelectedIndex = addedTabs;
                    }

                    addedTabs++;
                }

                // Populate Tab List at Top of the Page with authorized tabs
                tabs.DataSource = authorizedTabs;
                tabs.DataBind();
            }
        }
示例#2
0
        //*********************************************************************
        //
        // PopulateTabStrip method
        //
        // The PopulateTabStrip method is used to dynamically create and add
        // tabs for each tab view defined in the portal configuration.
        //
        //*********************************************************************

        private void PopulateTabStrip()
        {
            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            for (int i = 0; i < portalSettings.MobileTabs.Count; i++)
            {
                // Create a MobilePortalTab control for the tab,
                // and add it to the tab view.

                TabStripDetails tab = (TabStripDetails)portalSettings.MobileTabs[i];

                if (PortalSecurity.IsInRoles(tab.AuthorizedRoles))
                {
                    MobilePortalTab tabPanel = new MobilePortalTab();
                    tabPanel.Title = tab.TabName;

                    TabView.Panes.Add(tabPanel);
                }
            }
        }
        //*********************************************************************
        //
        // PortalSettings Constructor
        //
        // The PortalSettings Constructor encapsulates all of the logic
        // necessary to obtain configuration settings necessary to render
        // a Portal Tab view for a given request.
        //
        // These Portal Settings are stored within a SQL database, and are
        // fetched below by calling the "GetPortalSettings" stored procedure.
        // This stored procedure returns values as SPROC output parameters,
        // and using three result sets.
        //
        //*********************************************************************

        public PortalSettings(int tabIndex, int tabId)
        {
            // GetPortalSettings within SQL Server returns 3 Resultsets, as well as a set of output
            // Parameters.  For the Npgsql implementation, we will need 4 resultsets to duplicate
            // this functionality.  Also, the tabid used internal to the GetPortalSettings stored
            // procedure changes, but is not returned.  In this implementation, we will store that
            // temporary TabID value in the tmpTabId variable.
            int tmpTabId = tabId;

            // Create Instance of Connection and Command Object
            NpgsqlConnection myConnection = new NpgsqlConnection(ConfigurationSettings.AppSettings["NpgsqlConnectionString"]);
            NpgsqlCommand    myCommand    = new NpgsqlCommand("GetPortalSettings(:PortalAlias, :TabId)", myConnection);

            // Mark the Command as a SPROC
            myCommand.CommandType = CommandType.StoredProcedure;

            // Add Parameters to SPROC
            NpgsqlParameter parameterPortalAlias = new NpgsqlParameter("PortalAlias", DbType.String);

            parameterPortalAlias.Value = "p_default";
            myCommand.Parameters.Add(parameterPortalAlias);

            NpgsqlParameter parameterTabId = new NpgsqlParameter("TabId", DbType.Int32);

            parameterTabId.Value = tabId;
            myCommand.Parameters.Add(parameterTabId);

            // Open the database connection and execute the command
            myConnection.Open();
            NpgsqlDataReader result = myCommand.ExecuteReader();

            // Read Portal Settings (Output params from SQL implementation
            if (result.Read())
            {
                this.PortalId             = (int)result["portalid"];
                this.PortalName           = (String)result["portalname"];
                this.AlwaysShowEditButton = (bool)result["alwaysshoweditbutton"];
                tmpTabId = (int)result["tabid"];
                this.ActiveTab.TabOrder        = (int)result["taborder"];
                this.ActiveTab.MobileTabName   = (String)result["mobiletabname"];
                this.ActiveTab.AuthorizedRoles = (String)result["authorizedroles"];
                this.ActiveTab.TabName         = (String)result["tabname"];
                this.ActiveTab.ShowMobile      = (bool)result["showmobile"];
            }

            // Close the datareader
            result.Close();


            myCommand = new NpgsqlCommand("GetTabs(:PortalID)", myConnection);

            // Mark the Command as a SPROC
            myCommand.CommandType = CommandType.StoredProcedure;

            // Add Parameters to SPROC
            NpgsqlParameter parameterPortalId = new NpgsqlParameter("PortalID", DbType.Int32);

            parameterPortalId.Value = this.PortalId;
            myCommand.Parameters.Add(parameterPortalId);

            // Open the database connection and execute the command
            result = myCommand.ExecuteReader();


            // Read Desktop Tab Information
            while (result.Read())
            {
                TabStripDetails tabDetails = new TabStripDetails();
                tabDetails.TabId           = (int)result["tabid"];
                tabDetails.TabName         = (String)result["tabname"];
                tabDetails.TabOrder        = (int)result["taborder"];
                tabDetails.AuthorizedRoles = (String)result["authorizedroles"];

                this.DesktopTabs.Add(tabDetails);
            }

            // Close the datareader
            result.Close();

            if (this.ActiveTab.TabId == 0)
            {
                this.ActiveTab.TabId = ((TabStripDetails)this.DesktopTabs[0]).TabId;
            }

            // // Read Mobile Tab Information
            // result.NextResult();



            // while(result.Read()) {

            //     TabStripDetails tabDetails = new TabStripDetails();
            //     tabDetails.TabId = (int) result["TabId"];
            //     tabDetails.TabName = (String) result["MobileTabName"];
            //     tabDetails.AuthorizedRoles = (String) result["AuthorizedRoles"];

            //     this.MobileTabs.Add(tabDetails);
            // }

            // Module Tab Information

            myCommand = new NpgsqlCommand("GetModuleModuleDefinitions(:TabId)", myConnection);

            // Mark the Command as a SPROC
            myCommand.CommandType = CommandType.StoredProcedure;

            // Add Parameters to SPROC
            parameterTabId       = new NpgsqlParameter("TabId", DbType.Int32);
            parameterTabId.Value = tmpTabId;
            myCommand.Parameters.Add(parameterTabId);

            // Open the database connection and execute the command
            result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);


            while (result.Read())
            {
                ModuleSettings m = new ModuleSettings();
                m.ModuleId            = (int)result["moduleid"];
                m.ModuleDefId         = (int)result["moduledefid"];
                m.TabId               = (int)result["tabid"];
                m.PaneName            = (String)result["panename"];
                m.ModuleTitle         = (String)result["moduletitle"];
                m.AuthorizedEditRoles = (String)result["authorizededitroles"];
                m.CacheTime           = (int)result["cachetime"];
                m.ModuleOrder         = (int)result["moduleorder"];
                m.ShowMobile          = (bool)result["showmobile"];
                m.DesktopSrc          = (String)result["desktopsrc"];
                m.MobileSrc           = (String)result["mobilesrc"];

                this.ActiveTab.Modules.Add(m);
            }

            // Close the datareader
            result.Close();

            this.ActiveTab.TabIndex = tabIndex;
            this.ActiveTab.TabId    = tabId;


            myConnection.Close();
        }