Exemplo n.º 1
0
 /// <summary>
 /// Class Constructor.
 /// </summary>
 /// <param name="profileName">Integration Profile Name.</param>
 public IheFrameworkConfig(System.String profileName)
 {
     _profileName = profileName;
     _commonConfig = new CommonConfig();
     _actorConfigCollection = new ActorConfigCollection();
     _peerToPeerConfigCollection = new BasePeerToPeerConfigCollection();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Load the Actor Configuration into the Integration Profile.
        /// </summary>
        /// <param name="configurationFilename">Configuration Filename</param>
        public void Load(System.String configurationFilename)
        {
            _actorConfigCollection = new ActorConfigCollection();
            _peerToPeerConfigCollection = new BasePeerToPeerConfigCollection();

            try
            {
                XmlTextReader reader = new XmlTextReader(configurationFilename);
                while (reader.EOF == false)
                {
                    reader.ReadStartElement("IheIntegrationProfile");
                    _profileName = reader.ReadElementString("IntegrationProfileName");
                    _commonConfig.RootedBaseDirectory = reader.ReadElementString("RootedBaseDirectory");
                    _commonConfig.ResultsDirectory = reader.ReadElementString("ResultsDirectory");

                    // read OverwriteResults - added later - some config files may not contain this parameter
                    reader.ReadString();
                    if (reader.Name == "OverwriteResults")
                    {
                        System.String overwriteResults = reader.ReadElementString("OverwriteResults");
                        if (overwriteResults == "True")
                        {
                            _commonConfig.OverwriteResults = true;
                        }
                        else
                        {
                            _commonConfig.OverwriteResults = false;
                        }
                    }

                    _commonConfig.CredentialsFilename = reader.ReadElementString("CredentialsFilename");
                    _commonConfig.CertificateFilename = reader.ReadElementString("CertificateFilename");
                    _commonConfig.NistWebServiceUrl = reader.ReadElementString("NistWebServiceUrl");
                    _commonConfig.Hl7ProfileDirectory = reader.ReadElementString("Hl7ProfileDirectory");
                    _commonConfig.Hl7ProfileStoreName = reader.ReadElementString("Hl7ProfileStoreName");
                    _commonConfig.Hl7ValidationContextFilename = reader.ReadElementString("Hl7ValidationContextFilename");
                    System.String interactive = reader.ReadElementString("Interactive");
                    if (interactive == "True")
                    {
                        _commonConfig.Interactive = true;
                    }
                    else
                    {
                        _commonConfig.Interactive = false;
                    }

                    while ((reader.IsStartElement()) &&
                        (reader.Name == "ActorConfiguration"))
                    {
                        reader.ReadStartElement("ActorConfiguration");
                        reader.ReadStartElement("ActorName");
                        ActorTypeEnum actorType = ActorTypes.TypeEnum(reader.ReadElementString("ActorType"));
                        System.String id = reader.ReadElementString("ActorId");
                        ActorName actorName = new ActorName(actorType, id);
                        reader.ReadEndElement();
                        ActorConfigStateEnum configState = ActorConfigState.ConfigStateEnum(reader.ReadElementString("ConfigState"));
                        ActorConfig actorConfig = new ActorConfig(actorName, configState);
                        _actorConfigCollection.Add(actorConfig);
                        reader.ReadEndElement();
                    }

                    while ((reader.IsStartElement()) &&
                        ((reader.Name == "DicomPeerToPeerConfiguration") ||
                        (reader.Name == "Hl7PeerToPeerConfiguration")))
                    {
                        if (reader.Name == "DicomPeerToPeerConfiguration")
                        {
                            DicomPeerToPeerConfig dicomPeerToPeerConfig = new DicomPeerToPeerConfig();

                            reader.ReadStartElement("DicomPeerToPeerConfiguration");
                            reader.ReadStartElement("FromActor");
                            reader.ReadStartElement("ActorName");
                            ActorTypeEnum actorType = ActorTypes.TypeEnum(reader.ReadElementString("ActorType"));
                            System.String id = reader.ReadElementString("ActorId");
                            ActorName actorName = new ActorName(actorType, id);
                            dicomPeerToPeerConfig.FromActorName = actorName;
                            reader.ReadEndElement();
                            dicomPeerToPeerConfig.FromActorAeTitle = reader.ReadElementString("AeTitle");
                            reader.ReadEndElement();
                            reader.ReadStartElement("ToActor");
                            reader.ReadStartElement("ActorName");
                            actorType = ActorTypes.TypeEnum(reader.ReadElementString("ActorType"));
                            id = reader.ReadElementString("ActorId");
                            actorName = new ActorName(actorType, id);
                            dicomPeerToPeerConfig.ToActorName = actorName;
                            reader.ReadEndElement();
                            dicomPeerToPeerConfig.ToActorAeTitle = reader.ReadElementString("AeTitle");
                            dicomPeerToPeerConfig.ToActorIpAddress = reader.ReadElementString("IpAddress");
                            reader.ReadEndElement();
                            dicomPeerToPeerConfig.PortNumber = UInt16.Parse(reader.ReadElementString("PortNumber"));
                            System.String secureConnection = reader.ReadElementString("SecureConnection");
                            if (secureConnection == "True")
                            {
                                dicomPeerToPeerConfig.SecureConnection = true;
                            }
                            else
                            {
                                dicomPeerToPeerConfig.SecureConnection = false;
                            }

                            // read AutoValidate - added later - some config files may not contain this parameter
                            reader.ReadString();
                            if (reader.Name == "AutoValidate")
                            {
                                System.String autoValidate = reader.ReadElementString("AutoValidate");
                                if (autoValidate == "True")
                                {
                                    dicomPeerToPeerConfig.AutoValidate = true;
                                }
                                else
                                {
                                    dicomPeerToPeerConfig.AutoValidate = false;
                                }
                            }

                            dicomPeerToPeerConfig.ActorOption1 = reader.ReadElementString("ActorOption1");
                            dicomPeerToPeerConfig.ActorOption2 = reader.ReadElementString("ActorOption2");
                            dicomPeerToPeerConfig.ActorOption3 = reader.ReadElementString("ActorOption3");
                            dicomPeerToPeerConfig.SessionId = UInt16.Parse(reader.ReadElementString("SessionId"));
                            dicomPeerToPeerConfig.SourceDataDirectory = reader.ReadElementString("SourceDataDirectory");
                            dicomPeerToPeerConfig.StoreDataDirectory = reader.ReadElementString("StoreDataDirectory");
                            System.String storeData = reader.ReadElementString("StoreData");
                            if (storeData == "True")
                            {
                                dicomPeerToPeerConfig.StoreData = true;
                            }
                            else
                            {
                                dicomPeerToPeerConfig.StoreData = false;
                            }

                            reader.ReadStartElement("DefinitionFiles");

                            bool readingDefinitionFiles = true;
                            while (readingDefinitionFiles == true)
                            {
                                dicomPeerToPeerConfig.AddDefinitionFile(reader.ReadElementString("DefinitionFile"));
                                reader.Read();
                                if ((reader.NodeType == XmlNodeType.EndElement) &&
                                    (reader.Name == "DefinitionFiles"))
                                {
                                    reader.Read();
                                    readingDefinitionFiles = false;
                                }
                            }

                            _peerToPeerConfigCollection.Add(dicomPeerToPeerConfig);

                            reader.ReadEndElement();
                        }
                        else
                        {
                            Hl7PeerToPeerConfig hl7PeerToPeerConfig = new Hl7PeerToPeerConfig();

                            reader.ReadStartElement("Hl7PeerToPeerConfiguration");
                            reader.ReadStartElement("FromActor");
                            reader.ReadStartElement("ActorName");
                            ActorTypeEnum actorType = ActorTypes.TypeEnum(reader.ReadElementString("ActorType"));
                            System.String id = reader.ReadElementString("ActorId");
                            ActorName actorName = new ActorName(actorType, id);
                            hl7PeerToPeerConfig.FromActorName = actorName;
                            reader.ReadEndElement();
                            hl7PeerToPeerConfig.FromActorAeTitle = reader.ReadElementString("AeTitle");
                            reader.ReadEndElement();
                            reader.ReadStartElement("ToActor");
                            reader.ReadStartElement("ActorName");
                            actorType = ActorTypes.TypeEnum(reader.ReadElementString("ActorType"));
                            id = reader.ReadElementString("ActorId");
                            actorName = new ActorName(actorType, id);
                            hl7PeerToPeerConfig.ToActorName = actorName;
                            reader.ReadEndElement();
                            hl7PeerToPeerConfig.ToActorAeTitle = reader.ReadElementString("AeTitle");
                            hl7PeerToPeerConfig.ToActorIpAddress = reader.ReadElementString("IpAddress");
                            reader.ReadEndElement();
                            hl7PeerToPeerConfig.PortNumber = UInt16.Parse(reader.ReadElementString("PortNumber"));
                            hl7PeerToPeerConfig.MessageDelimiters.FromString(reader.ReadElementString("MessageDelimiters"));
                            System.String secureConnection = reader.ReadElementString("SecureConnection");
                            if (secureConnection == "True")
                            {
                                hl7PeerToPeerConfig.SecureConnection = true;
                            }
                            else
                            {
                                hl7PeerToPeerConfig.SecureConnection = false;
                            }

                            // read AutoValidate - added later - some config files may not contain this parameter
                            reader.ReadString();
                            if (reader.Name == "AutoValidate")
                            {
                                System.String autoValidate = reader.ReadElementString("AutoValidate");
                                if (autoValidate == "True")
                                {
                                    hl7PeerToPeerConfig.AutoValidate = true;
                                }
                                else
                                {
                                    hl7PeerToPeerConfig.AutoValidate = false;
                                }
                            }

                            hl7PeerToPeerConfig.ActorOption1 = reader.ReadElementString("ActorOption1");
                            hl7PeerToPeerConfig.ActorOption2 = reader.ReadElementString("ActorOption2");
                            hl7PeerToPeerConfig.ActorOption3 = reader.ReadElementString("ActorOption3");
                            hl7PeerToPeerConfig.SessionId = UInt16.Parse(reader.ReadElementString("SessionId"));

                            _peerToPeerConfigCollection.Add(hl7PeerToPeerConfig);

                            reader.ReadEndElement();
                        }
                    }

                    reader.ReadEndElement();
                }

                reader.Close();
            }
            catch (System.Exception e)
            {
                System.String message = System.String.Format("Failed to read configuration file: \"{0}\". Error: \"{1}\"", configurationFilename, e.Message);
                throw new System.SystemException(message, e);
            }
        }