NetReceiveCMoveRequest Example for C#

//This example uses the predefined variable “TreeView1” of type “TreeView” from “.NET Framework”.
//LEADDICOMNet1 is a predefined LEADDicomNet object
//LEADDICOM1 is a DICOM Dataset defined outside this method
private void LEADDICOMNet1_NetReceiveCMoveRequest(int hNet, short nPresentationID, short nMessageID, string pszClass, short nPriority, string pszMoveAE, int hDS)
{
   short nRet = 0;
   System.Windows.Forms.TreeNode NewNode = null;
   string szReply = null;
   string szName = null;
   int hPDU = 0;
   string szAbstract = null;
   string szTransfer = null;
   string szInstance = null;
   string szClassUID = null;
   short nID = 0;
   NewNode = new System.Windows.Forms.TreeNode("Command Set - " + "C-MOVE-REQUEST");
   TreeView1.Nodes.Add(NewNode);
   NewNode.EnsureVisible();
   hPDU = LEADDICOMNet1.   GetAssociate(hNet);
   NewNode.Nodes.Add("Presentation ID: " + System.Convert.ToString(nPresentationID));
   NewNode.Nodes.Add("Message ID: " + System.Convert.ToString(nMessageID));
   nRet = LEADDICOM1.FindUID(pszClass);
   if (nRet == 0)
   {
      szName = LEADDICOM1.get_CurrentUID().Name;
      NewNode.Nodes.Add("Affected SOP Class: " + szName + " - " + pszClass);
   }
   else
      NewNode.Nodes.Add("Affected SOP Class: " + pszClass);
   NewNode.Nodes.Add("Priority: " + System.Convert.ToString(nPriority));
   NewNode.Nodes.Add("Move AE Title: " + pszMoveAE);
   //this sample simply returns a fixed dicom data set.
   LEADDICOM1.LoadDS("e:\\images\\dicom16.dic", 0);
   LEADDICOM1.MoveFirstElement(false);
   LEADDICOM1.FindFirstElement((int)LTDICLib.DicomDataSetTagConstants1.TAG_SOP_INSTANCE_UID, false);
   LEADDICOM1.GetStringValue(0, 1);
   szInstance = LEADDICOM1.get_StringValues(0);
   LEADDICOM1.MoveFirstElement(false);
   LEADDICOM1.FindFirstElement((int)LTDICLib.DicomDataSetTagConstants1.TAG_SOP_CLASS_UID, false);
   LEADDICOM1.GetStringValue(0, 1);
   szClassUID = LEADDICOM1.get_StringValues(0);
   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!");
      //send a response
      LEADDICOMNet1.SendCMoveResponse(hNet, nPresentationID, nMessageID, pszClass, (int)LTDNCLib.DicomCommandStatusConstants.COMMAND_STATUS_NO_SUCH_CLASS, 0, 0, 1, 0, 0);
      return;
   }
   //now, send the C-STORE sub operation
   LEADDICOMNet1.SendCStoreRequest(hNet, nID, (short)(nMessageID + 1), szClassUID, szInstance, nPriority, pszMoveAE, nMessageID, LEADDICOM1.hDicomDS);
   //send a response
   LEADDICOMNet1.SendCMoveResponse(hNet, nPresentationID, nMessageID, pszClass, (int)LTDNCLib.DicomCommandStatusConstants.COMMAND_STATUS_SUCCESS, 0, 1, 0, 0, 0);
}