Exemplo n.º 1
0
 public void ClearMessages(DicomThread dicomThread)
 {
     lock (lockObject)
     {
         dicomThread.Messages.Clear();
     }
 }
Exemplo n.º 2
0
        public override void SetResultsOptions(Thread thread)
        {
            Thread topmostThread = thread.TopmostThread;

            if ((thread is DicomThread) && (topmostThread is DicomThread))
            {
                DicomThread dicomThread        = thread as DicomThread;
                DicomThread topmostDicomThread = topmostThread as DicomThread;

                if (topmostDicomThread == dicomThread)
                {
                    if (dicomThread.Options.ResultsFileName == null)
                    {
                        dicomThread.Options.ResultsFileName = String.Format("{0:000}_{1}_res.xml", dicomThread.Options.SessionId, this.baseName.Replace(".", "_"));
                    }
                }
                else
                {
                    dicomThread.Options.ResultsDirectory = topmostDicomThread.Options.ResultsDirectory;

                    if (dicomThread.Options.ResultsFileName == null)
                    {
                        dicomThread.Options.ResultsFileName = String.Format("{0:000}_{1}_{2}_res.xml", dicomThread.Options.SessionId, this.baseName.Replace(".", "_"), dicomThread.Options.Identifier);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private Dvtk.Sessions.ValidationControlFlags ValidateUseDefinitions(DicomThread dicomThread, DicomMessage dicomMessage)
        {
            Dvtk.Sessions.ValidationControlFlags validationFlag = Dvtk.Sessions.ValidationControlFlags.None;

            String iodName = dicomThread.GetIodNameFromDefinition(dicomMessage);

            if (iodName.Length == 0)
            {
                this.thread.WriteWarningInternal("- Skipping definition file validation: unable to find correct definition file for DimseCommand " + dicomMessage.CommandSet.DimseCommand.ToString() + " and SOP Class UID " + dicomMessage.CommandSet.GetSopClassUid() + ".  Are the correct definition files loaded?");
            }
            else
            {
                if (dicomMessage.IodNamesValidatedAgainst.Contains(iodName))
                {
                    this.thread.WriteInformationInternal("- Skipping definition file validation: already performed for \"" + iodName + "\".");
                }
                else
                {
                    dicomMessage.DataSet.IodId = iodName;
                    dicomMessage.IodNamesValidatedAgainst.Add(iodName);
                    validationFlag = Dvtk.Sessions.ValidationControlFlags.UseDefinitions;
                    this.thread.WriteInformationInternal("- Using \"" + iodName + "\" for definition file validation.");
                }
            }

            return(validationFlag);
        }
Exemplo n.º 4
0
        public virtual void AssociationReleasedEventHandler(DicomThread dicomThread)
        {
            DicomTransaction transaction = new DicomTransaction(TransactionNameEnum.RAD_10, TransactionDirectionEnum.TransactionReceived);

            foreach (DicomMessage dicomMessage in dicomThread.DataWarehouse.Messages(dicomThread).DicomMessages)
            {
                transaction.DicomMessages.Add(dicomMessage);
            }

            // publish the transaction event to any interested parties
            PublishEvent(ActorName, transaction);

            // get the next transaction number - needed to sort the
            // transactions correctly
            int transactionNumber = TransactionNumber.GetNextTransactionNumber();

            // save the transaction
            ActorsTransaction actorsTransaction = new ActorsTransaction(transactionNumber,
                                                                        ParentActor.ActorName,
                                                                        ActorName,
                                                                        transaction,
                                                                        dicomThread.ResultsFileName,
                                                                        dicomThread.NrOfErrors,
                                                                        dicomThread.NrOfWarnings);

            ParentActor.ActorsTransactionLog.Add(actorsTransaction);

            dicomThread.DataWarehouse.ClearMessages(dicomThread);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Validate the Dicom Message using a definition file.
        /// </summary>
        /// <param name="dicomMessage">The Dicom Message.</param>
        /// <param name="iodId">The IOD ID to use, implicitly determining which definition file to use.</param>
        ///

        public void Validate(DicomThread dicomThread, DicomMessage dicomMessage, String iodName)
        {
            this.thread.WriteInformationInternal("Validate Dicom message...");

            Dvtk.Sessions.ValidationControlFlags validationFlags = Dvtk.Sessions.ValidationControlFlags.None;

            // Determine if the VR's need to be validated.
            validationFlags |= ValidateValueRepresentations(dicomMessage);

            // Determine if the DicomMessage can or needs to be validated against a definition file.
            if (iodName.Length > 0)
            {
                validationFlags |= ValidateUseDefinitions(dicomMessage, iodName);
            }

            // If validation is needed, do it now.
            if (validationFlags != Dvtk.Sessions.ValidationControlFlags.None)
            {
                dicomThread.DvtkScriptSession.Validate(dicomMessage.DvtkDataDicomMessage, null, validationFlags);
            }
            else
            {
                dicomThread.WriteInformationInternal("No validation performed.");
            }
        }
Exemplo n.º 6
0
        public override void AssociationReleasedEventHandler(DicomThread storageScp)
        {
            // do SCP specific post association processing here

            // call base implementation to generate event, update transaction log and cleanup data warehouse
            base.AssociationReleasedEventHandler(storageScp);
        }
Exemplo n.º 7
0
        private void LogTransaction()
        {
            DicomThread dicomThread = (DicomThread)DvtkHighLevelInterface.Common.Threads.Thread.CurrentThread;

            if (dicomThread == null)
            {
                return;
            }

            if (_currentDicomTransaction == null)
            {
                return;
            }

            // save the transaction
            ActorsTransaction actorsTransaction = new ActorsTransaction(_transactionNumber,
                                                                        _dicomClient.ActorName,             // from actor
                                                                        _dicomClient.ParentActor.ActorName, // to actor
                                                                        _currentDicomTransaction,
                                                                        this.Options.ResultsFileNameOnly,
                                                                        this.Options.ResultsFullFileName,
                                                                        (uint)dicomThread.NrOfErrors,
                                                                        (uint)dicomThread.NrOfWarnings);

            // save the transaction in the Actor log
            _dicomClient.ParentActor.ActorsTransactionLog.Add(actorsTransaction);

            // publish the transaction event to any interested parties
            _dicomClient.PublishTransactionAvailableEvent(_dicomClient.ActorName, actorsTransaction);

            // remove any messages from the dicom thread
            dicomThread.ClearMessages();

            _currentDicomTransaction = null;
        }
Exemplo n.º 8
0
 internal void AddMessage(DicomThread dicomThread, DicomProtocolMessage message)
 {
     lock (lockObject)
     {
         dicomThread.Messages.Add(message);
         this.messages.Add(message);
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Read a Dicom file or a raw file (containing only a data set).
        /// Previously present attributes will not be available after this method call.
        ///
        /// The dicomThread.Option.StorageMode will determine if pixel data will
        /// be accessable after reading. The dicomThread.Option.DataDirectory will
        /// determine where it will be stored, if configured so and if available.
        ///
        /// When definition files are loaded by the supplied DicomThread, the
        /// content of these definition files are used to change the VR UN of
        /// attributes to the VR's found in the definition files.
        /// </summary>
        /// <param name="fullFileName">The full file name of the Dicom file or raw file.</param>
        /// <param name="dicomThread">The DicomThread.</param>
        public void Read(String fullFileName, DicomThread dicomThread)
        {
            DicomFile dicomFile = new DicomFile();

            dicomFile.Read(fullFileName, dicomThread);

            this.dvtkDataAttributeSet = dicomFile.DataSet.DvtkDataDataSet;
        }
Exemplo n.º 10
0
 public OverviewThread(DicomThread sourceQRDicomThread, ArrayList selectedTS, bool patientRoot, bool studyRoot, bool patientStudyRoot, List <DICOMPeer> dicomPeers)
 {
     this.sourceQRDicomThread = sourceQRDicomThread;
     this.selectedTSList      = selectedTS;
     isPatientRoot            = patientRoot;
     isStudyRoot        = studyRoot;
     isPatientStudyRoot = patientStudyRoot;
     DicomPeers         = dicomPeers;
 }
Exemplo n.º 11
0
 public void Validate(DicomThread dicomThread, DicomProtocolMessage dicomProtocolMessage)
 {
     if (dicomProtocolMessage is DulMessage)
     {
         Validate(dicomThread, dicomProtocolMessage as DulMessage);
     }
     else
     {
         Validate(dicomThread, dicomProtocolMessage as DicomMessage);
     }
 }
Exemplo n.º 12
0
 public OverviewThread(DicomThreadOptions mppsOptions, DicomThread thread,
                       ArrayList selectedTS, bool isSendRandomRsps, string dcmFile, int nrOfRsps)
 {
     this.mppsOptions       = mppsOptions;
     this.worklistThread    = thread;
     this.worklistOptions   = thread.Options;
     this.selectedTSList    = selectedTS;
     this.sendRandomizeRsps = isSendRandomRsps;
     this.selectedDCMFile   = dcmFile;
     this.nrOfRandomRsps    = nrOfRsps;
 }
Exemplo n.º 13
0
        //
        // - Methods -
        //

        /// <summary>
        /// Clear this collections, read in all DataSet files in the specified path and add them to this collection.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="searchPattern">The search pattern to use.</param>
        /// <param name="dicomThread">The DicomThread instance to use.</param>
        public void Read(String path, String searchPattern, DicomThread dicomThread)
        {
            Clear();

            String[] fileNames = Directory.GetFiles(path, searchPattern);

            foreach (String fileName in fileNames)
            {
                DataSet dataSet = new DataSet();
                dataSet.Read(fileName, dicomThread);
                Add(dataSet);
            }
        }
Exemplo n.º 14
0
        public DicomProtocolMessageCollection Messages(DicomThread dicomThread)
        {
            DicomProtocolMessageCollection dicomProtocolMessageCollection = new DicomProtocolMessageCollection();

            lock (lockObject)
            {
                foreach (DicomProtocolMessage dicomProtocolMessage in dicomThread.Messages)
                {
                    dicomProtocolMessageCollection.Add(dicomProtocolMessage);
                }
            }

            return(dicomProtocolMessageCollection);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Reads a Dicom File or Data Set file.
        /// </summary>
        /// <remarks>
        /// The previous attributes of this instance will be removed.
        /// <br></br><br></br>
        /// NOTE:<br></br>
        /// The intention of this method is to use only the definition files loaded in the supplied
        /// DicomThread. The current implementation however uses all already loaded definition files outside this
        /// method!
        /// <br></br><br></br>
        /// Also see properties UnVrDefinitionLookUpWhenReading and StoreOBOFOWValuesWhenReading.
        /// <br></br><br></br>
        /// If something goes wrong while reading the file, an exception is thrown.
        /// </remarks>
        /// <param name="fullFileName">The full file name.</param>
        /// <param name="dicomThread">The DicomThread, from which the definition files to use for determining the attribute names are used.</param>
        public void Read(String fullFileName, DicomThread dicomThread)
        {
            DicomFile dicomFile = new DicomFile();

            dicomFile.StoreOBOFOWValuesWhenReading    = this.storeOBOFOWValuesWhenReading;
            dicomFile.UnVrDefinitionLookUpWhenReading = this.unVrDefinitionLookUpWhenReading;

            // Make sure that the DicomFile object is using this object as the DataSet to put the
            // attributes in during reading.
            dicomFile.CreateNewDataSetObjectWhenReading = false;
            dicomFile.DataSet = this;

            dicomFile.Read(fullFileName, dicomThread);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Validate the Dul Message by inspecting the VR's and the definition.
        /// </summary>
        /// <param name="dulMessage">The Dul Message.</param>

        public void Validate(DicomThread dicomThread, DulMessage dulMessage)
        {
            this.thread.WriteInformationInternal("Validate Dul message...");

            if (!dulMessage.AreValueRepresentationsValidated)
            {
                dicomThread.DvtkScriptSession.Validate(dulMessage.DvtkDataDulMessage, null, Dvtk.Sessions.ValidationControlFlags.UseValueRepresentations);
                dulMessage.AreValueRepresentationsValidated = true;
            }
            else
            {
                dicomThread.WriteInformationInternal("VR's of DulMessage will not be validated again.\r\nNo validation performed.");
            }
        }
Exemplo n.º 17
0
        public void Validate(DicomThread dicomThread, DicomMessage dicomMessage1, DicomMessage dicomMessage2)
        {
            this.thread.WriteInformationInternal("Validate Dicom message...");

            Dvtk.Sessions.ValidationControlFlags validationFlags = Dvtk.Sessions.ValidationControlFlags.None;

            // Determine if the VR's need to be validated.
            validationFlags |= ValidateValueRepresentations(dicomMessage1);

            // Determine if the DicomMessage can or needs to be validated against a definition file.
            validationFlags |= ValidateUseDefinitions(dicomThread, dicomMessage1);

            this.thread.WriteInformationInternal("- Using reference Dicom message.");
            dicomThread.DvtkScriptSession.Validate(dicomMessage1.DvtkDataDicomMessage, dicomMessage2.DvtkDataDicomMessage, validationFlags | Dvtk.Sessions.ValidationControlFlags.UseReferences);
        }
Exemplo n.º 18
0
        public void Read(String fullFileName, DicomThread dicomThread)
        {
            DvtkData.Media.DicomFile dvtkDataDicomFile = null;

            if (!File.Exists(fullFileName))
            {
                throw new HliException("Dicom file or raw file \"" + fullFileName + "\" not found.");
            }

            dvtkDataDicomFile = dicomThread.DvtkScriptSession.ReadFile(fullFileName);

            this.dataSet.DvtkDataDataSet = dvtkDataDicomFile.DataSet;
            this.fileMetaInformation.DvtkDataFileMetaInformation = dvtkDataDicomFile.FileMetaInformation;
            this.dvtkDataFileHead = dvtkDataDicomFile.FileHead;
        }
Exemplo n.º 19
0
        public static void SetOptions(DicomThread dicomThread, String testName, String identifier)
        {
            String TestResultsDirectory = Path.Combine(Paths.ResultsDirectoryFullPath, testName);

            if (!Directory.Exists(TestResultsDirectory))
            {
                Directory.CreateDirectory(TestResultsDirectory);
            }

            dicomThread.Options.LocalPort        = 104;
            dicomThread.Options.RemotePort       = 104;
            dicomThread.Options.RemoteHostName   = "localhost";
            dicomThread.Options.ResultsDirectory = TestResultsDirectory;
            dicomThread.Options.Identifier       = identifier;
        }
Exemplo n.º 20
0
        public override bool HandleCGetRequest(DicomMessage dicomMessage)
        {
            // Validate the received message
            System.String iodName = DicomThread.GetIodNameFromDefinition(dicomMessage);
            DicomThread.Validate(dicomMessage, iodName);

            // Storage suboperations should be sent over the same association as the CGET.
            // The CGET SCU becomes a Storage SCP for the duration of the storage suboperations.
            // The CGET SCU should ensure that all the necessary storage SOP Classes are negotiated
            // during association establishment.

            DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CGETRSP);

            this.Send(responseMessage);
            return(true);
        }
Exemplo n.º 21
0
        public override bool HandleNSetRequest(DicomMessage dicomMessage)
        {
            // Try to get the IOD Name
            System.String iodName = DicomThread.GetIodNameFromDefinition(dicomMessage);

            System.String messsage = String.Format("Processed N-SET-RQ {0}", iodName);
            DicomThread.WriteInformation(messsage);

            DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.NSETRSP);

            responseMessage.Set("0x00000900", DvtkData.Dimse.VR.US, 0);

            this.Send(responseMessage);

            return(true);
        }
Exemplo n.º 22
0
        public override bool HandleCMoveRequest(DicomMessage retrieveMessage)
        {
            if (_informationModels == null)
            {
                return(false);
            }

            // Refresh the Information Models
            _informationModels.Refresh();

            // Validate the received message
            System.String iodName = DicomThread.GetIodNameFromDefinition(retrieveMessage);
            DicomThread.Validate(retrieveMessage, iodName);

            // try to get the SOP Class Uid so that we know which Information Model to use.
            DvtkHighLevelInterface.Values values       = retrieveMessage.CommandSet.GetAttributeValues("0x00000002");
            System.String sopClassUid                  = values.GetString(1);
            DvtkData.Dul.AbstractSyntax abstractSyntax = new DvtkData.Dul.AbstractSyntax(sopClassUid);

            // try to get the Move Destination AE.
            values = retrieveMessage.CommandSet.GetAttributeValues("0x00000600");
            System.String moveDestinationAE = values.GetString(1);

            DvtkData.Collections.StringCollection retrieveList = null;

            // check if we should use the Patient Root Information Model
            if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Patient_Root_Query_Retrieve_Information_Model_MOVE.UID) &&
                (_informationModels.PatientRoot != null))
            {
                retrieveList = _informationModels.PatientRoot.RetrieveInformationModel(retrieveMessage);
            }
            // check if we should use the Study Root Information Model
            else if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Study_Root_Query_Retrieve_Information_Model_MOVE.UID) &&
                     (_informationModels.StudyRoot != null))
            {
                retrieveList = _informationModels.StudyRoot.RetrieveInformationModel(retrieveMessage);
            }
            // check if we should use the Patient Study Only Information Model
            else if ((abstractSyntax.UID == DvtkData.Dul.AbstractSyntax.Patient_Study_Only_Query_Retrieve_Information_Model_MOVE.UID) &&
                     (_informationModels.PatientStudyOnly != null))
            {
                retrieveList = _informationModels.PatientStudyOnly.RetrieveInformationModel(retrieveMessage);
            }

            // process the retrieve list
            return(ProcessRetrieveList(moveDestinationAE, retrieveList));
        }
Exemplo n.º 23
0
        /// <summary>
        /// Overridden N-ACTION-RQ message handler.
        /// </summary>
        /// <param name="queryMessage">N-ACTION-RQ and Dataset.</param>
        /// <returns>Boolean - true if dicomMessage handled here.</returns>
        public override bool HandleNActionRequest(DicomMessage dicomMessage)
        {
            // Validate the received message
            System.String iodName = DicomThread.GetIodNameFromDefinition(dicomMessage);
            DicomThread.Validate(dicomMessage, iodName);

            // set up the default N-ACTION-RSP with a successful status
            DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.NACTIONRSP);

            responseMessage.Set("0x00000900", DvtkData.Dimse.VR.US, 0);

            // send the response
            this.Send(responseMessage);

            // message handled
            return(true);
        }
Exemplo n.º 24
0
            /// <summary>
            /// Determines if the first received DicomMessage in a DicomThread instance has an explicit transfer syntax.
            /// </summary>
            /// <param name="dicomThread">The DicomThread.</param>
            /// <returns>Boolean indicating if the first received DicomMessage has an explicit transfer syntax.</returns>
            private bool IsDataTransferExplicit(DicomThread dicomThread)
            {
                bool isDataTransferExplicit = true;

                if ((dicomThread.Messages.ReceivedMessages.DicomMessages.Count > 0))
                {
                    DicomMessage firstReceivedDicomMessage = dicomThread.Messages.ReceivedMessages.DicomMessages[0];

                    byte presentationContextIdFirstReceivedDicomMessage = firstReceivedDicomMessage.EncodedPresentationContextID;

                    AssociateAc firstReceivedAssociateAc = null;

                    foreach (DulMessage dulMessage in dicomThread.Messages.SendMessages.DulMessages)
                    {
                        if (dulMessage is AssociateAc)
                        {
                            firstReceivedAssociateAc = dulMessage as AssociateAc;

                            break;
                        }
                    }

                    if (firstReceivedAssociateAc != null)
                    {
                        foreach (PresentationContext presentationContext in firstReceivedAssociateAc.PresentationContexts)
                        {
                            if (presentationContext.ID == presentationContextIdFirstReceivedDicomMessage)
                            {
                                String transferSyntax = presentationContext.TransferSyntax;

                                if (transferSyntax == "1.2.840.10008.1.2")
                                {
                                    isDataTransferExplicit = false;
                                }
                                else
                                {
                                    isDataTransferExplicit = true;
                                }
                            }
                        }
                    }
                }

                return(isDataTransferExplicit);
            }
Exemplo n.º 25
0
        public override bool HandleNCreateRequest(DicomMessage dicomMessage)
        {
            // Try to get the IOD Name
            System.String iodName = DicomThread.GetIodNameFromDefinition(dicomMessage);

            // Try to get the Patient Name
            DvtkHighLevelInterface.Dicom.Other.Values attributeValues = dicomMessage["0x00100010"].Values;
            System.String patientName = attributeValues[0];
            System.String messsage    = String.Format("Processed N-CREATE-RQ {0}: \"{1}\"", iodName, patientName);
            WriteInformation(messsage);

            DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.NCREATERSP);

            responseMessage.Set("0x00000900", VR.US, 0);

            this.Send(responseMessage);
            return(true);
        }
Exemplo n.º 26
0
        public override void AssociationReleasedEventHandler(DicomThread storageCommitScp)
        {
            // do SCP specific post association processing here
            // iterate over all the dicomMessages in the data warehouse
            foreach (DicomMessage dicomMessage in storageCommitScp.DataWarehouse.Messages(storageCommitScp).DicomMessages)
            {
                // check for the N-ACTION-RQ
                if (dicomMessage.CommandSet.DimseCommand == DvtkData.Dimse.DimseCommand.NACTIONRQ)
                {
                    // produce a DICOM trigger for the Storage Commitment SCU - N-EVENT-REPORT-RQ
                    DicomTrigger storageCommitTrigger = GenerateTrigger(dicomMessage);
                    ParentActor.TriggerActor(ActorName, storageCommitTrigger);
                }
            }

            // call base implementation to generate event, update transaction log and cleanup data warehouse
            base.AssociationReleasedEventHandler(storageCommitScp);
        }
Exemplo n.º 27
0
        private void LogTransaction()
        {
            DicomThread dicomThread = (DicomThread)DvtkHighLevelInterface.Common.Threads.Thread.CurrentThread;

            if (dicomThread == null)
            {
                return;
            }

            if (_currentDicomTransaction == null)
            {
                return;
            }

            // get the next transaction number - needed to sort the
            // transactions correctly
            int transactionNumber = TransactionNumber.GetNextTransactionNumber();

            // save the transaction
            ActorsTransaction actorsTransaction = new ActorsTransaction(transactionNumber,
                                                                        ActorName,             // from actor
                                                                        ParentActor.ActorName, // to actor
                                                                        _currentDicomTransaction,
                                                                        dicomThread.Options.ResultsFileNameOnly,
                                                                        dicomThread.Options.ResultsFullFileName,
                                                                        (uint)dicomThread.NrOfErrors,
                                                                        (uint)dicomThread.NrOfWarnings);

            // save the transaction in the Actor log
            ParentActor.ActorsTransactionLog.Add(actorsTransaction);

            // publish the transaction event to any interested parties
            PublishTransactionAvailableEvent(ActorName, actorsTransaction);

            // remove any messages from the dicom thread
            dicomThread.ClearMessages();

            _currentDicomTransaction = null;
        }
Exemplo n.º 28
0
        /// <summary>
        /// Overridden C-STORE-RQ message handler that makes use of the appropriate Information Model to handle the storage.
        /// </summary>
        /// <param name="queryMessage">C-STORE-RQ and Dataset.</param>
        /// <returns>Boolean - true if dicomMessage handled here.</returns>
        public override bool HandleCStoreRequest(DicomMessage dicomMessage)
        {
            // Validate the received message
            System.String iodName = DicomThread.GetIodNameFromDefinition(dicomMessage);
            DicomThread.Validate(dicomMessage, iodName);

            // update the information models
            if (_informationModels != null)
            {
                // add this dataset to the information models
                _informationModels.Add(dicomMessage.DataSet);
            }

            // set up the default C-STORE-RSP with a successful status
            DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CSTORERSP);

            responseMessage.Set("0x00000900", DvtkData.Dimse.VR.US, 0);

            // send the response
            this.Send(responseMessage);

            // message handled
            return(true);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Get a HTML table containing an overview of all started Threads.
        /// <br></br><br></br>
        /// When no started Thread exists, the supplied noStartedThreadsText is returned.
        /// </summary>
        /// <param name="headerText">Text to be displayed in the table header.</param>
        /// <param name="noStartedThreadsText">Text that is returned when no started Threads exist.</param>
        /// <param name="hyperlinkFromDirectory">If hyperlinks to results are in the same directory as specified here, a relative path is used.</param>
        /// <returns></returns>
        public String GetStartedThreadsOverviewAsHTML(String headerText, String noStartedThreadsText, String hyperlinkFromDirectory)
        {
            // Start of table.
            int    rowCount    = 0;
            String returnValue = "";
            String htmlTable   = "<br /><table border=\"1\" width=\"100%\" cellpadding=\"3\">\r\n";

            htmlTable += "<font color=\"#000080\">\r\n";

            // Header row 1.
            htmlTable += "<tr><td align=\"center\" valign=\"top\" class=\"item\" colspan=\"3\"><b>" + headerText + "</b></td></tr>\r\n";

            // Header row 2.
            htmlTable += "<tr>\r\n";
            htmlTable += "<td valign=\"top\" width=\"200\" class=\"item\"><b>Thread<b></td>\r\n";
            htmlTable += "<td valign=\"top\" width=\"200\" class=\"item\"><b>Hyperlinks</b></td>\r\n";
            htmlTable += "<td valign=\"top\" class=\"item\"><b>Comments</b></td>\r\n";
            htmlTable += "</tr>\r\n";

            // For each sub Thread, a table row.
            foreach (Thread childThread in this)
            {
                // Only if the child Thread has been started, show it in the table.
                if (childThread.HasBeenStarted)
                {
                    String type       = "-";
                    String hyperlinks = "-";
                    String comments   = "";

                    htmlTable += "<tr>\r\n";

                    // If the child Thread is a DicomThread...
                    if (childThread is DicomThread)
                    {
                        DicomThread childDicomThread = childThread as DicomThread;
                        UInt32      errorCount       = childDicomThread.DvtkScriptSession.NrOfErrors;
                        UInt32      warningCount     = childDicomThread.DvtkScriptSession.NrOfWarnings;

                        // Type.
                        type = "Dicom Thread \"" + childThread.ThreadOptions.Identifier + "\"";

                        // Comments
                        if (errorCount > 0)
                        {
                            comments += "<font color=\"#FF0000\">";
                        }
                        comments += "Number of Errors: " + errorCount.ToString() + "<br />";
                        if (errorCount > 0)
                        {
                            comments += "</font>";
                        }

                        if (warningCount > 0)
                        {
                            comments += "<font color=\"#FF0000\">";
                        }
                        comments += "Number of Warnings: " + warningCount.ToString() + "\r\n";
                        if (warningCount > 0)
                        {
                            comments += "</font>";
                        }

                        if (comments.Length == 0)
                        {
                            comments = "-";
                        }

                        // Hyperlinks.
                        // If the results directories are the same, use a relative path.
                        if (hyperlinkFromDirectory == childDicomThread.Options.ResultsDirectory)
                        {
                            if (childDicomThread.Options.GenerateDetailedResults)
                            {
                                hyperlinks = "View <a href=\"" + childDicomThread.Options.DetailResultsFileNameOnly + "\">detail results</a><br />\r\n";
                            }

                            hyperlinks += "View <a href=\"" + childDicomThread.Options.SummaryResultsFileNameOnly + "\">summary results</a><br />\r\n";
                        }
                        // If the results directories are not the same, use an absolute path.
                        else
                        {
                            if (childDicomThread.Options.GenerateDetailedResults)
                            {
                                hyperlinks = "View <a href=\"" + childDicomThread.Options.DetailResultsFullFileName + "\">detail results</a><br />\r\n";
                            }

                            hyperlinks += "View <a href=\"" + childDicomThread.Options.SummaryResultsFullFileName + "\">summary results</a><br />\r\n";
                        }
                    }

                    // If the child Thread is a HL7Thread...
                    //						else if (childThread is Hl7Thread)
                    //						{
                    //							type = "HL7 Thread \"" + childThread.Options.Identifier + "\"";
                    //						}
                    // In all other cases...
                    else
                    {
                        // Do nothing.
                    }

                    htmlTable += "<td valign=\"top\" width=\"200\" class=\"item\">" + type + "</td>\r\n";
                    htmlTable += "<td valign=\"top\" width=\"200\" class=\"item\">" + hyperlinks + "</td>\r\n";
                    htmlTable += "<td valign=\"top\" class=\"item\">" + comments + "</td>\r\n";

                    htmlTable += "</tr>\r\n";
                    rowCount++;
                }
            }


            // End of table.
            htmlTable += "</td></tr></font></table>\r\n";

            if (rowCount > 0)
            {
                returnValue = htmlTable;
            }
            else
            {
                returnValue = "<br /><b>" + noStartedThreadsText + "</b><br />";
            }

            return(returnValue);
        }
Exemplo n.º 30
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="dicomThread">The DicomThread these options belong to.</param>
 public DicomThreadOptions(DicomThread dicomThread)
 {
     this.dicomThread            = dicomThread;
     this.styleSheetFullFileName = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "DVT_RESULTS.xslt");
 }