/// <summary> /// Save DICOM data and file /// </summary> public bool SaveDICOMInfo(MElementList dataset, ts_t baseTsn, string implClassUid, string versionName, string rootPath) { var dicom = new DICOMInfoDto(); DICOMUtility.BuildDICOMInfo(dataset, ref dicom); var path = rootPath + dicom.AccessionNo + Convert.ToString(Path.DirectorySeparatorChar); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var filePath = path + dicom.SOPInstanceUID + ".dcm"; var result1 = SaveDICOMFile(dataset, baseTsn, implClassUid, versionName, filePath); var result2 = false; if (result1) { result2 = SaveDICOMData(dicom, filePath); } return(result1 && result2); }
void AddSupportedStoreServices(ref MDTAe ae, DAPAcseObserver observer, AutoResetEvent sync, SSCPPara theStore) { ts_t[] tsn = null; // confirm the transfer syntax(es) that will be used tsn = new ts_t[5]; tsn[0] = ts_t.ImplicitVRLittleEndian; tsn[1] = ts_t.ExplicitVRLittleEndian; tsn[2] = ts_t.ExplicitVRBigEndian; tsn[3] = ts_t.JPEGLosslessNonHierarchical_14; tsn[4] = ts_t.JPEGLosslessNonHierarchicalFirstOrderPrediction; // confirm abstract syntax(es) that will be used DAPStoreService store_service = null; // add all the service store_service = new DAPStoreService(MDTStoreService.kMGPresentation, tsn, sync, theStore); store_service.setObserver(observer); ae.addService(store_service); store_service = new DAPStoreService(MDTStoreService.kMGProcessing, tsn, sync, theStore); store_service.setObserver(observer); ae.addService(store_service); store_service = new DAPStoreService(MDTStoreService.kDXPresentation, tsn, sync, theStore); store_service.setObserver(observer); ae.addService(store_service); store_service = new DAPStoreService(MDTStoreService.kDXProcessing, tsn, sync, theStore); store_service.setObserver(observer); ae.addService(store_service); store_service = new DAPStoreService(MDTStoreService.kCRImage, tsn, sync, theStore); store_service.setObserver(observer); ae.addService(store_service); store_service = new DAPStoreService(MDTStoreService.kCTImage, tsn, sync, theStore); store_service.setObserver(observer); ae.addService(store_service); store_service = new DAPStoreService(MDTStoreService.kMRImage, tsn, sync, theStore); store_service.setObserver(observer); ae.addService(store_service); store_service = new DAPStoreService(MDTStoreService.kNMImage, tsn, sync, theStore); store_service.setObserver(observer); ae.addService(store_service); store_service = new DAPStoreService(MDTStoreService.kUSImage, tsn, sync, theStore); store_service.setObserver(observer); ae.addService(store_service); store_service = new DAPStoreService(MDTStoreService.kXAImage, tsn, sync, theStore); store_service.setObserver(observer); ae.addService(store_service); store_service = new DAPStoreService(MDTStoreService.kSCImage, tsn, sync, theStore); store_service.setObserver(observer); ae.addService(store_service); store_service = new DAPStoreService(MDTStoreService.kXRFImage, tsn, sync, theStore); store_service.setObserver(observer); ae.addService(store_service); store_service = new DAPStoreService(MDTStoreService.kUSMFImage, tsn, sync, theStore); store_service.setObserver(observer); ae.addService(store_service); }
/// <summary> /// Save DICOM file /// </summary> /// <param name="dataset"></param> /// <param name="baseTsn"></param> /// <param name="implClassUid"></param> /// <param name="versionName"></param> /// <param name="path"></param> /// <returns></returns> private bool SaveDICOMFile(MElementList dataset, ts_t baseTsn, string implClassUid, string versionName, string filePath) { try { // add the following group 2 element for writing pt10 files string str_tsn = "1.2.840.10008.1.2"; switch (baseTsn) { case ts_t.ImplicitVRLittleEndian: str_tsn = "1.2.840.10008.1.2"; break; case ts_t.ExplicitVRBigEndian: str_tsn = "1.2.840.10008.1.2.2"; break; case ts_t.ExplicitVRLittleEndian: str_tsn = "1.2.840.10008.1.2.1"; break; case ts_t.JPEGLosslessNonHierarchical_14: str_tsn = "1.2.840.10008.1.2.4.57"; break; case ts_t.JPEGLosslessNonHierarchicalFirstOrderPrediction: str_tsn = "1.2.840.10008.1.2.4.70"; break; default: str_tsn = "1.2.840.10008.1.2"; break; } MElement tsnUid = new MElement(tag_t.kTransferSyntaxUID, vr_t.UI); UID tsn = new UID(str_tsn); tsnUid.set_uid(0, tsn); dataset.addElement(tsnUid); MElement implUid = new MElement(tag_t.kImplementationClassUID, vr_t.UI); UID uid = new UID(implClassUid); implUid.set_uid(0, uid); dataset.addElement(implUid); MElement implVer = new MElement(tag_t.kImplementationVersionName, vr_t.SH); string version = versionName; implVer.set_string(0, version); dataset.addElement(implVer); // Note: in the current version,saving file will use a large size of memory,this is a limitation // of the managed class in KDT,in the later version,if the limitation is resolved,we will use // the MDecoder to save files,not the MEncoder.wirte_pt10_file if (MEncoder.write_pt10_file ( filePath, dataset, true, // item length is explicit false // do not check group 2 items )) { _logger.Info("DAPStoreService.SaveFile(): " + "save file:" + filePath + "OK."); return(true); } else { _logger.Info("DAPStoreService.SaveFile(): " + "save file:" + filePath + "failed."); return(false); } } catch (Exception e) { _logger.Info("DAPStoreService.SaveFile(): " + "error occurred while trying to write part-10 file " + e.Message); return(false); } }