protected override void Execute() { SendAssociateRq( new PresentationContext(selectedQueryRootSop, explicitVRLittleEndian) ); DulMessage dulMsg = ReceiveAssociateRp(); if (dulMsg is AssociateAc) { if (selectedQueryRootSop == patientRootQRFindSOP) { DoPatientLevelQuery(); } else if (selectedQueryRootSop == studyRootQRFindSOP) { DoStudyLevelQuery(patientId); } if ((this.ThreadState != ThreadState.Stopping) && (this.ThreadState != ThreadState.Stopped)) { SendReleaseRq(); ReceiveReleaseRp(); } FilterQueryData(); } else if (dulMsg is AssociateRj) { AssociateRj assocRj = (AssociateRj)dulMsg; string msg = string.Format("Association Rejected for proposed presentation contexts:\nResult - {0}({1})\nSource - {2}({3})\nReason - {4}({5})", assocRj.Result, convertResult(assocRj.Result), assocRj.Source, convertSource(assocRj.Source), assocRj.Reason, convertReason(assocRj.Source, assocRj.Reason)); WriteInformation(msg); } else { WriteInformation("Unknown message is received from SCP."); } }
public override void BeforeHandlingAssociateReject(AssociateRj associateRj) { this.SendingMessageEvent -= new SendingMessageEventHandler(QRScp_SendingMessageEvent); this.MessageReceivedEvent -= new MessageReceivedEventHandler(QRScp_MessageReceivedEvent); base.BeforeHandlingAssociateReject(associateRj); }
protected override void Execute() { if (_presentationContexts.Length != 0) { SendAssociateRq(_presentationContexts); } else { WriteError("There is no presentation context available for proposing."); return; } DulMessage dulMsg = ReceiveAssociateRp(); if (dulMsg is AssociateAc) { AssociateAc assocAc = (AssociateAc)dulMsg; foreach (PresentationContext acceptedPC in assocAc.PresentationContexts) { if (acceptedPC.Result == 0) { string msg = string.Format("Accepted Presentation Context: Abstract Syntax - {0}, Transfer Syntax - {1}", acceptedPC.AbstractSyntax, acceptedPC.TransferSyntax); WriteInformation(msg); string sopClassUid = ""; string sopInstUid = ""; string transferSyntax = ""; foreach (DicomFile dcmFile in _dicomFileCollection) { // Get the SOP Class UID Values values = dcmFile.DataSet["0x00080016"].Values; sopClassUid = values[0]; // Get the SOP Instance UID Values sopClassUidvalues = dcmFile.DataSet["0x00080018"].Values; sopInstUid = sopClassUidvalues[0]; Values transferSyntaxes = dcmFile.FileMetaInformation["0x00020010"].Values; transferSyntax = transferSyntaxes[0]; // try for a match if ((acceptedPC.Result == 0) && (acceptedPC.AbstractSyntax == sopClassUid) && acceptedPC.TransferSyntax == transferSyntax) { DicomMessage storeMsg = new DicomMessage(DvtkData.Dimse.DimseCommand.CSTORERQ, dcmFile.DataSet); string message = string.Format("Sending DICOM object with PC ID - {0}", acceptedPC.ID); WriteInformation(message); System.Diagnostics.Debug.WriteLine(storeMsg.DataSet.Dump("set-")); Send(storeMsg, acceptedPC.ID); DicomMessage rspMsg = ReceiveDicomMessage(); Int32 statusVal = Int32.Parse(rspMsg.CommandSet.GetValues("0x00000900")[0]); if (statusVal == 0) { string infoMsg = string.Format("Image with SOP Instance UID{0} stored successfully.", sopInstUid); WriteInformation(infoMsg); } else { string warnMsg = string.Format("Non-zero status returned. Image with SOP Instance UID{0} storage failed.", sopInstUid); WriteWarning(warnMsg); } } } } else { string resultStr = convertAccResult(acceptedPC.Result); string message = string.Format("Can't store DICOM object with Rejected Abstract Syntax - {0}, PC ID - {1}, Reason - {2}", acceptedPC.AbstractSyntax, acceptedPC.ID, resultStr); WriteWarning(message); } } SendReleaseRq(); ReceiveReleaseRp(); } else if (dulMsg is AssociateRj) { AssociateRj assocRj = (AssociateRj)dulMsg; string msg = string.Format("Association Rejected for proposed presentation contexts:\nResult - {0}({1})\nSource - {2}({3})\nReason - {4}({5})", assocRj.Result, convertResult(assocRj.Result), assocRj.Source, convertSource(assocRj.Source), assocRj.Reason, convertReason(assocRj.Source, assocRj.Reason)); WriteInformation(msg); } else { WriteInformation("Unknown message is received from SCP."); } }
/// <summary> /// Override this method to handle an A-ASSOCIATE-RJ. /// </summary> /// <param name="associateRj">The received A-ASSOCIATE-RJ.</param> /// <returns>Return true when this methods has handled the received A-ASSOCIATE-RJ, otherwise false.</returns> public virtual bool HandleAssociateReject(AssociateRj associateRj) { return(false); }
/// <summary> /// This method is called after an A-ASSOCIATE-RJ has been received but before it /// (possibly) will be handled by the (zero or more) MessageHandler objects that /// are attached to this object. /// /// Default, nothing is done in this method. Override if needed. /// </summary> /// <param name="associateRj">The received A-ASSOCIATE-RJ</param> public virtual void BeforeHandlingAssociateReject(AssociateRj associateRj) { // Do nothing. }
/// <summary> /// This method is called after an A-ASSOCIATE-RJ has been received and has /// (possibly) been handled by the (zero or more) MessageHandler objects that /// are attached to this object. /// /// Default, nothing is done in this method. Override if needed. /// </summary> /// <param name="associateRj">The received A-ASSOCIATE-RJ.</param> public virtual void AfterHandlingAssociateReject(AssociateRj associateRj) { // Do nothing. }