Exemplo n.º 1
0
        private void UpdateServers()
        {
            ServersLV.Items.Clear();

            // 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();
            }

            // populate the list of wrapped servers.
            for (int ii = 0; ii < wrapperConfig.WrappedServers.Count; ii++)
            {
                ComClientConfiguration server = wrapperConfig.WrappedServers[ii];

                ListViewItem item = new ListViewItem(server.ServerName);
                item.SubItems.Add(server.ServerUrl);
                item.Tag = server;

                ServersLV.Items.Add(item);
            }

            for (int ii = 0; ii < ServersLV.Columns.Count; ii++)
            {
                ServersLV.Columns[ii].Width = -2;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parses the specified item id.
        /// </summary>
        /// <param name="server">The COM server that provided the item id.</param>
        /// <param name="configuration">The COM wrapper configuration.</param>
        /// <param name="itemId">The item id to parse.</param>
        /// <param name="browseName">The name of the item.</param>
        /// <returns>True if the item id could be parsed.</returns>
        public bool Parse(ComObject server, ComClientConfiguration configuration, string itemId, out string browseName)
        {
            browseName = null;

            if (configuration == null || itemId == null)
            {
                return false;
            }

            if (String.IsNullOrEmpty(configuration.SeperatorChars))
            {                
                return false;
            }

            for (int ii = 0; ii < configuration.SeperatorChars.Length; ii++)
            {
                int index = itemId.LastIndexOf(configuration.SeperatorChars[ii]);

                if (index >= 0)
                {
                    browseName = itemId.Substring(index + 1);
                    return true;
                }
            }

            return false;
        }
Exemplo n.º 3
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();
                }

                // get the selected server.
                Item item = (Item)ServersLV.SelectedItems[0].Tag;

                // create a new new COM client entry for the selected server.
                ComClientConfiguration clientConfig = null;

                if (item.Specification == Specification.Da20 || item.Specification == Specification.Da30)
                {
                    clientConfig = new ComDaClientConfiguration();
                }
                else if (item.Specification == Specification.Ae10)
                {
                    clientConfig = new ComAeClientConfiguration();
                }
                else if (item.Specification == Specification.Hda10)
                {
                    clientConfig = new ComHdaClientConfiguration();
                }

                clientConfig.ServerUrl        = item.Server.Url;
                clientConfig.ServerName       = item.Server.VersionIndependentProgId;
                clientConfig.MaxReconnectWait = 100000;

                wrapperConfig.WrappedServers.Add(clientConfig);

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

                // close the dialog.
                DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Displays the dialog.
        /// </summary>
        public bool ShowDialog(ComClientConfiguration configuration)
        {
            m_configuration = configuration;

            if (configuration != null)
            {
                ServerTypeTB.Text = "DA";

                switch (configuration.GetType().Name)
                {
                case "ComAeClientConfiguration": { ServerTypeTB.Text = "AE"; break; }

                case "ComHdaClientConfiguration": { ServerTypeTB.Text = "HDA"; break; }
                }

                BrowseNameTB.Text = configuration.ServerName;
                SeperatorsTB.Text = configuration.SeperatorChars;

                int reconnectTime = configuration.MaxReconnectWait / 1000;

                if (ReconnectTimeUD.Minimum <= reconnectTime && ReconnectTimeUD.Maximum >= reconnectTime)
                {
                    ReconnectTimeUD.Value = reconnectTime;
                }
                else
                {
                    ReconnectTimeUD.Value = ReconnectTimeUD.Maximum;
                }

                Uri url = Utils.ParseUri(configuration.ServerUrl);

                if (url != null)
                {
                    HostNameTB.Text = url.DnsSafeHost;

                    string[] parts = url.PathAndQuery.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

                    if (parts.Length > 0)
                    {
                        ProgIdTB.Text = parts[0];
                    }

                    if (parts.Length > 1)
                    {
                        ClsidTB.Text = parts[1];
                    }
                }
            }

            if (ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Displays the dialog.
        /// </summary>
        public bool ShowDialog(ComClientConfiguration configuration)
        {
            m_configuration = configuration;

            if (configuration != null)
            {
                ServerTypeTB.Text = "DA";

                switch (configuration.GetType().Name)
                {
                    case "ComAeClientConfiguration": { ServerTypeTB.Text = "AE"; break; }
                    case "ComHdaClientConfiguration": { ServerTypeTB.Text = "HDA"; break; }
                }

                BrowseNameTB.Text = configuration.ServerName;
                SeperatorsTB.Text = configuration.SeperatorChars;

                int reconnectTime = configuration.MaxReconnectWait/1000;

                if (ReconnectTimeUD.Minimum <= reconnectTime && ReconnectTimeUD.Maximum >= reconnectTime)
                {
                    ReconnectTimeUD.Value = reconnectTime;
                }
                else
                {
                    ReconnectTimeUD.Value = ReconnectTimeUD.Maximum;
                }

                Uri url = Utils.ParseUri(configuration.ServerUrl);

                if (url != null)
                {
                    HostNameTB.Text = url.DnsSafeHost;

                    string[] parts = url.PathAndQuery.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

                    if (parts.Length > 0)
                    {
                        ProgIdTB.Text = parts[0];
                    }

                    if (parts.Length > 1)
                    {
                        ClsidTB.Text = parts[1];
                    }
                }
            }

            if (ShowDialog() != DialogResult.OK)
            {
                return false;
            }

            return true;
        }
Exemplo n.º 6
0
        private int FindServer(ComWrapperServerConfiguration configuration, ComClientConfiguration server)
        {
            for (int ii = 0; ii < configuration.WrappedServers.Count; ii++)
            {
                if (server.GetType().Name != configuration.WrappedServers[ii].GetType().Name)
                {
                    continue;
                }

                if (configuration.WrappedServers[ii].ServerUrl == server.ServerUrl)
                {
                    return(ii);
                }
            }

            return(-1);
        }
Exemplo n.º 7
0
            public bool Parse(ComObject server, ComClientConfiguration configuration, string itemId, out string browseName)
            {
                browseName = String.Empty;

                if (String.IsNullOrEmpty(itemId))
                {
                    return(true);
                }

                browseName = itemId;

                int index = itemId.LastIndexOf('/');

                if (index == -1)
                {
                    return(true);
                }

                browseName = browseName.Substring(0, index + 1);
                return(true);
            }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes the object with the ProgID of the server being accessed.
 /// </summary>
 public ComClient(ComClientConfiguration configuration)
 {
     if (configuration == null) throw new ArgumentNullException("configuration");
     m_url = configuration.ServerUrl;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes the manager by creating the default instance.
        /// </summary>
        public void Initialize(
            ServerSystemContext context,
            ComClientConfiguration configuration, 
            ComServerStatusState statusNode,
            object statusNodeLock,
            WaitCallback reconnectCallback)
        {
            m_defaultSystemContext = context;
            m_configuration = configuration;
            m_statusNode = statusNode;
            m_statusNodeLock = statusNodeLock;
            m_statusUpdateInterval = m_configuration.MaxReconnectWait;
            m_reconnectCallback = reconnectCallback;

            // limit status updates to once per 10 seconds.
            if (m_statusUpdateInterval < 10000)
            {
                m_statusUpdateInterval = 10000;
            }

            StartStatusTimer(OnStatusTimerExpired);
        }
Exemplo n.º 10
0
        private int FindServer(ComWrapperServerConfiguration configuration, ComClientConfiguration server)
        {
            for (int ii = 0; ii < configuration.WrappedServers.Count; ii++)
            {
                if (server.GetType().Name != configuration.WrappedServers[ii].GetType().Name)
                {
                    continue;
                }

                if (configuration.WrappedServers[ii].ServerUrl == server.ServerUrl)
                {
                    return ii;
                }
            }

            return -1;
        }
Exemplo n.º 11
0
            public bool Parse(ComObject server, ComClientConfiguration configuration, string itemId, out string browseName)
            {
                browseName = String.Empty;

                if (String.IsNullOrEmpty(itemId))
                {
                    return true;
                }

                browseName = itemId;

                int index = itemId.LastIndexOf('/');

                if (index == -1)
                {
                    return true;
                }

                browseName = browseName.Substring(0, index + 1);
                return true;
            }