public async Task <bool> RestoreFile(IStorageLocation location, string filePath, string destinationPath = null) { var outPath = destinationPath ?? filePath; var hash = Catalog.GetFileNodeFromPath(location, filePath); return(await RestoreFileToDisk(hash, outPath)); }
private async Task <bool> StoreBranch(IStorageLocation location, string basePath, Branch root) { var results = true; foreach (var subtree in root.Subtrees) { var newPath = Path.Combine(basePath, subtree.Name); var success = await StoreBranch(location, newPath, subtree); if (!success) { results = false; } } foreach (var node in root.Nodes) { var filePath = Path.Combine(basePath, node.Name); Logger.LogDebug($"Storing file - {filePath}"); node.BackedUp = await location.StoreFile(filePath, node.Hash); if (!node.BackedUp) { results = false; } } return(results); }
public WadoResponse(IStorageLocation location, string mimeType) { StorageLocation = location; Content = StorageLocation.GetReadStream( ); ContentLength = Content.Length; MimeType = mimeType; }
protected override void Upload ( fo.DicomDataset dicomDataset, int frame, IStorageLocation location, DicomMediaProperties mediaProperties) { location.Upload(System.Text.Encoding.UTF8.GetBytes(Converter.Convert(dicomDataset)), MediaType); }
public Node GetFileNodeFromPath(IStorageLocation storageLocation, string path) { var latestBackup = GetMostRecentBackupIndex(storageLocation); var matchingSet = latestBackup.BackupSets.FirstOrDefault(s => path.Contains(s.BasePath)); var node = matchingSet?.FindNode(path); return(node); }
protected override void Upload(fo.DicomDataset dicomObject, int frame, IStorageLocation storeLocation) { var frameIndex = frame - 1; DicomPixelData pd = DicomPixelData.Create(dicomObject); byte[] buffer = pd.GetFrame(frameIndex).Data; storeLocation.Upload(buffer); }
protected override void Upload(DicomFile dicomObject, int frame, IStorageLocation storeLocation) { DicomPixelData pd = null; byte[] buffer = null; pd = DicomPixelData.CreateFrom(dicomObject); buffer = pd.GetFrame(frame - 1); storeLocation.Upload(buffer); }
protected override void Upload(fo.DicomDataset dicomDataset, int frame, IStorageLocation location) { fo.DicomFile df = new fo.DicomFile(dicomDataset); using (Stream stream = new MemoryStream()) { df.Save(stream); stream.Position = 0; location.Upload(stream); } }
public async Task <bool> RestoreBackupSet(IStorageLocation location, string backupSetPath, string destinationPath = null) { Logger.LogDebug($"Restoring BackupSet {backupSetPath}"); var backupSet = Catalog.GetBackupSet(location, backupSetPath); var outPath = destinationPath ?? backupSetPath; outPath = Path.Combine(outPath, backupSet.Root.Name); var destination = BackupIOFactory.GetBackupDirectory(outPath); if (!destination.Exists) { destination.Create(); } return(await RestoreBranch(backupSet.Root, backupSet.BasePath, outPath)); }
protected override void Upload(DicomFile dicomObject, int frame, IStorageLocation location) { if (!string.IsNullOrWhiteSpace(dicomObject.Filename)) { location.Upload(dicomObject.Filename); } else { using (Stream stream = new MemoryStream()) { dicomObject.Save(stream, DicomWriteOptions.Default); stream.Position = 0; location.Upload(stream); } } }
private async Task <bool> StoreBackupSets(IStorageLocation location, IBackupIndex filesToStore) { var results = true; foreach (var backupSet in filesToStore.BackupSets) { var basePath = backupSet.BasePath; var success = await StoreBranch(location, basePath, backupSet.Root); if (!success) { results = false; } } return(results); }
protected override void Upload(DicomFile dicomObject, int frame, IStorageLocation storeLocation) { var frameIndex = frame - 1; if (dicomObject.TransferSyntax == TransferSyntax.JpegBaselineProcess1) { DicomCompressedPixelData pd = DicomPixelData.CreateFrom(dicomObject) as DicomCompressedPixelData; byte[] buffer = pd.GetFrameFragmentData(frameIndex); storeLocation.Upload(buffer); } else if (false) //TODO: handle compressed images properly! { DicomFile dcmJpeg = new DicomFile( ); DicomUncompressedPixelData unCompressed = DicomPixelData.CreateFrom(dicomObject) as DicomUncompressedPixelData; DicomCompressedPixelData compressed = new DicomCompressedPixelData(unCompressed); //compressed.ImageWidth = unCompressed.ImageWidth; //compressed.ImageHeight = unCompressed.HighBit; compressed.BitsStored = 8; compressed.BitsAllocated = 8; //compressed.HighBit = 7; compressed.SamplesPerPixel = 3; //compressed.PlanarConfiguration = 0; compressed.PhotometricInterpretation = "YBR_FULL_422"; compressed.TransferSyntax = TransferSyntax.JpegBaselineProcess1; byte[] imageBuffer = unCompressed.GetFrame(frameIndex); compressed.AddFrameFragment(imageBuffer); compressed.UpdateMessage(dcmJpeg); storeLocation.Upload(compressed.GetFrame(frameIndex)); //ClearCanvas.Dicom.Codec.Jpeg.Jpeg8Codec codec = new ClearCanvas.Dicom.Codec.Jpeg.Jpeg8Codec (ClearCanvas.Dicom.Codec.Jpeg.JpegMode.Baseline, 0, 0 ) ; //ClearCanvas.Dicom.Codec.Jpeg.DicomJpegParameters jparam = new ClearCanvas.Dicom.Codec.Jpeg.DicomJpegParameters ( ) ; //jparam. //codec. //codec.Encode ( ) } }
protected override void Upload(fo.DicomDataset dicomDataset, int frame, IStorageLocation storeLocation) { var uncompressedData = new UncompressedPixelDataWrapper(dicomDataset); var buffer = uncompressedData.PixelData.GetFrame(frame - 1); var data = new byte[0]; try { //TODO: check fo-dicom, dicom file with no data will throw an exception althoug //it is wrapped with a RangeByteBuffer but Internal is EmptyBuffer //only way to find out is to ignore exception data = buffer.Data; } catch {} storeLocation.Upload(data); }
protected override void Upload ( DicomDataset dicomDataset, int frame, IStorageLocation location, DicomMediaProperties mediaProperties ) { DicomFile df = new DicomFile(dicomDataset); using (Stream stream = new MemoryStream()) { df.Save(stream); stream.Position = 0; location.Upload(stream, MediaType); } }
protected override void Upload ( fo.DicomDataset dicomObject, int frame, IStorageLocation storeLocation, DicomMediaProperties mediaProperties ) { var frameIndex = frame - 1; var dicomImage = new DicomImage(dicomObject, frameIndex); var bitmap = dicomImage.RenderImage(frameIndex).AsBitmap(); var stream = new MemoryStream( ); bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); stream.Position = 0; storeLocation.Upload(stream, MediaType); }
protected override void Upload(DicomFile data, int frame, IStorageLocation location) { location.Upload(System.Text.Encoding.UTF8.GetBytes(Converter.Convert(data.DataSet))); }
protected abstract void Upload(DicomFile dicomObject, int frame, IStorageLocation storeLocation);
protected abstract void Upload(fo.DicomDataset dataset, int frame, IStorageLocation storeLocation, DicomMediaProperties mediaProperties);
public ObjectRetrieveResult(IStorageLocation location, string transfer) { Location = location; TransferSyntax = transfer; }
public void DeleteLocation(IStorageLocation location) { location.Delete( ); }
protected abstract void Upload(fo.DicomDataset dataset, int frame, IStorageLocation storeLocation);
public LocationMessage(IStorageLocation location) { Location = location; }
public void DeleteLocation(IStorageLocation location) { throw new NotImplementedException(); }
protected override void Upload(fo.DicomDataset dicomDataset, int frame, IStorageLocation location) { location.Upload(System.Text.Encoding.UTF8.GetBytes(Converter.Convert(dicomDataset))); }
public LocationDeletedMessage(IStorageLocation location) : base(location) { }
public IBackupSet GetBackupSet(IStorageLocation location, string backupSetPath) { var latestBackup = GetMostRecentBackupIndex(location); return(latestBackup.BackupSets.FirstOrDefault(s => backupSetPath.Equals(s.BasePath, StringComparison.CurrentCultureIgnoreCase))); }
public LocationUploadedMessage(IStorageLocation location) : base(location) { }
public IBackupIndex GetMostRecentBackupIndex(IStorageLocation location) { return(BackupIndexes .Where(b => b.RootPath.Equals(location.RootPath, StringComparison.CurrentCultureIgnoreCase)) .OrderByDescending(b => b.BackupDate).FirstOrDefault()); }