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 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); }