Пример #1
0
        private bool CreatSOPFromDataHerderFile(XmlNode currNode)
        {
            //没有SopInstanceUID或者从数据库中找不到该SopInstanceUID
            bool result = false;

            this.DataHeaderFilePath = currNode.Attributes[OffScreenRenderXmlHelper.DATA_HEADER_FILE_PATH].Value;
            if (!string.IsNullOrEmpty(currNode.Attributes[OffScreenRenderXmlHelper.DATA_HEADER_LENGTH].Value))
            {
                this.DataHeaderLength = int.Parse(currNode.Attributes[OffScreenRenderXmlHelper.DATA_HEADER_LENGTH].Value);
            }

            if (!string.IsNullOrEmpty(this.DataHeaderFilePath))
            {
                if (File.Exists(this.DataHeaderFilePath))
                {
                    byte[] byteData = new byte[this.DataHeaderLength];
                    using (var fs = new FileStream(this.DataHeaderFilePath, FileMode.Open))
                    {
                        int read;
                        while ((read = fs.Read(byteData, 0, byteData.Length)) > 0)
                        {
                            fs.Write(byteData, 0, read);
                        }
                        fs.Close();
                    }
                    //删除文件
                    File.Delete(this.DataHeaderFilePath);

                    this.DataHeader = DicomAttributeCollection.Deserialize(byteData);
                    if (null == this.DataHeader)
                    {
                        Logger.LogWarning("[FilmingSerivceFE] Fail to Deserialized DicomAttributeCollection !");
                    }
                    this.Sop = SopInstanceFactory.Create(this.DataHeader, string.Empty);
                    this.Ps  = (this.Sop as ImageSop).PresentationState;
                    result   = true;
                }
                else
                {
                    Logger.LogError("[FilmingSerivceFE] CreatSOPFromDataHerderFile DataHeaderFilePath not exist !");
                }
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        /// use dicom convertor to load image
        /// </summary>
        /// <param name="fileFullPath"></param>
        private void ShowImage(string fileFullPath)
        {
            try
            {
                Logger.LogFuncUp();

                if (_dicomConvertorProxy == null)
                {
                    _dicomConvertorProxy = _dicomConvertorProxyFactory.CreateDicomConvertorProxy();
                }

                _dicomDataHeader = _dicomConvertorProxy.LoadFile(fileFullPath, _proxy);

                if (null == _dicomDataHeader)
                {
                    string msg = "Can't Load Dicom File " + fileFullPath;
                    Logger.LogError(msg);
                    throw new Exception(msg);
                }

                var    sopInstanceUidTag = _dicomDataHeader[Pipeline.Dictionary.Tag.SOPInstanceUID];
                string sopInstancUid     = null;
                sopInstanceUidTag.GetString(0, out sopInstancUid);

                if (null == sopInstancUid)
                {
                    string msg = "Dicom File " + fileFullPath + " is not in DB";
                    Logger.LogWarning(msg);
                }
                //Dispatcher.BeginInvoke(new Action(() =>_dataLoader.LoadSopByUid(sopInstancUid)));

                var         db        = DBWrapperHelper.DBWrapper;
                var         imageBase = db.GetImageBaseBySOPInstanceUID(sopInstancUid);
                string      psPath    = string.Empty;
                List <GSPS> listGsps  = db.GetGSPSListByImageUID(imageBase.SOPInstanceUID);
                if (null != listGsps && listGsps.Count == 1)
                {
                    psPath = listGsps[0].GSPSFilePath;
                }
                Logger.LogInfo("ps file path = " + psPath);

                //var psHeader = _dicomConvertorProxy.LoadFile(psPath, _proxy);
                string ps = string.Empty;
                //if (psHeader.Contains(0x00613100))
                //{
                //DicomAttribute psTag = psHeader[0x00613100];
                //    psTag.GetString(0, out ps);
                //    Logger.LogInfo("ps info = " + ps);
                //}

                if (File.Exists(psPath))
                {
                    var psFileStream       = new FileStream(psPath, FileMode.Open);
                    var psFileStreamReader = new StreamReader(psFileStream);
                    var psFileString       = psFileStreamReader.ReadToEnd();
                    psFileStreamReader.Close();
                    psFileStream.Dispose();
                    psFileStreamReader.Dispose();
                    int psStart  = psFileString.IndexOf("<PresentationState>");
                    int psEnd    = psFileString.IndexOf("</PresentationState>");
                    int psLength = psEnd + "</PresentationState>".Length - psStart;
                    ps = psFileString.Substring(psStart, psLength);
                }
                Logger.LogInfo("ps info = " + ps);

                //medViewerControl.Controller.LoadImageFE(_dicomDataHeader, -1, -1);
                var sop = SopInstanceFactory.Create(_dicomDataHeader, fileFullPath);

                AppendSop(sop, ps);

                //if(!File.Exists(fileFullPath))
                //{
                //    return;
                //}

                //var dataLoader = new DataAccessor();
                //var displayData = dataLoader.CreateImageDataByFilePath(fileFullPath);

                //dataLoader.AddOverlays(displayData);

                //if(displayData != null)
                //{
                //    var newCell = new MedViewerControlCell();
                //    newCell.Image.AddPage(displayData);
                //    displayData.DeserializePSInfo();
                //    newCell.Refresh();

                //    medViewerControl.AddCell(newCell);
                //}

                Logger.LogFuncDown();
            }
            catch (Exception ex)
            {
                Logger.LogFuncException(ex.Message + ex.StackTrace);
                throw;
            }
        }