/// <summary> /// 获取客户端所有的模块 /// </summary> /// <returns>返回当前用户可以加载的模块明细数组</returns> public ClientModuleInfo[] GetClientModules() { string user = sessionService.CurrentSession[SessionVariables.SESSION_CURRENT_USER].ToString(); List <ClientModuleInfo> list = new List <ClientModuleInfo>(); IConfigurationService configService = kernal[typeof(IConfigurationService)] as IConfigurationService; IConfiguration workstations = new XMLConfiguration(configService.GetItem(WORKSTATION_PATH)); foreach (IConfiguration workstation in workstations.Children) { // 检查拥有每个子系统的角色 bool hasPower = false; if (workstation.Attributes["allowroles"] != null) { string[] allowRoles = workstation.Attributes["allowroles"].Split(new char[] { ' ', ',', ';' }); if (allowRoles.Length == 1 && allowRoles[0].ToLower() == "all") { hasPower = true; } else { foreach (string role in allowRoles) { if (Roles.IsUserInRole(user, role)) { hasPower = true; } } } if (!hasPower) { continue; // 如果当前用户没有相关权限则处理下一个子系统 } // 逐个处理子系统中的每个模块 foreach (IConfiguration module in workstation.Children) { if (module.Attributes["assemblyfile"] == null) { throw new ArgumentException("没有定义模块的程序集属性[assemblyfile]。"); } string assemblyFile = module.Attributes["assemblyfile"]; ClientModuleInfo client = new ClientModuleInfo(assemblyFile, module.Value == "MainModule"); list.Add(client); } } } return(list.ToArray()); }
private void CheckMultiMainWorkspace(ClientModuleInfo[] infos) { int mainModuleCount = 0; foreach (ClientModuleInfo info in infos) { if (info.IsMainModule) mainModuleCount++; } hasMultiMainWorkspace = mainModuleCount > 1; }
/// <summary> /// ��ȡ�ͻ������е�ģ�� /// </summary> /// <returns>���ص�ǰ�û����Լ��ص�ģ����ϸ����</returns> public ClientModuleInfo[] GetClientModules() { string user = sessionService.CurrentSession[SessionVariables.SESSION_CURRENT_USER].ToString(); List<ClientModuleInfo> list = new List<ClientModuleInfo>(); IConfigurationService configService = kernal[typeof(IConfigurationService)] as IConfigurationService; IConfiguration workstations = new XMLConfiguration(configService.GetItem(WORKSTATION_PATH)); foreach (IConfiguration workstation in workstations.Children) { // ���ӵ��ÿ����ϵͳ�Ľ�ɫ bool hasPower = false; if (workstation.Attributes["allowroles"] != null) { string[] allowRoles = workstation.Attributes["allowroles"].Split(new char[]{' ', ',', ';'}); if (allowRoles.Length == 1 && allowRoles[0].ToLower() == "all") hasPower = true; else { foreach (string role in allowRoles) { if (Roles.IsUserInRole(user, role)) hasPower = true; } } if (!hasPower) continue; // �����ǰ�û�û�����Ȩ��������һ����ϵͳ // ���������ϵͳ�е�ÿ��ģ�� foreach (IConfiguration module in workstation.Children) { if (module.Attributes["assemblyfile"] == null) throw new ArgumentException("û�ж���ģ��ij�������[assemblyfile]��"); string assemblyFile = module.Attributes["assemblyfile"]; ClientModuleInfo client = new ClientModuleInfo(assemblyFile, module.Value == "MainModule"); list.Add(client); } } } return list.ToArray(); }