Changeset 4953 for branches/ClientManagement
- Timestamp:
- 11/27/10 09:20:02 (14 years ago)
- Location:
- branches/ClientManagement/HeuristicLab.Services.Authentication
- Files:
-
- 5 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.DataAccess/ClientManagment.dbml
r4802 r4953 1 <?xml version="1.0" encoding="utf-8"?><Database Class="ClientManagmentDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">2 <Connection Mode="AppSettings" ConnectionString="Data Source=.\SQL EXPRESS;Initial Catalog=HeuristicLab.ClientManagment;Integrated Security=True" SettingsObjectName="HeuristicLab.Services.Authentication.DataAccess.Properties.Settings" SettingsPropertyName="ClientManagementConnectionString" Provider="System.Data.SqlClient" />1 <?xml version="1.0" encoding="utf-8"?><Database Name="HeuristicLab.ClientManagment" Class="ClientManagmentDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007"> 2 <Connection Mode="AppSettings" ConnectionString="Data Source=.\SQL2008;Initial Catalog=HeuristicLab.ClientManagment;Integrated Security=True" SettingsObjectName="HeuristicLab.Services.Authentication.DataAccess.Properties.Settings" SettingsPropertyName="ClientManagementConnectionString" Provider="System.Data.SqlClient" /> 3 3 <Table Name="" Member="Resources"> 4 4 <Type Name="Resource" InheritanceCode="Resource"> 5 <Column Name=" ResourceID" Member="Id" Storage="_ResourceID" AutoSync="OnInsert" Type="System.Guid" IsPrimaryKey="true" CanBeNull="false" />5 <Column Name="Id" Storage="_ResourceID" AutoSync="OnInsert" Type="System.Guid" IsPrimaryKey="true" CanBeNull="false" /> 6 6 <Column Name="Name" Type="System.String" CanBeNull="false" /> 7 7 <Column Name="Description" Type="System.String" CanBeNull="true" /> … … 22 22 <Table Name="" Member="ResourceResourceGroups"> 23 23 <Type Name="ResourceResourceGroup"> 24 <Column Name="ResourceI D" Member="ResourceId" Storage="_ResourceID" Type="System.Guid" IsPrimaryKey="true" CanBeNull="false" />25 <Column Name="ResourceGroupI D" Member="ResourceGroupId" Storage="_ResourceGroupID" Type="System.Guid" IsPrimaryKey="true" CanBeNull="false" />24 <Column Name="ResourceId" Storage="_ResourceID" Type="System.Guid" IsPrimaryKey="true" CanBeNull="false" /> 25 <Column Name="ResourceGroupId" Storage="_ResourceGroupID" Type="System.Guid" IsPrimaryKey="true" CanBeNull="false" /> 26 26 <Association Name="Resource_ResourceResourceGroup" Member="Client" Storage="_Resource" ThisKey="ResourceId" OtherKey="Id" Type="Resource" IsForeignKey="true" /> 27 27 <Association Name="Resource_ResourceResourceGroup1" Member="ResourceGroup" Storage="_Resource1" ThisKey="ResourceGroupId" OtherKey="Id" Type="Resource" IsForeignKey="true" /> -
branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.DataAccess/ClientManagment.dbml.layout
r4802 r4953 3 3 <DataContextMoniker Name="/ClientManagmentDataContext" /> 4 4 <nestedChildShapes> 5 <classShape Id="cace4a80-c7a9-4132-9b82-c4ef3884dbc0" absoluteBounds="0.75, 3.875, 2, 1. 7535424804687496">5 <classShape Id="cace4a80-c7a9-4132-9b82-c4ef3884dbc0" absoluteBounds="0.75, 3.875, 2, 1.9631982421874996"> 6 6 <DataClassMoniker Name="/ClientManagmentDataContext/Client" /> 7 7 <nestedChildShapes> 8 <elementListCompartment Id="bce42ce5-f605-4c26-a210-ed4ea2812ca7" absoluteBounds="0.765, 4.335, 1.9700000000000002, 1. 19354248046875" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />8 <elementListCompartment Id="bce42ce5-f605-4c26-a210-ed4ea2812ca7" absoluteBounds="0.765, 4.335, 1.9700000000000002, 1.4031982421875" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 9 9 </nestedChildShapes> 10 10 </classShape> 11 <classShape Id="ea129a98-d63f-4c3a-a3e8-dff64ad53c30" absoluteBounds="2 .125, 1.25, 2, 1.424847819010417">11 <classShape Id="ea129a98-d63f-4c3a-a3e8-dff64ad53c30" absoluteBounds="2, 1.125, 2, 1.5785953776041666"> 12 12 <DataClassMoniker Name="/ClientManagmentDataContext/Resource" /> 13 13 <nestedChildShapes> 14 <elementListCompartment Id="3a656a72-fe83-45a4-87c2-c0aa13fa068f" absoluteBounds="2. 14, 1.71, 1.9700000000000002, 0.86484781901041663" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />14 <elementListCompartment Id="3a656a72-fe83-45a4-87c2-c0aa13fa068f" absoluteBounds="2.015, 1.585, 1.9700000000000002, 1.0185953776041665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 15 15 </nestedChildShapes> 16 16 </classShape> 17 <inheritanceConnector edgePoints="[(3 .125 : 2.67484781901042); (3.125: 3.5); (1.75 : 3.5); (1.75 : 3.875)]" fixedFrom="NotFixed" fixedTo="NotFixed" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62">17 <inheritanceConnector edgePoints="[(3 : 2.70359537760417); (3 : 3.5); (1.75 : 3.5); (1.75 : 3.875)]" fixedFrom="NotFixed" fixedTo="NotFixed" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62"> 18 18 <nodes> 19 19 <classShapeMoniker Id="ea129a98-d63f-4c3a-a3e8-dff64ad53c30" /> … … 21 21 </nodes> 22 22 </inheritanceConnector> 23 <classShape Id="7820d3d1-da69-4786-9415-4fa77e5fc03a" absoluteBounds="3.625, 3.875, 2, 0. 76745849609374961">23 <classShape Id="7820d3d1-da69-4786-9415-4fa77e5fc03a" absoluteBounds="3.625, 3.875, 2, 0.80938964843749961"> 24 24 <DataClassMoniker Name="/ClientManagmentDataContext/ResourceGroup" /> 25 25 <nestedChildShapes> 26 <elementListCompartment Id="125f9904-768c-4c01-9a04-5212a9e6e484" absoluteBounds="3.64, 4.335, 1.9700000000000002, 0.2 0745849609375" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />26 <elementListCompartment Id="125f9904-768c-4c01-9a04-5212a9e6e484" absoluteBounds="3.64, 4.335, 1.9700000000000002, 0.2493896484375" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 27 27 </nestedChildShapes> 28 28 </classShape> 29 <inheritanceConnector edgePoints="[(3 .125 : 2.67484781901042); (3.125: 3.5); (4.625 : 3.5); (4.625 : 3.875)]" fixedFrom="NotFixed" fixedTo="NotFixed" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62">29 <inheritanceConnector edgePoints="[(3 : 2.70359537760417); (3 : 3.5); (4.625 : 3.5); (4.625 : 3.875)]" fixedFrom="NotFixed" fixedTo="NotFixed" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62"> 30 30 <nodes> 31 31 <classShapeMoniker Id="ea129a98-d63f-4c3a-a3e8-dff64ad53c30" /> … … 33 33 </nodes> 34 34 </inheritanceConnector> 35 <classShape Id="9b206f4e-128f-4c3f-bd08-7f2d271ebb2b" absoluteBounds="5.125, 1.25, 2, 1. 0961531575520831">35 <classShape Id="9b206f4e-128f-4c3f-bd08-7f2d271ebb2b" absoluteBounds="5.125, 1.25, 2, 1.1939925130208331"> 36 36 <DataClassMoniker Name="/ClientManagmentDataContext/ResourceResourceGroup" /> 37 37 <nestedChildShapes> 38 <elementListCompartment Id="9d879183-e5e2-42e9-9fbf-3e68f959d459" absoluteBounds="5.14, 1.71, 1.9700000000000002, 0. 53615315755208326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />38 <elementListCompartment Id="9d879183-e5e2-42e9-9fbf-3e68f959d459" absoluteBounds="5.14, 1.71, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 39 39 </nestedChildShapes> 40 40 </classShape> 41 <associationConnector edgePoints="[(4 .125 : 2.01147048950195); (5.125 : 2.01147048950195)]" fixedFrom="NotFixed" fixedTo="NotFixed">41 <associationConnector edgePoints="[(4 : 1.84699625651042); (5.125 : 1.84699625651042)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 42 42 <AssociationMoniker Name="/ClientManagmentDataContext/Resource/Resource_ResourceResourceGroup" /> 43 43 <nodes> … … 46 46 </nodes> 47 47 </associationConnector> 48 <associationConnector edgePoints="[(4 .125 : 1.56823524475098); (5.125 : 1.56823524475098)]" fixedFrom="NotFixed" fixedTo="NotFixed">48 <associationConnector edgePoints="[(4 : 2.10706709867143); (5.125 : 2.10706709867143)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 49 49 <AssociationMoniker Name="/ClientManagmentDataContext/Resource/Resource_ResourceResourceGroup1" /> 50 50 <nodes> -
branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.DataAccess/ClientManagment.designer.cs
r4802 r4953 23 23 24 24 25 [global::System.Data.Linq.Mapping.DatabaseAttribute(Name="HeuristicLab.ClientManagment")] 25 26 public partial class ClientManagmentDataContext : System.Data.Linq.DataContext 26 27 { … … 127 128 } 128 129 129 [global::System.Data.Linq.Mapping.ColumnAttribute( Name="ResourceID",Storage="_ResourceID", AutoSync=AutoSync.OnInsert, IsPrimaryKey=true)]130 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ResourceID", AutoSync=AutoSync.OnInsert, IsPrimaryKey=true)] 130 131 public System.Guid Id 131 132 { … … 483 484 } 484 485 485 [global::System.Data.Linq.Mapping.ColumnAttribute( Name="ResourceID",Storage="_ResourceID", IsPrimaryKey=true)]486 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ResourceID", IsPrimaryKey=true)] 486 487 public System.Guid ResourceId 487 488 { … … 494 495 if ((this._ResourceID != value)) 495 496 { 497 if (this._Resource.HasLoadedOrAssignedValue) 498 { 499 throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); 500 } 496 501 this.OnResourceIdChanging(value); 497 502 this.SendPropertyChanging(); … … 503 508 } 504 509 505 [global::System.Data.Linq.Mapping.ColumnAttribute( Name="ResourceGroupID",Storage="_ResourceGroupID", IsPrimaryKey=true)]510 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ResourceGroupID", IsPrimaryKey=true)] 506 511 public System.Guid ResourceGroupId 507 512 { … … 514 519 if ((this._ResourceGroupID != value)) 515 520 { 521 if (this._Resource1.HasLoadedOrAssignedValue) 522 { 523 throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); 524 } 516 525 this.OnResourceGroupIdChanging(value); 517 526 this.SendPropertyChanging(); -
branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.DataTransfer/Resource.cs
r4731 r4953 7 7 { 8 8 [DataMember] 9 public System.Guid ResourceID{ get; set; }9 public System.Guid Id { get; set; } 10 10 [DataMember] 11 11 public string Name { get; set; } … … 15 15 public string ResourceType { get; set; } 16 16 [DataMember] 17 public stringResourceGroup { get; set; }17 public System.Guid ResourceGroup { get; set; } 18 18 } 19 19 } -
branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication/ClientService.cs
r4802 r4953 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Collections;4 3 using System.Linq; 5 using System.Data.Linq;6 using System.Data.Linq.Mapping;7 using System.Text;8 9 4 using HeuristicLab.Services.Authentication.DataAccess; 10 using HeuristicLab.Services.Authentication.DataTransfer;11 using HeuristicLab.Services.Authentication;12 5 using DA = HeuristicLab.Services.Authentication.DataAccess; 13 6 using DT = HeuristicLab.Services.Authentication.DataTransfer; 14 using HLSA = HeuristicLab.Services.Authentication;15 7 16 8 17 namespace HeuristicLab.Services.Authentication { 9 namespace HeuristicLab.Services.Authentication 10 { 18 11 19 public class ClientService : IClientService{ 12 public class ClientService : IClientService 13 { 14 15 public DataTransfer.Client GetClient(Guid id) 16 { 17 using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) 18 { 19 DA.Client client = cmdc.Resources.OfType<DA.Client>().First(x => x.Id == id); 20 return Convert.ToDto(client); 21 } 22 } 23 24 public IEnumerable<DataTransfer.Client> GetClients() 25 { 26 using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) 27 { 28 List<DT.Client> allClients = new List<DT.Client>(); 29 foreach (DA.Client dbClient in cmdc.Resources.OfType<DA.Client>()) 30 { 31 DT.Client client = Convert.ToDto(dbClient); 32 if (client != null) 33 { 34 DA.ResourceResourceGroup rrg = cmdc.ResourceResourceGroups.FirstOrDefault(x => x.ResourceId == client.Id); 35 if (rrg != null) 36 client.ResourceGroup = rrg.ResourceGroupId; 37 allClients.Add(client); 38 } 39 } 40 41 if (allClients.Count > 0) 42 return allClients; 43 return null; 44 } 45 } 46 47 public Guid AddClient(DataTransfer.Client dto) 48 { 49 using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) 50 { 51 return InsertResource(cmdc, dto); 52 } 53 } 20 54 21 55 22 private void RemoveRRGEntry(ClientManagmentDataContext cmdc, Guid resID) { 23 foreach (var rrg in cmdc.ResourceResourceGroups.Where(x => x.ResourceId == resID)) 24 cmdc.ResourceResourceGroups.DeleteOnSubmit(rrg); 56 public bool UpdateClient(DataTransfer.Client dto) 57 { 58 throw new NotImplementedException(); 59 } 60 61 public bool DeleteClient(DataTransfer.Client dto) 62 { 63 using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) 64 { 65 return RemoveResource(cmdc, dto); 66 } 67 } 68 69 public DataTransfer.ResourceGroup GetResourceGroup(Guid id) 70 { 71 using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) 72 { 73 DA.ResourceGroup client = cmdc.Resources.OfType<DA.ResourceGroup>().First(x => x.Id == id); 74 return Convert.ToDto(client); 75 } 76 } 77 78 public IEnumerable<DataTransfer.ResourceGroup> GetResourceGroups() 79 { 80 using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) 81 { 82 List<DT.ResourceGroup> allClients = new List<DT.ResourceGroup>(); 83 foreach (DA.ResourceGroup dbResourceGroup in cmdc.Resources.OfType<DA.ResourceGroup>()) 84 { 85 DT.ResourceGroup resourceGroup = Convert.ToDto(dbResourceGroup); 86 if (resourceGroup != null) 87 allClients.Add(resourceGroup); 88 } 89 90 if (allClients.Count > 0) 91 return allClients; 92 return null; 93 } 94 } 95 96 public Guid AddResourceGroup(DataTransfer.ResourceGroup dto) 97 { 98 using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) 99 { 100 return InsertResource(cmdc, dto); 101 } 102 } 103 104 public bool UpdateResourceGroup(DataTransfer.ResourceGroup dto) 105 { 106 throw new NotImplementedException(); 107 } 108 109 public bool DeleteResourceGroup(DataTransfer.ResourceGroup dto) 110 { 111 using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) 112 { 113 return RemoveResource(cmdc, dto); 114 } 115 } 116 117 public IEnumerable<DataTransfer.Resource> GetMembers(Guid id) 118 { 119 throw new NotImplementedException(); 120 } 121 122 public IEnumerable<DataTransfer.Resource> GetRootResources() 123 { 124 throw new NotImplementedException(); 125 } 126 127 private IEnumerable<DataTransfer.Resource> GetMembers(ClientManagmentDataContext cmdc, Guid id) 128 { 129 // TODO IMPLEMENTATION 130 return null; 131 } 132 133 private Guid InsertResource(ClientManagmentDataContext cmdc, DT.Resource dto) 134 { 135 ResourceResourceGroup rrg = null; 136 if (dto.ResourceGroup != Guid.Empty) 137 { 138 ResourceGroup grp = cmdc.Resources.OfType<DA.ResourceGroup>().FirstOrDefault(x => x.Id == dto.ResourceGroup); 139 if (grp == null) 140 return Guid.Empty; 141 rrg = new ResourceResourceGroup(); 142 rrg.ResourceGroup = grp; 143 } 144 DA.Resource entity = Convert.ToEntity(dto); 145 if (entity != null) 146 { 147 entity.Id = Guid.NewGuid(); 148 if (rrg != null) 149 rrg.Client = entity; 150 cmdc.Resources.InsertOnSubmit(entity); 151 if (rrg != null) 152 cmdc.ResourceResourceGroups.InsertOnSubmit(rrg); 153 cmdc.SubmitChanges(); 154 return entity.Id; 155 } 156 return Guid.Empty; 157 } 158 159 private static bool RemoveResource(ClientManagmentDataContext cmdc, DT.Resource dto) 160 { 161 RemoveRRGEntry(cmdc, dto.Id); 162 DA.Resource entity = cmdc.Resources.FirstOrDefault(x => x.Id == dto.Id); 163 if (entity != null) 164 { 165 cmdc.Resources.DeleteOnSubmit(entity); 166 cmdc.SubmitChanges(); 167 return true; 168 } 169 return false; 170 } 171 172 private static void RemoveRRGEntry(ClientManagmentDataContext cmdc, Guid resID) 173 { 174 foreach (var rrg in cmdc.ResourceResourceGroups.Where(x => x.ResourceId == resID)) 175 cmdc.ResourceResourceGroups.DeleteOnSubmit(rrg); 176 foreach (var rrg in cmdc.ResourceResourceGroups.Where(x => x.ResourceGroupId == resID)) 177 { 178 // Begin Cascade Delete 179 RemoveRRGEntry(cmdc, rrg.Client.Id); 180 cmdc.Resources.DeleteOnSubmit(rrg.Client); 181 // End Cascade Delete 182 cmdc.ResourceResourceGroups.DeleteOnSubmit(rrg); 183 } 184 } 25 185 } 26 27 28 public DataTransfer.Client GetClient(Guid id) {29 throw new NotImplementedException();30 }31 32 public IEnumerable<DataTransfer.Client> GetClients() {33 throw new NotImplementedException();34 }35 36 public Guid AddClient(DataTransfer.Client dto) {37 throw new NotImplementedException();38 }39 40 public bool UpdateClient(DataTransfer.Client dto) {41 throw new NotImplementedException();42 }43 44 public bool DeleteClient(DataTransfer.Client dto) {45 using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) {46 RemoveRRGEntry(cmdc, dto.ResourceID);47 DA.Resource entity = cmdc.Resources.FirstOrDefault(x => x.Id == dto.ResourceID);48 if (entity != null) {49 cmdc.Resources.DeleteOnSubmit(entity);50 cmdc.SubmitChanges();51 return true;52 }53 return false;54 }55 }56 57 public DataTransfer.ResourceGroup GetResourceGroup(Guid id) {58 throw new NotImplementedException();59 }60 61 public IEnumerable<DataTransfer.ResourceGroup> GetResourceGroups() {62 throw new NotImplementedException();63 }64 65 public Guid AddResourceGroup(DataTransfer.ResourceGroup dto) {66 throw new NotImplementedException();67 }68 69 public bool UpdateResourceGroup(DataTransfer.ResourceGroup dto) {70 throw new NotImplementedException();71 }72 73 public bool DeleteResourceGroup(DataTransfer.ResourceGroup id) {74 throw new NotImplementedException();75 }76 77 public IEnumerable<DataTransfer.Resource> GetMembers(Guid id) {78 throw new NotImplementedException();79 }80 81 public IEnumerable<DataTransfer.Resource> GetRootResources() {82 throw new NotImplementedException();83 }84 }85 186 } -
branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication/Convert.cs
r4732 r4953 21 21 22 22 using System.Data.Linq; 23 using HeuristicLab.Services.Authentication.DataTransfer; 23 24 using DA = HeuristicLab.Services.Authentication.DataAccess; 24 25 using DT = HeuristicLab.Services.Authentication.DataTransfer; 25 26 26 namespace HeuristicLab.Services.Authentication { 27 public static class Convert { 27 namespace HeuristicLab.Services.Authentication 28 { 29 public static class Convert 30 { 28 31 29 #region Client 30 public static DT.Client ToDto(DA.Client source) { 31 if (source == null) return null; 32 return new DT.Client { 33 ResourceID = source.Id, 34 Name = source.Name, 35 Description = source.Description, 36 ResourceType = source.ResourceType, 37 ProcessorType = source.ProcessorType, 38 NumberOfProcessors = source.NumberOfProcessors, 39 NumberOfThreads = source.NumberOfThreads, 40 IPAdress = source.IPAdress, 41 MemorySize = source.MemorySize, 42 OperatingSystem = source.OperatingSystem 43 }; 32 #region Client 33 public static DT.Client ToDto(DA.Client source) 34 { 35 if (source == null) return null; 36 return new DT.Client 37 { 38 Id = source.Id, 39 Name = source.Name, 40 Description = source.Description, 41 ResourceType = source.ResourceType, 42 ProcessorType = source.ProcessorType, 43 NumberOfProcessors = source.NumberOfProcessors, 44 NumberOfThreads = source.NumberOfThreads, 45 IPAdress = source.IPAdress, 46 MemorySize = source.MemorySize, 47 OperatingSystem = source.OperatingSystem 48 }; 49 } 50 51 public static DA.Client ToEntity(DT.Client source) 52 { 53 if (source == null) return null; 54 return new DA.Client 55 { 56 Id = source.Id, 57 Name = source.Name, 58 Description = source.Description, 59 ResourceType = source.ResourceType, 60 ProcessorType = source.ProcessorType, 61 NumberOfProcessors = source.NumberOfProcessors, 62 NumberOfThreads = source.NumberOfThreads, 63 IPAdress = source.IPAdress, 64 MemorySize = source.MemorySize, 65 OperatingSystem = source.OperatingSystem 66 }; 67 } 68 69 public static DA.Resource ToEntity(DT.Resource source) 70 { 71 if (source == null) return null; 72 if (source is DT.Client) 73 { 74 DT.Client client = (Client) source; 75 return ToEntity(client); 76 } 77 if (source is DT.ResourceGroup) 78 { 79 DT.ResourceGroup resourceGroup = (ResourceGroup) source; 80 return ToEntity(resourceGroup); 81 } 82 return null; 83 } 84 85 public static void ToEntity(DT.Client source, DA.Client target) 86 { 87 if ((source != null) && (target != null)) 88 { 89 target.Id = source.Id; 90 target.Name = source.Name; 91 target.Description = source.Description; 92 target.ResourceType = source.ResourceType; 93 target.ProcessorType = source.ProcessorType; 94 target.NumberOfProcessors = source.NumberOfProcessors; 95 target.NumberOfThreads = source.NumberOfThreads; 96 target.IPAdress = source.IPAdress; 97 target.MemorySize = source.MemorySize; 98 target.OperatingSystem = source.OperatingSystem; 99 } 100 } 101 #endregion // Client 102 103 #region ResourceGroup 104 public static DT.ResourceGroup ToDto(DA.ResourceGroup source) 105 { 106 if (source == null) return null; 107 return new DT.ResourceGroup 108 { 109 Id = source.Id, 110 Name = source.Name, 111 Description = source.Description, 112 ResourceType = source.ResourceType, 113 }; 114 } 115 116 public static DA.ResourceGroup ToEntity(DT.ResourceGroup source) 117 { 118 if (source == null) return null; 119 return new DA.ResourceGroup 120 { 121 Id = source.Id, 122 Name = source.Name, 123 Description = source.Description, 124 ResourceType = source.ResourceType, 125 }; 126 } 127 128 public static void ToEntity(DT.ResourceGroup source, DA.ResourceGroup target) 129 { 130 if ((source != null) && (target != null)) 131 { 132 target.Id = source.Id; 133 target.Name = source.Name; 134 target.Description = source.Description; 135 target.ResourceType = source.ResourceType; 136 } 137 } 138 #endregion // ResourceGroup 44 139 } 45 46 public static DA.Client ToEntity(DT.Client source) {47 if (source == null) return null;48 return new DA.Client {49 Id = source.ResourceID,50 Name = source.Name,51 Description = source.Description,52 ResourceType = source.ResourceType,53 ProcessorType = source.ProcessorType,54 NumberOfProcessors = source.NumberOfProcessors,55 NumberOfThreads = source.NumberOfThreads,56 IPAdress = source.IPAdress,57 MemorySize = source.MemorySize,58 OperatingSystem = source.OperatingSystem59 };60 }61 62 public static void ToEntity(DT.Client source, DA.Client target) {63 if ((source != null) && (target != null)) {64 target.Id = source.ResourceID;65 target.Name = source.Name;66 target.Description = source.Description;67 target.ResourceType = source.ResourceType;68 target.ProcessorType = source.ProcessorType;69 target.NumberOfProcessors = source.NumberOfProcessors;70 target.NumberOfThreads = source.NumberOfThreads;71 target.IPAdress = source.IPAdress;72 target.MemorySize = source.MemorySize;73 target.OperatingSystem = source.OperatingSystem;74 }75 }76 #endregion // Client77 78 79 #region ResourceGroup80 public static DT.ResourceGroup ToDto(DA.ResourceGroup source) {81 if (source == null) return null;82 return new DT.ResourceGroup {83 ResourceID = source.Id,84 Name = source.Name,85 Description = source.Description,86 ResourceType = source.ResourceType,87 };88 }89 90 public static DA.ResourceGroup ToEntity(DT.ResourceGroup source) {91 if (source == null) return null;92 return new DA.ResourceGroup {93 Id = source.ResourceID,94 Name = source.Name,95 Description = source.Description,96 ResourceType = source.ResourceType,97 };98 }99 100 public static void ToEntity(DT.ResourceGroup source, DA.ResourceGroup target) {101 if ((source != null) && (target != null)) {102 target.Id = source.ResourceID;103 target.Name = source.Name;104 target.Description = source.Description;105 target.ResourceType = source.ResourceType;106 }107 }108 #endregion // ResourceGroup109 }110 140 } -
branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication/Interfaces/IClientService.cs
r4802 r4953 36 36 bool UpdateResourceGroup(ResourceGroup dto); 37 37 [OperationContract] 38 bool DeleteResourceGroup(ResourceGroup id);38 bool DeleteResourceGroup(ResourceGroup dto); 39 39 #endregion 40 40 -
branches/ClientManagement/HeuristicLab.Services.Authentication/Test/Program.cs
r4732 r4953 3 3 using System.Linq; 4 4 using System.Text; 5 using HeuristicLab.Services.Authentication.DataAccess; 5 using HeuristicLab.Services.Authentication; 6 using DA = HeuristicLab.Services.Authentication.DataAccess; 7 using DT = HeuristicLab.Services.Authentication.DataTransfer; 6 8 7 9 namespace Test … … 12 14 { 13 15 14 ClientManagmentDataContext dc = new ClientManagmentDataContext(@"Data Source=nb-1\sqlexpress;Initial Catalog=HeuristicLab.ClientManagment;Integrated Security=SSPI;"); 15 16 if (dc.DatabaseExists()) { 17 Console.WriteLine("DB exsits"); 18 dc.DeleteDatabase(); 19 Console.WriteLine("DB deleted"); 16 //DA.ClientManagmentDataContext dc = new DA.ClientManagmentDataContext(@"Data Source=.\SQL2008;Initial Catalog=HeuristicLab.ClientManagment;Integrated Security=True"); 17 DA.ClientManagmentDataContext dc = new DA.ClientManagmentDataContext(); 18 19 if (dc.DatabaseExists()) 20 { 21 Console.WriteLine("DB exsits"); 22 dc.DeleteDatabase(); 23 dc.SubmitChanges(); 24 Console.WriteLine("DB deleted"); 20 25 } 21 26 Console.WriteLine("DB create"); 22 27 dc.CreateDatabase(); 28 dc.SubmitChanges(); 23 29 Console.WriteLine("Finished"); 24 25 26 Client c = new Client(); 30 31 ClientService cs = new ClientService(); 32 33 DT.Client c = new DT.Client(); 27 34 28 35 c.Id = Guid.NewGuid(); … … 30 37 c.Description = "Development-PC"; 31 38 c.IPAdress = "192.168.0.1"; 39 32 40 //c.ResourceType = "Client"; 33 ResourceGroup r = newResourceGroup();41 DT.ResourceGroup r = new DT.ResourceGroup(); 34 42 r.Name = "test"; 35 43 36 ResourceResourceGroup rrg = new ResourceResourceGroup(); 37 rrg.ResourceGroup = r; 38 rrg.Client = c; 44 r.Id = cs.AddResourceGroup(r); 45 46 c.ResourceGroup = r.Id; 47 c.Id = cs.AddClient(c); 48 49 //ResourceResourceGroup rrg = new ResourceResourceGroup(); 50 //rrg.ResourceGroup = r; 51 //rrg.Client = c; 39 52 40 53 41 dc.GetTable<Resource>().InsertOnSubmit(r);42 dc.GetTable<Resource>().InsertOnSubmit(c);54 //dc.GetTable<Resource>().InsertOnSubmit(r); 55 //dc.GetTable<Resource>().InsertOnSubmit(c); 43 56 44 dc.GetTable<ResourceResourceGroup>().InsertOnSubmit(rrg);57 //dc.GetTable<ResourceResourceGroup>().InsertOnSubmit(rrg); 45 58 46 dc.SubmitChanges();59 //dc.SubmitChanges(); 47 60 61 62 // cs.GetClients(); 48 63 64 //cs.DeleteClient(c); 65 cs.DeleteResourceGroup(r); 49 66 50 67 -
branches/ClientManagement/HeuristicLab.Services.Authentication/Test/Test.csproj
r4583 r4953 53 53 <Name>HeuristicLab.Services.Authentication.DataAccess</Name> 54 54 </ProjectReference> 55 <ProjectReference Include="..\HeuristicLab.Services.Authentication.DataTransfer\HeuristicLab.Services.Authentication.DataTransfer.csproj"> 56 <Project>{73E5113E-A293-4384-8B16-3CE38F2CFDC9}</Project> 57 <Name>HeuristicLab.Services.Authentication.DataTransfer</Name> 58 </ProjectReference> 59 <ProjectReference Include="..\HeuristicLab.Services.Authentication\HeuristicLab.Services.Authentication.csproj"> 60 <Project>{ED8DC6E8-57C6-49E0-8CDF-25703AC52350}</Project> 61 <Name>HeuristicLab.Services.Authentication</Name> 62 </ProjectReference> 55 63 </ItemGroup> 56 64 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Note: See TracChangeset
for help on using the changeset viewer.