Skip to content

Commit

Permalink
independentDatabase, required only on secondary threads
Browse files Browse the repository at this point in the history
  • Loading branch information
rossetantoine committed Oct 28, 2013
1 parent c3f2e5e commit 12f070e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions WebPortal+Email+Log.mm
Expand Up @@ -200,9 +200,13 @@ -(void)updateLogEntryForStudy:(DicomStudy*)study withMessage:(NSString*)message
{
if ([[NSUserDefaults standardUserDefaults] boolForKey: @"logWebServer"] == NO) return;

// [self.dicomDatabase.managedObjectContext lock];

DicomDatabase* independentDatabase = self.dicomDatabase.independentDatabase;
DicomDatabase* independentDatabase = nil;

if( [NSThread isMainThread])
independentDatabase = self.dicomDatabase;
else
independentDatabase = self.dicomDatabase.independentDatabase;

@try {
if (user)
message = [user stringByAppendingFormat:@": %@", message];
Expand All @@ -213,7 +217,6 @@ -(void)updateLogEntryForStudy:(DicomStudy*)study withMessage:(NSString*)message
// Search for same log entry during last 5 min
NSArray* logs = NULL;


NSPredicate* predicate = [NSPredicate predicateWithFormat: @"(patientName==%@) AND (studyName==%@) AND (message==%@) AND (originName==%@) AND (endTime >= CAST(%lf, \"NSDate\"))", study.name, study.studyName, message, ip, [[NSDate dateWithTimeIntervalSinceNow: -5 * 60] timeIntervalSinceReferenceDate]];
logs = [independentDatabase objectsForEntity:independentDatabase.logEntryEntity predicate:predicate];

Expand Down

0 comments on commit 12f070e

Please sign in to comment.