NetReceiveNGetRequest Example for C++ 6.0 or later
void CDicomNetSink::OnNetReceiveNGetRequest (long hNet, short nPresentationID, short nMessageID, LPCTSTR pszClass, LPCTSTR pszInstance)
{
//In this example, the server receives a N-Get request, and sends an N-Get response 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("*** OnNetReceiveNGetRequest ***\nPeer[%s]\nnPresentationID[%d]\nnMessageID[%d]\npszClass[%s]\npszInstance[%s]\n",
(char *)strPeerAddress,
nPresentationID,
nMessageID,
pszClass,
pszInstance
);
//An acutal server should check the class and instance against all SOP classes
//it manages, and then fill out hDS from the correctly matching instance
//This sample loads a fixed data set
//Load DS1
m_pDlg->m_pLEADDicomDS->LoadDS ("e:\\images\\dicom16.dic", 0);
//Initialize DS2 to send
m_pDlg->m_pLEADDicomDS2->InitDS (DICOM_CLASS_UNKNOWN, 0);
m_pDlg->m_pLEADDicomDS->MoveFirstElement (FALSE);
for (int i = 0; i<m_pDlg->m_pLEADDicomNet->GetRequestAttributeCount(); i++)
{
//get each element
long nTag = m_pDlg->m_pLEADDicomNet->GetRequestAttributes(i);
m_pDlg->m_pLEADDicomDS->FindTag(nTag);
int nRet = m_pDlg->m_pLEADDicomDS->FindFirstElement (nTag, FALSE);
if (nRet == 0)
{
//copy the element value
m_pDlg->m_pLEADDicomDS->GetConvertValue ();
m_pDlg->m_pLEADDicomDS2->InsertElement (FALSE, nTag, m_pDlg->m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pDlg->m_pLEADDicomDS2->StringValueCount = 1;
m_pDlg->m_pLEADDicomDS2->PutStringValues(0, m_pDlg->m_pLEADDicomDS->GetStringValues (0));
m_pDlg->m_pLEADDicomDS2->SetConvertValue();
}
}
//send a response
short nStatus = COMMAND_STATUS_SUCCESS;
m_pDlg->m_pLEADDicomNet->SendNGetResponse(hNet, nPresentationID, nMessageID, pszClass, pszInstance, nStatus, m_pDlg->m_pLEADDicomDS2->GethDicomDS());
strMsg = strMsg + "SendNGetResponse\n";
AfxMessageBox(strMsg);
}