void CreateArchivePackage() { if (hasFailure) { return; } ArchivePackageBuilder.CreateArchivePackage(record, ProcessingDirectory, true, ArchiveDirectory, "published"); record.ArchiveDate = DateTime.UtcNow; // Mark this step as done. var task = db.TaskStatuses.Where(x => x.CatalogRecord.Id == record.Id && x.TaskId == BuiltInCatalogRecordTasks.ArchiveCatalogRecordTaskId) .FirstOrDefault(); if (task != null) { task.IsComplete = true; task.CompletedDate = DateTime.UtcNow; task.CompletedBy = user; } LogEvent(EventTypes.CreateArchivePackage, "Created Archive Package"); }
public bool Execute() { using (db = ApplicationDbContext.Create()) { var siteSettings = GetSiteSettings(); var user = db.Users.Find(UserId.ToString()); var record = db.CatalogRecords.Where(x => x.Id == CatalogRecordId) .Include(x => x.Organization) .Include(x => x.Files) .Include(x => x.CreatedBy) .Include(x => x.Approvers) .FirstOrDefault(); logger.Debug("Archiving ingest files for " + record.Title); // Create the archive package. try { ArchivePackageBuilder.CreateArchivePackage(record, IngestDirectory, false, ArchiveDirectory, "ingest"); // Log an event. var log = new Event() { EventType = EventTypes.CreateArchivePackage, Timestamp = DateTime.UtcNow, User = user, RelatedCatalogRecord = record, Title = "Archived ingest files for " + record.Title, Details = string.Empty }; db.Events.Add(log); db.SaveChanges(); } catch (Exception ex) { logger.Warn("Error while archiving ingest files", ex); // Log an event. var log = new Event() { EventType = EventTypes.CreateArchivePackage, Timestamp = DateTime.UtcNow, User = user, RelatedCatalogRecord = record, Title = "Error while archiving ingest files for " + record.Title, Details = ex.Message }; db.Events.Add(log); db.SaveChanges(); } return(true); } }