NetReceiveCGetRequest Example for C++ 6.0 and later
void CDicomNetSink::OnNetReceiveCGetRequest (long hNet, short nPresentationID, short nMessageID, LPCTSTR pszClass, short nPriority, long hDS)
{
//In this example, the server receives a C-Get request, and sends a C-Store request to the client
//
//In this example:
//1. m_LEADRasterView1, m_LEADRasterView2 are LEAD ActiveX Raster View (CLEADRasterView)
//
//2. m_pLEADDicomNet is LEAD DicomNet COM object (ILEADDicomNet *m_pLEADDicomNet)
//
//3. m_nClientOrServer: can be (STATUS_NONE, STATUS_SERVER, STATUS_CLIENT)
// identifieds the LMyDicomNet object as a server or a client
//4. m_nDataCommand: can be (COMMAND_C_MOVE,COMMAND_C_GET)
// set so the server knows how a C-Store Response was generated
//
//5. A connection exists between client and server
//6. An association exists between the client and server
CString strMsg;
_bstr_t strPeerAddress = m_pDlg->m_pLEADDicomNet->GetPeerAddress (hNet);
strMsg.Format("*** OnNetReceiveCGetRequest ***\nPeer[%s]\nnPresentationID[%d]\nnMessageID[%d]\npszClass[%s]\nnPriority[%d]",
(char *)strPeerAddress,
nPresentationID,
nMessageID,
pszClass,
nPriority);
//The AE should check the data set, and perform
//matching against the files stored on the AE to determine
//what data set(s) should be sent back to the calling AE.
//For this sample, just send a predetermined file
//load the sample file
_bstr_t strFile = "e:\\images\\dicom16.dic";
m_pDlg->m_pLEADDicomDS->LoadDS (strFile, 0);
//send a store command for the GET sub-operation
long hAssociate = m_pDlg->m_pLEADDicomNet->GetAssociate (hNet);
_bstr_t strAE = m_pDlg->m_pLEADDicomNet->GetCalling (hAssociate);
//Find element with TAG == TAG_SOP_INSTANCE_UID
m_pDlg->m_pLEADDicomDS->FindFirstElement (TAG_SOP_INSTANCE_UID, FALSE);
m_pDlg->m_pLEADDicomDS->GetStringValue (0,1);
_bstr_t strInstance = m_pDlg->m_pLEADDicomDS->GetStringValues (0);
//the following will cause a ReceiveCStoreResponse event on this machine
m_pDlg->m_nDataCommand = COMMAND_C_GET;
m_pDlg->m_pLEADDicomNet->SendCStoreRequest (
hNet,
nPresentationID,
nMessageID+ 1,
pszClass,
strInstance,
nPriority,
strAE,
nMessageID,
m_pDlg-> m_pLEADDicomDS->GethDicomDS()
);
strMsg = strMsg + "SendCStoreRequest\n";
AfxMessageBox(strMsg);
//Client sends C-Get response after receiving the CStoreResponse from the calling AE
}