Beispiel #1
0
        private void HandleDoWork(object sender, DoWorkEventArgs e)
        {
            MainBackgroundWorkerArgument argument = (MainBackgroundWorkerArgument)e.Argument;

            lock (this.fieldLock)
            {
                this.validationCompleted = false;
                this.xmlToHtmlCompleted  = false;
                this.exception           = null;
            }


            //
            // Perform the validation in the background.
            //

            ValidatorBackgroundWorkerArgument validatorBackgroundWorkerArgument = new ValidatorBackgroundWorkerArgument();

            validatorBackgroundWorkerArgument.structuredReportPath = argument.structuredReportPath;
            validatorBackgroundWorkerArgument.xmlPath = argument.xmlPath;
            this.validatorBackgroundWorker.RunWorkerAsync(validatorBackgroundWorkerArgument);


            //
            // Wait until validation has been completed.
            //

            bool wait = true;

            while (wait)
            {
                lock (this.fieldLock)
                {
                    wait = !this.validationCompleted;
                }

                if (wait)
                {
                    System.Threading.Thread.Sleep(100);
                }
            }


            //
            // If an exception has been thrown during validation, rethrow it again.
            //

            lock (this.fieldLock)
            {
                if (this.exception != null)
                {
                    throw (this.exception);
                }
            }


            //
            // Convert the .xml files to .html files.
            //

            // Iterate through all template files in the templates folder.
            foreach (string templatePath in Directory.GetFiles(this.templatesPath))
            {
                // Create for each template a Xslt Transformation Workitem and place it in the queue.
                string xmlFile  = Path.Combine(argument.xmlPath, "Output.xml");
                string htmlFile = Path.Combine(argument.htmlPath, Path.GetFileNameWithoutExtension(templatePath) + ".html");
                xsltProcessor.AddWorkItem(new WorkItem(xmlFile, templatePath, htmlFile));
            }

            string part3ValidationStyleSheetTransformationFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DVT_RESULTS.xslt");

            string part3ValidationSummaryXmlFile  = Path.Combine(argument.xmlPath, "Summary_Part 3 validation.xml");
            string part3ValidationSummaryHtmlFile = Path.Combine(argument.htmlPath, "Part 3 validation summary.html");

            xsltProcessor.AddWorkItem(new WorkItem(part3ValidationSummaryXmlFile, part3ValidationStyleSheetTransformationFile, part3ValidationSummaryHtmlFile));

            string part3ValidationDetailXmlFile  = Path.Combine(argument.xmlPath, "Detail_Part 3 validation.xml");
            string part3ValidationDetailHtmlFile = Path.Combine(argument.htmlPath, "Part 3 validation detail.html");

            xsltProcessor.AddWorkItem(new WorkItem(part3ValidationDetailXmlFile, part3ValidationStyleSheetTransformationFile, part3ValidationDetailHtmlFile));

            // Process the queue.
            xsltProcessor.StartAsync();


            //
            // Wait until .xml to .html conversion has been completed.
            //

            wait = true;

            while (wait)
            {
                lock (this.fieldLock)
                {
                    wait = !this.xmlToHtmlCompleted;
                }

                if (wait)
                {
                    System.Threading.Thread.Sleep(100);
                }
            }


            //
            // If an exception has been thrown during the xml to html conversion, rethrow it again.
            //

            lock (this.fieldLock)
            {
                if (this.exception != null)
                {
                    throw (this.exception);
                }
            }
        }
Beispiel #2
0
        private void HandleDoWork(object sender, DoWorkEventArgs e)
        {
            // Report Progress
            ReportProgress(0, "Start");


            ValidatorBackgroundWorkerArgument argument = (ValidatorBackgroundWorkerArgument)e.Argument;


            //
            // Initialization of the media session and context groups.
            //

            if (this.mediaSession == null)
            {
                InitializeMediaSession();
            }

            if (this.contextGroups == null)
            {
                InitializeContextGroups();
            }


            //
            // Read DICOM file and check if this is a Structured Report file.
            //

            // Report Progress
            ReportProgress(0, "Reading DICOM file: " + argument.structuredReportPath);

            DicomFile dicomFile = new DicomFile();

            dicomFile.Read(argument.structuredReportPath);

            // Perform sanity check if this is a valid Structured Report.
            bool valueTypeRootContentItemCorrect = false;

            DvtkHighLevelInterface.Dicom.Other.Attribute valueType = dicomFile.DataSet["0x0040A040"];
            if (valueType.Exists)
            {
                if (valueType.Values[0].Trim() == "CONTAINER")
                {
                    valueTypeRootContentItemCorrect = true;
                }
            }


            //
            // Validate against the loaded Context Groups and loaded definition files.
            //

            if (valueTypeRootContentItemCorrect)
            {
                // Report Progress.
                ReportProgress(40, "Parsing DICOM Structured Report: " + argument.structuredReportPath);

                // Parse the DICOM Structured Report.
                StructuredReport structuredReport = new StructuredReport(dicomFile.DataSet);

                // Report Progress.
                ReportProgress(60, "Validating content item values...");

                // Validate Content Items Value.
                ContentItemValueValidationRule contentItemValueValidationRule = new ContentItemValueValidationRule(contextGroups);
                structuredReport.RootContentItem.Accept(contentItemValueValidationRule);

                // Report Progress.
                ReportProgress(85, "Saving results: " + e.Argument.ToString());

                // Export structured report results to Xml file.
                String xmlFullFileName = Path.Combine(argument.xmlPath, "Output.xml");
                structuredReport.ToXml(xmlFullFileName);

                // Perform part 3 validation.
                this.mediaSession.ResultsRootDirectory = argument.xmlPath;
                this.mediaSession.StartResultsGathering("Part 3 validation.xml");
                //this.mediaSession.Validate(dicomFile.DvtkDataDicomFile, Dvtk.Sessions.ValidationControlFlags.None);
                this.mediaSession.ValidateMediaFiles(new string[] { argument.structuredReportPath });
                this.mediaSession.EndResultsGathering();

                // Report Progress.
                ReportProgress(100, "");
            }
            else
            {
                // Report Progress.
                ReportProgress(100, "");

                throw new Exception("Aborting validation because DICOM file does not contain Attribute Value Type (0040,A040) with value \"CONTAINER\" for root Content Item.");
            }
        }
Beispiel #3
0
        private void HandleDoWork(object sender, DoWorkEventArgs e)
        {
            MainBackgroundWorkerArgument argument = (MainBackgroundWorkerArgument)e.Argument;

            lock (this.fieldLock)
            {
                this.validationCompleted = false;
                this.xmlToHtmlCompleted = false;
                this.exception = null;
            }

            //
            // Perform the validation in the background.
            //

            ValidatorBackgroundWorkerArgument validatorBackgroundWorkerArgument = new ValidatorBackgroundWorkerArgument();
            validatorBackgroundWorkerArgument.structuredReportPath = argument.structuredReportPath;
            validatorBackgroundWorkerArgument.xmlPath = argument.xmlPath;
            this.validatorBackgroundWorker.RunWorkerAsync(validatorBackgroundWorkerArgument);

            //
            // Wait until validation has been completed.
            //

            bool wait = true;

            while (wait)
            {
                lock (this.fieldLock)
                {
                    wait = !this.validationCompleted;
                }

                if (wait)
                {
                    System.Threading.Thread.Sleep(100);
                }
            }

            //
            // If an exception has been thrown during validation, rethrow it again.
            //

            lock (this.fieldLock)
            {
                if (this.exception != null)
                {
                    throw (this.exception);
                }
            }

            //
            // Convert the .xml files to .html files.
            //

            // Iterate through all template files in the templates folder.
            foreach (string templatePath in Directory.GetFiles(this.templatesPath))
            {
                // Create for each template a Xslt Transformation Workitem and place it in the queue.
                string xmlFile = Path.Combine(argument.xmlPath, "Output.xml");
                string htmlFile = Path.Combine(argument.htmlPath, Path.GetFileNameWithoutExtension(templatePath) + ".html");
                xsltProcessor.AddWorkItem(new WorkItem(xmlFile, templatePath, htmlFile));
            }

            string part3ValidationStyleSheetTransformationFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DVT_RESULTS.xslt");

            string part3ValidationSummaryXmlFile = Path.Combine(argument.xmlPath, "Summary_Part 3 validation.xml");
            string part3ValidationSummaryHtmlFile = Path.Combine(argument.htmlPath, "Part 3 validation summary.html");
            xsltProcessor.AddWorkItem(new WorkItem(part3ValidationSummaryXmlFile, part3ValidationStyleSheetTransformationFile, part3ValidationSummaryHtmlFile));

            string part3ValidationDetailXmlFile = Path.Combine(argument.xmlPath, "Detail_Part 3 validation.xml");
            string part3ValidationDetailHtmlFile = Path.Combine(argument.htmlPath, "Part 3 validation detail.html");
            xsltProcessor.AddWorkItem(new WorkItem(part3ValidationDetailXmlFile, part3ValidationStyleSheetTransformationFile, part3ValidationDetailHtmlFile));

            // Process the queue.
            xsltProcessor.StartAsync();

            //
            // Wait until .xml to .html conversion has been completed.
            //

            wait = true;

            while (wait)
            {
                lock (this.fieldLock)
                {
                    wait = !this.xmlToHtmlCompleted;
                }

                if (wait)
                {
                    System.Threading.Thread.Sleep(100);
                }
            }

            //
            // If an exception has been thrown during the xml to html conversion, rethrow it again.
            //

            lock (this.fieldLock)
            {
                if (this.exception != null)
                {
                    throw (this.exception);
                }
            }
        }