Changeset 3578 for trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess
- Timestamp:
- 05/01/10 13:58:24 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/BaseDao.cs
r3011 r3578 3 3 using System.Linq; 4 4 using System.Text; 5 using System.Data.Linq; 6 using HeuristicLab.Tracing; 5 7 6 8 namespace HeuristicLab.Hive.Server.LINQDataAccess { … … 12 14 } 13 15 16 protected void CommitChanges() { 17 try { 18 Context.SubmitChanges(ConflictMode.ContinueOnConflict); 19 } catch (ChangeConflictException e) { 20 Logger.Warn("Concurrency Exception! " + e.Message); 21 foreach (ObjectChangeConflict conflict in Context.ChangeConflicts) { 22 conflict.Resolve(RefreshMode.KeepChanges); 23 } 24 } 25 } 26 14 27 public abstract TDatabaseEntity DtoToEntity(TBusiness source, TDatabaseEntity target); 15 28 public abstract TBusiness EntityToDto(TDatabaseEntity source, TBusiness target); -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ClientConfigDao.cs
r3011 r3578 26 26 ClientConfig c = DtoToEntity(bObj, null); 27 27 Context.ClientConfigs.InsertOnSubmit(c); 28 Co ntext.SubmitChanges();28 CommitChanges(); 29 29 bObj.Id = c.ClientConfigId; 30 30 return bObj; … … 33 33 public void Delete(ClientConfigDto bObj) { 34 34 Context.ClientConfigs.DeleteOnSubmit(Context.ClientConfigs.SingleOrDefault(c => c.ClientConfigId.Equals(bObj.Id))); 35 Co ntext.SubmitChanges();35 CommitChanges(); 36 36 } 37 37 … … 39 39 ClientConfig cc = Context.ClientConfigs.SingleOrDefault(c => c.ClientConfigId.Equals(bObj.Id)); 40 40 DtoToEntity(bObj, cc); 41 Co ntext.SubmitChanges();41 CommitChanges(); 42 42 } 43 43 -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ClientDao.cs
r3203 r3578 43 43 dbclient.UseCalendarFromResourceId = clientGroupId; 44 44 dbclient.CalendarSyncStatus = Enum.GetName(typeof(CalendarState), CalendarState.Fetch); 45 Co ntext.SubmitChanges();45 CommitChanges(); 46 46 } 47 47 … … 49 49 Client c = DtoToEntity(info, null); 50 50 Context.Clients.InsertOnSubmit(c); 51 Co ntext.SubmitChanges();51 CommitChanges(); 52 52 info.Id = c.ResourceId; 53 53 return info; … … 58 58 Resource res = Context.Resources.SingleOrDefault(c => c.ResourceId.Equals(info.Id)); 59 59 Context.Resources.DeleteOnSubmit(res); 60 Co ntext.SubmitChanges();60 CommitChanges(); 61 61 } 62 62 … … 64 64 Client client = Context.Clients.SingleOrDefault(c => c.ResourceId.Equals(info.Id)); 65 65 DtoToEntity(info, client); 66 try { 67 Console.WriteLine("Sending from thread: " + Thread.CurrentThread.ManagedThreadId); 68 Context.SubmitChanges(); 69 } catch (System.Data.Linq.ChangeConflictException cce) { 70 Console.WriteLine(cce); 71 } 66 CommitChanges(); 72 67 } 73 68 -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ClientGroupDao.cs
r3220 r3578 31 31 ClientGroup cc = DtoToEntity(bObj, null); 32 32 Context.ClientGroups.InsertOnSubmit(cc); 33 Co ntext.SubmitChanges();33 CommitChanges(); 34 34 bObj.Id = cc.ResourceId; 35 35 return bObj; … … 44 44 45 45 Context.Resources.DeleteOnSubmit(res); 46 Co ntext.SubmitChanges();46 CommitChanges(); 47 47 } 48 48 … … 50 50 ClientGroup client = Context.ClientGroups.SingleOrDefault(c => c.ResourceId.Equals(bObj.Id)); 51 51 DtoToEntity(bObj, client); 52 Co ntext.SubmitChanges();52 CommitChanges(); 53 53 } 54 54 … … 57 57 Resource res = Context.Resources.SingleOrDefault(r => r.ResourceId.Equals(resource)); 58 58 cg.ClientGroup_Resources.Add(new ClientGroup_Resource { ClientGroup = cg, Resource = res }); 59 Co ntext.SubmitChanges();59 CommitChanges(); 60 60 } 61 61 … … 65 65 cg => cg.ResourceId.Equals(resource) && cg.ClientGroupId.Equals(clientGroupId)); 66 66 Context.ClientGroup_Resources.DeleteOnSubmit(cgr); 67 Co ntext.SubmitChanges();67 CommitChanges(); 68 68 } 69 69 -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ContextFactory.cs
r3220 r3578 9 9 public class ContextFactory { 10 10 [ThreadStatic] 11 private static HiveDataContext _hiveDataContext ;11 private static HiveDataContext _hiveDataContext = null; 12 12 13 13 [ThreadStatic] 14 private static SqlTransaction _currentTransaction ;14 private static SqlTransaction _currentTransaction = null; 15 15 16 16 public static HiveDataContext Context { -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/HeuristicLab.Hive.Server.LINQDataAccess-3.2.csproj
r3220 r3578 134 134 <Name>HeuristicLab.PluginInfrastructure</Name> 135 135 </ProjectReference> 136 <ProjectReference Include="..\..\HeuristicLab.Tracing\3.2\HeuristicLab.Tracing-3.2.csproj"> 137 <Project>{EE2034D9-6E27-48A1-B855-42D45F69A4FC}</Project> 138 <Name>HeuristicLab.Tracing-3.2</Name> 139 </ProjectReference> 136 140 </ItemGroup> 137 141 <ItemGroup> -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Hive.dbml
r3203 r3578 88 88 <Column Name="ResourceId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" /> 89 89 <Column Name="Percentage" Type="System.Double" DbType="Float" CanBeNull="true" /> 90 <Column Name="SerializedJob" Type="System.Data.Linq.Binary" DbType="VarBinary(MAX)" CanBeNull="true" UpdateCheck="Never" />90 <Column Name="SerializedJob" Type="System.Data.Linq.Binary" DbType="VarBinary(MAX)" CanBeNull="true" UpdateCheck="Never" IsDelayLoaded="true" /> 91 91 <Column Name="DateCreated" Type="System.DateTime" DbType="DateTime" CanBeNull="true" /> 92 92 <Column Name="DateCalculated" Type="System.DateTime" DbType="DateTime" CanBeNull="true" /> -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Hive.designer.cs
r3203 r3578 1774 1774 private System.Nullable<double> _Percentage; 1775 1775 1776 private System.Data.Linq. Binary_SerializedJob;1776 private System.Data.Linq.Link<System.Data.Linq.Binary> _SerializedJob; 1777 1777 1778 1778 private System.Nullable<System.DateTime> _DateCreated; … … 1957 1957 } 1958 1958 1959 [Column(Storage="_SerializedJob", DbType="VarBinary(MAX)", CanBeNull=true,UpdateCheck=UpdateCheck.Never)]1959 [Column(Storage="_SerializedJob", DbType="VarBinary(MAX)", UpdateCheck=UpdateCheck.Never)] 1960 1960 public System.Data.Linq.Binary SerializedJob 1961 1961 { 1962 1962 get 1963 1963 { 1964 return this._SerializedJob ;1965 } 1966 set 1967 { 1968 if ((this._SerializedJob != value))1964 return this._SerializedJob.Value; 1965 } 1966 set 1967 { 1968 if ((this._SerializedJob.Value != value)) 1969 1969 { 1970 1970 this.OnSerializedJobChanging(value); 1971 1971 this.SendPropertyChanging(); 1972 this._SerializedJob = value;1972 this._SerializedJob.Value = value; 1973 1973 this.SendPropertyChanged("SerializedJob"); 1974 1974 this.OnSerializedJobChanged(); -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/JobDao.cs
r3220 r3578 25 25 } 26 26 27 public IEnumerable<JobDto> FindWithLimitations(State jobState, int offset, int count) { 28 29 IQueryable<JobDto> query = null; 30 if (jobState == State.finished) { 31 query = from job in Context.Jobs 32 where job.JobState == Enum.GetName(typeof (State), jobState) 33 orderby job.DateFinished 34 select EntityToDto(job, null); 35 } else if (jobState == State.calculating || jobState == State.requestSnapshot || jobState == State.requestSnapshotSent) { 36 query = from job in Context.Jobs 37 where job.JobState == Enum.GetName(typeof(State), jobState) 38 orderby job.DateCalculated 39 select EntityToDto(job, null); 40 } else { 41 query = from job in Context.Jobs 42 where job.JobState == Enum.GetName(typeof(State), jobState) 43 orderby job.DateCreated 44 select EntityToDto(job, null); 45 } 46 47 return query.Skip(offset).Take(count).ToList(); 48 } 49 50 27 51 public byte[] GetBinaryJobFile(Guid jobId) { 28 52 return (from job in Context.Jobs … … 34 58 Job j = DtoToEntity(bObj, null); 35 59 Context.Jobs.InsertOnSubmit(j); 36 Co ntext.SubmitChanges();60 CommitChanges(); 37 61 bObj.Id = j.JobId; 38 62 return bObj; … … 45 69 j.AssignedResources.Add(new AssignedResource { ResourceId = assignRessourceId}); 46 70 Context.Jobs.InsertOnSubmit(j); 47 Co ntext.SubmitChanges();71 CommitChanges(); 48 72 job.JobInfo.Id = j.JobId; 49 73 return job; … … 54 78 Job job = Context.Jobs.SingleOrDefault(j => j.JobId.Equals(bObj.Id)); 55 79 Context.Jobs.DeleteOnSubmit(job); 56 Co ntext.SubmitChanges();80 CommitChanges(); 57 81 } 58 82 59 83 public void Update(JobDto bObj) { 60 84 Job job = Context.Jobs.SingleOrDefault(j => j.JobId.Equals(bObj.Id)); 61 DtoToEntity(bObj, job); 62 try { 63 Context.SubmitChanges(); 64 } catch (ChangeConflictException cfe) { 65 66 } 85 DtoToEntity(bObj, job); 86 CommitChanges(); 67 87 } 68 88 … … 105 125 c.Jobs.Add(j); 106 126 j.Client = c; 107 Co ntext.SubmitChanges();127 CommitChanges(); 108 128 } 109 129 … … 112 132 j.Client = null; 113 133 j.JobState = Enum.GetName(typeof(State), State.offline); 114 Co ntext.SubmitChanges();134 CommitChanges(); 115 135 } 116 136 … … 137 157 target.DateCalculated = source.DateCalculated; 138 158 target.DateCreated = source.DateCreated; 159 target.DateFinished = source.DateFinished; 139 160 target.JobId = source.Id; 140 161 … … 162 183 target.MemoryNeeded = source.MemoryNeeded; 163 184 164 165 166 185 target.DateCalculated = source.DateCalculated; 167 186 target.DateCreated = source.DateCreated; 187 target.DateFinished = source.DateFinished; 168 188 target.Id = source.JobId; 169 170 189 171 190 target.Percentage = source.Percentage; 172 191 -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/LINQDataAccessPlugin.cs
r3011 r3578 11 11 [PluginDependency("HeuristicLab.Hive.Contracts-3.2")] 12 12 [PluginDependency("HeuristicLab.Hive.Server.DataAccess-3.2")] 13 [PluginDependency("HeuristicLab.Tracing", "3.2.0")] 13 14 public class LINQDataAccessPlugin: PluginBase { 14 15 } -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/PluginInfoDao.cs
r3011 r3578 26 26 PluginInfo pi = DtoToEntity(bObj, null); 27 27 Context.PluginInfos.InsertOnSubmit(pi); 28 Co ntext.SubmitChanges();28 CommitChanges(); 29 29 bObj.Id = pi.PluginId; 30 30 return bObj; … … 39 39 PluginInfo pi = Context.PluginInfos.SingleOrDefault(p => p.PluginId.Equals(bObj.Id)); 40 40 DtoToEntity(bObj, pi); 41 Co ntext.SubmitChanges();41 CommitChanges(); 42 42 } 43 43 … … 53 53 }; 54 54 Context.PluginInfos.InsertOnSubmit(dbpi); 55 Co ntext.SubmitChanges();55 CommitChanges(); 56 56 } 57 57 … … 60 60 rq.PluginInfo = dbpi; 61 61 Context.RequiredPlugins.InsertOnSubmit(rq); 62 Co ntext.SubmitChanges();62 CommitChanges(); 63 63 } 64 } 65 66 public List<HivePluginInfoDto> GetPluginDependenciesForJob(JobDto jobDto) { 67 return (from rp in Context.RequiredPlugins 68 where rp.JobId.Equals(jobDto.Id) 69 select EntityToDto(rp.PluginInfo, null)).ToList(); 70 64 71 } 65 72 -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Properties/Settings.Designer.cs
r2904 r3578 27 27 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 28 [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] 29 [global::System.Configuration.DefaultSettingValueAttribute("Data Source= SEMTEX-PC;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=" +29 [global::System.Configuration.DefaultSettingValueAttribute("Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=" + 30 30 "True")] 31 31 public string HeuristicLab_Hive_LinqConnectionString { -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/Properties/Settings.settings
r2904 r3578 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= SEMTEX-PC;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</ConnectionString> 9 9 <ProviderName>System.Data.SqlClient</ProviderName> 10 10 </SerializableConnectionString></DesignTimeValue> 11 <Value Profile="(Default)">Data Source= SEMTEX-PC;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</Value> 12 12 </Setting> 13 13 </Settings> -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/UptimeCalendarDao.cs
r3203 r3578 60 60 UptimeCalendar uc = DtoToEntity(bObj, null); 61 61 Context.UptimeCalendars.InsertOnSubmit(uc); 62 Co ntext.SubmitChanges();62 CommitChanges(); 63 63 bObj.Id = uc.UptimeCalendarId; 64 64 return bObj; … … 67 67 public void Delete(AppointmentDto bObj) { 68 68 Context.UptimeCalendars.DeleteOnSubmit(Context.UptimeCalendars.SingleOrDefault(uc => uc.UptimeCalendarId.Equals(bObj.Id))); 69 Co ntext.SubmitChanges();69 CommitChanges(); 70 70 } 71 71 … … 73 73 UptimeCalendar cc = Context.UptimeCalendars.SingleOrDefault(c => c.UptimeCalendarId.Equals(bObj.Id)); 74 74 DtoToEntity(bObj, cc); 75 Co ntext.SubmitChanges();75 CommitChanges(); 76 76 } 77 77 … … 95 95 } 96 96 97 Co ntext.SubmitChanges();97 CommitChanges(); 98 98 } 99 99 … … 143 143 } 144 144 145 Co ntext.SubmitChanges();145 CommitChanges(); 146 146 147 147 //Get all Subgroups -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/VarBinaryStream.cs
r3220 r3578 7 7 using System.Data.SqlClient; 8 8 using System.Data; 9 using HeuristicLab.Tracing; 9 10 10 11 namespace HeuristicLab.Hive.Server.LINQDataAccess { … … 253 254 254 255 public void Close() { 256 Logger.Info("Closing Stream"); 255 257 if (_transaction != null) { 256 258 _transaction.Commit(); 257 259 _transaction = null; 260 Logger.Info("Transaction commited and closed"); 258 261 } 259 262 … … 262 265 ContextFactory.Context.Dispose(); 263 266 ContextFactory.Context = null; 267 Logger.Info("Connection and Context disposed and set null"); 264 268 } 265 269 } -
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/app.config
r2904 r3578 5 5 <connectionStrings> 6 6 <add name="HeuristicLab.Hive.Server.LINQDataAccess.Properties.Settings.HeuristicLab_Hive_LinqConnectionString" 7 connectionString="Data Source= SEMTEX-PC;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=True"7 connectionString="Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive.Linq;Integrated Security=True" 8 8 providerName="System.Data.SqlClient" /> 9 9 </connectionStrings>
Note: See TracChangeset
for help on using the changeset viewer.