Exemplo n.º 1
0
        private void btnRetrieve_Click(object sender, EventArgs e)
        {
            XmlDocument retrieveDocumentSetRequest = new XmlDocument();

            try
            {
                XmlElement root = retrieveDocumentSetRequest.CreateElement("RetrieveDocumentSetRequest", "urn:ihe:iti:xds-b:2007");

                foreach (DocumentRequest docRequest in docRequestSrc)
                {
                    XmlElement documentRequest    = retrieveDocumentSetRequest.CreateElement("DocumentRequest", "urn:ihe:iti:xds-b:2007");
                    XmlElement homeCommunityID    = retrieveDocumentSetRequest.CreateElement("HomeCommunityId", "urn:ihe:iti:xds-b:2007");
                    XmlElement repositoryUniqueID = retrieveDocumentSetRequest.CreateElement("RepositoryUniqueId", "urn:ihe:iti:xds-b:2007");
                    XmlElement documentUniqueID   = retrieveDocumentSetRequest.CreateElement("DocumentUniqueId", "urn:ihe:iti:xds-b:2007");

                    homeCommunityID.InnerText    = docRequest.HomeCommunityID;
                    repositoryUniqueID.InnerText = docRequest.RepositoryUniqueID;
                    documentUniqueID.InnerText   = docRequest.DocumentUniqueID;

                    documentRequest.AppendChild(homeCommunityID);
                    documentRequest.AppendChild(repositoryUniqueID);
                    documentRequest.AppendChild(documentUniqueID);

                    root.AppendChild(documentRequest);
                }

                retrieveDocumentSetRequest.AppendChild(root);

                WCF.Message msgInput, msgOutput;

                msgInput = WCF.Message.CreateMessage(MESSAGE_VERSION
                                                     , RETRIEVEDOCUMENTSET_WSAACTION
                                                     , new XmlNodeReader(retrieveDocumentSetRequest));
                msgOutput = WCF.Message.CreateMessage(MESSAGE_VERSION, "");

                XDSRepository.XDSRepositoryClient client = new XDSRepository.XDSRepositoryClient(GetRepositoryEndPointName());

                msgOutput = client.RetrieveDocumentSet(msgInput);

                XmlDictionaryReader rdr = msgOutput.GetReaderAtBodyContents();

                XmlDocument result = new XmlDocument();
                result.Load(rdr);

                XmlNode fault     = result.SelectSingleNode(@"//*[local-name()='Fault']");
                XmlNode errorList = result.SelectSingleNode(@"//*[local-name()='RegistryErrorList']");

                if (fault != null)
                {
                    lblRetrieveDocumentSet.Text = "Error occurred when executing web service.";
                    rtfRetrieveDocumentSet.Text = fault.OuterXml;
                }
                else
                {
                    if (errorList != null)
                    {
                        lblRetrieveDocumentSet.Text = "Transaction resulted in Error!";
                        rtfRetrieveDocumentSet.Text = result.OuterXml;
                    }
                    else
                    {
                        lblRetrieveDocumentSet.Text = "Transaction succeded!";
                        rtfRetrieveDocumentSet.Text = result.OuterXml;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private void btnPRExecute_Click(object sender, EventArgs e)
        {
            try
            {
                string innerXml = null;

                if (PRDocumentMetadata != null)
                {
                    ProvideAndRegisterDocumentSetRequest request = new ProvideAndRegisterDocumentSetRequest();
                    request.DocumentMetadata = PRDocumentMetadata.SelectSingleNode(@".//*[local-name()='SubmitObjectsRequest']");
                    if (!(String.IsNullOrEmpty(txtPRPatientID.Text)))
                    {
                        innerXml = request.DocumentMetadata.InnerXml;
                        innerXml = innerXml.Replace("$PatientId", txtPRPatientID.Text.Replace("&", "&"));
                        request.DocumentMetadata.InnerXml = innerXml;
                        //request.DocumentMetadata.InnerXml = request.DocumentMetadata.InnerXml.Replace("$PatientId", txtPRPatientID.Text);
                    }

                    XmlNodeList docs = request.DocumentMetadata.SelectNodes(@"//*[local-name()='ExtrinsicObject']");

                    if (txtPRDocument1.Enabled == true && !string.IsNullOrEmpty(txtPRDocument1.Text))
                    {
                        IHEDocument doc1 = new IHEDocument();
                        doc1.DocumentID = docs.Item(0).Attributes["id"].Value;
                        doc1.Document   = LoadFile(txtPRDocument1.Text);
                        docs.Item(0).Attributes["mimeType"].Value = GetMimeType(txtPRDocument1.Text);
                        request.Documents.Add(doc1);
                    }

                    if (txtPRDocument2.Enabled == true && !string.IsNullOrEmpty(txtPRDocument2.Text))
                    {
                        IHEDocument doc2 = new IHEDocument();
                        doc2.DocumentID = docs.Item(1).Attributes["id"].Value;
                        doc2.Document   = LoadFile(txtPRDocument2.Text);
                        docs.Item(1).Attributes["mimeType"].Value = GetMimeType(txtPRDocument2.Text);
                        request.Documents.Add(doc2);
                    }

                    WCF.Message msgInput, msgOutput;
                    msgInput = WCF.Message.CreateMessage(MESSAGE_VERSION
                                                         , PROVIDEANDREGISTERDOCUMENTSETB_WSAACTION
                                                         , request);
                    msgOutput = WCF.Message.CreateMessage(WCF.MessageVersion.Soap12WSAddressing10, "");

                    XDSRepository.XDSRepositoryClient client = new XDSRepository.XDSRepositoryClient(GetRepositoryEndPointName());

                    msgOutput = client.ProvideAndRegisterDocumentSet(msgInput);

                    XmlDictionaryReader rdr = msgOutput.GetReaderAtBodyContents();

                    XmlDocument result = new XmlDocument();
                    result.Load(rdr);

                    XmlNode fault     = result.SelectSingleNode(@"//*[local-name()='Fault']");
                    XmlNode errorList = result.SelectSingleNode(@"//*[local-name()='RegistryErrorList']");

                    if (fault != null)
                    {
                        lblPRResult.Text          = "Error occurred when executing web service.";
                        rtfPRMetadataContent.Text = fault.OuterXml;
                    }
                    else
                    {
                        if (errorList != null)
                        {
                            lblPRResult.Text          = "Transaction resulted in Error!";
                            rtfPRMetadataContent.Text = result.OuterXml;
                        }
                        else
                        {
                            lblPRResult.Text          = "Transaction succeded!";
                            rtfPRMetadataContent.Text = result.OuterXml;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }