Пример #1
0
        private void menuItem5_Click(object sender, System.EventArgs e)
        {
            //File/Save
            sFD1.ShowDialog();
            if (sFD1.FileName == "")
            {
                return;
            }

            CurDCM.WriteFile(sFD1.FileName, new NullLogger());
        }
Пример #2
0
        private void listener_StoreRequest(DICOMConnection conn, DICOMData data)
        {
            try
            {
                if (!this._settings.StoreMetadataOnlyFiles && !data.Elements.ContainsKey(DICOMTags.PixelData))
                {
                    this._logger.Log(LogLevel.Info, "Data set has no image data (only metadata). Metadata storing is disabled, so image will not be persisted.");
                    conn.SendCSTORERSP(CommandStatus.Error_MissingAttribute);
                    return;
                }

                if (this._settings.AutoDecompress && data.TransferSyntax.Compression != DICOMSharp.Data.Compression.CompressionInfo.None)
                {
                    this._logger.Log(LogLevel.Info, "Image is compressed, decompressing before storage!");
                    if (!data.Uncompress())
                    {
                        this._logger.Log(LogLevel.Warning, "Image decompression failed! Storing compressed image.");
                    }
                }

                string postName = FileUtil.GenerateFilenameFromImage(data, this._logger);

                //form full file path
                string diskPath = _db.FixImagePath(this._settings.ImageStoragePath);
                if (!diskPath.EndsWith("\\"))
                {
                    diskPath += "\\";
                }
                diskPath += postName;

                data.WriteFile(diskPath, this._logger);

                // Db path can save a ~ path, so recalc without MapPath
                string dbPath = this._settings.ImageStoragePath;
                if (!dbPath.EndsWith("\\"))
                {
                    dbPath += "\\";
                }
                dbPath += postName;

                this._db.PersistImage(data, diskPath, dbPath);

                conn.SendCSTORERSP(CommandStatus.Success);
            }
            catch (Exception e)
            {
                this._logger.Log(LogLevel.Error, "Error in StoreRequest: " + e.ToString());
                conn.SendCSTORERSP(CommandStatus.Error_UnrecognizedOperation);
            }
        }
Пример #3
0
        private TaskInfo ImportFromPath(string basePath)
        {
            var taskInfo = new TaskInfo()
            {
                Token = new CancellationTokenSource()
            };

            taskInfo.Task = Task.Run(() =>
            {
                taskInfo.Token.Token.ThrowIfCancellationRequested();

                this._logger.Log(LogLevel.Info, "Importing from Path: " + basePath);

                DirectoryInfo di = new DirectoryInfo(basePath);
                if (!di.Exists)
                {
                    this._logger.Log(LogLevel.Error, "Directory not found!");
                    return;
                }
                else
                {
                    FileUtil.ImageAddedHandler callback = (DICOMData data, string path) =>
                    {
                        taskInfo.ProgressCount++;
                        taskInfo.ProgressTotal++;

                        if (!data.Elements.ContainsKey(DICOMTags.PixelData) && !this._settings.StoreMetadataOnlyFiles)
                        {
                            this._logger.Log(LogLevel.Info, "Data set has no image data (only metadata). Metadata storing is disabled, so image will not be persisted.");
                            return;
                        }

                        if (this._settings.AutoDecompress && data.TransferSyntax.Compression != DICOMSharp.Data.Compression.CompressionInfo.None)
                        {
                            this._logger.Log(LogLevel.Info, "Image is compressed, decompressing in place!");

                            DICOMData fullData = new DICOMData();
                            if (fullData.ParseFile(path, true, this._logger))
                            {
                                if (fullData.Uncompress())
                                {
                                    if (fullData.WriteFile(path, this._logger))
                                    {
                                        // Stuff the new decompressed and written file into the DB instead
                                        data = fullData;
                                    }
                                    else
                                    {
                                        this._logger.Log(LogLevel.Warning, "Failed to write out decompressed file! Storing compressed image.");
                                    }
                                }
                                else
                                {
                                    this._logger.Log(LogLevel.Warning, "Image decompression failed! Storing compressed image.");
                                }
                            }
                            else
                            {
                                this._logger.Log(LogLevel.Warning, "Couldn't parse full image data! Storing compressed image.");
                            }
                        }

                        this._db.PersistImage(data, path, path);
                    };

                    FileUtil.ParseAndLoadImagesFromDirectoryRecursively(di, callback, this._logger, taskInfo.Token.Token);
                }

                this._logger.Log(LogLevel.Info, "Done Importing from Path: " + basePath);
            }, taskInfo.Token.Token);

            return(taskInfo);
        }