public static List <STD_MENU_ITEMS> GetMenu(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, string PATH)
        {
            List <STD_MENU_ITEMS> objReturn = new List <STD_MENU_ITEMS>();
            STD_MENU_ITEMSDB      objDB     = new STD_MENU_ITEMSDB();
            STD_MENU_ITEMS        menuItem  = null;

            if (string.IsNullOrEmpty(PATH) ||
                PATH.Equals("~/Default.aspx", StringComparison.InvariantCultureIgnoreCase) ||
                PATH.Equals("~/DataDictionary.aspx", StringComparison.InvariantCultureIgnoreCase) ||
                PATH.Equals("~/RegistryInfo.aspx", StringComparison.InvariantCultureIgnoreCase))
            {
                string[] roles = USER_ROLESManager.GetRoles(CURRENT_USER);

                List <STD_REGISTRY> allRegs = STD_REGISTRYManager.GetNonSystemRegistries();
                List <STD_REGISTRY> uRegs   = null;

                if (IsSystemUser(roles))
                {
                    uRegs = STD_REGISTRYManager.GetNonSystemRegistries();
                }
                else
                {
                    uRegs = STD_REGISTRYManager.GetNonSystemRegistriesByUser(CURRENT_USER, CURRENT_REGISTRY_ID);
                }

                if (uRegs != null && uRegs.Count > 0)
                {
                    menuItem           = new STD_MENU_ITEMS();
                    menuItem.MENU_PAGE = new STD_WEB_PAGES();
                    menuItem.MENU_PAGE.DISPLAY_TEXT = "Your Registries";
                    menuItem.MENU_PAGE.URL          = string.Empty;
                    objReturn.Add(menuItem);

                    foreach (STD_REGISTRY reg in uRegs)
                    {
                        menuItem           = new STD_MENU_ITEMS();
                        menuItem.MENU_PAGE = new STD_WEB_PAGES();
                        menuItem.MENU_PAGE.DISPLAY_TEXT = reg.NAME;
                        menuItem.MENU_PAGE.URL          = "~/Common/Default.aspx?id=" + reg.ID.ToString();
                        objReturn.Add(menuItem);

                        if (allRegs != null && allRegs.Count > 0)
                        {
                            int?index = null;
                            for (int i = 0; i < allRegs.Count; i++)
                            {
                                if (reg.ID == allRegs[i].ID)
                                {
                                    index = i;
                                    break;
                                }
                            }
                            if (index != null)
                            {
                                allRegs.RemoveAt(index.Value);
                            }
                        }
                    }
                }

                if (allRegs != null && allRegs.Count > 0)
                {
                    if (objReturn.Count > 1)
                    {
                        menuItem           = new STD_MENU_ITEMS();
                        menuItem.MENU_PAGE = new STD_WEB_PAGES();
                        menuItem.MENU_PAGE.DISPLAY_TEXT = string.Empty;
                        menuItem.MENU_PAGE.URL          = string.Empty;
                        objReturn.Add(menuItem);
                    }

                    menuItem           = new STD_MENU_ITEMS();
                    menuItem.MENU_PAGE = new STD_WEB_PAGES();
                    menuItem.MENU_PAGE.DISPLAY_TEXT = "Available Registries";
                    menuItem.MENU_PAGE.URL          = string.Empty;
                    objReturn.Add(menuItem);

                    foreach (STD_REGISTRY reg in allRegs)
                    {
                        menuItem           = new STD_MENU_ITEMS();
                        menuItem.MENU_PAGE = new STD_WEB_PAGES();
                        menuItem.MENU_PAGE.DISPLAY_TEXT = reg.NAME;
                        menuItem.MENU_PAGE.URL          = "~/RegistryInfo.aspx?id=" + reg.ID.ToString();
                        objReturn.Add(menuItem);
                    }
                }
            }
            else if (PATH.ToLower().Contains("~/reports/"))
            {
                string reportStore = string.Empty;

                List <ReportItem> reports = ReportManager.GetAllByUserAndRegistry(CURRENT_USER, CURRENT_REGISTRY_ID);
                if (reports != null && reports.Count > 0)
                {
                    foreach (ReportItem report in reports)
                    {
                        if (report.ReportStore != reportStore)
                        {
                            reportStore = report.ReportStore;

                            if (objReturn.Count > 1)
                            {
                                menuItem           = new STD_MENU_ITEMS();
                                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                                menuItem.MENU_PAGE.DISPLAY_TEXT = string.Empty;
                                menuItem.MENU_PAGE.URL          = string.Empty;
                                objReturn.Add(menuItem);
                            }

                            menuItem           = new STD_MENU_ITEMS();
                            menuItem.MENU_PAGE = new STD_WEB_PAGES();
                            menuItem.MENU_PAGE.DISPLAY_TEXT = reportStore + " Reports";
                            menuItem.MENU_PAGE.URL          = string.Empty;
                            objReturn.Add(menuItem);
                        }

                        menuItem           = new STD_MENU_ITEMS();
                        menuItem.MENU_PAGE = new STD_WEB_PAGES();
                        menuItem.MENU_PAGE.DISPLAY_TEXT = report.Name;
                        menuItem.MENU_PAGE.URL          = "~/Reports/RunReport.aspx?path=" + report.Path;
                        objReturn.Add(menuItem);
                    }
                }

                string[] roles = USER_ROLESManager.GetRoles(CURRENT_USER);
                if (!IsReadOnlyUser(roles))
                {
                    if (objReturn.Count > 1)
                    {
                        menuItem           = new STD_MENU_ITEMS();
                        menuItem.MENU_PAGE = new STD_WEB_PAGES();
                        menuItem.MENU_PAGE.DISPLAY_TEXT = string.Empty;
                        menuItem.MENU_PAGE.URL          = string.Empty;
                        objReturn.Add(menuItem);
                    }

                    DBUtils utils = new DBUtils();

                    menuItem           = new STD_MENU_ITEMS();
                    menuItem.MENU_PAGE = new STD_WEB_PAGES();
                    menuItem.MENU_PAGE.DISPLAY_TEXT = "Report Builder";
                    menuItem.MENU_PAGE.URL          = utils.ReportBuilderUrl;
                    objReturn.Add(menuItem);
                }
            }
            else if (PATH.ToLower().Contains("~/cohorts/"))
            {
                string titleName = "Registry and Cohort Administration";

                STD_REGISTRY reg = STD_REGISTRYManager.GetItem(CURRENT_USER, CURRENT_REGISTRY_ID, CURRENT_REGISTRY_ID);
                if (reg != null)
                {
                    titleName = reg.NAME;
                }

                menuItem           = new STD_MENU_ITEMS();
                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                menuItem.MENU_PAGE.DISPLAY_TEXT = titleName;
                menuItem.MENU_PAGE.URL          = string.Empty;
                objReturn.Add(menuItem);

                menuItem           = new STD_MENU_ITEMS();
                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                menuItem.MENU_PAGE.DISPLAY_TEXT = "Cohort Criteria";
                menuItem.MENU_PAGE.URL          = "~/Cohorts/Cohort.aspx";
                objReturn.Add(menuItem);

                menuItem           = new STD_MENU_ITEMS();
                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                menuItem.MENU_PAGE.DISPLAY_TEXT = "Framework Data";
                menuItem.MENU_PAGE.URL          = "~/Cohorts/FrameworkData.aspx";
                objReturn.Add(menuItem);

                menuItem           = new STD_MENU_ITEMS();
                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                menuItem.MENU_PAGE.DISPLAY_TEXT = "User-Defined Fields";
                menuItem.MENU_PAGE.URL          = "~/Cohorts/UDF.aspx";
                objReturn.Add(menuItem);

                menuItem           = new STD_MENU_ITEMS();
                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                menuItem.MENU_PAGE.DISPLAY_TEXT = "Work Streams";
                menuItem.MENU_PAGE.URL          = "~/Cohorts/Workstream.aspx";
                objReturn.Add(menuItem);

                menuItem           = new STD_MENU_ITEMS();
                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                menuItem.MENU_PAGE.DISPLAY_TEXT = "Activities";
                menuItem.MENU_PAGE.URL          = "~/Cohorts/Activity.aspx";
                objReturn.Add(menuItem);

                menuItem           = new STD_MENU_ITEMS();
                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                menuItem.MENU_PAGE.DISPLAY_TEXT = string.Empty;
                menuItem.MENU_PAGE.URL          = string.Empty;
                objReturn.Add(menuItem);

                menuItem           = new STD_MENU_ITEMS();
                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                menuItem.MENU_PAGE.DISPLAY_TEXT = "Registries and Cohorts";
                menuItem.MENU_PAGE.URL          = "~/Cohorts/Default.aspx";
                objReturn.Add(menuItem);
            }
            else if (PATH.ToLower().Contains("~/admin/"))
            {
                menuItem           = new STD_MENU_ITEMS();
                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                menuItem.MENU_PAGE.DISPLAY_TEXT = "Administration";
                menuItem.MENU_PAGE.URL          = string.Empty;
                objReturn.Add(menuItem);

                menuItem           = new STD_MENU_ITEMS();
                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                menuItem.MENU_PAGE.DISPLAY_TEXT = "Survey Administration";
                menuItem.MENU_PAGE.URL          = "~/Admin/Survey.aspx";
                objReturn.Add(menuItem);

                menuItem           = new STD_MENU_ITEMS();
                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                menuItem.MENU_PAGE.DISPLAY_TEXT = "User Administration";
                menuItem.MENU_PAGE.URL          = "~/Admin/User.aspx";
                objReturn.Add(menuItem);

                menuItem           = new STD_MENU_ITEMS();
                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                menuItem.MENU_PAGE.DISPLAY_TEXT = "Menu Administration";
                menuItem.MENU_PAGE.URL          = "~/Admin/Menu.aspx";
                objReturn.Add(menuItem);

                menuItem           = new STD_MENU_ITEMS();
                menuItem.MENU_PAGE = new STD_WEB_PAGES();
                menuItem.MENU_PAGE.DISPLAY_TEXT = "Settings";
                menuItem.MENU_PAGE.URL          = "~/Admin/Settings.aspx";
                objReturn.Add(menuItem);
            }
            else
            {
                objReturn = objDB.GetItemsByUserRegistryPath(CURRENT_USER, CURRENT_REGISTRY_ID, PATH);
                if (objReturn != null && objReturn.Count > 0)
                {
                    menuItem           = new STD_MENU_ITEMS();
                    menuItem.MENU_PAGE = new STD_WEB_PAGES();
                    menuItem.MENU_PAGE.DISPLAY_TEXT = objReturn[0].STD_REGISTRY.NAME;
                    menuItem.MENU_PAGE.URL          = string.Empty;
                    objReturn.Insert(0, menuItem);
                }
            }

            if (objReturn != null && objReturn.Count > 0)
            {
                return(objReturn);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        public static List <ReportItem> GetAllByUserAndRegistry(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID)
        {
            List <ReportItem> objReturn = null;
            ReportDB          objDB     = new ReportDB();

            List <ReportItem> objSystem = GetSystemReports(CURRENT_USER, CURRENT_REGISTRY_ID);

            if (objSystem != null)
            {
                if (objReturn == null)
                {
                    objReturn = new List <ReportItem>();
                }
                foreach (ReportItem ri in objSystem)
                {
                    objReturn.Add(ri);
                }
            }

            if (CURRENT_REGISTRY_ID > 0)
            {
                List <ReportItem> objRegistry = GetRegistryReports(CURRENT_USER, CURRENT_REGISTRY_ID);
                if (objRegistry != null)
                {
                    if (objReturn == null)
                    {
                        objReturn = new List <ReportItem>();
                    }
                    foreach (ReportItem ri in objRegistry)
                    {
                        objReturn.Add(ri);
                    }
                }
            }
            else
            {
                List <USER_ROLES> roles = USER_ROLESManager.GetItemsByUser(CURRENT_USER, CURRENT_REGISTRY_ID, CURRENT_USER);
                if (roles != null)
                {
                    bool systemUser = false;
                    //First check if they have a system level role
                    foreach (USER_ROLES role in roles)
                    {
                        if (!role.INACTIVE_FLAG)
                        {
                            if (role.STD_ROLE != null && role.STD_ROLE.SUPER_USER_FLAG)
                            {
                                systemUser = true;
                                break;
                            }
                        }
                    }

                    //If system user, get registry reports for all registries
                    if (systemUser)
                    {
                        List <STD_REGISTRY> registries = STD_REGISTRYManager.GetNonSystemRegistries();
                        if (registries != null)
                        {
                            foreach (STD_REGISTRY reg in registries)
                            {
                                List <ReportItem> objRegistry = GetRegistryReports(CURRENT_USER, reg.ID);
                                if (objRegistry != null)
                                {
                                    if (objReturn == null)
                                    {
                                        objReturn = new List <ReportItem>();
                                    }
                                    foreach (ReportItem ri in objRegistry)
                                    {
                                        objReturn.Add(ri);
                                    }
                                }
                            }
                        }
                    }
                    else //if not sytem user, get registry reports for all registries user has access to
                    {
                        foreach (USER_ROLES role in roles)
                        {
                            if (!role.INACTIVE_FLAG)
                            {
                                if (role.STD_ROLE != null && role.STD_ROLE.STD_REGISTRY_ID > 0)
                                {
                                    List <ReportItem> objRegistry = GetRegistryReports(CURRENT_USER, role.STD_ROLE.STD_REGISTRY_ID);
                                    if (objRegistry != null)
                                    {
                                        if (objReturn == null)
                                        {
                                            objReturn = new List <ReportItem>();
                                        }
                                        foreach (ReportItem ri in objRegistry)
                                        {
                                            objReturn.Add(ri);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            List <ReportItem> objUser = GetUserReports(CURRENT_USER, CURRENT_REGISTRY_ID);

            if (objUser != null)
            {
                if (objReturn == null)
                {
                    objReturn = new List <ReportItem>();
                }
                foreach (ReportItem ri in objUser)
                {
                    objReturn.Add(ri);
                }
            }

            objDB.Dispose();

            return(objReturn);
        }