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);
        }
示例#3
0
        public WadoResponse(IStorageLocation location, string mimeType)
        {
            StorageLocation = location;

            Content       = StorageLocation.GetReadStream( );
            ContentLength = Content.Length;
            MimeType      = mimeType;
        }
示例#4
0
 protected override void Upload
 (
     fo.DicomDataset dicomDataset,
     int frame,
     IStorageLocation location,
     DicomMediaProperties mediaProperties)
 {
     location.Upload(System.Text.Encoding.UTF8.GetBytes(Converter.Convert(dicomDataset)), MediaType);
 }
示例#5
0
        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);
        }
示例#6
0
        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);
        }
示例#8
0
        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);
        }
示例#12
0
        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);
        }
示例#14
0
        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);
            }
        }
示例#15
0
        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);
        }
示例#16
0
 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);
示例#19
0
 public ObjectRetrieveResult(IStorageLocation location, string transfer)
 {
     Location       = location;
     TransferSyntax = transfer;
 }
示例#20
0
 public void DeleteLocation(IStorageLocation location)
 {
     location.Delete( );
 }
示例#21
0
 protected abstract void Upload(fo.DicomDataset dataset, int frame, IStorageLocation storeLocation);
示例#22
0
 public LocationMessage(IStorageLocation location)
 {
     Location = location;
 }
示例#23
0
 public void DeleteLocation(IStorageLocation location)
 {
     throw new NotImplementedException();
 }
示例#24
0
 protected override void Upload(fo.DicomDataset dicomDataset, int frame, IStorageLocation location)
 {
     location.Upload(System.Text.Encoding.UTF8.GetBytes(Converter.Convert(dicomDataset)));
 }
示例#25
0
 public LocationDeletedMessage(IStorageLocation location) : base(location)
 {
 }
示例#26
0
        public IBackupSet GetBackupSet(IStorageLocation location, string backupSetPath)
        {
            var latestBackup = GetMostRecentBackupIndex(location);

            return(latestBackup.BackupSets.FirstOrDefault(s => backupSetPath.Equals(s.BasePath, StringComparison.CurrentCultureIgnoreCase)));
        }
示例#27
0
 public LocationUploadedMessage(IStorageLocation location) : base(location)
 {
 }
示例#28
0
 public IBackupIndex GetMostRecentBackupIndex(IStorageLocation location)
 {
     return(BackupIndexes
            .Where(b => b.RootPath.Equals(location.RootPath, StringComparison.CurrentCultureIgnoreCase))
            .OrderByDescending(b => b.BackupDate).FirstOrDefault());
 }