Beispiel #1
0
        public DcmDataset ToDataset(DicomTransferSyntax ts)
        {
            DcmDataset dataset = new DcmDataset(ts);

            if (QueryRetrieveLevel != DcmQueryRetrieveLevel.Worklist)
            {
                dataset.AddElementWithValue(DicomTags.QueryRetrieveLevel, QueryRetrieveLevel.ToString().ToUpper());
            }
            dataset.SaveDicomFields(this);
            AdditionalMembers(dataset);
            return(dataset);
        }
Beispiel #2
0
        internal CStoreRequestResult Send(CStoreClient client)
        {
            Load(client);

            if (HasError)
            {
                if (client.Associate.FindAbstractSyntax(SOPClassUID) == 0)
                {
                    client.Reassociate();
                    return(CStoreRequestResult.Reassociate);
                }
            }

            if (client.OnCStoreRequestBegin != null)
            {
                client.OnCStoreRequestBegin(client, this);
            }

            if (HasError)
            {
                Status = DcmStatus.UnrecognizedOperation;
                if (client.OnCStoreRequestFailed != null)
                {
                    client.OnCStoreRequestFailed(client, this);
                }
                return(CStoreRequestResult.Failure);
            }

            byte pcid = client.Associate.FindAcceptedAbstractSyntaxWithTransferSyntax(SOPClassUID, TransferSyntax);

            if (pcid == 0)
            {
                client.Log.Info("{0} -> C-Store request failed: No accepted presentation context for {1}", client.LogID, SOPClassUID.Description);
                Status = DcmStatus.SOPClassNotSupported;
                if (client.OnCStoreRequestFailed != null)
                {
                    client.OnCStoreRequestFailed(client, this);
                }
                return(CStoreRequestResult.Failure);
            }

            if (_dataset != null)
            {
                if (_userState != null)
                {
                    _dataset.SaveDicomFields(_userState);
                }

                client.SendCStoreRequest(pcid, SOPInstanceUID, _dataset);
            }
            else
            {
                using (Stream s = DicomFileFormat.GetDatasetStream(FileName)) {
                    client.SendCStoreRequest(pcid, SOPInstanceUID, s);
                    s.Close();
                }
            }

            if (client.OnCStoreRequestComplete != null)
            {
                client.OnCStoreRequestComplete(client, this);
            }

            return(CStoreRequestResult.Success);
        }