SendNActionRequest Example for C++ 6.0 or later
{
//This example sends a N-Action Request to a server
//
//In this example:
//1. m_Dicom, m_Dicom2 are LEAD ActiveX Dicom objects (CLEADDICOM)
//
//2. m_DicomNet is LEAD ActiveX DicomNet object (CLEADDICOMNet)
//
//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 = "N-Action\n";
//Choose a supported Action ID
short nAction = 1;
//Choose an SOP Class to find
_bstr_t strClassUID = UID_BASIC_FILM_BOX_CLASS;
//Choose an SOP Instance to modify
_bstr_t strInstanceUID = "1.1.1.1";
//...
//...Create a data set that encodes the Action Arguments (based on value of nAction)
//...For this example, add a tag to the Data set so that it is non-empty
//...
m_pLEADDicomDS->InitDS (DICOM_CLASS_UNKNOWN, 0);
//...Add the action arugments
m_pLEADDicomDS->FindTag(TAG_IMAGE_TYPE);
m_pLEADDicomDS->InsertElement (FALSE, TAG_IMAGE_TYPE, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
//Get the associate object
long hAssociate = m_pLEADDicomNet->GetAssociate (m_pLEADDicomNet->GethNet());
//Is class supported in the assocation?
short nPresentationID = m_pLEADDicomNet->FindPresentationAbstract (hAssociate, strClassUID);
//nPresentationID must be odd--0 indicates failure
if (nPresentationID==0)
{
CString strTmp;
strTmp.Format("Abstract Syntax[%s] Not Included in the Association", (char*)strClassUID);
strMsg = strMsg + strTmp;
}
else //success
{
short uUniqueID = 99;
m_pLEADDicomNet->SendNActionRequest(
m_pLEADDicomNet->GethNet(),
nPresentationID,
uUniqueID,
strClassUID,
strInstanceUID,
nAction,
m_pLEADDicomDS->GethDicomDS());
}
AfxMessageBox(strMsg);
}