Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComDaClient"/> class.
 /// </summary>
 /// <param name="configuration"></param>
 public ComDaClient(ComDaClientConfiguration configuration) : base(configuration)
 {
     m_cache         = new Dictionary <string, DaElement>();
     m_configuration = configuration;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the Click event of the OkBTN control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void OkBTN_Click(object sender, EventArgs e)
        {
            try
            {
                if (ServersLV.SelectedItems.Count != 1)
                {
                    return;
                }

                // extract the wrapper configuration from the application configuration.
                ComWrapperServerConfiguration wrapperConfig = m_configuration.ParseExtension <ComWrapperServerConfiguration>();

                if (wrapperConfig == null)
                {
                    wrapperConfig = new ComWrapperServerConfiguration();
                }

                if (wrapperConfig.WrappedServers == null)
                {
                    wrapperConfig.WrappedServers = new ComClientConfigurationCollection();
                }

                if (!m_delete)
                {
                    // get the selected server.
                    ComServerDescription server = (ComServerDescription)ServersLV.SelectedItems[0].Tag;

                    // create a new new COM client entry for the selected server.
                    ComDaClientConfiguration clientConfig = new ComDaClientConfiguration();

                    clientConfig.ServerUrl        = server.Url;
                    clientConfig.ServerName       = server.VersionIndependentProgId;
                    clientConfig.MaxReconnectWait = 100000;

                    wrapperConfig.WrappedServers.Add(clientConfig);

                    // update the configuration.
                    m_configuration.UpdateExtension <ComWrapperServerConfiguration>(null, wrapperConfig);
                }
                else
                {
                    // get the selected server.
                    ComDaClientConfiguration server = (ComDaClientConfiguration)ServersLV.SelectedItems[0].Tag;

                    for (int ii = 0; ii < wrapperConfig.WrappedServers.Count; ii++)
                    {
                        if (wrapperConfig.WrappedServers[ii].ServerUrl == server.ServerUrl)
                        {
                            wrapperConfig.WrappedServers.RemoveAt(ii);
                            break;
                        }
                    }

                    // update the configuration.
                    m_configuration.UpdateExtension <ComWrapperServerConfiguration>(null, wrapperConfig);
                }

                // close the dialog.
                DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }