Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/19/10 09:17:24 (15 years ago)
Author:
kgrading
Message:

added minor speedups and better transaction handling to the server (#828)

Location:
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/BaseDao.cs

    r3578 r3931  
    1515
    1616    protected void CommitChanges() {
     17      //TODO: DoWhile
    1718      try {
    1819        Context.SubmitChanges(ConflictMode.ContinueOnConflict);
    1920      } catch (ChangeConflictException e) {
    2021        Logger.Warn("Concurrency Exception! " + e.Message);
    21         foreach (ObjectChangeConflict conflict in Context.ChangeConflicts) {         
     22        foreach (ObjectChangeConflict conflict in Context.ChangeConflicts) {
     23          Logger.Info("Conflicted: ");
     24          foreach (MemberChangeConflict memberChangeConflict in conflict.MemberConflicts) {
     25            Logger.Info("    Member in Conflict: " + memberChangeConflict.Member.Name);
     26            Logger.Info("    Database Value: " + memberChangeConflict.DatabaseValue);
     27            Logger.Info("    Original value: " + memberChangeConflict.OriginalValue);
     28            Logger.Info("    Current value: " + memberChangeConflict.CurrentValue);             
     29          }
    2230          conflict.Resolve(RefreshMode.KeepChanges);
    2331        }
     32        Context.SubmitChanges(ConflictMode.FailOnFirstConflict);
    2433      }
    2534    }
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ClientDao.cs

    r3578 r3931  
    1414
    1515    public ClientDto FindById(Guid id) {
    16       return (from client in Context.Clients
     16      return (from client in Context.Resources.OfType<Client>()                         
    1717              where client.ResourceId.Equals(id)
    1818              select EntityToDto(client, null)
     
    2121
    2222    public IEnumerable<ClientDto> FindAll() {
    23       return (from client in Context.Clients
     23      return (from client in Context.Resources.OfType<Client>()
    2424              select
    2525                EntityToDto(client, null)
     
    2828
    2929    public IEnumerable<ClientDto> FindAllClientsWithoutGroup() {
    30       return (from client in Context.Clients
    31               where client.Resource.ClientGroup_Resources.Count == 0
     30      return (from client in Context.Resources.OfType<Client>()
     31              where client.ClientGroup_Resources_Parents.Count == 0
    3232              select EntityToDto(client, null)).ToList();
    3333    }
     
    4040
    4141    public void SetServerSideCalendar(ClientDto client, Guid clientGroupId) {
    42       Client dbclient = Context.Clients.SingleOrDefault(c => c.ResourceId.Equals(client.Id));
     42      Client dbclient = Context.Resources.OfType<Client>().SingleOrDefault(c => c.ResourceId.Equals(client.Id));
    4343      dbclient.UseCalendarFromResourceId = clientGroupId;
    4444      dbclient.CalendarSyncStatus = Enum.GetName(typeof(CalendarState), CalendarState.Fetch);
     
    4848    public ClientDto Insert(ClientDto info) {
    4949      Client c = DtoToEntity(info, null);     
    50       Context.Clients.InsertOnSubmit(c);
     50      Context.Resources.InsertOnSubmit(c);
    5151      CommitChanges();
    5252      info.Id = c.ResourceId;
     
    6262
    6363    public void Update(ClientDto info) {
    64       Client client = Context.Clients.SingleOrDefault(c => c.ResourceId.Equals(info.Id));
     64      Client client = Context.Resources.OfType<Client>().SingleOrDefault(c => c.ResourceId.Equals(info.Id));
    6565      DtoToEntity(info, client);
    6666      CommitChanges();     
     
    7575      target.CPUSpeed = source.CpuSpeedPerCore;
    7676     
    77       if(target.Resource == null)
    78         target.Resource = new Resource();
    79 
    8077      target.FreeMemory = source.FreeMemory;
    81       target.Resource.Name = source.Name;
    82       target.Resource.ResourceId = source.Id;
     78      target.Name = source.Name;
     79      target.ResourceId = source.Id;
    8380      target.CalendarSyncStatus = Enum.GetName(typeof(CalendarState), source.CalendarSyncStatus);
    8481      target.Login = source.Login;
     
    9693        target = new ClientDto();
    9794      target.CpuSpeedPerCore = source.CPUSpeed;
    98       target.FreeMemory = source.FreeMemory;
     95      target.FreeMemory = source.FreeMemory ?? 0;
    9996      target.Id = source.ResourceId;
    10097      target.CalendarSyncStatus = (CalendarState) Enum.Parse(typeof (CalendarState), source.CalendarSyncStatus);
    10198      target.Login = source.Login;
    102       target.Memory = source.Memory;
    103       target.Name = source.Resource.Name;
    104       target.NrOfCores = source.NumberOfCores;
    105       target.NrOfFreeCores = source.NumberOfFreeCores;
     99      target.Memory = source.Memory ?? 0;
     100      target.Name = source.Name;
     101      target.NrOfCores = source.NumberOfCores ?? 0;
     102      target.NrOfFreeCores = source.NumberOfFreeCores ?? 0;
    106103      target.State = (State) Enum.Parse(typeof (State), source.Status);
    107104      return target;
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ClientGroupDao.cs

    r3578 r3931  
    1313
    1414    public ClientGroupDto FindById(Guid id) {
    15       return (from cc in Context.ClientGroups
     15      return (from cc in Context.Resources.OfType<ClientGroup>()
    1616              where cc.ResourceId.Equals(id)
    1717              select EntityToDto(cc, null)).SingleOrDefault();
     
    2020
    2121    public IEnumerable<ClientGroupDto> FindAll() {
    22       return (from cc in Context.ClientGroups
     22      return (from cc in Context.Resources.OfType<ClientGroup>()
    2323              select EntityToDto(cc, null)).ToList();
    2424    }
     
    3030
    3131      ClientGroup cc = DtoToEntity(bObj, null);
    32       Context.ClientGroups.InsertOnSubmit(cc);
     32      Context.Resources.InsertOnSubmit(cc);
    3333      CommitChanges();
    3434      bObj.Id = cc.ResourceId;
     
    4848
    4949    public void Update(ClientGroupDto bObj) {
    50       ClientGroup client = Context.ClientGroups.SingleOrDefault(c => c.ResourceId.Equals(bObj.Id));
     50      ClientGroup client = Context.Resources.OfType<ClientGroup>().SingleOrDefault(c => c.ResourceId.Equals(bObj.Id));
    5151      DtoToEntity(bObj, client);
    5252      CommitChanges();
     
    5454
    5555    public void AddRessourceToClientGroup(Guid resource, Guid clientGroupId) {
    56       ClientGroup cg = Context.ClientGroups.SingleOrDefault(c => c.ResourceId.Equals(clientGroupId));
     56      ClientGroup cg = Context.Resources.OfType<ClientGroup>().SingleOrDefault(c => c.ResourceId.Equals(clientGroupId));
    5757      Resource res = Context.Resources.SingleOrDefault(r => r.ResourceId.Equals(resource));
    58       cg.ClientGroup_Resources.Add(new ClientGroup_Resource { ClientGroup = cg, Resource = res });     
     58      cg.ClientGroup_Resources_Children.Add(new ClientGroup_Resource { ClientGroup = cg, Resource = res });     
    5959      CommitChanges();
    6060    }
     
    7777      List<ClientGroupDto> groupList = new List<ClientGroupDto>();
    7878
    79       var q = (from cg in Context.ClientGroups
     79      var q = (from cg in Context.Resources.OfType<ClientGroup>()
    8080               where !Context.ClientGroup_Resources.Any(cgr => cgr.ResourceId.Equals(cg.ResourceId))
    8181               select cg);
     
    8484        ClientGroupDto cgd = EntityToDto(cg, null);
    8585        groupList.Add(cgd);
    86         FillSubGroupsAndClientsRecursivly(cgd, cg.ClientGroup_Resources);       
     86        FillSubGroupsAndClientsRecursivly(cgd, cg.ClientGroup_Resources_Children);       
    8787      }
    8888      return groupList;
     
    9393      //Get all the Groups
    9494     
    95       var qGroups = (from cg in Context.ClientGroups
    96                where cg.Resource.ClientGroup_Resources.Any(cgr => cgr.ClientGroupId.Equals(parentClientGroup.Id))
     95      var qGroups = (from cg in Context.Resources.OfType<ClientGroup>()
     96               where cg.ClientGroup_Resources_Parents.Any(cgr => cgr.ClientGroupId.Equals(parentClientGroup.Id))
    9797               select cg);
    9898
     
    100100        ClientGroupDto cgd = EntityToDto(cg, null);
    101101        parentClientGroup.Resources.Add(cgd);
    102         FillSubGroupsAndClientsRecursivly(cgd, cg.ClientGroup_Resources);
     102        FillSubGroupsAndClientsRecursivly(cgd, cg.ClientGroup_Resources_Children);
    103103      }
    104104
    105105      //get the clients
    106       var qClients = (from cl in Context.Clients
    107                where cl.Resource.ClientGroup_Resources.Any(cgr => cgr.ClientGroupId.Equals(parentClientGroup.Id))
     106      var qClients = (from cl in Context.Resources.OfType<Client>()
     107               where cl.ClientGroup_Resources_Parents.Any(cgr => cgr.ClientGroupId.Equals(parentClientGroup.Id))
    108108               select cl);
    109109      foreach (Client client in qClients) {
     
    114114    public IEnumerable<Guid> FindAllGroupAndParentGroupIdsForClient(Guid clientId) {
    115115      List<Guid> guids = new List<Guid>();
    116       Client c = Context.Clients.SingleOrDefault(client => client.ResourceId.Equals(clientId));
    117       FindAllGroupAndParentGroupIdsForClientRecursive(c.Resource, guids);
     116      Client c = Context.Resources.OfType<Client>().SingleOrDefault(client => client.ResourceId.Equals(clientId));
     117      FindAllGroupAndParentGroupIdsForClientRecursive(c, guids);
    118118      return guids;
    119119    }
    120120
     121    //Massivly error Prone
    121122    private void FindAllGroupAndParentGroupIdsForClientRecursive(Resource resource, List<Guid> guids) {
    122       foreach (ClientGroup_Resource cgr in resource.ClientGroup_Resources) {
     123      foreach (ClientGroup_Resource cgr in resource.ClientGroup_Resources_Parents) {
    123124        guids.Add(cgr.ClientGroupId);
    124         FindAllGroupAndParentGroupIdsForClientRecursive(cgr.ClientGroup.Resource, guids);       
     125        FindAllGroupAndParentGroupIdsForClientRecursive(cgr.ClientGroup, guids);       
    125126      }
    126127    }
     
    133134      if (target == null)
    134135        target = new ClientGroup();
    135       if (target.Resource == null)
    136         target.Resource = new Resource();
    137136
    138       target.Resource.Name = source.Name;
    139       target.Resource.ResourceId = source.Id;
     137      target.Name = source.Name;
     138      target.ResourceId = source.Id;
    140139
    141140      return target;
     
    149148
    150149      target.Id = source.ResourceId;
    151       target.Name = source.Resource.Name;
     150      target.Name = source.Name;
    152151
    153152      return target;
     
    155154
    156155    public IEnumerable<ClientGroupDto> FindByName(string res) {
    157       return (from cq in Context.ClientGroups
    158               where cq.Resource.Name == res
     156      return (from cq in Context.Resources.OfType<ClientGroup>()
     157              where cq.Name == res
    159158              select EntityToDto(cq, null)).ToList();     
    160159    }
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ContextFactory.cs

    r3578 r3931  
    55using System.Data.Common;
    66using System.Data.SqlClient;
     7using HeuristicLab.Tracing;
    78
    89namespace HeuristicLab.Hive.Server.LINQDataAccess {
     
    1617    public static HiveDataContext Context {
    1718      get {
    18         if(_hiveDataContext == null)
    19           _hiveDataContext = new HiveDataContext();
     19        if (_hiveDataContext == null) {
     20          Logger.Debug("Requested new Data Context");
     21          _hiveDataContext = new HiveDataContext("Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq.Test;Integrated Security=SSPI");
     22          _hiveDataContext.CommandTimeout = 240;
     23        }
    2024        return _hiveDataContext;       
    2125      }
     
    3236      }
    3337    }
     38
     39    public static bool IsContextNull() {
     40      return _hiveDataContext == null;
     41    }
    3442  }
    3543}
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/HeuristicLab.Hive.Server.LINQDataAccess-3.2.csproj

    r3578 r3931  
    9191    <Compile Include="ClientGroupDao.cs" />
    9292    <Compile Include="ContextFactory.cs" />
    93     <Compile Include="Hive.designer.cs">
    94       <AutoGen>True</AutoGen>
    95       <DesignTime>True</DesignTime>
    96       <DependentUpon>Hive.dbml</DependentUpon>
    97     </Compile>
     93    <Compile Include="HiveDataContext.cs" />
    9894    <Compile Include="JobDao.cs" />
    9995    <Compile Include="LINQDataAccessPlugin.cs" />
     
    109105  </ItemGroup>
    110106  <ItemGroup>
    111     <None Include="Hive.dbml">
    112       <Generator>MSLinqToSQLGenerator</Generator>
    113       <LastGenOutput>Hive.designer.cs</LastGenOutput>
    114       <SubType>Designer</SubType>
    115     </None>
    116107    <None Include="HeuristicLab.snk" />
    117108    <None Include="Properties\AssemblyInfo.frame" />
     
    144135  <ItemGroup>
    145136    <None Include="app.config" />
    146     <None Include="Hive.dbml.layout">
    147       <DependentUpon>Hive.dbml</DependentUpon>
    148     </None>
    149137    <None Include="Properties\Settings.settings">
    150138      <Generator>SettingsSingleFileGenerator</Generator>
    151139      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    152140    </None>
     141  </ItemGroup>
     142  <ItemGroup>
     143    <Content Include="HiveDataContext.xml" />
    153144  </ItemGroup>
    154145  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Hive.dbml

    r3578 r3931  
    7878      <Association Name="Resource_UptimeCalendar" Member="UptimeCalendars" ThisKey="ResourceId" OtherKey="ResourceId" Type="UptimeCalendar" />
    7979      <Association Name="Resource_Client" Member="Client" ThisKey="ResourceId" OtherKey="ResourceId" Type="Client" Cardinality="One" />
    80       <Association Name="Resource_Client1" Member="Client1" ThisKey="ResourceId" OtherKey="ResourceId" Type="Client" Cardinality="One" />
    8180    </Type>
    8281  </Table>
     
    133132      <Association Name="Client_Job" Member="Jobs" ThisKey="ResourceId" OtherKey="ResourceId" Type="Job" />
    134133      <Association Name="Resource_Client" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" DeleteRule="CASCADE" DeleteOnNull="true" />
    135       <Association Name="Resource_Client1" Member="Resource1" ThisKey="ResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" />
    136134      <Association Name="ClientConfig_Client" Member="ClientConfig" ThisKey="ClientConfigId" OtherKey="ClientConfigId" Type="ClientConfig" IsForeignKey="true" DeleteRule="SET NULL" />
    137135    </Type>
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Hive.dbml.layout

    r3203 r3931  
    166166      </nodes>
    167167    </associationConnector>
    168     <associationConnector edgePoints="[(5.0625 : 6.94399251302083); (5.0625 : 8.25)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    169       <AssociationMoniker Name="/HiveDataContext/Resource/Resource_Client1" />
    170       <nodes>
    171         <classShapeMoniker Id="e44e8355-4290-42f0-8b46-4473e91e504b" />
    172         <classShapeMoniker Id="51cb317e-413a-4e25-a9b6-e903322f0371" />
    173       </nodes>
    174     </associationConnector>
    175168    <associationConnector edgePoints="[(4.75 : 12); (4.75 : 11.1747054036458)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    176169      <AssociationMoniker Name="/HiveDataContext/ClientConfig/ClientConfig_Client" />
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Hive.designer.cs

    r3578 r3931  
    15121512    private EntityRef<Client> _Client;
    15131513   
    1514     private EntityRef<Client> _Client1;
    1515    
    15161514    #region Extensibility Method Definitions
    15171515    partial void OnLoaded();
     
    15311529      this._UptimeCalendars = new EntitySet<UptimeCalendar>(new Action<UptimeCalendar>(this.attach_UptimeCalendars), new Action<UptimeCalendar>(this.detach_UptimeCalendars));
    15321530      this._Client = default(EntityRef<Client>);
    1533       this._Client1 = default(EntityRef<Client>);
    15341531      OnCreated();
    15351532    }
     
    16681665          }
    16691666          this.SendPropertyChanged("Client");
    1670         }
    1671       }
    1672     }
    1673    
    1674     [Association(Name="Resource_Client1", Storage="_Client1", ThisKey="ResourceId", OtherKey="ResourceId", IsUnique=true, IsForeignKey=false)]
    1675     public Client Client1
    1676     {
    1677       get
    1678       {
    1679         return this._Client1.Entity;
    1680       }
    1681       set
    1682       {
    1683         Client previousValue = this._Client1.Entity;
    1684         if (((previousValue != value)
    1685               || (this._Client1.HasLoadedOrAssignedValue == false)))
    1686         {
    1687           this.SendPropertyChanging();
    1688           if ((previousValue != null))
    1689           {
    1690             this._Client1.Entity = null;
    1691             previousValue.Resource1 = null;
    1692           }
    1693           this._Client1.Entity = value;
    1694           if ((value != null))
    1695           {
    1696             value.Resource1 = this;
    1697           }
    1698           this.SendPropertyChanged("Client1");
    16991667        }
    17001668      }
     
    26202588    private EntityRef<Resource> _Resource;
    26212589   
    2622     private EntityRef<Resource> _Resource1;
    2623    
    26242590    private EntityRef<ClientConfig> _ClientConfig;
    26252591   
     
    26572623      this._Jobs = new EntitySet<Job>(new Action<Job>(this.attach_Jobs), new Action<Job>(this.detach_Jobs));
    26582624      this._Resource = default(EntityRef<Resource>);
    2659       this._Resource1 = default(EntityRef<Resource>);
    26602625      this._ClientConfig = default(EntityRef<ClientConfig>);
    26612626      OnCreated();
     
    29502915    }
    29512916   
    2952     [Association(Name="Resource_Client1", Storage="_Resource1", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true)]
    2953     public Resource Resource1
    2954     {
    2955       get
    2956       {
    2957         return this._Resource1.Entity;
    2958       }
    2959       set
    2960       {
    2961         Resource previousValue = this._Resource1.Entity;
    2962         if (((previousValue != value)
    2963               || (this._Resource1.HasLoadedOrAssignedValue == false)))
    2964         {
    2965           this.SendPropertyChanging();
    2966           if ((previousValue != null))
    2967           {
    2968             this._Resource1.Entity = null;
    2969             previousValue.Client1 = null;
    2970           }
    2971           this._Resource1.Entity = value;
    2972           if ((value != null))
    2973           {
    2974             value.Client1 = this;
    2975             this._ResourceId = value.ResourceId;
    2976           }
    2977           else
    2978           {
    2979             this._ResourceId = default(System.Guid);
    2980           }
    2981           this.SendPropertyChanged("Resource1");
    2982         }
    2983       }
    2984     }
    2985    
    29862917    [Association(Name="ClientConfig_Client", Storage="_ClientConfig", ThisKey="ClientConfigId", OtherKey="ClientConfigId", IsForeignKey=true, DeleteRule="SET NULL")]
    29872918    public ClientConfig ClientConfig
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/HiveDataContext.xml

    r3808 r3931  
    11<?xml version="1.0" encoding="utf-8"?>
    2 <Database Name="HeuristicLab.Hive.Linq" Class="HiveDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
     2<Database Name="HeuristicLab.Hive.Linq.Test" Class="HiveDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
    33  <Table Name="dbo.AssignedResources" Member="AssignedResources">
    44    <Type Name="AssignedResource">
     
    66      <Column Name="JobId" Member="JobId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" />
    77      <Column Name="AssignedRessourcesId" Member="AssignedRessourcesId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" IsPrimaryKey="true" IsDbGenerated="true" AutoSync="OnInsert" />
    8       <Association Name="Resource_AssignedResource" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" DeleteRule="CASCADE" DeleteOnNull="true" IsForeignKey="true" Type="Resource"/>
    9       <Association Name="Job_AssignedResource" Member="Job" ThisKey="JobId" OtherKey="JobId" DeleteRule="CASCADE" DeleteOnNull="true" IsForeignKey="true" Type="Job"/>
     8      <Association Name="Resource_AssignedResource" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" DeleteRule="CASCADE" IsForeignKey="true" Type="Resource"/>
     9      <Association Name="Job_AssignedResource" Member="Job" ThisKey="JobId" OtherKey="JobId" DeleteRule="CASCADE" IsForeignKey="true" Type="Job"/>
    1010    </Type>
    1111  </Table>
     
    2323      <Column Name="ClientConfigId" Member="ClientConfigId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" IsPrimaryKey="true" IsDbGenerated="true" AutoSync="OnInsert" />
    2424      <Column Name="UpDownTimeCalendar" Member="UpDownTimeCalendar" DbType="Xml" UpdateCheck="Never" Type="System.Xml.Linq.XElement"/>
    25       <Column Name="HeartBeatIntervall" Member="HeartBeatIntervall" DbType="Int" Type="System.Int32"/>
     25      <Column Name="HeartBeatIntervall" Member="HeartBeatIntervall" DbType="Int" Type="System.Int32" CanBeNull="true"/>
    2626      <Association Name="ClientConfig_Client" Member="Clients"  ThisKey="ClientConfigId" OtherKey="ClientConfigId" Type="Client"/>
    2727    </Type>
     
    3030  <Table Name="dbo.ClientGroup_Resource" Member="ClientGroup_Resources">
    3131    <Type Name="ClientGroup_Resource">
    32       <Column Name="ClientGroup_RessourceId" Member="ClientGroup_RessourceId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" IsPrimaryKey="true" IsDbGenerated="true" AutoSync="OnInsert" />
     32      <Column Name="ClientGroup_RessourceId" Member="ClientGroup_RessourceId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" IsPrimaryKey="true" IsDbGenerated="true" AutoSync="OnInsert"  />
    3333      <Column Name="ClientGroupId" Member="ClientGroupId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" />
    3434      <Column Name="ResourceId" Member="ResourceId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" />
    3535   
    3636      <Association Name="ClientGroup_ClientGroup_Resource" Member="ClientGroup" ThisKey="ClientGroupId" OtherKey="ResourceId" IsForeignKey="true" Type="ClientGroup" />
    37       <Association Name="Resource_ClientGroup_Resource" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" DeleteRule="CASCADE" DeleteOnNull="true" IsForeignKey="true" Type="Resource"/>
     37      <Association Name="Resource_ClientGroup_Resource" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" DeleteRule="CASCADE" IsForeignKey="true" Type="Resource"/>
    3838    </Type>
    3939  </Table>
     
    5959      <Column Name="JobId" Member="JobId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" />
    6060      <Column Name="PluginId" Member="PluginId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" />
    61       <Association Name="PluginInfo_RequiredPlugin" Member="PluginInfo" ThisKey="PluginId" OtherKey="PluginId" DeleteRule="CASCADE" DeleteOnNull="true" IsForeignKey="true" Type="PluginInfo"/>
     61      <Association Name="PluginInfo_RequiredPlugin" Member="PluginInfo" ThisKey="PluginId" OtherKey="PluginId" DeleteRule="CASCADE" IsForeignKey="true" Type="PluginInfo"/>
    6262      <Association Name="Job_RequiredPlugin" Member="Job" ThisKey="JobId" OtherKey="JobId" IsForeignKey="true" Type="Job"/>
    6363    </Type>
     
    6969      <Column Name="ResourceType" Member="ResourceType" IsDiscriminator="true" Type="System.String"/>
    7070      <Association Name="Resource_AssignedResource" Member="AssignedResources" ThisKey="ResourceId" OtherKey="ResourceId" Type="AssignedResource"/>     
    71       <Association Name="Resource_ClientGroup_Resource" Member="ClientGroup_Resources" ThisKey="ResourceId" OtherKey="ResourceId" Type="ClientGroup_Resource" />
     71      <Association Name="Resource_ClientGroup_Resource" Member="ClientGroup_Resources_Parents" ThisKey="ResourceId" OtherKey="ResourceId" Type="ClientGroup_Resource" />
    7272      <Association Name="Resource_UptimeCalendar" Member="UptimeCalendars" ThisKey="ResourceId" OtherKey="ResourceId" Type="UptimeCalendar" />     
    7373      <Type Name="Client" InheritanceCode="CLIENT" IsInheritanceDefault="true">       
    74         <Column Name="CPUSpeed" Member="CPUSpeed" DbType="Int NOT NULL" Type="System.Int32" />
    75         <Column Name="Memory" Member="Memory" DbType="Int NOT NULL" Type="System.Int32" />
    76         <Column Name="Login" Member="Login" DbType="DateTime NOT NULL" Type="System.DateTime" />
    77         <Column Name="Status" Member="Status" DbType="VarChar(MAX)" Type="System.String" />
    78         <Column Name="CalendarSyncStatus" Member="CalendarSyncStatus" DbType="VarChar(MAX)" Type="System.String" />
    79         <Column Name="UseCalendarFromResourceId" Member="UseCalendarFromResourceId" DbType="UniqueIdentifier" Type="System.Guid"/>
    80         <Column Name="ClientConfigId" Member="ClientConfigId" DbType="UniqueIdentifier" Type="System.Guid"/>
    81         <Column Name="NumberOfCores" Member="NumberOfCores" DbType="Int NOT NULL" Type="System.Int32" />
    82         <Column Name="NumberOfFreeCores" Member="NumberOfFreeCores" DbType="Int NOT NULL" Type="System.Int32"/>
    83         <Column Name="FreeMemory" Member="FreeMemory" DbType="Int NOT NULL" Type="System.Int32"/>
     74        <Column Name="CPUSpeed" Member="CPUSpeed" DbType="Int" Type="System.Int32" CanBeNull="true"/>
     75        <Column Name="Memory" Member="Memory" DbType="Int" Type="System.Int32" CanBeNull="true"/>
     76        <Column Name="Login" Member="Login" DbType="DateTime" Type="System.DateTime" CanBeNull="true"/>
     77        <Column Name="Status" Member="Status" DbType="VarChar(MAX)" Type="System.String" CanBeNull="true"/>
     78        <Column Name="CalendarSyncStatus" Member="CalendarSyncStatus" DbType="VarChar(MAX)" Type="System.String" CanBeNull="true"/>
     79        <Column Name="UseCalendarFromResourceId" Member="UseCalendarFromResourceId" DbType="UniqueIdentifier" Type="System.Guid" CanBeNull="true"/>
     80        <Column Name="ClientConfigId" Member="ClientConfigId" DbType="UniqueIdentifier" Type="System.Guid" CanBeNull="true"/>
     81        <Column Name="NumberOfCores" Member="NumberOfCores" DbType="Int" Type="System.Int32" CanBeNull="true"/>
     82        <Column Name="NumberOfFreeCores" Member="NumberOfFreeCores" DbType="Int" Type="System.Int32" CanBeNull="true"/>
     83        <Column Name="FreeMemory" Member="FreeMemory" DbType="Int" Type="System.Int32" CanBeNull="true"/>
    8484        <Association Name="Client_UptimeStatistic" Member="UptimeStatistics" ThisKey="ResourceId" OtherKey="ResourceId" Type="UptimeStatistic"/>
    85         <Association Name="Client_Job" Member="Jobs" ThisKey="ResourceId" OtherKey="ResourceId" Type="Job"/>       
     85        <Association Name="Client_Job" Member="Jobs" ThisKey="ResourceId" OtherKey="ResourceId" Type="Job" DeleteRule="SET NULL"/>       
    8686        <Association Name="ClientConfig_Client" Member="ClientConfig" ThisKey="ClientConfigId" OtherKey="ClientConfigId" DeleteRule="SET NULL" IsForeignKey="true" Type="ClientConfig"/>
    8787      </Type>
    8888      <Type Name="ClientGroup" InheritanceCode="GROUP" IsInheritanceDefault="false">
    89         <Association Name="ClientGroup_ClientGroup_Resource" Member="ClientGroup_Resources" ThisKey="ResourceId" OtherKey="ClientGroupId" Type="ClientGroup_Resource" />
     89        <Association Name="ClientGroup_ClientGroup_Resource" Member="ClientGroup_Resources_Children" ThisKey="ResourceId" OtherKey="ClientGroupId" Type="ClientGroup_Resource" />
    9090      </Type>
    9191    </Type>
     
    9595    <Type Name="Job">
    9696      <Column Name="JobId" Member="JobId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" IsPrimaryKey="true" IsDbGenerated="true" AutoSync="OnInsert" />
    97       <Column Name="ParentJobId" Member="ParentJobId" DbType="UniqueIdentifier" Type="System.Guid" />
     97      <Column Name="ParentJobId" Member="ParentJobId" DbType="UniqueIdentifier" Type="System.Guid" CanBeNull="true" />
    9898      <Column Name="JobState" Member="JobState" DbType="VarChar(MAX)" Type="System.String"/>
    99       <Column Name="ResourceId" Member="ResourceId" DbType="UniqueIdentifier" Type="System.Guid"/>
    100       <Column Name="Percentage" Member="Percentage" DbType="Float" Type="System.Double"/>
    101       <Column Name="SerializedJob" Member="SerializedJob" DbType="VarBinary(MAX)" UpdateCheck="Never" Type="System.Data.Linq.Binary"/>
    102       <Column Name="DateCreated" Member="DateCreated" DbType="DateTime" Type="System.DateTime"/>
    103       <Column Name="DateCalculated" Member="DateCalculated" DbType="DateTime" Type="System.DateTime"/>
    104       <Column Name="DateFinished" Member="DateFinished" DbType="DateTime" Type="System.DateTime"/>
     99      <Column Name="ResourceId" Member="ResourceId" DbType="UniqueIdentifier" Type="System.Guid" CanBeNull="true"/>
     100      <Column Name="Percentage" Member="Percentage" DbType="Float" Type="System.Double" CanBeNull="true"/>
     101      <Column Name="SerializedJob" Member="SerializedJob" DbType="VarBinary(MAX)" UpdateCheck="Never" Type="System.Data.Linq.Binary" IsDelayLoaded="true"/>
     102      <Column Name="DateCreated" Member="DateCreated" DbType="DateTime" Type="System.DateTime" CanBeNull="true"/>
     103      <Column Name="DateCalculated" Member="DateCalculated" DbType="DateTime" Type="System.DateTime" CanBeNull="true"/>
     104      <Column Name="DateFinished" Member="DateFinished" DbType="DateTime" Type="System.DateTime" CanBeNull="true"/>
    105105      <Column Name="Priority" Member="Priority" DbType="Int NOT NULL" Type="System.Int32"/>
    106       <Column Name="ProjectId" Member="ProjectId" DbType="UniqueIdentifier" Type="System.Guid"/>
    107       <Column Name="UserId" Member="UserId" DbType="UniqueIdentifier" Type="System.Guid"/>
     106      <Column Name="ProjectId" Member="ProjectId" DbType="UniqueIdentifier" Type="System.Guid" CanBeNull="true"/>
     107      <Column Name="UserId" Member="UserId" DbType="UniqueIdentifier" Type="System.Guid" CanBeNull="true"/>
    108108      <Column Name="CoresNeeded" Member="CoresNeeded" DbType="Int NOT NULL" Type="System.Int32"/>
    109109      <Column Name="MemoryNeeded" Member="MemoryNeeded" DbType="Int NOT NULL" Type="System.Int32"/>
     
    125125      <Column Name="Recurring" Member="Recurring" DbType="Bit NOT NULL" Type="System.Boolean"/>
    126126      <Column Name="RecurringId" Member="RecurringId" DbType="UniqueIdentifier" Type="System.Guid"/>
    127       <Association Name="Resource_UptimeCalendar" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" DeleteRule="CASCADE" DeleteOnNull="true" IsForeignKey="true" Type="Resource"/>
     127      <Association Name="Resource_UptimeCalendar" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" DeleteRule="CASCADE" IsForeignKey="true" Type="Resource"/>
    128128    </Type>
    129129  </Table>
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/JobDao.cs

    r3578 r3931  
    6363    }
    6464
     65    public void SetBinaryJobFile(Guid jobId, byte[] data) {
     66      Job j = (from job in Context.Jobs
     67               where job.JobId.Equals(jobId)
     68               select job).SingleOrDefault();
     69      j.SerializedJob = data;
     70      CommitChanges();
     71    }
     72
    6573    public SerializedJob InsertWithAttachedJob(SerializedJob job) {
    6674      Job j = DtoToEntity(job.JobInfo, null);
     
    121129
    122130    public void AssignClientToJob(Guid clientId, Guid jobId) {
    123       Client c = Context.Clients.SingleOrDefault(client => client.ResourceId.Equals(clientId));
     131      Client c = Context.Resources.OfType<Client>().SingleOrDefault(client => client.ResourceId.Equals(clientId));
    124132      Job j = Context.Jobs.SingleOrDefault(job => job.JobId.Equals(jobId));
    125133      c.Jobs.Add(j);
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Properties/Settings.Designer.cs

    r3578 r3931  
    2828        [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
    2929        [global::System.Configuration.DefaultSettingValueAttribute("Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=" +
    30             "True")]
     30            "True;MultipleActiveResultSets=True")]
    3131        public string HeuristicLab_Hive_LinqConnectionString {
    3232            get {
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Properties/Settings.settings

    r3578 r3931  
    66      <DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
    77&lt;SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    8   &lt;ConnectionString&gt;Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=True&lt;/ConnectionString&gt;
     8  &lt;ConnectionString&gt;Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=True;MultipleActiveResultSets=True&lt;/ConnectionString&gt;
    99  &lt;ProviderName&gt;System.Data.SqlClient&lt;/ProviderName&gt;
    1010&lt;/SerializableConnectionString&gt;</DesignTimeValue>
    11       <Value Profile="(Default)">Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=True</Value>
     11      <Value Profile="(Default)">Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=True;MultipleActiveResultSets=True</Value>
    1212    </Setting>
    1313  </Settings>
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/UptimeCalendarDao.cs

    r3578 r3931  
    9999
    100100    public IEnumerable<AppointmentDto> GetCalendarForClient(ClientDto client) {
    101       Client dbc = Context.Clients.SingleOrDefault(c => c.ResourceId.Equals(client.Id));
     101      Client dbc = Context.Resources.OfType<Client>().SingleOrDefault(c => c.ResourceId.Equals(client.Id));
    102102      IList<AppointmentDto> appointments = new List<AppointmentDto>();
    103103      if (dbc != null) {
    104104        ClientGroup cg =
    105           Context.ClientGroups.SingleOrDefault(cgroup => cgroup.ResourceId.Equals(dbc.UseCalendarFromResourceId));
     105          Context.Resources.OfType<ClientGroup>().SingleOrDefault(cgroup => cgroup.ResourceId.Equals(dbc.UseCalendarFromResourceId));
    106106        //in case no plan has been set
    107107        if (cg == null)
    108           if (dbc.Resource.ClientGroup_Resources.FirstOrDefault() != null)
    109             cg = dbc.Resource.ClientGroup_Resources.FirstOrDefault().ClientGroup;
     108          if (dbc.ClientGroup_Resources_Parents.FirstOrDefault() != null)
     109            cg = dbc.ClientGroup_Resources_Parents.FirstOrDefault().ClientGroup;
    110110
    111111        if (cg == null)
    112112          return appointments;
    113113
    114         while (cg.Resource.UptimeCalendars.Count == 0) {
    115           if (cg.Resource.ClientGroup_Resources.FirstOrDefault() != null)
    116             cg = cg.Resource.ClientGroup_Resources.FirstOrDefault().ClientGroup;
     114        while (cg.UptimeCalendars.Count == 0) {
     115          if (cg.ClientGroup_Resources_Parents.FirstOrDefault() != null)
     116            cg = cg.ClientGroup_Resources_Parents.FirstOrDefault().ClientGroup;
    117117          else {
    118118            break;
     
    120120        }
    121121
    122         foreach (UptimeCalendar appointment in cg.Resource.UptimeCalendars) {
     122        foreach (UptimeCalendar appointment in cg.UptimeCalendars) {
    123123          appointments.Add(EntityToDto(appointment,null)); 
    124124        }
     
    131131     
    132132      //Get the current ClientGroup
    133       ClientGroup cg = Context.ClientGroups.SingleOrDefault(cgroup => cgroup.ResourceId.Equals(groupId));
     133      ClientGroup cg = Context.Resources.OfType<ClientGroup>().SingleOrDefault(cgroup => cgroup.ResourceId.Equals(groupId));
    134134      if(cg == null)
    135135        return;
    136136
    137137      //Get all the affected clients
    138       List<Client> clients = Context.Clients.Where(c => c.UseCalendarFromResourceId.Equals(cg.ResourceId)).ToList();
     138      List<Client> clients = Context.Resources.OfType<Client>().Where(c => c.UseCalendarFromResourceId.Equals(cg.ResourceId)).ToList();
    139139     
    140140      //Set new state
     
    146146
    147147      //Get all Subgroups
    148       List<ClientGroup> groups = (from cg1 in Context.ClientGroups
    149                                   where cg1.Resource.ClientGroup_Resources.Any(
     148      List<ClientGroup> groups = (from cg1 in Context.Resources.OfType<ClientGroup>()
     149                                  where cg1.ClientGroup_Resources_Parents.Any(
    150150                                cgr => cgr.ClientGroupId.Equals(groupId))
    151151                              select cg1).ToList();
     
    154154      //otherweise - propagate
    155155      foreach (ClientGroup cgroup in groups) {
    156         if(cgroup.Resource.UptimeCalendars.Count == 0)
    157           NotifyClientsOfNewCalendar(groupId, forcePush);       
     156        if(cgroup.UptimeCalendars.Count == 0)
     157          NotifyClientsOfNewCalendar(cgroup.ResourceId, forcePush);       
    158158      }
    159159    }
  • branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/app.config

    r3578 r3931  
    55    <connectionStrings>
    66        <add name="HeuristicLab.Hive.Server.LINQDataAccess.Properties.Settings.HeuristicLab_Hive_LinqConnectionString"
    7             connectionString="Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=True"
     7            connectionString="Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=True;MultipleActiveResultSets=True"
    88            providerName="System.Data.SqlClient" />
    99    </connectionStrings>
Note: See TracChangeset for help on using the changeset viewer.