/// <summary> /// Clone this into a new instance of the <see cref="ReceiveServiceConfig"/> class. /// </summary> /// <param name="gatewayDicomEndPoint">The gateway dicom end point.</param> /// <param name="rootDicomFolder">The root dicom folder.</param> /// <param name="acceptedSopClassesAndTransferSyntaxesUIDs">The accepted sop classes and transfer syntaxes UI ds.</param> public ReceiveServiceConfig With( DicomEndPoint gatewayDicomEndPoint = null, string rootDicomFolder = null, Dictionary <string, string[]> acceptedSopClassesAndTransferSyntaxesUIDs = null) => new ReceiveServiceConfig( gatewayDicomEndPoint ?? GatewayDicomEndPoint, rootDicomFolder ?? RootDicomFolder, acceptedSopClassesAndTransferSyntaxesUIDs ?? AcceptedSopClassesAndTransferSyntaxesUIDs);
/// <summary> /// Initializes a new instance of the <see cref="ReceiveServiceConfig"/> class. /// </summary> /// <param name="gatewayDicomEndPoint">The gateway dicom end point.</param> /// <param name="rootDicomFolder">The root dicom folder.</param> /// <param name="acceptedSopClassesAndTransferSyntaxesUIDs">The accepted sop classes and transfer syntaxes UI ds.</param> /// <exception cref="ArgumentNullException"> /// gatewayDicomEndPoint /// or /// rootDicomFolder /// or /// acceptedSopClassesAndTransferSyntaxesUIDs /// </exception> public ReceiveServiceConfig( DicomEndPoint gatewayDicomEndPoint, string rootDicomFolder, Dictionary <string, string[]> acceptedSopClassesAndTransferSyntaxesUIDs) { GatewayDicomEndPoint = gatewayDicomEndPoint ?? throw new ArgumentNullException(nameof(gatewayDicomEndPoint)); RootDicomFolder = rootDicomFolder ?? throw new ArgumentNullException(nameof(rootDicomFolder)); AcceptedSopClassesAndTransferSyntaxesUIDs = acceptedSopClassesAndTransferSyntaxesUIDs ?? throw new ArgumentNullException(nameof(acceptedSopClassesAndTransferSyntaxesUIDs)); if (AcceptedSopClassesAndTransferSyntaxesUIDs.Count == 0) { throw new ArgumentException("The GatewayReceiveConfiguration must have at least 1 acceptable SOPClassUID", nameof(acceptedSopClassesAndTransferSyntaxesUIDs)); } if (AcceptedSopClassesAndTransferSyntaxesUIDs.Any(kvp => kvp.Value.Length == 0)) { throw new ArgumentException("Every SopClassUID must have at least 1 supported Transfer Syntax", nameof(acceptedSopClassesAndTransferSyntaxesUIDs)); } }
/// <summary> /// Validates the DICOM endpoint. /// </summary> /// <param name="uploadQueueItem">Upload queue item.</param> /// <param name="dicomEndPoint">The DICOM endpoint to validate.</param> private void ValidateDicomEndpoint(UploadQueueItem uploadQueueItem, DicomEndPoint dicomEndPoint) { var titleValidationResult = ApplicationEntityValidationHelpers.ValidateTitle(dicomEndPoint.Title); var portValidationResult = ApplicationEntityValidationHelpers.ValidatePort(dicomEndPoint.Port); var ipValidationResult = ApplicationEntityValidationHelpers.ValidateIPAddress(dicomEndPoint.Ip); var result = titleValidationResult && portValidationResult && ipValidationResult; // Validate the destination before uploading. if (!result) { var exception = new ArgumentException("The DICOM endpoint is not valid.", nameof(dicomEndPoint)); LogError(LogEntry.Create(AssociationStatus.UploadErrorDicomEndpointInvalid, uploadQueueItem: uploadQueueItem, destination: (ipAddress: dicomEndPoint.Ip, title: dicomEndPoint.Title, port: dicomEndPoint.Port)), exception); // We cannot process message throw exception; } }