- Timestamp:
- 01/25/09 11:32:31 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/ClientConfig.cs
r995 r1175 29 29 30 30 [DataContract] 31 public class ClientConfig: IHiveObject { 32 [DataMember] 33 public long Id { get; set; } 31 public class ClientConfig: HiveBaseObject { 34 32 [DataMember] 35 33 public String UpDownTimeCalendar { get; set; } // TODO define DataStructure -
trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/GrantedPermissions.cs
r995 r1175 29 29 30 30 [DataContract] 31 public class GrantedPermissions: IHiveObject { 32 [DataMember] 33 public long Id { get; set; } 31 public class GrantedPermissions: HiveBaseObject { 34 32 [DataMember] 35 33 public Permission Permission { get; set; } -
trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/Job.cs
r1168 r1175 29 29 30 30 [DataContract] 31 public class Job: IHiveObject { 32 [DataMember] 33 public long Id { get; set; } 31 public class Job : HiveBaseObject { 34 32 [DataMember] 35 33 public State State { get; set; } … … 50 48 [DataMember] 51 49 public int Priority { get; set; } 52 53 public override bool Equals(object obj) {54 if (obj is Job) {55 return (obj as Job).Id.Equals(Id);56 } else57 return base.Equals(obj);58 }59 60 public override int GetHashCode() {61 return Id.GetHashCode();62 }63 50 } 64 51 } -
trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/JobResult.cs
r1168 r1175 29 29 30 30 [DataContract] 31 public class JobResult: IHiveObject { 32 [DataMember] 33 public long Id { get; set; } 31 public class JobResult: HiveBaseObject { 34 32 [DataMember] 35 33 public Job Job { get; set; } -
trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/Permission.cs
r995 r1175 29 29 30 30 [DataContract] 31 public class Permission: IHiveObject { 32 [DataMember] 33 public long Id { get; set; } 31 public class Permission: HiveBaseObject { 34 32 [DataMember] 35 33 public String Name { get; set; } -
trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/PermissionOwner.cs
r995 r1175 29 29 30 30 [DataContract] 31 public class PermissionOwner: IHiveObject { 32 [DataMember] 33 public long Id { get; set; } 31 public class PermissionOwner: HiveBaseObject { 34 32 [DataMember] 35 33 public string Name { get; set; } 36 37 public override bool Equals(object obj) {38 if (obj is PermissionOwner)39 return this.Id.Equals(40 (obj as PermissionOwner).Id);41 else42 return base.Equals(obj);43 }44 45 public override int GetHashCode() {46 return this.Id.GetHashCode();47 }48 34 } 49 35 } -
trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/Resource.cs
r995 r1175 29 29 30 30 [DataContract] 31 public class Resource: IHiveObject { 32 [DataMember] 33 public long Id { get; set; } 31 public class Resource: HiveBaseObject { 34 32 [DataMember] 35 33 public string Name { get; set; } 36 37 public override bool Equals(object obj) {38 if (obj is Resource)39 return (obj as Resource).Id.Equals(Id);40 else41 return base.Equals(obj);42 }43 44 public override int GetHashCode() {45 return Id.GetHashCode();46 }47 34 } 48 35 } -
trunk/sources/HeuristicLab.Hive.Contracts/HeuristicLab.Hive.Contracts.csproj
r1120 r1175 74 74 <Compile Include="BusinessObjects\ClientGroup.cs" /> 75 75 <Compile Include="BusinessObjects\HeartBeatData.cs" /> 76 <Compile Include="BusinessObjects\HiveBaseObject.cs" /> 76 77 <Compile Include="BusinessObjects\IHiveObject.cs" /> 77 78 <Compile Include="BusinessObjects\Job.cs" /> -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/CachedDataAdapter.cs
r1166 r1175 227 227 public override void Update(ObjT obj) { 228 228 if (obj != null) { 229 RowT row = 230 GetRowById(obj.Id); 229 RowT row = null; 230 long locked = default(long); 231 232 if (obj.Id != default(long)) { 233 LockRow(obj.Id); 234 locked = obj.Id; 235 236 row = GetRowById(obj.Id); 237 } 231 238 232 239 if (row == null) { … … 238 245 239 246 UpdateRow(row); 240 } 241 242 obj.Id = (long)row[row.Table.PrimaryKey[0]]; 243 LockRow(obj.Id); 247 obj.Id = (long)row[row.Table.PrimaryKey[0]]; 248 } 249 250 if (locked == default(long)) { 251 LockRow(obj.Id); 252 locked = obj.Id; 253 } 244 254 245 255 ConvertObj(obj, row); … … 256 266 } 257 267 258 UnlockRow( obj.Id);268 UnlockRow(locked); 259 269 } 260 270 } -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ClientAdapter.cs
r1166 r1175 27 27 using HeuristicLab.Hive.Contracts.BusinessObjects; 28 28 using System.Linq.Expressions; 29 using System.Runtime.CompilerServices;30 29 31 30 namespace HeuristicLab.Hive.Server.ADODataAccess { … … 79 78 80 79 private void Preprocess(ClientInfo client) { 81 if (client != null) { 82 if (client.Id == default(long)) { 83 ClientInfo found = GetById(client.ClientId); 84 if (found != null) 85 client.Id = found.Id; 86 } 80 if (client != null && client.Id == default(long)) { 81 ClientInfo found = GetById(client.ClientId); 82 if (found != null) 83 client.Id = found.Id; 87 84 } 88 85 } … … 215 212 216 213 #region IClientAdapter Members 217 [MethodImpl(MethodImplOptions.Synchronized)]218 214 public override void Update(ClientInfo client) { 219 215 if (client != null) { 216 Guid locked = Guid.Empty; 217 if (client.ClientId != Guid.Empty) { 218 LockRow(client.ClientId); 219 locked = client.ClientId; 220 } 221 220 222 Preprocess(client); 221 223 … … 223 225 224 226 base.Update(client); 227 228 if (locked != Guid.Empty) { 229 UnlockRow(locked); 230 } 225 231 } 226 232 } … … 248 254 } 249 255 250 [MethodImpl(MethodImplOptions.Synchronized)] 251 public override bool Delete(ClientInfo client) { 256 public override bool Delete(ClientInfo client) { 257 bool success = false; 258 Guid locked = Guid.Empty; 259 252 260 if (client != null) { 261 if (client.ClientId != Guid.Empty) { 262 LockRow(client.ClientId); 263 locked = client.ClientId; 264 } 265 253 266 Preprocess(client); 254 267 … … 264 277 } 265 278 266 returnbase.Delete(client) &&279 success = base.Delete(client) && 267 280 ResAdapter.Delete(client); 268 281 } 269 282 } 270 283 271 return false; 284 if (locked != Guid.Empty) { 285 UnlockRow(locked); 286 } 287 288 return success; 272 289 } 273 290 -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ClientGroupAdapter.cs
r1166 r1175 27 27 using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess; 28 28 using HeuristicLab.Hive.Contracts.BusinessObjects; 29 using System.Runtime.CompilerServices;30 29 using System.Data; 31 30 … … 233 232 234 233 #region IClientGroupAdapter Members 235 [MethodImpl(MethodImplOptions.Synchronized)]236 234 public override void Update(ClientGroup group) { 237 235 if (group != null) { … … 273 271 } 274 272 275 [MethodImpl(MethodImplOptions.Synchronized)]276 273 public override bool Delete(ClientGroup group) { 277 274 if (group != null) { -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/DataAdapterBase.cs
r1134 r1175 37 37 new Mutex(); 38 38 39 private static IDictionary< long, Mutex> lockers =40 new Dictionary< long, Mutex>();41 42 private static IDictionary< long, int> lockCount =43 new Dictionary< long, int>();44 45 protected void LockRow( longid) {39 private static IDictionary<object, Mutex> lockers = 40 new Dictionary<object, Mutex>(); 41 42 private static IDictionary<object, int> lockCount = 43 new Dictionary<object, int>(); 44 45 protected void LockRow(object id) { 46 46 Mutex rowLock = null; 47 47 … … 62 62 } 63 63 64 protected void UnlockRow( longid) {64 protected void UnlockRow(object id) { 65 65 Mutex rowLock = lockers[id]; 66 66 rowLock.ReleaseMutex(); … … 163 163 public virtual void Update(ObjT obj) { 164 164 if (obj != null) { 165 RowT row = 166 GetRowById(obj.Id); 165 RowT row = null; 166 long locked = default(long); 167 168 if (obj.Id != default(long)) { 169 LockRow(obj.Id); 170 locked = obj.Id; 171 172 row = GetRowById(obj.Id); 173 } 167 174 168 175 if (row == null) { 169 176 row = InsertNewRow(obj); 170 177 UpdateRow(row); 178 179 obj.Id = (long)row[row.Table.PrimaryKey[0]]; 171 180 } 172 181 173 obj.Id = (long)row[row.Table.PrimaryKey[0]]; 174 LockRow(obj.Id); 182 if (locked == default(long)) { 183 LockRow(obj.Id); 184 locked = obj.Id; 185 } 175 186 176 187 ConvertObj(obj, row); 177 188 UpdateRow(row); 178 189 179 UnlockRow( obj.Id);190 UnlockRow(locked); 180 191 } 181 192 } -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/JobAdapter.cs
r1169 r1175 27 27 using HeuristicLab.Hive.Contracts.BusinessObjects; 28 28 using System.Linq.Expressions; 29 using System.Runtime.CompilerServices;30 29 31 30 namespace HeuristicLab.Hive.Server.ADODataAccess { … … 119 118 job.DateCalculated = DateTime.MinValue; 120 119 121 job.Priority = row.Priority; 120 if (!row.IsPriorityNull()) 121 job.Priority = row.Priority; 122 else 123 job.Priority = default(int); 122 124 123 125 return job; … … 332 334 } 333 335 334 [MethodImpl(MethodImplOptions.Synchronized)]335 336 public override bool Delete(Job job) { 336 337 if (job != null) { -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/PermissionOwnerAdapter.cs
r1166 r1175 27 27 using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess; 28 28 using HeuristicLab.Hive.Contracts.BusinessObjects; 29 using System.Runtime.CompilerServices;30 29 31 30 namespace HeuristicLab.Hive.Server.ADODataAccess { -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ResourceAdapter.cs
r1166 r1175 26 26 using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess; 27 27 using HeuristicLab.Hive.Contracts.BusinessObjects; 28 using System.Runtime.CompilerServices;29 28 30 29 namespace HeuristicLab.Hive.Server.ADODataAccess { -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/UserAdapter.cs
r1166 r1175 27 27 using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess; 28 28 using HeuristicLab.Hive.Contracts.BusinessObjects; 29 using System.Runtime.CompilerServices;30 29 31 30 namespace HeuristicLab.Hive.Server.ADODataAccess { … … 136 135 #region IUserAdapter Members 137 136 138 [MethodImpl(MethodImplOptions.Synchronized)]139 137 public override void Update(User user) { 140 138 if (user != null) { … … 156 154 } 157 155 158 [MethodImpl(MethodImplOptions.Synchronized)]159 156 public override bool Delete(User user) { 160 157 if (user != null) { -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/UserGroupAdapter.cs
r1166 r1175 27 27 using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess; 28 28 using HeuristicLab.Hive.Contracts.BusinessObjects; 29 using System.Runtime.CompilerServices;30 29 using System.Data; 31 30 … … 234 233 235 234 #region IUserGroupAdapter Members 236 [MethodImpl(MethodImplOptions.Synchronized)]237 235 public override void Update(UserGroup group) { 238 236 if (group != null) { … … 273 271 } 274 272 275 [MethodImpl(MethodImplOptions.Synchronized)]276 273 public override bool Delete(UserGroup group) { 277 274 if (group != null) { -
trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/DataAccess/IDataAdapter.cs
r1005 r1175 24 24 using System.Linq; 25 25 using System.Text; 26 using HeuristicLab.Hive.Contracts.BusinessObjects; 26 27 27 28 namespace HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess { 28 public interface IDataAdapter<ObjT> { 29 public interface IDataAdapter<ObjT> 30 where ObjT: IHiveObject 31 { 29 32 /// <summary> 30 33 /// Save or update the object
Note: See TracChangeset
for help on using the changeset viewer.