/// <summary> /// 根据描述得到一组角色集合 /// </summary> /// <param name="rolesDesp"></param> /// <returns></returns> public static IRole[] GetRoles(string rolesDesp) { List <IRole> result = new List <IRole>(); if (string.IsNullOrEmpty(rolesDesp) == false) { AppRolesDespsCollection allAppRolesDesps = GetAppRolesDesps(rolesDesp); ApplicationCollection apps = PermissionMechanismFactory.GetMechanism().GetApplications(allAppRolesDesps.GetAppNames()); foreach (AppRolesDesps appRolesDesps in allAppRolesDesps) { if (apps.ContainsKey(appRolesDesps.AppName)) { IApplication app = apps[appRolesDesps.AppName]; foreach (string roleName in appRolesDesps.RolesDesp) { if (app.Roles.ContainsKey(roleName)) { result.Add(app.Roles[roleName]); } } } } } return(result.ToArray()); }
// Creates a Dictionary of DGS Applications, using the server name as the key private static ApplicationCollection CreateApplicationItemList() { ApplicationCollection itemDic = new ApplicationCollection(); // Get the Server Inventory as a ListItemCollection ListItemCollection list = GetApplicationListItems(); // Itterate through each item in the list foreach (ListItem lItem in list) { try { ApplicationItem app = new ApplicationItem(lItem["Title"].ToString()); // Set the simple text fields app.SupportContact = lItem[_supportContactField] != null ? (string)lItem[_supportContactField] : ""; app.SupportGroup = lItem[_supportGroupField] != null ? (string)lItem[_supportGroupField] : ""; app.Status = lItem[_statusField] != null ? (string)lItem[_statusField] : ""; app.ApplicationType = lItem[_applicationTypeField] != null ? (string)lItem[_applicationTypeField] : ""; app.Description = lItem[_descriptionField] != null ? (string)lItem[_descriptionField] : ""; // Add server to the Dictionary if (!itemDic.ContainsKey(app.ApplicationName)) { itemDic.Add(app); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } return(itemDic); }