- Timestamp:
- 08/24/10 02:37:56 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Services.OKB/3.3/RunnerService.cs
r4279 r4298 142 142 public void AddRun(Algorithm algorithm, Problem problem, Project project) { 143 143 Log("adding run for {0}@{1}({2})[{3}, {4}]", 144 algorithm.Name, problem.Name, project.Name, authentication.User.Name, authentication.Client.Name);144 algorithm.Name, problem.Name, project.Name, currentUser.Name, currentClient.Name); 145 145 try { 146 146 using (OKBDataContext okb = new OKBDataContext()) { 147 var user = okb.Users.Single(u => u.Id == authentication.User.Id); 148 var client = okb.Clients.Single(c => c.Id == authentication.Client.Id); 149 Experiment experiment = GetOrCreateExperiment(algorithm, problem, project, authentication.User, okb); 147 Experiment experiment = GetOrCreateExperiment(algorithm, problem, project, currentUser, okb); 150 148 Run run = new Run() { 151 149 Experiment = experiment, 152 UserId = authentication.User.Id,153 ClientId = authentication.Client.Id,150 UserId = currentUser.Id, 151 ClientId = currentClient.Id, 154 152 FinishedDate = DateTime.Now, 155 153 ResultValues = algorithm.ResultValues … … 175 173 Log("reusing existing experiment"); 176 174 Experiment experiment = experimentQuery.First(); 177 if (experiment.ExperimentCreators.Where(ec => ec.UserId == user.Id).Count() == 0) {178 experiment.ExperimentCreators.Add(new ExperimentCreator() { UserId = user.Id });179 }180 175 return experiment; 181 176 } else { … … 187 182 ParameterValues = algorithm.ParameterValues 188 183 }; 189 experiment.ExperimentCreators.Add(new ExperimentCreator() { UserId = user.Id });190 184 okb.Experiments.InsertOnSubmit(experiment); 191 185 return experiment; … … 292 286 /// </summary> 293 287 /// <returns> 294 /// 288 /// <c>true</c> if this instance is connected; otherwise, <c>false</c>. 295 289 /// </returns> 296 290 public bool IsConnected() { 297 return authentication != null; 298 } 299 300 Authentication authentication = null; 291 return currentUser != null; 292 } 293 294 User currentUser = null; 295 Client currentClient = null; 301 296 302 297 /// <summary> … … 309 304 /// <param name="clientname">The clientname.</param> 310 305 /// <returns> 311 /// 306 /// <c>true</c> if the login was successful; <c>false</c> otherwise. 312 307 /// </returns> 313 308 public bool Login(string username, string clientname) { … … 320 315 } 321 316 using (OKBDataContext okb = new OKBDataContext()) { 322 authentication = new Authentication() { 323 User = okb.Users.SingleOrDefault(u => u.Name == username), 324 Client = okb.Clients.SingleOrDefault(c => c.Name == clientname) 325 }; 326 if (authentication.User == null) { 327 User user = new User() { Name = username, Id = Guid.NewGuid() }; 328 okb.Users.InsertOnSubmit(user); 329 authentication.User = user; 317 currentUser = okb.Users.SingleOrDefault(u => u.Name == username); 318 currentClient = okb.Clients.SingleOrDefault(c => c.Name == clientname); 319 if (currentUser == null) { 320 currentUser = new User() { Name = username, Id = Guid.NewGuid() }; 321 okb.Users.InsertOnSubmit(currentUser); 330 322 okb.SubmitChanges(); 331 323 } 332 if (authentication.Client == null) { 333 Client client = new Client() { Name = clientname, Id = Guid.NewGuid() }; 334 okb.Clients.InsertOnSubmit(client); 335 authentication.Client = client; 324 if (currentClient == null) { 325 currentClient = new Client() { Name = clientname, Id = Guid.NewGuid() }; 326 okb.Clients.InsertOnSubmit(currentClient); 336 327 okb.SubmitChanges(); 337 328 } 338 Log(" auth = {0}", authentication);329 Log(" user = {0}, client = {1}", currentUser, currentClient); 339 330 return true; 340 331 } … … 346 337 public void Logout() { 347 338 Log("Logging out"); 348 authentication = null; 339 currentUser = null; 340 currentClient = null; 349 341 } 350 342
Note: See TracChangeset
for help on using the changeset viewer.