private void CreateArchivePanel() { DeletedStudyArchiveInfoCollection archiveList = _viewModel.DeletedStudyRecord.Archives; Platform.CheckTrue(archiveList.Count > 0, "archiveList is empty"); // make sure the list is sorted by timestamp archiveList.Sort( (archive1, archive2) => archive2.ArchiveTime.CompareTo(archive1.ArchiveTime)); Control panel = LoadArchiveInformationPanel(GetArchiveType(archiveList[0]), archiveList[0]); ArchiveViewPlaceHolder.Controls.Add(panel); if (archiveList.Count > 1) { var container = new TabContainer { CssClass = "DialogTabControl" }; for (int i = 1; i < archiveList.Count; i++) { DeletedStudyArchiveInfo theArchive = archiveList[i]; Control detailPanel = LoadArchiveInformationPanel(GetArchiveType(theArchive), theArchive); var tabPanel = new TabPanel { HeaderText = String.Format("{0} {1}", DateTimeFormatter.Format(theArchive.ArchiveTime, DateTimeFormatter.Style. Date), TransferSyntax.GetTransferSyntax( theArchive.TransferSyntaxUid). LossyCompressed ? "(Lossy)" : String.Empty) }; tabPanel.Controls.Add(detailPanel); container.Tabs.Add(tabPanel); } AdditionalArchivePlaceHolder.Controls.Add(container); } AdditionalArchivePlaceHolder.Visible = archiveList.Count > 1; ArchiveViewPlaceHolder.DataBind(); AdditionalArchivePlaceHolder.DataBind(); }
public void OnStudyDeleting() { if (!Enabled) { return; } StudyStorageLocation storage = _context.StorageLocation; IList <ArchiveStudyStorage> archives = StudyStorageLocation.GetArchiveLocations(storage.GetKey()); if (archives != null && archives.Count > 0) { _archives = new DeletedStudyArchiveInfoCollection(); foreach (ArchiveStudyStorage archive in archives) { DeletedStudyArchiveInfo archiveInfo = new DeletedStudyArchiveInfo(); archiveInfo.ArchiveTime = archive.ArchiveTime; archiveInfo.ArchiveXml = archive.ArchiveXml; archiveInfo.PartitionArchiveRef = PartitionArchive.Load(archive.PartitionArchiveKey).GetKey().Key; archiveInfo.TransferSyntaxUid = archive.ServerTransferSyntax.Uid; _archives.Add(archiveInfo); } } // only backup if study is manually deleted if (_context.WorkQueueItem.WorkQueueTypeEnum == WorkQueueTypeEnum.WebDeleteStudy) { using (var processor = new ServerCommandProcessor("Backup deleted study")) { string path = _context.Filesystem.ResolveAbsolutePath(BackupSubPath); Platform.Log(LogLevel.Info, "Saving a copy of the study to {0}...", path); var mkdir = new CreateDirectoryCommand(path); processor.AddCommand(mkdir); var zip = new ZipStudyFolderCommand(storage.GetStudyPath(), BackupFullPath); processor.AddCommand(zip); if (!processor.Execute()) { throw new ApplicationException(String.Format("Unable to backup study: {0}", processor.FailureReason)); } } } }