NetReceiveNActionRequest Example for VB.NET

'LEADDICOMNet1 is a predefined LEADDicomNet object
'LEADDICOM1 is a DICOM Dataset defined outside this method
'This example uses the predefined variable "TreeView1" of type "TreeView" from ".NET Framework".
Private Sub LEADDICOMNet1_NetReceiveNActionRequest(ByVal hNet As Integer, ByVal nPresentationID As Short, ByVal nMessageID As Short, ByVal pszClass As String, ByVal pszInstance As String, ByVal nAction As Short, ByVal hDS As Integer) Handles LEADDICOMNet1.NetReceiveNActionRequest
   Dim nRet As Short
   Dim NewNode As System.Windows.Forms.TreeNode
   Dim szReply As String
   Dim szName As String

   NewNode = New System.Windows.Forms.TreeNode("Command Set - " & "N-ACTION-REQUEST")
   TreeView1.Nodes.Add(NewNode)
   NewNode.EnsureVisible()

   NewNode.Nodes.Add("Presentation ID: " & CStr(nPresentationID))
   NewNode.Nodes.Add("Message ID: " & CStr(nMessageID))
   nRet = LEADDICOM1.FindUID(pszClass)
   If (nRet = 0) Then
      szName = LEADDICOM1.CurrentUID.Name
      NewNode.Nodes.Add("Requested SOP Class: " & szName & " - " & pszClass)
   Else
      NewNode.Nodes.Add("Requested SOP Class: " & pszClass)
   End If
   NewNode.Nodes.Add("Requested SOP Instance: " & pszInstance)
   NewNode.Nodes.Add("Action: " & CStr(nAction))

   'this function should perform the action command - this is a function that you have to write
   nRet = PerformActionCommand(pszClass, pszInstance, hDS)

   If (nRet <> LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS) Then
      nRet = LTDNCLib.DicomCommandStatusConstants.COMMAND_STATUS_PROCESSING_FAILURE
   End If

   'send a response
   LEADDICOMNet1.SendNActionResponse(hNet, nPresentationID, nMessageID, pszClass, pszInstance, nRet, nAction, hDS)

End Sub