public Source FeedSource(int feedingSourceId) { FeedingSource fs = this.GetFeedingSource(feedingSourceId); if (fs != null && fs.FileData != null) { Source s = new Source(); s.SourceName = fs.Name; s.SourcePath = fs.Name; s.SourceDate = DateTime.Now; s.FileExtension = FileUtil.GetExtension(fs.Name); s.FileData = fs.FileData; s.IsRestricted = fs.Restricted; s.IsReadOnly = fs.IsReadOnly; s.Notes = "Fed from FeedingSourceID=" + fs.Id; if (!string.IsNullOrEmpty(fs.UploadNotes)) { s.Notes += "\n\n" + fs.UploadNotes; } s.FileDateTimeStamp = fs.FileModifiedDateTime; foreach (SourceAuthor a in fs.SourceAuthors) { s.AddSourceAuthor(a); } foreach (SourceOwningEntity e in fs.SourceOwningEntities) { s.AddSourceOwningEntity(e); } // persist Source s = this.sourceTasks.SaveSource(s); // link FeedingSource with Source fs.Source = s; s.AddFeedingSource(fs); // persist the join fs = this.SaveFeedingSource(fs); // queue ocr scan of new source var jobId = BackgroundJob.Enqueue <ISourceContentTasks>(x => x.OcrScanAndSetSourceQueueable(s.Id)); // queue indexing of the new Source BackgroundJob.ContinueWith <ISourceTasks>(jobId, x => x.IndexSourceQueueable(s.Id, s.HasUploadedBy() ? s.GetUploadedBy().UserID : string.Empty, s.SourceAuthors.Select(y => y.Author).ToList(), s.SourceOwningEntities.Select(y => y.Name).ToList(), s.JhroCase != null ? s.JhroCase.CaseNumber : string.Empty, this.sourceTasks.GetSourceDTO(s.Id).FileSize) ); return(s); } return(null); }
public Source SaveSource(ISession session, Source s) { // check if we can automatically add a SourceOwningEntity if (!string.IsNullOrEmpty(s.SourcePath)) { IList <SourceOwningEntity> owners = this.sourcePermissionTasks.GetSourceOwningEntities(session, s.GetSourcePathOnly()); if (owners != null && owners.Any()) { s.AddSourceOwningEntity(owners.First()); } } this.sourceQueries.SaveSource(session, s); return(s); }