Changeset 899
- Timestamp:
- 12/04/08 15:53:04 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ClientAdapter.cs
r845 r899 36 36 37 37 #region IClientAdapter Members 38 private ClientInfo Convert(dsHiveServer.ClientRow row) { 39 if(row != null) { 40 ClientInfo client = new ClientInfo(); 41 38 private ClientInfo Convert(dsHiveServer.ClientRow row, 39 ClientInfo client) { 40 if(row != null && client != null) { 42 41 /*Parent - resource*/ 43 Resource resource = 44 resAdapter.GetResourceById(row.ResourceId); 45 client.ResourceId = resource.ResourceId; 46 client.Name = resource.Name; 42 client.ResourceId = row.ResourceId; 43 resAdapter.FillResource(client); 47 44 48 45 /*ClientInfo*/ 49 46 client.ClientId = row.GUID; 50 client.CpuSpeedPerCore = row.CPUSpeed; 51 client.Memory = row.Memory; 52 client.Login = row.Login; 53 if (row.Status != null) 47 48 if (!row.IsCPUSpeedNull()) 49 client.CpuSpeedPerCore = row.CPUSpeed; 50 else 51 client.CpuSpeedPerCore = 0; 52 53 if (!row.IsMemoryNull()) 54 client.Memory = row.Memory; 55 else 56 client.Memory = 0; 57 58 if (!row.IsLoginNull()) 59 client.Login = row.Login; 60 else 61 client.Login = DateTime.MinValue; 62 63 if (!row.IsStatusNull()) 54 64 client.State = (State)Enum.Parse(typeof(State), row.Status, true); 55 client.NrOfCores = row.NumberOfCores; 65 else 66 client.State = State.idle; 67 68 if (!row.IsNumberOfCoresNull()) 69 client.NrOfCores = row.NumberOfCores; 70 else 71 client.NrOfCores = 0; 56 72 57 73 //todo: config adapter (client.config) … … 107 123 108 124 public ClientInfo GetClientById(Guid clientId) { 125 ClientInfo client = new ClientInfo(); 126 109 127 dsHiveServer.ClientDataTable data = 110 128 adapter.GetDataById(clientId); … … 112 130 dsHiveServer.ClientRow row = 113 131 data[0]; 114 return Convert(row); 132 Convert(row, client); 133 134 return client; 115 135 } else { 116 136 return null; … … 126 146 127 147 foreach (dsHiveServer.ClientRow row in data) { 128 allClients.Add(Convert(row)); 148 ClientInfo client = new ClientInfo(); 149 Convert(row, client); 150 allClients.Add(client); 129 151 } 130 152 -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/PermissionOwnerAdapter.cs
r845 r899 55 55 } 56 56 57 internal bool FillPermissionOwner(PermissionOwner permOwner) { 58 if (permOwner != null) { 59 return true; 60 } 61 62 return false; 63 } 64 57 65 public PermissionOwner GetPermissionOwnerById(long resourceId) { 58 66 throw new NotImplementedException(); -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ResourceAdapter.cs
r845 r899 33 33 new dsHiveServerTableAdapters.ResourceTableAdapter(); 34 34 35 private Resource Convert(dsHiveServer.ResourceRow row) { 36 if (row != null) { 37 Resource resource = new Resource(); 38 35 private Resource Convert(dsHiveServer.ResourceRow row, 36 Resource resource) { 37 if (row != null && resource != null) { 39 38 resource.ResourceId = row.ResourceId; 40 resource.Name = row.Name; 39 if (!row.IsNameNull()) 40 resource.Name = row.Name; 41 else 42 resource.Name = String.Empty; 41 43 42 44 return resource; 43 } else 45 } else 44 46 return null; 45 47 } … … 49 51 if (resource != null && row != null) { 50 52 row.Name = resource.Name; 51 }52 53 53 return row; 54 return row; 55 } else 56 return null; 54 57 } 55 58 … … 75 78 } 76 79 80 internal bool FillResource(Resource resource) { 81 if (resource != null) { 82 dsHiveServer.ResourceDataTable data = 83 adapter.GetDataById(resource.ResourceId); 84 if (data.Count == 1) { 85 dsHiveServer.ResourceRow row = 86 data[0]; 87 Convert(row, resource); 88 89 return true; 90 } 91 } 92 93 return false; 94 } 95 77 96 public Resource GetResourceById(long resourceId) { 78 dsHiveServer.ResourceDataTable data = 79 adapter.GetDataById(resourceId); 80 if (data.Count == 1) { 81 dsHiveServer.ResourceRow row = 82 data[0]; 83 return Convert(row); 84 } else { 97 Resource resource = new Resource(); 98 resource.ResourceId = resourceId; 99 100 if(FillResource(resource)) 101 return resource; 102 else 85 103 return null; 86 }87 104 } 88 105 … … 95 112 96 113 foreach (dsHiveServer.ResourceRow row in data) { 97 allResources.Add(Convert(row)); 114 Resource resource = new Resource(); 115 Convert(row, resource); 116 allResources.Add(resource); 98 117 } 99 118 -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/UserAdapter.cs
r845 r899 36 36 new PermissionOwnerAdapter(); 37 37 38 private User Convert(dsHiveServer.HiveUserRow row) { 39 if (row != null) { 40 User user = new User(); 41 42 /*Parent - resource*/ 43 PermissionOwner permOwner = 44 permOwnerAdapter.GetPermissionOwnerById(row.PermissionOwnerId); 45 user.PermissionOwnerId = permOwner.PermissionOwnerId; 46 user.Name = permOwner.Name; 38 private User Convert(dsHiveServer.HiveUserRow row, 39 User user) { 40 if (row != null && user != null) { 41 /*Parent - PermissionOwner*/ 42 user.PermissionOwnerId = row.PermissionOwnerId; 43 permOwnerAdapter.FillPermissionOwner(user); 47 44 48 45 /*User*/ 49 user.Password = row.Password; 46 if (!row.IsPasswordNull()) 47 user.Password = row.Password; 48 else 49 user.Password = String.Empty; 50 50 51 51 return user; … … 59 59 row.PermissionOwnerId = user.PermissionOwnerId; 60 60 row.Password = user.Password; 61 }62 61 63 return row; 62 return row; 63 } else 64 return null; 64 65 } 65 66 … … 70 71 } 71 72 72 public ClientInfo GetUserById(long userId) { 73 public User GetUserById(long userId) { 74 throw new NotImplementedException(); 75 } 76 77 public User GetUserByName(String name) { 73 78 throw new NotImplementedException(); 74 79 } -
trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/DataAccess/IUserAdapter.cs
r845 r899 42 42 /// <param name="userId"></param> 43 43 /// <returns></returns> 44 ClientInfo GetUserById(long userId); 44 User GetUserById(long userId); 45 46 /// <summary> 47 /// Get the user with the specified name 48 /// </summary> 49 /// <param name="userId"></param> 50 /// <returns></returns> 51 User GetUserByName(string name); 45 52 46 53 /// <summary> -
trunk/sources/HeuristicLab.Hive.Server.Core/ServiceLocator.cs
r826 r899 31 31 32 32 private static IClientAdapter clientAdapter = null; 33 34 private static IUserAdapter userAdapter = null; 33 35 34 36 /// <summary> … … 43 45 return clientAdapter; 44 46 } 47 48 /// <summary> 49 /// Gets the user database adapter 50 /// </summary> 51 /// <returns></returns> 52 internal static IUserAdapter GetUserAdapter() { 53 if (userAdapter == null) { 54 userAdapter = discoveryService.GetInstances<IUserAdapter>()[0]; 55 } 56 57 return userAdapter; 58 } 45 59 } -
trunk/sources/HeuristicLab.Hive.Server/MainForm.Designer.cs
r800 r899 40 40 this.label1.Location = new System.Drawing.Point(18, 18); 41 41 this.label1.Name = "label1"; 42 this.label1.Size = new System.Drawing.Size(11 3, 13);42 this.label1.Size = new System.Drawing.Size(115, 13); 43 43 this.label1.TabIndex = 0; 44 this.label1.Text = "Hive server running @";44 this.label1.Text = "Hive Server running @"; 45 45 // 46 46 // lblAddress1
Note: See TracChangeset
for help on using the changeset viewer.