- Timestamp:
- 06/19/10 09:17:24 (15 years ago)
- 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 15 15 16 16 protected void CommitChanges() { 17 //TODO: DoWhile 17 18 try { 18 19 Context.SubmitChanges(ConflictMode.ContinueOnConflict); 19 20 } catch (ChangeConflictException e) { 20 21 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 } 22 30 conflict.Resolve(RefreshMode.KeepChanges); 23 31 } 32 Context.SubmitChanges(ConflictMode.FailOnFirstConflict); 24 33 } 25 34 } -
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ClientDao.cs
r3578 r3931 14 14 15 15 public ClientDto FindById(Guid id) { 16 return (from client in Context. Clients16 return (from client in Context.Resources.OfType<Client>() 17 17 where client.ResourceId.Equals(id) 18 18 select EntityToDto(client, null) … … 21 21 22 22 public IEnumerable<ClientDto> FindAll() { 23 return (from client in Context. Clients23 return (from client in Context.Resources.OfType<Client>() 24 24 select 25 25 EntityToDto(client, null) … … 28 28 29 29 public IEnumerable<ClientDto> FindAllClientsWithoutGroup() { 30 return (from client in Context. Clients31 where client. Resource.ClientGroup_Resources.Count == 030 return (from client in Context.Resources.OfType<Client>() 31 where client.ClientGroup_Resources_Parents.Count == 0 32 32 select EntityToDto(client, null)).ToList(); 33 33 } … … 40 40 41 41 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)); 43 43 dbclient.UseCalendarFromResourceId = clientGroupId; 44 44 dbclient.CalendarSyncStatus = Enum.GetName(typeof(CalendarState), CalendarState.Fetch); … … 48 48 public ClientDto Insert(ClientDto info) { 49 49 Client c = DtoToEntity(info, null); 50 Context. Clients.InsertOnSubmit(c);50 Context.Resources.InsertOnSubmit(c); 51 51 CommitChanges(); 52 52 info.Id = c.ResourceId; … … 62 62 63 63 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)); 65 65 DtoToEntity(info, client); 66 66 CommitChanges(); … … 75 75 target.CPUSpeed = source.CpuSpeedPerCore; 76 76 77 if(target.Resource == null)78 target.Resource = new Resource();79 80 77 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; 83 80 target.CalendarSyncStatus = Enum.GetName(typeof(CalendarState), source.CalendarSyncStatus); 84 81 target.Login = source.Login; … … 96 93 target = new ClientDto(); 97 94 target.CpuSpeedPerCore = source.CPUSpeed; 98 target.FreeMemory = source.FreeMemory ;95 target.FreeMemory = source.FreeMemory ?? 0; 99 96 target.Id = source.ResourceId; 100 97 target.CalendarSyncStatus = (CalendarState) Enum.Parse(typeof (CalendarState), source.CalendarSyncStatus); 101 98 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; 106 103 target.State = (State) Enum.Parse(typeof (State), source.Status); 107 104 return target; -
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ClientGroupDao.cs
r3578 r3931 13 13 14 14 public ClientGroupDto FindById(Guid id) { 15 return (from cc in Context. ClientGroups15 return (from cc in Context.Resources.OfType<ClientGroup>() 16 16 where cc.ResourceId.Equals(id) 17 17 select EntityToDto(cc, null)).SingleOrDefault(); … … 20 20 21 21 public IEnumerable<ClientGroupDto> FindAll() { 22 return (from cc in Context. ClientGroups22 return (from cc in Context.Resources.OfType<ClientGroup>() 23 23 select EntityToDto(cc, null)).ToList(); 24 24 } … … 30 30 31 31 ClientGroup cc = DtoToEntity(bObj, null); 32 Context. ClientGroups.InsertOnSubmit(cc);32 Context.Resources.InsertOnSubmit(cc); 33 33 CommitChanges(); 34 34 bObj.Id = cc.ResourceId; … … 48 48 49 49 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)); 51 51 DtoToEntity(bObj, client); 52 52 CommitChanges(); … … 54 54 55 55 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)); 57 57 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 }); 59 59 CommitChanges(); 60 60 } … … 77 77 List<ClientGroupDto> groupList = new List<ClientGroupDto>(); 78 78 79 var q = (from cg in Context. ClientGroups79 var q = (from cg in Context.Resources.OfType<ClientGroup>() 80 80 where !Context.ClientGroup_Resources.Any(cgr => cgr.ResourceId.Equals(cg.ResourceId)) 81 81 select cg); … … 84 84 ClientGroupDto cgd = EntityToDto(cg, null); 85 85 groupList.Add(cgd); 86 FillSubGroupsAndClientsRecursivly(cgd, cg.ClientGroup_Resources );86 FillSubGroupsAndClientsRecursivly(cgd, cg.ClientGroup_Resources_Children); 87 87 } 88 88 return groupList; … … 93 93 //Get all the Groups 94 94 95 var qGroups = (from cg in Context. ClientGroups96 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)) 97 97 select cg); 98 98 … … 100 100 ClientGroupDto cgd = EntityToDto(cg, null); 101 101 parentClientGroup.Resources.Add(cgd); 102 FillSubGroupsAndClientsRecursivly(cgd, cg.ClientGroup_Resources );102 FillSubGroupsAndClientsRecursivly(cgd, cg.ClientGroup_Resources_Children); 103 103 } 104 104 105 105 //get the clients 106 var qClients = (from cl in Context. Clients107 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)) 108 108 select cl); 109 109 foreach (Client client in qClients) { … … 114 114 public IEnumerable<Guid> FindAllGroupAndParentGroupIdsForClient(Guid clientId) { 115 115 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); 118 118 return guids; 119 119 } 120 120 121 //Massivly error Prone 121 122 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) { 123 124 guids.Add(cgr.ClientGroupId); 124 FindAllGroupAndParentGroupIdsForClientRecursive(cgr.ClientGroup .Resource, guids);125 FindAllGroupAndParentGroupIdsForClientRecursive(cgr.ClientGroup, guids); 125 126 } 126 127 } … … 133 134 if (target == null) 134 135 target = new ClientGroup(); 135 if (target.Resource == null)136 target.Resource = new Resource();137 136 138 target. Resource.Name = source.Name;139 target.Resource .ResourceId = source.Id;137 target.Name = source.Name; 138 target.ResourceId = source.Id; 140 139 141 140 return target; … … 149 148 150 149 target.Id = source.ResourceId; 151 target.Name = source. Resource.Name;150 target.Name = source.Name; 152 151 153 152 return target; … … 155 154 156 155 public IEnumerable<ClientGroupDto> FindByName(string res) { 157 return (from cq in Context. ClientGroups158 where cq. Resource.Name == res156 return (from cq in Context.Resources.OfType<ClientGroup>() 157 where cq.Name == res 159 158 select EntityToDto(cq, null)).ToList(); 160 159 } -
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ContextFactory.cs
r3578 r3931 5 5 using System.Data.Common; 6 6 using System.Data.SqlClient; 7 using HeuristicLab.Tracing; 7 8 8 9 namespace HeuristicLab.Hive.Server.LINQDataAccess { … … 16 17 public static HiveDataContext Context { 17 18 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 } 20 24 return _hiveDataContext; 21 25 } … … 32 36 } 33 37 } 38 39 public static bool IsContextNull() { 40 return _hiveDataContext == null; 41 } 34 42 } 35 43 } -
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/HeuristicLab.Hive.Server.LINQDataAccess-3.2.csproj
r3578 r3931 91 91 <Compile Include="ClientGroupDao.cs" /> 92 92 <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" /> 98 94 <Compile Include="JobDao.cs" /> 99 95 <Compile Include="LINQDataAccessPlugin.cs" /> … … 109 105 </ItemGroup> 110 106 <ItemGroup> 111 <None Include="Hive.dbml">112 <Generator>MSLinqToSQLGenerator</Generator>113 <LastGenOutput>Hive.designer.cs</LastGenOutput>114 <SubType>Designer</SubType>115 </None>116 107 <None Include="HeuristicLab.snk" /> 117 108 <None Include="Properties\AssemblyInfo.frame" /> … … 144 135 <ItemGroup> 145 136 <None Include="app.config" /> 146 <None Include="Hive.dbml.layout">147 <DependentUpon>Hive.dbml</DependentUpon>148 </None>149 137 <None Include="Properties\Settings.settings"> 150 138 <Generator>SettingsSingleFileGenerator</Generator> 151 139 <LastGenOutput>Settings.Designer.cs</LastGenOutput> 152 140 </None> 141 </ItemGroup> 142 <ItemGroup> 143 <Content Include="HiveDataContext.xml" /> 153 144 </ItemGroup> 154 145 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Hive.dbml
r3578 r3931 78 78 <Association Name="Resource_UptimeCalendar" Member="UptimeCalendars" ThisKey="ResourceId" OtherKey="ResourceId" Type="UptimeCalendar" /> 79 79 <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" />81 80 </Type> 82 81 </Table> … … 133 132 <Association Name="Client_Job" Member="Jobs" ThisKey="ResourceId" OtherKey="ResourceId" Type="Job" /> 134 133 <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" />136 134 <Association Name="ClientConfig_Client" Member="ClientConfig" ThisKey="ClientConfigId" OtherKey="ClientConfigId" Type="ClientConfig" IsForeignKey="true" DeleteRule="SET NULL" /> 137 135 </Type> -
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Hive.dbml.layout
r3203 r3931 166 166 </nodes> 167 167 </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>175 168 <associationConnector edgePoints="[(4.75 : 12); (4.75 : 11.1747054036458)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 176 169 <AssociationMoniker Name="/HiveDataContext/ClientConfig/ClientConfig_Client" /> -
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Hive.designer.cs
r3578 r3931 1512 1512 private EntityRef<Client> _Client; 1513 1513 1514 private EntityRef<Client> _Client1;1515 1516 1514 #region Extensibility Method Definitions 1517 1515 partial void OnLoaded(); … … 1531 1529 this._UptimeCalendars = new EntitySet<UptimeCalendar>(new Action<UptimeCalendar>(this.attach_UptimeCalendars), new Action<UptimeCalendar>(this.detach_UptimeCalendars)); 1532 1530 this._Client = default(EntityRef<Client>); 1533 this._Client1 = default(EntityRef<Client>);1534 1531 OnCreated(); 1535 1532 } … … 1668 1665 } 1669 1666 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 Client11676 {1677 get1678 {1679 return this._Client1.Entity;1680 }1681 set1682 {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");1699 1667 } 1700 1668 } … … 2620 2588 private EntityRef<Resource> _Resource; 2621 2589 2622 private EntityRef<Resource> _Resource1;2623 2624 2590 private EntityRef<ClientConfig> _ClientConfig; 2625 2591 … … 2657 2623 this._Jobs = new EntitySet<Job>(new Action<Job>(this.attach_Jobs), new Action<Job>(this.detach_Jobs)); 2658 2624 this._Resource = default(EntityRef<Resource>); 2659 this._Resource1 = default(EntityRef<Resource>);2660 2625 this._ClientConfig = default(EntityRef<ClientConfig>); 2661 2626 OnCreated(); … … 2950 2915 } 2951 2916 2952 [Association(Name="Resource_Client1", Storage="_Resource1", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true)]2953 public Resource Resource12954 {2955 get2956 {2957 return this._Resource1.Entity;2958 }2959 set2960 {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 else2978 {2979 this._ResourceId = default(System.Guid);2980 }2981 this.SendPropertyChanged("Resource1");2982 }2983 }2984 }2985 2986 2917 [Association(Name="ClientConfig_Client", Storage="_ClientConfig", ThisKey="ClientConfigId", OtherKey="ClientConfigId", IsForeignKey=true, DeleteRule="SET NULL")] 2987 2918 public ClientConfig ClientConfig -
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/HiveDataContext.xml
r3808 r3931 1 1 <?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"> 3 3 <Table Name="dbo.AssignedResources" Member="AssignedResources"> 4 4 <Type Name="AssignedResource"> … … 6 6 <Column Name="JobId" Member="JobId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" /> 7 7 <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"/> 10 10 </Type> 11 11 </Table> … … 23 23 <Column Name="ClientConfigId" Member="ClientConfigId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" IsPrimaryKey="true" IsDbGenerated="true" AutoSync="OnInsert" /> 24 24 <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"/> 26 26 <Association Name="ClientConfig_Client" Member="Clients" ThisKey="ClientConfigId" OtherKey="ClientConfigId" Type="Client"/> 27 27 </Type> … … 30 30 <Table Name="dbo.ClientGroup_Resource" Member="ClientGroup_Resources"> 31 31 <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" /> 33 33 <Column Name="ClientGroupId" Member="ClientGroupId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" /> 34 34 <Column Name="ResourceId" Member="ResourceId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" /> 35 35 36 36 <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"/> 38 38 </Type> 39 39 </Table> … … 59 59 <Column Name="JobId" Member="JobId" DbType="UniqueIdentifier NOT NULL" Type="System.Guid" /> 60 60 <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"/> 62 62 <Association Name="Job_RequiredPlugin" Member="Job" ThisKey="JobId" OtherKey="JobId" IsForeignKey="true" Type="Job"/> 63 63 </Type> … … 69 69 <Column Name="ResourceType" Member="ResourceType" IsDiscriminator="true" Type="System.String"/> 70 70 <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" /> 72 72 <Association Name="Resource_UptimeCalendar" Member="UptimeCalendars" ThisKey="ResourceId" OtherKey="ResourceId" Type="UptimeCalendar" /> 73 73 <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"/> 84 84 <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"/> 86 86 <Association Name="ClientConfig_Client" Member="ClientConfig" ThisKey="ClientConfigId" OtherKey="ClientConfigId" DeleteRule="SET NULL" IsForeignKey="true" Type="ClientConfig"/> 87 87 </Type> 88 88 <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" /> 90 90 </Type> 91 91 </Type> … … 95 95 <Type Name="Job"> 96 96 <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" /> 98 98 <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"/> 105 105 <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"/> 108 108 <Column Name="CoresNeeded" Member="CoresNeeded" DbType="Int NOT NULL" Type="System.Int32"/> 109 109 <Column Name="MemoryNeeded" Member="MemoryNeeded" DbType="Int NOT NULL" Type="System.Int32"/> … … 125 125 <Column Name="Recurring" Member="Recurring" DbType="Bit NOT NULL" Type="System.Boolean"/> 126 126 <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"/> 128 128 </Type> 129 129 </Table> -
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/JobDao.cs
r3578 r3931 63 63 } 64 64 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 65 73 public SerializedJob InsertWithAttachedJob(SerializedJob job) { 66 74 Job j = DtoToEntity(job.JobInfo, null); … … 121 129 122 130 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)); 124 132 Job j = Context.Jobs.SingleOrDefault(job => job.JobId.Equals(jobId)); 125 133 c.Jobs.Add(j); -
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Properties/Settings.Designer.cs
r3578 r3931 28 28 [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] 29 29 [global::System.Configuration.DefaultSettingValueAttribute("Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=" + 30 "True ")]30 "True;MultipleActiveResultSets=True")] 31 31 public string HeuristicLab_Hive_LinqConnectionString { 32 32 get { -
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Properties/Settings.settings
r3578 r3931 6 6 <DesignTimeValue Profile="(Default)"><?xml version="1.0" encoding="utf-16"?> 7 7 <SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 8 <ConnectionString>Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=True </ConnectionString>8 <ConnectionString>Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=True;MultipleActiveResultSets=True</ConnectionString> 9 9 <ProviderName>System.Data.SqlClient</ProviderName> 10 10 </SerializableConnectionString></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> 12 12 </Setting> 13 13 </Settings> -
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/UptimeCalendarDao.cs
r3578 r3931 99 99 100 100 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)); 102 102 IList<AppointmentDto> appointments = new List<AppointmentDto>(); 103 103 if (dbc != null) { 104 104 ClientGroup cg = 105 Context. ClientGroups.SingleOrDefault(cgroup => cgroup.ResourceId.Equals(dbc.UseCalendarFromResourceId));105 Context.Resources.OfType<ClientGroup>().SingleOrDefault(cgroup => cgroup.ResourceId.Equals(dbc.UseCalendarFromResourceId)); 106 106 //in case no plan has been set 107 107 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; 110 110 111 111 if (cg == null) 112 112 return appointments; 113 113 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; 117 117 else { 118 118 break; … … 120 120 } 121 121 122 foreach (UptimeCalendar appointment in cg. Resource.UptimeCalendars) {122 foreach (UptimeCalendar appointment in cg.UptimeCalendars) { 123 123 appointments.Add(EntityToDto(appointment,null)); 124 124 } … … 131 131 132 132 //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)); 134 134 if(cg == null) 135 135 return; 136 136 137 137 //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(); 139 139 140 140 //Set new state … … 146 146 147 147 //Get all Subgroups 148 List<ClientGroup> groups = (from cg1 in Context. ClientGroups149 where cg1. Resource.ClientGroup_Resources.Any(148 List<ClientGroup> groups = (from cg1 in Context.Resources.OfType<ClientGroup>() 149 where cg1.ClientGroup_Resources_Parents.Any( 150 150 cgr => cgr.ClientGroupId.Equals(groupId)) 151 151 select cg1).ToList(); … … 154 154 //otherweise - propagate 155 155 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); 158 158 } 159 159 } -
branches/3.2/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/app.config
r3578 r3931 5 5 <connectionStrings> 6 6 <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" 8 8 providerName="System.Data.SqlClient" /> 9 9 </connectionStrings>
Note: See TracChangeset
for help on using the changeset viewer.