Changeset 934
- Timestamp:
- 12/10/08 11:35:34 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Contracts/ApplicationConstants.cs
r929 r934 12 12 public static string RESPONSE_USERROLE_USER_DOESNT_EXIST = "UserRole.UserDoesntExist"; 13 13 public static string RESPONSE_USERROLE_USER_REMOVED = "UserRole.UserRemoved"; 14 public static string RESPONSE_USERROLE_USERGROUP_EXISTS_ALLREADY = "UserRole.UsergroupExistsAllready"; 15 public static string RESPONSE_USERROLE_USERGROUP_ADDED = "UserRole.UserGroupAdded"; 16 public static string RESPONSE_USERROLE_USERGROUP_DOESNT_EXIST = "UserRole.UserGroupDoesntExist"; 17 public static string RESPONSE_USERROLE_PERMISSIONOWNER_DOESNT_EXIST = "UserRole.PermissionOwnerDoesntExist"; 18 public static string RESPONSE_USERROLE_PERMISSIONOWNER_REMOVED = "UserRole.PermissionOwnerRemoved"; 19 public static string RESPONSE_USERROLE_PERMISSIONOWNER_ADDED = "UserRole.PermissionOwnerAdded"; 20 public static string RESPONSE_USERROLE_GET_ALL_USERGROUPS = "UserRole.AllUserGroupsReturned"; 14 21 15 22 public static string RESPONSE_CLIENT_GET_ALL_CLIENTS = "Client.GetAllClients"; 23 public static string RESPONSE_CLIENT_GET_ALL_CLIENTGROUPS = "Client.GetAllClientGroups"; 16 24 17 25 public static string RESPONSE_COMMUNICATOR_HARDBEAT_RECEIVED = "Communicator.HeardbeatReceived"; -
trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/ClientGroup.cs
r827 r934 34 34 [DataMember] 35 35 public List<Resource> Resources { get; set; } 36 37 public ClientGroup() { 38 Resources = new List<Resource>(); 39 } 36 40 } 37 41 } -
trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/UserGroup.cs
r930 r934 32 32 [DataMember] 33 33 public IList<PermissionOwner> Members { get; set; } 34 35 public UserGroup() { 36 Members = new List<PermissionOwner>(); 37 } 34 38 } 35 39 } -
trunk/sources/HeuristicLab.Hive.Contracts/HeuristicLab.Hive.Contracts.csproj
r925 r934 4 4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 5 5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 6 <ProductVersion>9.0. 21022</ProductVersion>6 <ProductVersion>9.0.30729</ProductVersion> 7 7 <SchemaVersion>2.0</SchemaVersion> 8 8 <ProjectGuid>{134F93D7-E7C8-4ECD-9923-7F63259A60D8}</ProjectGuid> … … 116 116 <None Include="Properties\AssemblyInfo.frame" /> 117 117 </ItemGroup> 118 <ItemGroup> 119 <EmbeddedResource Include="HiveServerMessages.resx" /> 120 </ItemGroup> 118 121 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 119 122 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/IClientManager.cs
r902 r934 19 19 ResponseList<ClientGroup> GetAllClientGroups(); 20 20 [OperationContract] 21 Response AddClientGroup(ClientGroup clientGroup); 22 [OperationContract] 23 Response AddResourceToGroup(long clientGroupId, Resource resource); 24 [OperationContract] 25 Response DeleteResourceFromGroup(long clientGroupId, long resourceId); 26 [OperationContract] 21 27 ResponseList<UpTimeStatistics> GetAllUpTimeStatistics(); 22 28 } -
trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/IUserRoleManager.cs
r902 r934 25 25 ResponseList<UserGroup> GetAllUserGroups(); 26 26 [OperationContract] 27 Response Add UserToGroup(long groupId, long userId);27 Response AddPermissionOwnerToGroup(long groupId, PermissionOwner permissionOwner); 28 28 [OperationContract] 29 Response Remove UserFromGroup(long groupId, long userId);29 Response RemovePermissionOwnerFromGroup(long groupId, long userId); 30 30 } 31 31 } -
trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs
r929 r934 16 16 /// </summary> 17 17 public class ClientCommunicator: IClientCommunicator { 18 List<ClientInfo> clients;19 18 LinkedList<long> jobs; 20 19 int nrOfJobs = 1; -
trunk/sources/HeuristicLab.Hive.Server.Core/ClientManager.cs
r929 r934 33 33 34 34 IClientAdapter clientAdapter; 35 IClientGroupAdapter clientGroupAdapter; 35 36 36 List<ClientInfo> clients;37 37 List<ClientGroup> clientGroups; 38 38 39 39 public ClientManager() { 40 40 clientAdapter = ServiceLocator.GetClientAdapter(); 41 clientGroupAdapter = ServiceLocator.GetClientGroupAdapter(); 41 42 42 clients = new List<ClientInfo>();43 43 clientGroups = new List<ClientGroup>(); 44 45 ClientInfo c1 = new ClientInfo { ClientId=Guid.NewGuid(), Name="Client1", CpuSpeedPerCore=2500, Memory=4096, ResourceId=1, State=State.idle };46 ClientInfo c2 = new ClientInfo { ClientId=Guid.NewGuid(), Name="Client2", CpuSpeedPerCore=2100, Memory=2048, ResourceId=2, State=State.idle };47 ClientInfo c3 = new ClientInfo { ClientId = Guid.NewGuid(), Name="Client3", CpuSpeedPerCore = 3400, Memory = 4096, ResourceId = 3, State = State.calculating };48 49 clients.Add(c1);50 clients.Add(c2);51 clients.Add(c3);52 44 53 45 ClientGroup cg = new ClientGroup { ResourceId = 4, Name = "SuperGroup", ClientGroupId = 1 }; 54 46 cg.Resources = new List<Resource>(); 55 cg.Resources.Add(c1);56 cg.Resources.Add(c2);57 cg.Resources.Add(c3);58 47 59 48 clientGroups.Add(cg); … … 74 63 public ResponseList<ClientGroup> GetAllClientGroups() { 75 64 ResponseList<ClientGroup> response = new ResponseList<ClientGroup>(); 76 response.List = clientGroups; 65 66 response.List = new List<ClientGroup>(clientGroupAdapter.GetAllClientGroups()); 67 response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_GET_ALL_CLIENTGROUPS; 77 68 response.Success = true; 69 78 70 return response; 79 71 } … … 85 77 } 86 78 79 public Response AddClientGroup(ClientGroup clientGroup) { 80 throw new NotImplementedException(); 81 } 82 83 public Response AddResourceToGroup(long clientGroupId, Resource resource) { 84 throw new NotImplementedException(); 85 } 86 87 public Response DeleteResourceFromGroup(long clientGroupId, long resourceId) { 88 throw new NotImplementedException(); 89 } 87 90 #endregion 88 91 } -
trunk/sources/HeuristicLab.Hive.Server.Core/HeuristicLab.Hive.Server.Core.csproj
r925 r934 4 4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 5 5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 6 <ProductVersion>9.0. 21022</ProductVersion>6 <ProductVersion>9.0.30729</ProductVersion> 7 7 <SchemaVersion>2.0</SchemaVersion> 8 8 <ProjectGuid>{898B31CF-81DC-453B-AEB3-BDF83197A7EE}</ProjectGuid> … … 103 103 </ProjectReference> 104 104 </ItemGroup> 105 <ItemGroup>106 <EmbeddedResource Include="HiveServerMessages.resx" />107 </ItemGroup>108 105 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 109 106 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
trunk/sources/HeuristicLab.Hive.Server.Core/ServerConsoleFacade.cs
r925 r934 48 48 } 49 49 50 public Response AddClientGroup(ClientGroup clientGroup) { 51 return clientManager.AddClientGroup(clientGroup); 52 } 53 54 public Response AddResourceToGroup(long clientGroupId, Resource resource) { 55 return clientManager.AddResourceToGroup(clientGroupId, resource); 56 } 57 58 public Response DeleteResourceFromGroup(long clientGroupId, long resourceId) { 59 return clientManager.DeleteResourceFromGroup(clientGroupId, resourceId); 60 } 61 50 62 #endregion 51 63 … … 73 85 74 86 public Response RemoveUser(long userId) { 75 throw new NotImplementedException();87 return userRoleManager.RemoveUser(userId); 76 88 } 77 89 78 90 public Response AddNewUserGroup(UserGroup userGroup) { 79 throw new NotImplementedException();91 return userRoleManager.AddNewUserGroup(userGroup); 80 92 } 81 93 82 94 public Response RemoveUserGroup(long groupId) { 83 throw new NotImplementedException();95 return userRoleManager.RemoveUserGroup(groupId); 84 96 } 85 97 86 public Response Add UserToGroup(long groupId, long userId) {87 throw new NotImplementedException();98 public Response AddPermissionOwnerToGroup(long groupId, PermissionOwner permissionOwner) { 99 return userRoleManager.AddPermissionOwnerToGroup(groupId, permissionOwner); 88 100 } 89 101 90 public Response Remove UserFromGroup(long groupId, long userId) {91 throw new NotImplementedException();102 public Response RemovePermissionOwnerFromGroup(long groupId, long userId) { 103 return userRoleManager.RemovePermissionOwnerFromGroup(groupId, userId); 92 104 } 93 105 94 106 #endregion 95 96 107 } 97 108 } -
trunk/sources/HeuristicLab.Hive.Server.Core/UserRoleManager.cs
r929 r934 13 13 class UserRoleManager: IUserRoleManager { 14 14 15 List<User> users;16 List<UserGroup> userGroups;17 18 15 IUserAdapter userAdapter; 16 IUserGroupAdapter userGroupAdapter; 19 17 20 18 public UserRoleManager() { 21 19 userAdapter = ServiceLocator.GetUserAdapter(); 22 23 users = new List<User>(); 24 userGroups = new List<UserGroup>(); 25 26 users.Add(new User { PermissionOwnerId = 1, Name = "Hugo", Password = "hUg0" }); 27 users.Add(new User { PermissionOwnerId = 2, Name = "Seppl", Password = "seppl" }); 28 users.Add(new User { PermissionOwnerId = 3, Name = "Greg", Password = "greg" }); 29 30 userGroups.Add(new UserGroup { PermissionOwnerId = 4 }); 31 userGroups.Add(new UserGroup { PermissionOwnerId = 5 }); 20 userGroupAdapter = ServiceLocator.GetUserGroupAdapter(); 32 21 } 33 22 … … 64 53 ResponseList<UserGroup> response = new ResponseList<UserGroup>(); 65 54 55 response.List = new List<UserGroup>(userGroupAdapter.GetAllUserGroups()); 56 response.Success = true; 57 response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_GET_ALL_USERGROUPS; 58 66 59 return response; 67 60 } … … 75 68 return response; 76 69 } 70 userAdapter.DeleteUser(user); 77 71 response.Success = true; 78 72 response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_USER_REMOVED; … … 82 76 83 77 public Response AddNewUserGroup(UserGroup userGroup) { 84 return null; 78 Response response = new Response(); 79 80 UserGroup userGroupFromDb = userGroupAdapter.GetUserGroupById(userGroup.PermissionOwnerId); 81 if (userGroupFromDb != null) { 82 response.Success = false; 83 response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_USERGROUP_EXISTS_ALLREADY; 84 return response; 85 } 86 userGroupAdapter.UpdateUserGroup(userGroup); 87 response.Success = false; 88 response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_USERGROUP_ADDED; 89 90 return response; 85 91 } 86 92 87 93 public Response RemoveUserGroup(long groupId) { 88 return null; 94 Response response = new Response(); 95 96 UserGroup userGroupFromDb = userGroupAdapter.GetUserGroupById(groupId); 97 if (userGroupFromDb == null) { 98 response.Success = false; 99 response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_USERGROUP_DOESNT_EXIST; 100 return response; 101 } 102 userGroupAdapter.DeleteUserGroup(userGroupFromDb); 103 response.Success = false; 104 response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_USERGROUP_ADDED; 105 106 return response; 89 107 } 90 108 91 public Response AddUserToGroup(long groupId, long userId) { 92 throw new NotImplementedException(); 109 public Response AddPermissionOwnerToGroup(long groupId, PermissionOwner permissionOwner) { 110 Response response = new Response(); 111 112 UserGroup userGroup = userGroupAdapter.GetUserGroupById(groupId); 113 if (userGroup == null) { 114 response.Success = false; 115 response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_USERGROUP_DOESNT_EXIST; 116 return response; 117 } 118 userGroup.Members.Add(permissionOwner); 119 userGroupAdapter.UpdateUserGroup(userGroup); 120 121 response.Success = true; 122 response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_PERMISSIONOWNER_ADDED; 123 124 return response; 93 125 } 94 126 95 public Response RemoveUserFromGroup(long groupId, long userId) { 96 throw new NotImplementedException(); 127 public Response RemovePermissionOwnerFromGroup(long groupId, long permissionOwnerId) { 128 Response response = new Response(); 129 130 UserGroup userGroup = userGroupAdapter.GetUserGroupById(groupId); 131 if (userGroup == null) { 132 response.Success = false; 133 response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_USERGROUP_DOESNT_EXIST; 134 return response; 135 } 136 User user = userAdapter.GetUserById(permissionOwnerId); 137 if (user == null) { 138 response.Success = false; 139 response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_PERMISSIONOWNER_DOESNT_EXIST; 140 return response; 141 } 142 foreach (PermissionOwner permissionOwner in userGroup.Members) { 143 if (permissionOwner.PermissionOwnerId == permissionOwnerId) { 144 userGroup.Members.Remove(permissionOwner); 145 userGroupAdapter.UpdateUserGroup(userGroup); 146 response.Success = true; 147 response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_PERMISSIONOWNER_REMOVED; 148 return response; 149 } 150 } 151 response.Success = false; 152 response.StatusMessage = ApplicationConstants.RESPONSE_USERROLE_PERMISSIONOWNER_DOESNT_EXIST; 153 154 return response; 97 155 } 98 156
Note: See TracChangeset
for help on using the changeset viewer.