Example #1
0
        /// <summary>
        /// Retrieves a list of Widgets specific to current User.
        /// </summary>
        /// <param name="page">The page object used to load widget controls</param>
        /// <returns>A list of Widgets specific to current users.</returns>
        public static IEnumerable <BaseWidgetControl> GetWidgets(Page page)
        {
            // retrieve all widgets
            var widgets = GetAllWidgets(page);
            // retrieve widget config
            var configs = CaisisConfiguration.GetWidgetConfigList();

            // a list of filtered (by permission, configuration) user widgets
            var filteredWidgets = new List <BaseWidgetControl>();

            // FILTER: filter widgets which have config nodes and are active
            foreach (var config in configs)
            {
                // only care about active widgets
                if (config.Active)
                {
                    // find widget which matches config
                    foreach (var widget in widgets)
                    {
                        if (widget.Name == config.Name)
                        {
                            // set widget properties via config
                            SetWidgetByConfig(widget, config);
                            // add to filtered list
                            filteredWidgets.Add(widget);
                        }
                    }
                }
            }

            // FILTER: filter nodes which are associated with tabs
            XmlDocument xmlDoc = XmlUtil.GetModulesConfigXml();

            string        groupViewCode = page.Session[SessionKey.GroupViewCode].ToString();
            TabController ct            = new TabController(groupViewCode);
            DataTable     tabs          = ct.CreateTabDataTable(xmlDoc);
            var           tabNames      = from row in tabs.AsEnumerable()
                                          let tabName = row["TabName"].ToString()
                                                        select tabName;
            var filtered = from widget in filteredWidgets
                           where
                           // if not associated with a module
                           widget.Modules.Count() == 0
                           ||
                           // otherwise validate, user has access to at least one tab
                           (from module in widget.Modules
                            where tabNames.Contains(module, StringComparer.OrdinalIgnoreCase)
                            select module).Count() > 0
                           select widget;


            // return filters list
            return(filtered);
        }
Example #2
0
        /// <summary>
        /// Builds list of User datasets
        /// </summary>
        //private void SetDatasetsDropdown()
        //{
        //    // get a list of user's datasets
        //    UserController uc = new UserController();
        //    DataTable dataSetsTable = uc.GetUserDatasets().Tables[0];

        //    // build dropdown of available datasets
        //    DatasetsSelector.DataSource = dataSetsTable.DefaultView;
        //    DatasetsSelector.DataBind();

        //    // set active user dataset
        //    string activeDatasetId = Session[SessionKey.DatasetId].ToString();
        //    DataRow[] activeUserDataset = dataSetsTable.Select(Dataset.DatasetId + " = " + activeDatasetId);
        //    if (activeUserDataset.Count() > 0)
        //    {
        //        ActiveDataset.Text = activeUserDataset[0][Dataset.DatasetName].ToString();
        //    }
        //}

        ///// <summary>
        ///// Update the users dataset and associated permissions
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //protected void OnDatasetChange(object sender, CommandEventArgs e)
        //{
        //    // get the dataset of clicked item
        //    int datasetId = int.Parse(e.CommandArgument.ToString());
        //    //empty patient session in case dataset is being switched
        //    SessionHandler handler = new SessionHandler(Session);
        //    handler.EmptySession();


        //    int loginId = (int)Session[SessionKey.LoginId];
        //    string userName = new SecurityController().GetUserName();


        //    uc.SetPermissions("IN DEV", datasetId, loginId, userName);
        //    Session[SessionKey.DatasetId] = datasetId;
        //    Session[SessionKey.GroupViewCode] = uc.SetGroupViewCode(datasetId);

        //    Response.Redirect("Dashboard.aspx");
        //}


        private void BuildModulesWidget()
        {
            if (Session[SessionKey.GroupViewCode] != null)
            {
                XmlDocument xmlDoc = XmlUtil.GetModulesConfigXml();


                string currentSection = HttpContext.Current.Request.RawUrl;

                string        groupViewCode = Session[SessionKey.GroupViewCode].ToString();
                TabController ct            = new TabController(groupViewCode);
                DataTable     HeaderDt      = ct.CreateTabDataTable(xmlDoc);

                DashboardModulesList.DataSource = HeaderDt.DefaultView;
                DashboardModulesList.DataBind();
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        private void HandleSingleGroupCode(string userPurpose)
        {
            // determine if user has access to only 1 tab
            if (Session[SessionKey.DatasetId] != null && !string.IsNullOrEmpty(Session[SessionKey.DatasetId].ToString()) && Session[SessionKey.GroupViewCode] != null && !string.IsNullOrEmpty(Session[SessionKey.GroupViewCode].ToString()))
            {
                // v4.2
                string        groupViewCode = Session[SessionKey.GroupViewCode].ToString();
                TabController tc            = new TabController(groupViewCode);
                DataTable     tabsDt        = tc.CreateTabDataTable(XmlUtil.GetModulesConfigXml());

                // if user can only see 1 tab, forward to path
                if (tabsDt.Rows.Count == 1)
                {
                    string modTab = tabsDt.Rows[0]["Path"].ToString();
                    RedirectToModule(modTab);
                }
                // otherwise, need to reload spash to ensure permissions
                else if (Request.QueryString["login"] != null)
                {
                    Response.Redirect("Splash.aspx?purpose=" + userPurpose, true);
                }
            }
        }
Example #4
0
        private void SetHeaderTabs(XmlDocument xmlDoc)
        {
            if (Session[SessionKey.GroupViewCode] != null)
            {
                int maxTabs = 5;  // this is the maximum number of tabs shown before using the "More" menu.  maybe change based on Screen Resolution?


                string currentSection = HttpContext.Current.Request.RawUrl;

                string        groupViewCode = Session[SessionKey.GroupViewCode].ToString();
                TabController ct            = new TabController(groupViewCode);
                DataTable     HeaderDt      = ct.CreateTabDataTable(xmlDoc);

                int    numTabs             = HeaderDt.Rows.Count;
                bool   showMoreTabsMenu    = false;
                string TabsRightEndImgName = "HeaderTabsRightEndOff";
                if (HeaderDt.Rows.Count > maxTabs)
                {
                    showMoreTabsMenu = true;
                }

                int ActiveTabRowIndex = 0;


                // make current tab active
                if (currentSection != null)
                {
                    bool isSplashPage = false;
                    if (currentSection.IndexOf("/Utilities/Dashboard.aspx") > -1)
                    {
                        isSplashPage = true;
                    }

                    if (numTabs > 0)
                    {
                        for (int i = 0; i < (numTabs); i++)
                        {
                            if (currentSection.ToLower().IndexOf(HeaderDt.Rows[i]["Path"].ToString().ToLower()) > -1)
                            {
                                HeaderDt.Rows[i]["IsActiveTab"] = "true";
                                ActiveTabRowIndex = i;

                                if (numTabs > (i + 1))
                                {
                                    HeaderDt.Rows[i + 1]["IsActiveTab"] = "previous";

                                    if (showMoreTabsMenu && (i == (maxTabs - 1)))
                                    {
                                        TabsRightEndImgName = "HeaderTabsRightEndOn";
                                    }
                                }
                                else  // tab is last tab
                                {
                                    if (!showMoreTabsMenu)
                                    {
                                        TabsRightEndImgName = "HeaderTabsRightEndOn";
                                    }
                                    //                                    TabRightEnd.Src = "../../Images/Header/HeaderTabsRightEndOn.gif";
                                }
                            }
                        }

                        if (isSplashPage)
                        {
                            HeaderDt.Rows[0]["IsActiveTab"] = "previous";
                        }
                    }
                    else
                    {
                        TabsRightEndImgName = "HeaderTabsRightEndOn";
                        //                      TabRightEnd.Src = "../../Images/Header/HeaderTabsRightEndOn.gif";
                    }

                    if (isSplashPage)
                    {
                        TabLeftEnd.Src = "../../Images/Header/HeaderTabsLeftEndOn.gif";
                        TabHome.Src    = "../../Images/Header/HeaderTabsHomeOn.gif";
                    }
                    else
                    {
                        TabHome.Attributes["style"] = "cursor:hand;";
                    }
                }


                if (showMoreTabsMenu)
                {
                    // make sure active tab is shown even if selected from more menu
                    // do this by moving the active tab up in the table if necessary
                    if (ActiveTabRowIndex != null && ActiveTabRowIndex > (maxTabs - 1))
                    {
                        DataRow activeRow = HeaderDt.Rows[ActiveTabRowIndex];
                        DataRow newRow    = HeaderDt.NewRow();
                        newRow.ItemArray = activeRow.ItemArray;
                        HeaderDt.Rows.Remove(activeRow);
                        HeaderDt.Rows.InsertAt(newRow, maxTabs - 1);
                        TabsRightEndImgName = "HeaderTabsRightEndOn";
                    }


                    TabsRightEndImgName    += "_withMoreMenu";
                    MoreModulesTab.Visible  = true;
                    MoreModulesMenu.Visible = true;


                    DataTable MoreTabsMenuDt = HeaderDt.Copy();

                    for (int i = 0; i < maxTabs; i++)  // delete unneeded tabs from MoreTabsMenuDt
                    {
                        MoreTabsMenuDt.Rows[0].Delete();
                    }

                    MoreTabsRpt.DataSource = MoreTabsMenuDt.DefaultView;
                    MoreTabsRpt.DataBind();


                    for (int j = maxTabs; j < numTabs; j++) // delete excess tabs from HeaderDt and add tab names to title attribute of the "more" tab
                    {
                        //                        MoreModulesTab.Attributes["title"] += HeaderDt.Rows[maxTabs]["TabName"];
                        //                        if (j < (numTabs - 1)) MoreModulesTab.Attributes["title"] += ", ";

                        HeaderDt.Rows[maxTabs].Delete();
                    }
                }



                TabRightEnd.Src = "../../Images/Header/" + TabsRightEndImgName + ".gif";


                rptHeaderTabs.DataSource = HeaderDt.DefaultView;
                rptHeaderTabs.DataBind();
            }
        }