public ImportSopResponse ImportSop(ImportSopRequest request) { try { var theFile = new DicomFile(string.Format("{0}{1}", request.SopInstanceUid, ServerPlatform.DicomFileExtension)); using (var stream = new LargeMemoryStream(request.SopInstance)) { theFile.Load(stream); } var partition = ServerPartitionMonitor.Instance.GetPartition(request.CalledAETitle); string aeTitle = theFile.SourceApplicationEntityTitle; if (_importerContext == null) _importerContext = new SopInstanceImporterContext( String.Format("{0}_{1}", aeTitle, DateTime.Now.ToString("yyyyMMddhhmmss")), partition.AeTitle, partition); var utility = new SopInstanceImporter(_importerContext); var importResult = utility.Import(theFile); if (!importResult.Successful) Platform.Log(LogLevel.Error, "Failure importing file file from Web Service: {0}, SOP Instance UID: {1}", importResult.ErrorMessage, request.SopInstanceUid); else Platform.Log(LogLevel.Info, "Processed import for SOP through Web Service: {0}.", request.SopInstanceUid); var result = new ImportSopResponse { DicomStatusCode = importResult.DicomStatus.Code, FailureMessage = importResult.ErrorMessage, Successful = importResult.Successful }; return result; } catch (Exception ex) { var message = string.Format("Failed to import files: {0}, SOP Instance UID: {1}", ex.Message, request.SopInstanceUid); Platform.Log(LogLevel.Error, message); throw new FaultException(message); } }
/// <summary> /// Imports in memory <see cref="DicomFile"/> to a remote server. /// </summary> /// <param name="callingAETitle">AE title of the local application.</param> /// <param name="calledAeTitle">AE title of the remote server</param> /// <param name="file">The DICOM file to import</param> /// <returns></returns> public ImportSopResponse ImportFile(string callingAETitle, string calledAeTitle, DicomFile file) { var request = new ImportSopRequest { CallingAETitle = callingAETitle, CalledAETitle = calledAeTitle, SopInstanceUid = file.DataSet[DicomTags.SopInstanceUid].ToString(), }; using (var stream = new LargeMemoryStream()) { file.Save(stream, DicomWriteOptions.Default); request.SopInstance = stream.ToArray(); } var response = ImportSop(request); return(response); }
/// <summary> /// Gets the study header (xml) as a gzipped stream. /// </summary> /// <param name="request">AE title of the local application.</param> /// <returns></returns> public ImportSopResponse ImportSop(ImportSopRequest request) { return(base.Channel.ImportSop(request)); }