Пример #1
0
 public void CanPerformTransform()
 {
     Xslt xslt = new Xslt(IDENTITY_TRANSFORM);
     string input = "<qwerty>uiop</qwerty>";
     string output = new string(input.ToCharArray());
     Assert.Equal(output, xslt.Transform(input).AsString());
     Assert.Equal(output, xslt.Transform(input).AsString());
 }
Пример #2
0
        [Test] public void CanPerformTransform()
        {
            Xslt   xslt   = new Xslt(IDENTITY_TRANSFORM);
            string input  = "<qwerty>uiop</qwerty>";
            string output = new string(input.ToCharArray());

            Assert.AreEqual(output, xslt.Transform(input).AsString());
            Assert.AreEqual(output, xslt.Transform(input).AsString());
        }
Пример #3
0
        /// <summary>
        /// Asserts that the results of an XSL transform on some XML are the expected result
        /// </summary>
        /// <param name="xslTransform">The XSL transform.</param>
        /// <param name="xmlToTransform">The XML to transform.</param>
        /// <param name="expectedResult">The expected result.</param>
        public static void XslTransformResults(XmlInput xslTransform, XmlInput xmlToTransform, XmlInput expectedResult)
        {
            Xslt      xslt   = new Xslt(xslTransform);
            XmlOutput output = xslt.Transform(xmlToTransform);

            XmlEquals(expectedResult, output.AsXml());
        }
Пример #4
0
        /// <summary>
        /// Close the Results reporting.
        /// </summary>
        /// <returns>System.String - results filename.</returns>
        public System.String CloseResults()
        {
            _resultsReporter.Stop();

            // convert the results file
            System.String resultsFilename = Xslt.Transform(_resultsDirectory, _resultsFilename);

            // create the result overview
            CreateResultOverview(resultsFilename);

            return(resultsFilename);
        }
        /// <summary>
        /// Transforms the XML string using the <see cref="XslCompiledTransform" />
        /// defined by the instance's <see cref="XslOpenXmlTransformation{TDocument}.Xslt" />
        /// property and the <see cref="XsltArgumentList" /> defined in the instance's
        /// <see cref="XslOpenXmlTransformation{TDocument}.Arguments" /> property.
        /// </summary>
        /// <param name="xml">The XML string to be transformed</param>
        /// <returns>The transformed XML string</returns>
        public override string Transform(string xml)
        {
            if (xml == null)
            {
                return(null);
            }
            if (Xslt == null)
            {
                throw new OpenXmlTransformationException("Xslt is not initialized");
            }

            var sb = new StringBuilder();

            using (var sr = new StringReader(xml))
                using (var xr = XmlReader.Create(sr))
                    using (var xw = XmlWriter.Create(sb))
                        Xslt.Transform(xr, Arguments, xw);

            return(sb.ToString());
        }
Пример #6
0
 public static void AssertXslTransformResults(XmlInput xslTransform, XmlInput xmlToTransform,
                                              XmlInput expectedResult)
 {
     Xslt xslt = new Xslt(xslTransform);
     XmlOutput output = xslt.Transform(xmlToTransform);
     AssertXmlEquals(expectedResult, output.AsXml());
 }
Пример #7
0
        private bool HandleSubOperation(System.String moveDestinationAE, System.String dcmFilename, int subOperationIndex)
        {
            SCU storageScu = new SCU();

            storageScu.Initialize(DicomThread.ThreadManager);
            storageScu.Options.DeepCopyFrom(DicomThread.Options);

            storageScu.Options.Identifier = "StorageSubOperationAsScu";

            ////Check for Secure connection
            //if (DicomThread.Options.SecureConnection)
            //{
            //    storageScu.Options.SecureConnection = true;
            //    storageScu.Options.CertificateFilename = DicomThread.Options.CertificateFilename;
            //    storageScu.Options.CredentialsFilename = DicomThread.Options.CredentialsFilename;
            //}

            storageScu.Options.ResultsFileNameOnlyWithoutExtension = "StorageSubOperationAsScu" + subOperationIndex.ToString();
            storageScu.Options.ResultsDirectory = DicomThread.Options.ResultsDirectory;

            storageScu.Options.LocalAeTitle = DicomThread.Options.LocalAeTitle;
            storageScu.Options.LocalPort    = DicomThread.Options.LocalPort;
            if (IsHaveMoveDestinations)
            {
                storageScu.Options.RemoteAeTitle  = moveDestinationAE;
                storageScu.Options.RemotePort     = MoveDestiantions[MoveAEdetailsIndex].Port;
                storageScu.Options.RemoteHostName = MoveDestiantions[MoveAEdetailsIndex].IP;
            }
            else
            {
                storageScu.Options.RemoteAeTitle  = moveDestinationAE;
                storageScu.Options.RemotePort     = DicomThread.Options.RemotePort;
                storageScu.Options.RemoteHostName = DicomThread.Options.RemoteHostName;
            }

            storageScu.Options.DataDirectory = DicomThread.Options.DataDirectory;
            storageScu.Options.StorageMode   = Dvtk.Sessions.StorageMode.AsDataSet;

            // Read the DCM File
            DicomFile dcmFile = new DicomFile();

            dcmFile.Read(dcmFilename, storageScu);

            FileMetaInformation fMI = dcmFile.FileMetaInformation;

            // Get the transfer syntax and SOP class UID
            System.String transferSyntax = "1.2.840.10008.1.2";
            if ((fMI != null) && fMI.Exists("0x00020010"))
            {
                // Get the Transfer syntax
                DvtkHighLevelInterface.Dicom.Other.Attribute tranferSyntaxAttr = fMI["0x00020010"];
                transferSyntax = tranferSyntaxAttr.Values[0];
            }

            Values values = dcmFile.DataSet["0x00080016"].Values;

            System.String sopClassUid = values[0];

            PresentationContext presentationContext = new PresentationContext(sopClassUid,             // Abstract Syntax Name
                                                                              transferSyntax);         // Transfer Syntax Name(s)

            PresentationContext[] presentationContexts = new PresentationContext[1];
            presentationContexts[0] = presentationContext;

            DicomMessage storageMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CSTORERQ);

            storageMessage.DataSet.CloneFrom(dcmFile.DataSet);

            storageScu.Start();

            bool sendResult = storageScu.TriggerSendAssociationAndWait(storageMessage, presentationContexts);

            if (!sendResult)
            {
                WriteWarning("Association to move destination for Storage Sub-Operation is rejected.");
            }

            if (storageScu.HasExceptionOccured)
            {
                WriteError("Storage Sub-Operation As SCU Failed");
            }
            storageScu.Stop();

            DicomMessageCollection cStoreResponses = storageScu.Messages.DicomMessages.CStoreResponses;

            // Obtain the value of the C-STORE RSP.The value of this variable is used to determine the attributes of the C-MOVE RSP.
            foreach (DicomMessage cStoreRsp in cStoreResponses)
            {
                cStoreStatusVal = Int32.Parse(cStoreRsp.CommandSet.GetValues("0x00000900")[0]);
            }

            // Transform the sub results
            Xslt.StyleSheetFullFileName = DicomThread.Options.StyleSheetFullFileName;
            System.String htmlResultsFilename = Xslt.Transform(storageScu.Options.ResultsDirectory, storageScu.Options.ResultsFileNameOnly);

            // Make link to the sub-operation results file
            System.String message = System.String.Format("<a href=\"{0}\">Storage sub-operation {1} to AE Title \"{2}\"</a><br/>",
                                                         htmlResultsFilename,
                                                         subOperationIndex,
                                                         moveDestinationAE);
            DicomThread.WriteHtmlInformation(message);

            return(sendResult);
        }
Пример #8
0
        private void ReportTransactions()
        {
            System.String message = System.String.Format("<h1>DVTk IHE Framework - {0}</h1>", Config.ProfileName);
            _resultsReporter.WriteHtmlInformation(message);
            _resultsReporter.WriteHtmlInformation("<h2>HL7 and DICOM Actor Transactions</h2>");
            for (int i = 0; i < _actorsTransactionLog.Count; i++)
            {
                foreach (ActorsTransaction actorsTransaction in _actorsTransactionLog)
                {
                    if (actorsTransaction.TransactionNumber == i + 1)
                    {
                        _nrErrors   += actorsTransaction.NrErrors;
                        _nrWarnings += actorsTransaction.NrWarnings;

                        System.String testResult = System.String.Empty;
                        System.String fontColor  = System.String.Empty;
                        if (actorsTransaction.NrErrors > 0)
                        {
                            fontColor  = "red";
                            testResult = "FAILED";
                        }
                        else
                        {
                            fontColor  = "green";
                            testResult = "PASSED";
                        }

                        message = System.String.Format("{0:000} <font color={1}>{2}</font>",
                                                       actorsTransaction.TransactionNumber,
                                                       fontColor,
                                                       testResult);
                        _resultsReporter.WriteHtmlInformation(message);

                        System.String resultsFilename = Xslt.Transform(_resultsDirectory, actorsTransaction.ResultsFilename);
                        switch (actorsTransaction.Direction)
                        {
                        case TransactionDirectionEnum.TransactionReceived:
                            message = System.String.Format(" - <a href=\"{0}\">Received by {1} from {2}</a></br>",
                                                           resultsFilename,
                                                           actorsTransaction.ToActorName.TypeId,
                                                           actorsTransaction.FromActorName.TypeId);
                            _resultsReporter.WriteHtmlInformation(message);
                            break;

                        case TransactionDirectionEnum.TransactionSent:
                            message = System.String.Format(" - <a href=\"{0}\">Sent from {1} to {2}</a></br>",
                                                           resultsFilename,
                                                           actorsTransaction.ToActorName.TypeId,
                                                           actorsTransaction.FromActorName.TypeId);
                            _resultsReporter.WriteHtmlInformation(message);
                            break;

                        default:
                            break;
                        }
                        break;
                    }
                }
            }
            _resultsReporter.WriteHtmlInformation("<br/><br/>");
        }