Пример #1
0
        public static Int32 SaveWithReporting(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, USERS objSave)
        {
            Int32   objReturn = 0;
            USERSDB objDB     = new USERSDB();

            objReturn = objDB.Save(CURRENT_USER, CURRENT_REGISTRY_ID, objSave);
            if (objReturn > 0)
            {
                //Create System User
                ReportManager.AddSystemUser(CURRENT_USER, CURRENT_REGISTRY_ID, objSave.USERNAME);

                //Give Read Only to Root
                ReportManager.AddItemReadOnly(CURRENT_USER, CURRENT_REGISTRY_ID, objSave.USERNAME, "/");

                //Give Read Only to Reports
                ReportManager.AddItemReadOnly(CURRENT_USER, CURRENT_REGISTRY_ID, objSave.USERNAME, "/Reports");

                //Give Read Only to System
                STD_REGISTRY registry = STD_REGISTRYManager.GetSystemRegistry();
                if (registry != null && !string.IsNullOrEmpty(registry.CODE))
                {
                    ReportManager.AddItemReadOnly(CURRENT_USER, CURRENT_REGISTRY_ID, objSave.USERNAME, "/Reports/" + registry.CODE);
                }

                //Add User Folder and Give Admin
                string itemPath = ReportManager.CreateUserFolder(CURRENT_USER, CURRENT_REGISTRY_ID, objSave.USERNAME);
                if (!string.IsNullOrEmpty(itemPath))
                {
                    ReportManager.AddItemAdmin(CURRENT_USER, CURRENT_REGISTRY_ID, objSave.USERNAME, itemPath);
                }
            }

            return(objReturn);
        }
        public static Int32 SaveWithReporting(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, STD_REGISTRY objSave)
        {
            Int32          objReturn = 0;
            STD_REGISTRYDB objDB     = new STD_REGISTRYDB();

            objReturn = objDB.Save(CURRENT_USER, CURRENT_REGISTRY_ID, objSave);

            if (objReturn > 0)
            {
                string itemPath = ReportManager.CreateRegistryFolder(CURRENT_USER, objReturn);

                if (!string.IsNullOrEmpty(itemPath))
                {
                    ReportManager.CreateDataSet(CURRENT_USER, objReturn);

                    List <USERS> adminUsers = USERSManager.GetSystemUsers(CURRENT_USER, CURRENT_REGISTRY_ID);
                    if (adminUsers != null)
                    {
                        foreach (USERS user in adminUsers)
                        {
                            bool blnFound = false;

                            if (user.USER_ROLES != null)
                            {
                                foreach (USER_ROLES userRole in user.USER_ROLES)
                                {
                                    if (userRole.STD_ROLE != null)
                                    {
                                        switch (userRole.STD_ROLE.CODE)
                                        {
                                        case "CRSADMIN":
                                            ReportManager.AddItemAdmin(CURRENT_USER, CURRENT_REGISTRY_ID, user.USERNAME, itemPath);
                                            blnFound = true;
                                            break;

                                        case "CRSUPD":
                                            ReportManager.AddItemUpdate(CURRENT_USER, CURRENT_REGISTRY_ID, user.USERNAME, itemPath);
                                            blnFound = true;
                                            break;

                                        case "CRSREAD":
                                            ReportManager.AddItemReadOnly(CURRENT_USER, CURRENT_REGISTRY_ID, user.USERNAME, itemPath);
                                            blnFound = true;
                                            break;

                                        default:
                                            break;
                                        }
                                    }

                                    if (blnFound)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }

                ReportManager.CreateDataSet(CURRENT_USER, objReturn);
            }

            return(objReturn);
        }
        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);
            }
        }
Пример #4
0
        public static Boolean SaveAll(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, List <USER_ROLES> USER_ROLES)
        {
            if (USER_ROLES == null || USER_ROLES.Count == 0)
            {
                return(false);
            }

            Boolean      objReturn = false;
            USER_ROLESDB objDB     = new USER_ROLESDB();

            objReturn = objDB.SaveAll(CURRENT_USER, CURRENT_REGISTRY_ID, USER_ROLES);
            if (objReturn)
            {
                //Get a system role if available
                string systemRole = string.Empty;
                foreach (USER_ROLES userRole in USER_ROLES)
                {
                    if (userRole.STD_ROLE == null && userRole.STD_ROLE_ID > 0)
                    {
                        userRole.STD_ROLE = STD_ROLEManager.GetItem(CURRENT_USER, CURRENT_REGISTRY_ID, userRole.STD_ROLE_ID);
                    }
                    if (userRole.STD_ROLE != null)
                    {
                        if (userRole.STD_ROLE.SUPER_USER_FLAG && !userRole.INACTIVE_FLAG)
                        {
                            systemRole = userRole.STD_ROLE.CODE;
                            break;
                        }
                    }
                }

                USERS user = USERSManager.GetItem(CURRENT_USER, CURRENT_REGISTRY_ID, USER_ROLES[0].USER_ID);
                if (user != null)
                {
                    List <STD_REGISTRY> allRegs = STD_REGISTRYManager.GetItems(CURRENT_USER, CURRENT_REGISTRY_ID);
                    if (allRegs != null)
                    {
                        foreach (STD_REGISTRY reg in allRegs)
                        {
                            foreach (USER_ROLES userRole in USER_ROLES)
                            {
                                Boolean blnFound = false;

                                if (userRole.STD_ROLE != null)
                                {
                                    if (reg.ID == userRole.STD_ROLE.STD_REGISTRY_ID)
                                    {
                                        switch (userRole.STD_ROLE.CODE)
                                        {
                                        case "REGADMIN":
                                            blnFound = true;
                                            ReportManager.AddItemAdmin(CURRENT_USER, CURRENT_REGISTRY_ID, user.USERNAME, "/Reports/" + reg.CODE);
                                            break;

                                        case "REGUPD":
                                            if (systemRole != "CRSADMIN")
                                            {
                                                blnFound = true;
                                                ReportManager.AddItemUpdate(CURRENT_USER, CURRENT_REGISTRY_ID, user.USERNAME, "/Reports/" + reg.CODE);
                                            }
                                            break;

                                        case "REGREAD":
                                            if (systemRole != "CRSADMIN" && systemRole != "CRSUPD")
                                            {
                                                blnFound = true;
                                                ReportManager.AddItemReadOnly(CURRENT_USER, CURRENT_REGISTRY_ID, user.USERNAME, "/Reports/" + reg.CODE);
                                            }
                                            break;

                                        default:
                                            break;
                                        }
                                    }
                                }

                                if (!blnFound && string.IsNullOrEmpty(systemRole))
                                {
                                    ReportManager.RemovePrivileges(CURRENT_USER, CURRENT_REGISTRY_ID, user.USERNAME, "/Reports/" + reg.CODE);
                                }
                                else if (!blnFound)
                                {
                                    switch (systemRole)
                                    {
                                    case "CRSADMIN":
                                        ReportManager.AddItemAdmin(CURRENT_USER, CURRENT_REGISTRY_ID, user.USERNAME, "/Reports/" + reg.CODE);
                                        break;

                                    case "CRSUPD":
                                        ReportManager.AddItemUpdate(CURRENT_USER, CURRENT_REGISTRY_ID, user.USERNAME, "/Reports/" + reg.CODE);
                                        break;

                                    case "CRSREAD":
                                        ReportManager.AddItemReadOnly(CURRENT_USER, CURRENT_REGISTRY_ID, user.USERNAME, "/Reports/" + reg.CODE);
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(objReturn);
        }