private FutureDimseResponse SendDataset(IActiveAssociation activeAssociation, DcmParser parser, DataSet dataSet) { String sopInstUniqueId = dataSet.GetString(Tags.SOPInstanceUniqueId); if (string.IsNullOrEmpty(sopInstUniqueId)) { Logger.Error("SOP instance UniqueId is null or empty"); return null; } String sopClassUniqueId = dataSet.GetString(Tags.SOPClassUniqueId); if (string.IsNullOrEmpty(sopClassUniqueId)) { Logger.Error("SOP class UniqueId is null or empty"); return null; } PresentationContext pc = null; IAssociation association = activeAssociation.Association; if (parser != null) { if (parser.DcmDecodeParam.encapsulated) { String tsUniqueId = dataSet.FileMetaInfo.TransferSyntaxUniqueId; if ((pc = association.GetAcceptedPresContext(sopClassUniqueId, tsUniqueId)) == null) { Logger.Error(SOP_CLASS_UNIQUEID_NOT_SUPPORTED); return null; } } else if (IsSopClassUniqueIdNotSupported(association, sopClassUniqueId, out pc)) { Logger.Error(SOP_CLASS_UNIQUEID_NOT_SUPPORTED); return null; } DicomCommand cStoreRequest = _dcmObjectFactory.NewCommand().InitCStoreRQ(association.NextMsgID(), sopClassUniqueId, sopInstUniqueId, Priority.HIGH); return activeAssociation.Invoke(_associationFactory.NewDimse(pc.pcid(), cStoreRequest, new FileDataSource(parser, dataSet, new byte[2048]))); } if ((dataSet.FileMetaInfo != null) && (dataSet.FileMetaInfo.TransferSyntaxUniqueId != null)) { String tsUniqueId = dataSet.FileMetaInfo.TransferSyntaxUniqueId; if ((pc = association.GetAcceptedPresContext(sopClassUniqueId, tsUniqueId)) == null) { Logger.Error(SOP_CLASS_UNIQUEID_NOT_SUPPORTED); return null; } } else if (IsSopClassUniqueIdNotSupported(association, sopClassUniqueId, out pc)) { Logger.Error(SOP_CLASS_UNIQUEID_NOT_SUPPORTED); return null; } DicomCommand cStoreRq = _dcmObjectFactory.NewCommand().InitCStoreRQ(association.NextMsgID(), sopClassUniqueId, sopInstUniqueId, Priority.HIGH); IDimse dimse = _associationFactory.NewDimse(pc.pcid(), cStoreRq, dataSet); return activeAssociation.Invoke(dimse); }
private List<DataSet> ExecuteCFindDicomCommand(IActiveAssociation active, DataSet dataSet, int pcid) { IAssociation association = active.Association; if (association.GetAcceptedPresContext(UIDs.StudyRootQueryRetrieveInformationModelFIND, TransferSyntaxUniqueId) == null) { Logger.Error(SOP_CLASS_UNIQUEID_NOT_SUPPORTED); return null; } IDicomCommand cFindDicomCommand = _dcmObjectFactory.NewCommand().InitCFindRQ(association.NextMsgID(), UIDs.StudyRootQueryRetrieveInformationModelFIND, Priority.HIGH); IDimse dimseRequest = _associationFactory.NewDimse(pcid, cFindDicomCommand, dataSet); string message = string.Format("{0} sending CFind request to {1} @ {2}:{3}", _aAssociateRequest.Name, _aAssociateRequest.ApplicationEntityTitle, _hostName, _port); Logger.Info(message); FutureDimseResponse dimseResponse = active.Invoke(dimseRequest); while (!dimseResponse.IsReady()) { Thread.Sleep(0); } return dimseResponse.ListPending().Select(dimse => dimse.DataSet).ToList(); }