/// <summary> /// <see cref="ISniffer.Validate(DulMessage , ValidationControlFlags )"/> /// </summary> public bool Validate( DulMessage message, ValidationControlFlags validationControlFlags) { if (message == null) { throw new System.ArgumentNullException(); } //Set the validation options Wrappers.ValidationControlFlags wrappersValidationControlFlags = Wrappers.ValidationControlFlags.None; if ((validationControlFlags & ValidationControlFlags.UseDefinitions) != 0) { wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseDefinitions; } if ((validationControlFlags & ValidationControlFlags.UseValueRepresentations) != 0) { wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseValueRepresentations; } return((this.m_adaptee as Wrappers.MSnifferSession).Validate( message, wrappersValidationControlFlags)); }
/// <summary> /// <see cref="IDimseValidation.Validate"/> /// </summary> public bool Validate( DicomMessage message, DicomMessage referenceMessage, ValidationControlFlags validationControlFlags) { if (message == null) { throw new System.ArgumentNullException(); } // referenceMessage may be null // // Convert flags // Wrappers.ValidationControlFlags wrappersValidationControlFlags = Wrappers.ValidationControlFlags.None; if ((validationControlFlags & ValidationControlFlags.UseDefinitions) != 0) { wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseDefinitions; } if ((validationControlFlags & ValidationControlFlags.UseReferences) != 0) { wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseReferences; } if ((validationControlFlags & ValidationControlFlags.UseValueRepresentations) != 0) { wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseValueRepresentations; } return((this.m_adaptee as Wrappers.MScriptSession).Validate( message, referenceMessage, wrappersValidationControlFlags)); }
/// <summary> /// <see cref="IMediaValidation.Validate"/> /// </summary> public bool Validate(DicomFile file, ValidationControlFlags validationControlFlags) { if (file == null) { throw new System.ArgumentNullException("file"); } if ((validationControlFlags & ValidationControlFlags.UseReferences) != 0) { throw new System.ArgumentException(); } // // Convert flags // Wrappers.ValidationControlFlags wrappersValidationControlFlags = Wrappers.ValidationControlFlags.None; if ((validationControlFlags & ValidationControlFlags.UseDefinitions) != 0) { wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseDefinitions; } if ((validationControlFlags & ValidationControlFlags.UseReferences) != 0) { wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseReferences; } if ((validationControlFlags & ValidationControlFlags.UseValueRepresentations) != 0) { wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseValueRepresentations; } return(this.m_adaptee.Validate(file, wrappersValidationControlFlags)); }
/// <summary> /// <see cref="IDulValidation.Validate"/> /// </summary> public bool Validate( DulMessage message, DulMessage referenceMessage, ValidationControlFlags validationControlFlags) { if (message == null) { throw new System.ArgumentNullException(); } // // referenceMessage may be null // if (referenceMessage != null) { // // Check runtime instance type equality of message and referenceMessage // if (referenceMessage.GetType() != message.GetType()) { throw new System.ArgumentException( string.Concat( "message and referenceMessage should have the same type.\n", string.Format( "message type = {0}\n", message.GetType().ToString() ), string.Format( "referenceMessage type = {0}\n", referenceMessage.GetType().ToString() ) ), "referenceMessage"); } } // // Remove obsolete flag ValidationControlFlags.UseValueRepresentations // Wrappers.ValidationControlFlags wrappersValidationControlFlags = Wrappers.ValidationControlFlags.None; if ((validationControlFlags & ValidationControlFlags.UseDefinitions) != 0) { wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseDefinitions; } if ((validationControlFlags & ValidationControlFlags.UseReferences) != 0) { wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseReferences; } // if ((validationControlFlags & ValidationControlFlags.UseValueRepresentations) != 0) // wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseValueRepresentations; return((this.m_adaptee as Wrappers.MScriptSession).Validate( message, referenceMessage, wrappersValidationControlFlags)); }
protected override void Execute() { // loop through all associations // Get all kind of DICOM messages from the sniffer file stream. DvtkData.Message message = null; DvtkData.Dimse.DicomMessage lastMessage = null; DvtkData.Dul.AcceptedPresentationContextList accPCs = null; ReceivedMsgReturnCode retcode = ReceivedMsgReturnCode.Failure; retcode = dvtkSnifferSession.ReceiveMessage(out message); try { while ((retcode == ReceivedMsgReturnCode.Success) && (message != null)) { // DicomMessage needs to be validated against a definition file and VR. ValidationControlFlags validationFlags = ValidationControlFlags.None; validationFlags |= ValidationControlFlags.UseDefinitions; validationFlags |= ValidationControlFlags.UseValueRepresentations; if (message is DvtkData.Dul.DulMessage) { //Extract Calling/Called AE Title from received message and save is to // Dvtk Script session if (message is DvtkData.Dul.A_ASSOCIATE_RQ) { DvtkData.Dul.A_ASSOCIATE_RQ assocReq = (DvtkData.Dul.A_ASSOCIATE_RQ)message; Options.DvtkScriptSession.DvtSystemSettings.AeTitle = assocReq.CalledAETitle; Options.DvtkScriptSession.SutSystemSettings.AeTitle = assocReq.CallingAETitle; } if (message is DvtkData.Dul.A_ASSOCIATE_AC) { DvtkData.Dul.A_ASSOCIATE_AC assocAcc = (DvtkData.Dul.A_ASSOCIATE_AC)message; Options.DvtkScriptSession.DvtSystemSettings.AeTitle = assocAcc.CallingAETitle; Options.DvtkScriptSession.SutSystemSettings.AeTitle = assocAcc.CalledAETitle; accPCs = assocAcc.PresentationContexts; } Options.DvtkScriptSession.Validate(message as DvtkData.Dul.DulMessage, null, validationFlags); } else { DvtkData.Dimse.DicomMessage dimseMsg = (DvtkData.Dimse.DicomMessage)message; if (dimseMsg.CommandField == DvtkData.Dimse.DimseCommand.CFINDRQ) { lastMessage = dimseMsg; } foreach (DvtkData.Dul.AcceptedPresentationContext acc in accPCs) { if ((acc.Result == 0) && (acc.ID == dimseMsg.EncodedPresentationContextID)) { if (acc.TransferSyntax != DvtkData.Dul.TransferSyntax.Implicit_VR_Little_Endian) { Options.DvtkScriptSession.IsDataTransferExplicit = true; } else { Options.DvtkScriptSession.IsDataTransferExplicit = false; } break; } } if ((dimseMsg.CommandField == DvtkData.Dimse.DimseCommand.CFINDRSP) && (lastMessage != null)) { Options.DvtkScriptSession.Validate(dimseMsg, null, lastMessage, validationFlags); } else { Options.DvtkScriptSession.Validate(dimseMsg, null, validationFlags); } } message = null; retcode = dvtkSnifferSession.ReceiveMessage(out message); if ((retcode == ReceivedMsgReturnCode.IncompleteByteStream) && (message == null)) { string msg = string.Format("Incomplete byte stream, unable to perform further validation, see {0} for detail logging in {1} directory.", (associationName + ".log"), this.Options.ResultsDirectory); WriteHtmlInformation("<b><br />"); WriteInformation(msg); WriteHtmlInformation("</b><br />"); } } } catch (Exception except) { string msg = string.Format("Validation error: {0}\n", except.Message); MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } //again set the original directory dvtkSnifferSession.DataDirectory = orgDataDir; }
/// <summary> /// <see cref="IMediaValidation.Validate"/> /// </summary> public bool Validate(DicomFile file, ValidationControlFlags validationControlFlags) { if (file == null) throw new System.ArgumentNullException("file"); if ((validationControlFlags & ValidationControlFlags.UseReferences) != 0) throw new System.ArgumentException(); // // Convert flags // Wrappers.ValidationControlFlags wrappersValidationControlFlags = Wrappers.ValidationControlFlags.None; if ((validationControlFlags & ValidationControlFlags.UseDefinitions) != 0) wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseDefinitions; if ((validationControlFlags & ValidationControlFlags.UseReferences) != 0) wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseReferences; if ((validationControlFlags & ValidationControlFlags.UseValueRepresentations) != 0) wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseValueRepresentations; return this.m_adaptee.Validate(file, wrappersValidationControlFlags); }
/// <summary> /// <see cref="ISniffer.Validate"/> /// </summary> public bool Validate( DulMessage message, ValidationControlFlags validationControlFlags) { if (message == null) throw new System.ArgumentNullException(); //Set the validation options Wrappers.ValidationControlFlags wrappersValidationControlFlags = Wrappers.ValidationControlFlags.None; if ((validationControlFlags & ValidationControlFlags.UseDefinitions) != 0) wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseDefinitions; if ((validationControlFlags & ValidationControlFlags.UseValueRepresentations) != 0) wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseValueRepresentations; return (this.m_adaptee as Wrappers.MSnifferSession).Validate( message, wrappersValidationControlFlags); }
/// <summary> /// <see cref="IDulValidation.Validate"/> /// </summary> public bool Validate( DulMessage message, DulMessage referenceMessage, ValidationControlFlags validationControlFlags) { if (message == null) throw new System.ArgumentNullException(); // // referenceMessage may be null // if (referenceMessage != null) { // // Check runtime instance type equality of message and referenceMessage // if (referenceMessage.GetType() != message.GetType()) throw new System.ArgumentException( string.Concat( "message and referenceMessage should have the same type.\n", string.Format( "message type = {0}\n", message.GetType().ToString() ), string.Format( "referenceMessage type = {0}\n", referenceMessage.GetType().ToString() ) ), "referenceMessage"); } // // Remove obsolete flag ValidationControlFlags.UseValueRepresentations // Wrappers.ValidationControlFlags wrappersValidationControlFlags = Wrappers.ValidationControlFlags.None; if ((validationControlFlags & ValidationControlFlags.UseDefinitions) != 0) wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseDefinitions; if ((validationControlFlags & ValidationControlFlags.UseReferences) != 0) wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseReferences; // if ((validationControlFlags & ValidationControlFlags.UseValueRepresentations) != 0) // wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseValueRepresentations; return (this.m_adaptee as Wrappers.MScriptSession).Validate( message, referenceMessage, wrappersValidationControlFlags); }
/// <summary> /// <see cref="IDimseValidation.Validate( DicomMessage , /// DicomMessage , /// DicomMessage , /// ValidationControlFlags )"/> /// </summary> public bool Validate( DicomMessage message, DicomMessage referenceMessage, DicomMessage lastMessage, ValidationControlFlags validationControlFlags) { if (message == null) throw new System.ArgumentNullException(); // referenceMessage may be null // // Convert flags // Wrappers.ValidationControlFlags wrappersValidationControlFlags = Wrappers.ValidationControlFlags.None; if ((validationControlFlags & ValidationControlFlags.UseDefinitions) != 0) wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseDefinitions; if ((validationControlFlags & ValidationControlFlags.UseReferences) != 0) wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseReferences; if ((validationControlFlags & ValidationControlFlags.UseValueRepresentations) != 0) wrappersValidationControlFlags |= Wrappers.ValidationControlFlags.UseValueRepresentations; return (this.m_adaptee as Wrappers.MScriptSession).Validate( message, referenceMessage, lastMessage, wrappersValidationControlFlags); }