/// <summary> /// Marks the file as completed so that it doesn't get interrogated repeatedly /// </summary> /// <param name="file"></param> private void MarkFileDone(TrackedFile file) { using (DbModelContainer db = new DbModelContainer()) { //Remove was giving poor performance for large result //sets, presumably because of how EF handles junction //tables, so a SPROC does it. db.MarkFileDone(file.Id, this.Id); } }
/// <summary> /// Categorises the file as having matches at least /// one of the supplied regexes or strings, using /// the category assigned to this search job /// </summary> /// <param name="file">the file to categorise</param> private void CategoriseFile(TrackedFile file) { using (DbModelContainer db = new DbModelContainer()) { //Can't use attach here as was getting exceptions to do //with EF graph tracking. I think the way that the //converter works between the SPROC for getting due files //and tracked files causes the issue, not a major issue //to do it this way though, has no other bearing on the //rest of the code TrackedFile fileToMark = db.TrackedFiles.Find(file.Id); SearchJob job = db.SearchJobs.Find(this.Id); Category category = db.Categories.Find(job.Category.Id); fileToMark.Categories.Add(category); db.SaveChanges(); } }