Ejemplo n.º 1
0
        private void conn_CommandReceived(DICOMConnection conn, PDATACommands command, DICOMData cmdDICOM, DICOMData dataDICOM)
        {
            switch (command)
            {
            case PDATACommands.CECHORQ:
                conn.LogLine(LogLevel.Info, "Received C-ECHO-RQ");
                conn.SendCECHORSP();
                break;

            case PDATACommands.CSTORERQ:
                conn.LogLine(LogLevel.Info, "Received C-STORE-RQ");

                //Add source AE title to image
                dataDICOM[DICOMTags.SourceApplicationEntityTitle].Data = conn.CallingAE;

                if (StoreRequest != null)
                {
                    StoreRequest(conn, dataDICOM);
                }
                else
                {
                    conn.SendCSTORERSP(CommandStatus.Success);
                }
                break;

            case PDATACommands.CSTORERSP:
                conn.LogLine(LogLevel.Info, "Received C-STORE-RSP");

                break;

            case PDATACommands.CFINDRQ:
                conn.LogLine(LogLevel.Info, "Received C-FIND-RQ");
                if (FindRequest != null)
                {
                    QRResponseData response = FindRequest(conn, new QRRequestData(cmdDICOM, dataDICOM));
                    conn.SendCFINDRSP(response);
                }
                else
                {
                    conn.SendCFINDRSP(null, CommandStatus.Success);
                }
                break;

            case PDATACommands.CGETRQ:
                conn.LogLine(LogLevel.Info, "Received C-GET-RQ");
                if (GetRequest != null)
                {
                    QRResponseData response = GetRequest(conn, new QRRequestData(cmdDICOM, dataDICOM));
                    conn.StartGetResponse(response);
                }
                else
                {
                    conn.SendCGETRSP((ushort)cmdDICOM[DICOMTags.MessageID].Data, CommandStatus.Success, 0, 0, 0, 0);
                }
                break;

            case PDATACommands.CMOVERQ:
                conn.LogLine(LogLevel.Info, "Received C-MOVE-RQ");
                if (MoveRequest != null)
                {
                    string            newAE  = cmdDICOM[DICOMTags.MoveDestination].Display.Trim();
                    ApplicationEntity entity = null;
                    if (EntityLookup != null)
                    {
                        entity = EntityLookup(newAE);
                    }

                    if (entity != null)
                    {
                        QRResponseData response = MoveRequest(conn, new QRRequestData(cmdDICOM, dataDICOM));
                        conn.StartMoveResponse(entity, response);
                    }
                    else
                    {
                        conn.LogLine(LogLevel.Warning, "No entity found for the MOVE request: " + newAE);
                        conn.SendCMOVERSP(CommandStatus.Error_ProcessingFailure, 0, 0, 0, 0);
                    }
                }
                else
                {
                    conn.SendCMOVERSP(CommandStatus.Error_ProcessingFailure, 0, 0, 0, 0);
                }
                break;

            case PDATACommands.NGETRQ:
                conn.LogLine(LogLevel.Info, "Received N-GET-RQ");

                // No idea what we're supposed to do with these yet
                conn.SendNGETRSP(CommandStatus.Refused_SOPClassNotSupported, null);
                break;

            default:
                conn.LogLine(LogLevel.Warning, "Unhandled P-DATA Command Type: " + command + "...");
                break;
            }
        }