/// <summary>
        /// True if the option is configured
        /// </summary>
        public bool IsConfigured(System.Xml.XmlDocument configurationDom)
        {
            // Determine if this is configured from the dom
            XmlNode configSection    = configurationDom.SelectSingleNode("//*[local-name() = 'section'][@name = 'marc.hi.ehrs.cr.messaging.hl7']"),
                    messagingSection = configurationDom.SelectSingleNode("//*[local-name() = 'marc.hi.ehrs.cr.messaging.hl7']"),
                    multiNode        = configurationDom.SelectSingleNode(String.Format("//*[local-name() = 'marc.hi.ehrs.svc.messaging.multi']//*[local-name() = 'add'][@type = '{0}']", typeof(HL7MessageHandler).AssemblyQualifiedName)) as XmlElement;

            bool isConfigured = configSection != null && messagingSection != null && multiNode != null;

            // Get connection string
            if (!this.m_needsSync)
            {
                return(isConfigured);
            }
            this.m_needsSync         = false;
            this.EnableConfiguration = isConfigured;
            // Load
            if (messagingSection != null)
            {
                ConfigurationSectionHandler handler = new ConfigurationSectionHandler();
                this.m_configuration = handler.Create(null, null, messagingSection) as HL7ConfigurationSection;
            }
            this.m_panel.Configuration = this.m_configuration;
            this.m_panel.Handlers      = this.m_templates;
            // Enable configuration
            return(isConfigured);
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lsvEp.SelectedItems.Count == 0)
            {
                return;
            }

            if (MessageBox.Show(string.Format("Are you sure you want to remove the endpoint '{0}'?", lsvEp.SelectedItems[0].Text), "Confirm Removal", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                this.m_configuration.Services.Remove(lsvEp.SelectedItems[0].Tag as ServiceDefinition);
                this.Configuration = this.m_configuration;
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmAddHandler addHandler = new frmAddHandler()
            {
                ServiceDefinition = new ServiceDefinition()
                {
                    Address        = new Uri("tcp://0.0.0.0:2100"),
                    Name           = Guid.NewGuid().ToString().Substring(0, 6),
                    ReceiveTimeout = new TimeSpan(0, 0, 30)
                },
                HandlerTemplates = this.Handlers
            };

            if (addHandler.ShowDialog() == DialogResult.OK)
            {
                this.m_configuration.Services.Add(addHandler.ServiceDefinition);
                this.Configuration = this.m_configuration;
            }
        }
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (lsvEp.SelectedItems.Count == 0)
            {
                return;
            }
            var           currentService = lsvEp.SelectedItems[0].Tag as ServiceDefinition;
            frmAddHandler addHandler     = new frmAddHandler()
            {
                HandlerTemplates  = this.Handlers,
                ServiceDefinition = currentService
            };

            if (addHandler.ShowDialog() == DialogResult.OK)
            {
                this.m_configuration.Services.Insert(this.m_configuration.Services.IndexOf(currentService), addHandler.ServiceDefinition);
                this.m_configuration.Services.Remove(currentService);
                this.Configuration = this.m_configuration;
            }
        }
 /// <summary>
 /// Load configuration
 /// </summary>
 public HL7MessageHandler()
 {
     this.m_configuration = ApplicationContext.Current.GetService <IConfigurationManager>().GetSection("marc.hi.ehrs.svc.messaging.hapi") as HL7ConfigurationSection;
 }
 /// <summary>
 /// Load configuration
 /// </summary>
 public HL7MessageHandler()
 {
     this.m_configuration = ConfigurationManager.GetSection("marc.hi.ehrs.cr.messaging.hl7") as HL7ConfigurationSection;
 }