SendCMoveRequest Example for C#

//LEADDICOMNet1 is a predefined LEADDicomNet object
//LEADDICOM1 is a DICOM Dataset defined outside this method
//This example uses the predefined variable "gszGetFile" of type "string"
private void TestSendCMoveRequest ( )
{
   const string UID_NM_IMAGE_STORAGE = "1.2.840.10008.5.1.4.1.1.20";
   // Nuclear Medicine Image Storage
   short nRet = 0;
   string szClassUID = null;
   short nVR = 0;
   int hPDU = 0;
   short nID = 0;
   //send a Move Request to the server
   //gszGetFile is a global variable that will be used when we get
   //the C-STORE-RQ event to store the file
   gszGetFile = "d:\\temp\\move_request.dic" ;
   szClassUID = UID_NM_IMAGE_STORAGE ;
   //create the data set that encodes the identifier to be matched
   LEADDICOM1.InitDS((int)LTDICLib.DicomClassConstants.DICOM_CLASS_UNKNOWN, 0);
   //add the required elements
   LEADDICOM1.FindTag((int)LTDICLib.DicomDataSetTagConstants1.TAG_QUERY_RETRIEVE_LEVEL);
   nVR = LEADDICOM1.get_CurrentTag().VR;
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants1.TAG_QUERY_RETRIEVE_LEVEL, nVR, false, 0);
   LEADDICOM1.StringValueCount = 1;
   LEADDICOM1.set_StringValues(0, "PATIENT");
   LEADDICOM1.SetStringValue(1);
   LEADDICOM1.FindTag((int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_NAME);
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_NAME, LEADDICOM1.get_CurrentTag().VR, false, 0);
   //add the optional fields that we want returned
   LEADDICOM1.FindTag((int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_ID);
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_ID, LEADDICOM1.get_CurrentTag().VR, false, 0);
   LEADDICOM1.FindTag((int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_BIRTH_DATE);
   nVR = LEADDICOM1.get_CurrentTag().VR;
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_BIRTH_DATE, nVR, false, 0);
   LEADDICOM1.FindTag((int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_SEX);
   nVR = LEADDICOM1.get_CurrentTag().VR;
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_SEX, nVR, false, 0);
   LEADDICOM1.FindTag((int)LTDICLib.DicomDataSetTagConstants5.TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES);
   nVR = LEADDICOM1.get_CurrentTag().VR;
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants5.TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES, nVR, false, 0);
   hPDU = LEADDICOMNet1.GetAssociate(LEADDICOMNet1.hNet);
   //now, send a request
   nID = LEADDICOMNet1.FindPresentationAbstract(hPDU, szClassUID);
   if (nID == 0)
   {
      nRet = LEADDICOM1.FindUID(szClassUID);
      if (nRet == 0)
         MessageBox.Show("Abstract Syntax, " + LEADDICOM1.get_CurrentUID().Name + ", Not Supported by Association!");
      else
         MessageBox.Show("Abstract Syntax, " + szClassUID + ", Not Supported by Association!");
      return;
   }
   //we are asking the Called AE to move the SOP Instance to ourselves
   LEADDICOMNet1.SendCMoveRequest(LEADDICOMNet1.hNet, nID, 1, szClassUID, (short)LTDICLib.DicomCommandSetMessagePriorities.COMMAND_PRIORITY_MEDIUM, "MI_TEST", LEADDICOM1.hDicomDS);
   //we now must wait for the response and for the C-STORE sub-operations
}