예제 #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);
            }
        }
예제 #2
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);
        }