Beispiel #1
0
        public static void GetDcmInfo(List <string> PrcFileList, out List <DCMInfo> dcmInfoList)
        {
            dcmInfoList = new List <DCMInfo>();
            try
            {
                foreach (String prcFilePath in PrcFileList)
                {
                    FileInfo file = new FileInfo(prcFilePath);

                    MElementList elmlist = new MElementList();
                    using (DicomHeader dicomHeader = new DicomHeader())
                    {
                        if (!MDecoder.read_pt10_file(prcFilePath, ref elmlist, null, -1))
                        {
                            _logger.Error("Archiver.ProcessDcmFile(): " + "read dicom file " + prcFilePath + " error.");
                            continue;
                        }
                        bool bRet = dicomHeader.BuildDicomInfo(elmlist);
                        elmlist.Dispose();
                        if (bRet)
                        {
                            DCMInfo dcmInfo = dicomHeader.GetDCMInfo();
                            dcmInfo.ImageDto.SrcFilePath = prcFilePath;
                            dcmInfo.ImageDto.FileSize    = file.Length;
                            dcmInfoList.Add(dcmInfo);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Archiver.ProcessDcmFile(): " + "archive file failed " +
                              ex.Message);
            }
        }
        /// <summary>
        /// indicate receiving over of an image
        /// </summary>
        /// <param name="ind">all the information about the received image</param>
        /// <param name="status">status that returned to the SCU</param>
        public override void indication(MElementList ind, MElementList status)
        {
            using (MElementRef eref = ind.get_Element(tag_t.kSOPInstanceUID))
            {
                if (eref != null)
                {
                    m_fileName = eref.get_string(0);
                }
            }

            MElementList pt10file = ind.getDataset();

            // save image and update case information
            if (!SaveFile(pt10file))
            {
                try
                {
                    using (MElementRef statusRef = status.get_Element(tag_t.kStatus))
                    {
                        // notify the client that image processing failed and cancel the whole association
                        statusRef.set_ushort(0, (ushort)MDTService.status_t.PROCESSING_FAILURE);
                        statusRef.set_ushort(1, (ushort)MDTService.status_t.CANCEL);
                    }

                    // file saving failed,the case should not be submitted
                    m_theObserver.m_OK = false;
                }
                catch (Exception e)
                {
                    m_theObserver.m_OK = false;
                    _logger.Info("DAPStoreService.indication(): " + "set response status error " + e.Message);
                }
            }

            // release the memory used by MElementList
            pt10file.Dispose();
            ind.Dispose();

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Beispiel #3
0
        public static bool ModifyAccNoAndPatientID(string filePath, string tempFilePath, string prefix, out string message)
        {
            Boolean ret = false;

            message = "";
            //String strAccPrefix = @"-" + m_infoDAP.HospitalID.ToString();
            String strAccPrefix = prefix;

            try
            {
                MElementList elmlist = new MElementList();
                if (!MDecoder.read_pt10_file(filePath, ref elmlist, null, -1))
                {
                    _logger.Error("ImageSubmitService.ModifyAccNoAndPatientID(): " + "read dicom file " + filePath + " error.");
                    message = "SendFTPError002";
                    return(ret);
                }

                //Modify AccessionNumber
                String accNoOrg = "";
                String patIDOrg = "";
                GetDICOMInfo(elmlist, ref accNoOrg, ref patIDOrg);

                #region process Num
                //PID,AccNo为空时拒绝接受该图像
                if (patIDOrg.Length == 0 || accNoOrg.Length == 0)
                {
                    IDEmptyProcess(patIDOrg);

                    elmlist.Dispose();
                    message = "SendFTPError003";
                    return(false);
                }

                #endregion

                int PrefixLength = 32 - strAccPrefix.Length;
                if (accNoOrg.Length > PrefixLength)
                {
                    accNoOrg = accNoOrg.Remove(PrefixLength);
                }

                patIDOrg = AddPrefix(strAccPrefix, elmlist, accNoOrg, patIDOrg, PrefixLength);

                //judge TransferSyntax
                SetTSN(elmlist);

                if (MEncoder.write_pt10_file
                    (
                        tempFilePath,
                        elmlist,
                        true,   // item length is explicit
                        false   // do not check group 2 items
                    ))
                {
                    elmlist.Dispose();
                    _logger.Debug("ImageSubmitService.ModifyAccNoAndPatientID(): " + "save dicom file " + tempFilePath + " ok.");
                    return(true);
                }
                else
                {
                    elmlist.Dispose();
                    _logger.Error("ImageSubmitService.ModifyAccNoAndPatientID(): " + "save dicom file " + tempFilePath + " error.");
                    message = "SendFTPError002";
                    return(false);
                }
            }
            catch (Exception e)
            {
                _logger.Error("ImageSubmitService.ModifyAccNoAndPatientID(): " + "pop up an exception--" + e.Message);
            }
            return(ret);
        }