Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4953


Ignore:
Timestamp:
11/27/10 09:20:02 (13 years ago)
Author:
jhaider
Message:

#1197
WebService implementation

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=.\SQLEXPRESS;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" />
    33  <Table Name="" Member="Resources">
    44    <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" />
    66      <Column Name="Name" Type="System.String" CanBeNull="false" />
    77      <Column Name="Description" Type="System.String" CanBeNull="true" />
     
    2222  <Table Name="" Member="ResourceResourceGroups">
    2323    <Type Name="ResourceResourceGroup">
    24       <Column Name="ResourceID" Member="ResourceId" Storage="_ResourceID" Type="System.Guid" IsPrimaryKey="true" CanBeNull="false" />
    25       <Column Name="ResourceGroupID" 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" />
    2626      <Association Name="Resource_ResourceResourceGroup" Member="Client" Storage="_Resource" ThisKey="ResourceId" OtherKey="Id" Type="Resource" IsForeignKey="true" />
    2727      <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  
    33  <DataContextMoniker Name="/ClientManagmentDataContext" />
    44  <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">
    66      <DataClassMoniker Name="/ClientManagmentDataContext/Client" />
    77      <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" />
    99      </nestedChildShapes>
    1010    </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">
    1212      <DataClassMoniker Name="/ClientManagmentDataContext/Resource" />
    1313      <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" />
    1515      </nestedChildShapes>
    1616    </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">
    1818      <nodes>
    1919        <classShapeMoniker Id="ea129a98-d63f-4c3a-a3e8-dff64ad53c30" />
     
    2121      </nodes>
    2222    </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">
    2424      <DataClassMoniker Name="/ClientManagmentDataContext/ResourceGroup" />
    2525      <nestedChildShapes>
    26         <elementListCompartment Id="125f9904-768c-4c01-9a04-5212a9e6e484" absoluteBounds="3.64, 4.335, 1.9700000000000002, 0.20745849609375" 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" />
    2727      </nestedChildShapes>
    2828    </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">
    3030      <nodes>
    3131        <classShapeMoniker Id="ea129a98-d63f-4c3a-a3e8-dff64ad53c30" />
     
    3333      </nodes>
    3434    </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">
    3636      <DataClassMoniker Name="/ClientManagmentDataContext/ResourceResourceGroup" />
    3737      <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" />
    3939      </nestedChildShapes>
    4040    </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">
    4242      <AssociationMoniker Name="/ClientManagmentDataContext/Resource/Resource_ResourceResourceGroup" />
    4343      <nodes>
     
    4646      </nodes>
    4747    </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">
    4949      <AssociationMoniker Name="/ClientManagmentDataContext/Resource/Resource_ResourceResourceGroup1" />
    5050      <nodes>
  • branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.DataAccess/ClientManagment.designer.cs

    r4802 r4953  
    2323 
    2424 
     25  [global::System.Data.Linq.Mapping.DatabaseAttribute(Name="HeuristicLab.ClientManagment")]
    2526  public partial class ClientManagmentDataContext : System.Data.Linq.DataContext
    2627  {
     
    127128    }
    128129   
    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)]
    130131    public System.Guid Id
    131132    {
     
    483484    }
    484485   
    485     [global::System.Data.Linq.Mapping.ColumnAttribute(Name="ResourceID", Storage="_ResourceID", IsPrimaryKey=true)]
     486    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ResourceID", IsPrimaryKey=true)]
    486487    public System.Guid ResourceId
    487488    {
     
    494495        if ((this._ResourceID != value))
    495496        {
     497          if (this._Resource.HasLoadedOrAssignedValue)
     498          {
     499            throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
     500          }
    496501          this.OnResourceIdChanging(value);
    497502          this.SendPropertyChanging();
     
    503508    }
    504509   
    505     [global::System.Data.Linq.Mapping.ColumnAttribute(Name="ResourceGroupID", Storage="_ResourceGroupID", IsPrimaryKey=true)]
     510    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ResourceGroupID", IsPrimaryKey=true)]
    506511    public System.Guid ResourceGroupId
    507512    {
     
    514519        if ((this._ResourceGroupID != value))
    515520        {
     521          if (this._Resource1.HasLoadedOrAssignedValue)
     522          {
     523            throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
     524          }
    516525          this.OnResourceGroupIdChanging(value);
    517526          this.SendPropertyChanging();
  • branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.DataTransfer/Resource.cs

    r4731 r4953  
    77    {
    88        [DataMember]
    9         public System.Guid ResourceID { get; set; }
     9        public System.Guid Id { get; set; }
    1010        [DataMember]
    1111        public string Name { get; set; }
     
    1515        public string ResourceType { get; set; }
    1616        [DataMember]
    17         public string ResourceGroup { get; set; }
     17        public System.Guid ResourceGroup { get; set; }
    1818    }
    1919}
  • branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication/ClientService.cs

    r4802 r4953  
    11using System;
    22using System.Collections.Generic;
    3 using System.Collections;
    43using System.Linq;
    5 using System.Data.Linq;
    6 using System.Data.Linq.Mapping;
    7 using System.Text;
    8 
    94using HeuristicLab.Services.Authentication.DataAccess;
    10 using HeuristicLab.Services.Authentication.DataTransfer;
    11 using HeuristicLab.Services.Authentication;
    125using DA = HeuristicLab.Services.Authentication.DataAccess;
    136using DT = HeuristicLab.Services.Authentication.DataTransfer;
    14 using HLSA = HeuristicLab.Services.Authentication;
    157
    168
    17 namespace HeuristicLab.Services.Authentication {
     9namespace HeuristicLab.Services.Authentication
     10{
    1811
    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        }
    2054
    2155
    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        }
    25185    }
    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   }
    85186}
  • branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication/Convert.cs

    r4732 r4953  
    2121
    2222using System.Data.Linq;
     23using HeuristicLab.Services.Authentication.DataTransfer;
    2324using DA = HeuristicLab.Services.Authentication.DataAccess;
    2425using DT = HeuristicLab.Services.Authentication.DataTransfer;
    2526
    26 namespace HeuristicLab.Services.Authentication {
    27   public static class Convert {
     27namespace HeuristicLab.Services.Authentication
     28{
     29    public static class Convert
     30    {
    2831
    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
    44139    }
    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.OperatingSystem
    59       };
    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 // Client
    77 
    78 
    79     #region ResourceGroup
    80     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 // ResourceGroup
    109   }
    110140}
  • branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication/Interfaces/IClientService.cs

    r4802 r4953  
    3636        bool UpdateResourceGroup(ResourceGroup dto);
    3737        [OperationContract]
    38         bool DeleteResourceGroup(ResourceGroup id);
     38        bool DeleteResourceGroup(ResourceGroup dto);
    3939        #endregion
    4040
  • branches/ClientManagement/HeuristicLab.Services.Authentication/Test/Program.cs

    r4732 r4953  
    33using System.Linq;
    44using System.Text;
    5 using HeuristicLab.Services.Authentication.DataAccess;
     5using HeuristicLab.Services.Authentication;
     6using DA = HeuristicLab.Services.Authentication.DataAccess;
     7using DT = HeuristicLab.Services.Authentication.DataTransfer;
    68
    79namespace Test
     
    1214        {
    1315
    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");
    2025            }
    2126            Console.WriteLine("DB create");
    2227            dc.CreateDatabase();
     28            dc.SubmitChanges();
    2329            Console.WriteLine("Finished");
    24                      
    25            
    26             Client c = new Client();
     30
     31            ClientService cs = new ClientService();
     32
     33            DT.Client c = new DT.Client();
    2734
    2835            c.Id = Guid.NewGuid();
     
    3037            c.Description = "Development-PC";
    3138            c.IPAdress = "192.168.0.1";
     39
    3240            //c.ResourceType = "Client";
    33             ResourceGroup r = new ResourceGroup();
     41            DT.ResourceGroup r = new DT.ResourceGroup();
    3442            r.Name = "test";
    3543
    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;
    3952           
    4053           
    41             dc.GetTable<Resource>().InsertOnSubmit(r);
    42             dc.GetTable<Resource>().InsertOnSubmit(c);
     54            //dc.GetTable<Resource>().InsertOnSubmit(r);
     55            //dc.GetTable<Resource>().InsertOnSubmit(c);
    4356
    44             dc.GetTable<ResourceResourceGroup>().InsertOnSubmit(rrg);
     57            //dc.GetTable<ResourceResourceGroup>().InsertOnSubmit(rrg);
    4558
    46             dc.SubmitChanges();
     59            //dc.SubmitChanges();
    4760
     61           
     62           // cs.GetClients();
    4863
     64            //cs.DeleteClient(c);
     65           cs.DeleteResourceGroup(r);
    4966
    5067
  • branches/ClientManagement/HeuristicLab.Services.Authentication/Test/Test.csproj

    r4583 r4953  
    5353      <Name>HeuristicLab.Services.Authentication.DataAccess</Name>
    5454    </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>
    5563  </ItemGroup>
    5664  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Note: See TracChangeset for help on using the changeset viewer.