- Timestamp:
- 06/28/09 14:28:30 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs
r2117 r2122 37 37 using HeuristicLab.DataAccess.Interfaces; 38 38 using System.IO; 39 using System.Runtime.Serialization.Formatters.Binary; 39 40 40 41 namespace HeuristicLab.Hive.Server.Core { … … 465 466 466 467 public ResponseResultReceived ProcessJobResult( 467 JobResult result,468 468 Stream stream, 469 469 bool finished) { … … 474 474 475 475 try { 476 BinaryFormatter formatter = 477 new BinaryFormatter(); 478 479 JobResult result = 480 (JobResult)formatter.Deserialize(stream); 481 476 482 tx = session.BeginTransaction(); 477 483 … … 485 491 finished); 486 492 487 //second deserialize the BLOB 488 IJobResultsAdapter jobResultsAdapter = 489 session.GetDataAdapter<JobResult, IJobResultsAdapter>(); 490 491 IJobAdapter jobAdapter = 492 session.GetDataAdapter<Job, IJobAdapter>(); 493 494 jobResultStream = 495 jobResultsAdapter.GetSerializedJobResultStream(result.Id, true); 496 497 jobStream = 498 jobAdapter.GetSerializedJobStream(result.JobId, true); 499 500 byte[] buffer = new byte[3024]; 501 int read = 0; 502 while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) { 503 jobResultStream.Write(buffer, 0, read); 504 505 if (finished) 493 if (response.Success) { 494 //second deserialize the BLOB 495 IJobResultsAdapter jobResultsAdapter = 496 session.GetDataAdapter<JobResult, IJobResultsAdapter>(); 497 498 IJobAdapter jobAdapter = 499 session.GetDataAdapter<Job, IJobAdapter>(); 500 501 jobResultStream = 502 jobResultsAdapter.GetSerializedJobResultStream(response.JobResultId, true); 503 504 jobStream = 505 jobAdapter.GetSerializedJobStream(result.JobId, true); 506 507 byte[] buffer = new byte[3024]; 508 int read = 0; 509 while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) { 510 jobResultStream.Write(buffer, 0, read); 506 511 jobStream.Write(buffer, 0, read); 507 } 508 509 jobStream.Close(); 510 511 tx.Commit(); 512 } 513 514 jobResultStream.Close(); 515 jobStream.Close(); 516 517 tx.Commit(); 518 } 512 519 513 520 return response; … … 565 572 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOB_WITH_THIS_ID; 566 573 response.JobId = jobId; 574 tx.Rollback(); 567 575 return response; 568 576 } … … 570 578 response.Success = false; 571 579 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_WAS_ABORTED; 580 tx.Rollback(); 581 return response; 572 582 } 573 583 if (job.JobInfo.Client == null) { … … 575 585 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED; 576 586 response.JobId = jobId; 587 tx.Rollback(); 577 588 return response; 578 589 } … … 581 592 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_CLIENT_FOR_JOB; 582 593 response.JobId = jobId; 594 tx.Rollback(); 583 595 return response; 584 596 } … … 587 599 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOBRESULT_RECEIVED; 588 600 response.JobId = jobId; 601 tx.Rollback(); 589 602 return response; 590 603 } … … 597 610 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_JOB_STATE; 598 611 response.JobId = jobId; 612 tx.Rollback(); 599 613 return response; 600 614 } … … 602 616 603 617 if (finished) { 604 job.JobInfo.State = State.finished; 605 job.SerializedJobData = result; 606 jobAdapter.UpdateSerializedJob(job); 607 } 618 job.JobInfo.State = State.finished; 619 } 620 621 job.SerializedJobData = result; 622 jobAdapter.UpdateSerializedJob(job); 608 623 609 624 List<JobResult> jobResults = new List<JobResult>( … … 625 640 626 641 jobResultAdapter.UpdateSerializedJobResult(serializedjobResult); 627 jobAdapter.Update(job.JobInfo);628 642 629 643 response.Success = true; … … 631 645 response.JobId = jobId; 632 646 response.finished = finished; 647 response.JobResultId = jobResult.Id; 633 648 634 649 tx.Commit();
Note: See TracChangeset
for help on using the changeset viewer.