NetReceiveCGetRequest 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_NetReceiveCGetRequest(int hNet, short nPresentationID, short nMessageID, string pszClass, short nPriority, int hDS)
{
   short nRet = 0;
   string szFile = null;
   System.Windows.Forms.TreeNode NewNode = null;
   string szReply = null;
   string szName = null;
   string szAE = null;
   int hPDU = 0;
   string szInstance = null;
   NewNode = new System.Windows.Forms.TreeNode("Command Set - " + "C-GET-REQUEST");
   TreeView1.Nodes.Add(NewNode);
   NewNode.EnsureVisible();
   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));
   //perform the get
   //here, 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.
   //In our case, we just send back a predetermined file for
   //this demo!
   //load the sample file
   //NOTE: this sample is looking for a particular filename
   TEST2.DIC szFile = "e:\\images\\dicom16.dic";
   nRet = LEADDICOM1.LoadDS(szFile, 0);
   //now, send a store command for the get sub-operation
   hPDU = LEADDICOMNet1.GetAssociate(hNet);
   szAE = LEADDICOMNet1.GetCalling(hPDU);
   nRet = LEADDICOM1.FindFirstElement((int)LTDICLib.DicomDataSetTagConstants1.TAG_SOP_INSTANCE_UID, false);
   if (nRet == 0)
   {
      nRet = LEADDICOM1.GetStringValue(0, 1);
      if (nRet == 0)
         szInstance = LEADDICOM1.get_StringValues(0);
   }
   nRet = LEADDICOMNet1.SendCStoreRequest(hNet, nPresentationID, (short)(nMessageID + 1), pszClass, szInstance, nPriority, szAE, nMessageID, LEADDICOM1.hDicomDS);
   //the above will cause a ReceiveCStoreResponse event on this machine
   //we will send a get response after we have received the CStoreResponse from the calling AE
}