Esempio n. 1
0
 private void HostNameCTRL_HostConnected(object sender, SelectHostCtrlEventArgs e)
 {
     try {
         m_hostname = e.Hostname;
         ServersCTRL.Initialize(m_hostname, this.StartingRecordUP, this.MaxRecordsUP, this.CapabilityFilterTB,
                                m_configuration);
         m_server      = null;
         OkBTN.Enabled = false;
     } catch (Exception exception) {
         GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
     }
 }
Esempio n. 2
0
        private void ServersCTRL_ItemsSelected(object sender, ListItemActionEventArgs e)
        {
            try {
                m_server = null;

                foreach (ServerOnNetwork server in e.Items)
                {
                    m_server = server;
                    break;
                }

                OkBTN.Enabled = m_server != null;
            } catch (Exception exception) {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
        private void ShowServerOnNetworks(TreeNodeCollection nodes)
        {
            ServersTable.Rows.Clear();

            foreach (TreeNode node in nodes)
            {
                ServerOnNetwork server = node.Tag as ServerOnNetwork;

                if (server == null)
                {
                    continue;
                }

                DataRow row = ServersTable.NewRow();

                row[0] = server.ServerName;

                StringBuilder buffer = new StringBuilder();

                if (server.ServerCapabilities != null)
                {
                    foreach (var capability in server.ServerCapabilities)
                    {
                        if (buffer.Length > 0)
                        {
                            buffer.Append(", ");
                        }

                        buffer.Append(capability);
                    }
                }

                row[1] = buffer.ToString();
                row[2] = server.DiscoveryUrl;
                row[3] = server;
                row[4] = null;

                ServersTable.Rows.Add(row);
            }

            m_dataset.AcceptChanges();

            foreach (DataGridViewRow row in ServersGridView.Rows)
            {
                row.Selected = false;
            }
        }
        /// <summary>
        /// Updates an item in the control.
        /// </summary>
        protected override void UpdateItem(ListViewItem listItem, object item)
        {
            ServerOnNetwork server = listItem.Tag as ServerOnNetwork;

            if (server == null)
            {
                base.UpdateItem(listItem, server);
                return;
            }

            listItem.SubItems[0].Text = String.Format("{0}", server.RecordId);
            listItem.SubItems[1].Text = String.Format("{0}", server.ServerName);
            listItem.SubItems[2].Text = String.Format("{0}", server.DiscoveryUrl);
            listItem.SubItems[3].Text = String.Format("{0}", string.Join(",", server.ServerCapabilities));

            listItem.ImageKey = GuiUtils.Icons.Service;
        }
Esempio n. 5
0
        private void ServersCTRL_ItemsPicked(object sender, ListItemActionEventArgs e)
        {
            try {
                m_server = null;

                foreach (ServerOnNetwork server in e.Items)
                {
                    m_server = server;
                    break;
                }

                if (m_server != null)
                {
                    DialogResult = DialogResult.OK;
                }
            } catch (Exception exception) {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
        private ApplicationDescription GetApplicationDescription(ServerOnNetwork server)
        {
            ApplicationDescription fallback = null;

            try
            {
                foreach (var application in m_lds.FindServers(server.DiscoveryUrl, null))
                {
                    if (fallback == null)
                    {
                        fallback = application;
                    }

                    if (application.DiscoveryUrls != null)
                    {
                        if (application.DiscoveryUrls.Contains(server.DiscoveryUrl))
                        {
                            return(application);
                        }
                    }
                }
            }
            catch (Exception)
            {
                fallback = new ApplicationDescription()
                {
                    ApplicationType = ApplicationType.Server,
                    ApplicationName = server.ServerName,
                    ApplicationUri  = server.DiscoveryUrl
                };

                fallback.DiscoveryUrls.Add(server.DiscoveryUrl);
            }

            return(fallback);
        }
        private void DiscoveryTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                if (RootFolders.LocalMachine.Equals(e.Node.Tag))
                {
                    ServersTable.Rows.Clear();
                    ShowPanel(true);

                    if (e.Node.Nodes.Count == 1 && String.IsNullOrEmpty(e.Node.Nodes[0].Text))
                    {
                        e.Node.Nodes.Clear();

                        m_lds.BeginFindServers(
                            OnFindServersComplete,
                            new ExpandNodeData()
                        {
                            Parent = e.Node, Lds = m_lds
                        });
                    }
                    else
                    {
                        ShowApplicationDescriptions(e.Node.Nodes);
                    }

                    return;
                }

                if (RootFolders.LocalNetwork.Equals(e.Node.Tag))
                {
                    ServersTable.Rows.Clear();
                    ShowPanel(true);

                    if (e.Node.Nodes.Count == 1 && String.IsNullOrEmpty(e.Node.Nodes[0].Text))
                    {
                        e.Node.Nodes.Clear();

                        m_lds.BeginFindServersOnNetwork(
                            0,
                            1000,
                            OnFindServersOnNetworkComplete,
                            new ExpandNodeData()
                        {
                            Parent = e.Node, Lds = m_lds
                        });
                    }
                    else
                    {
                        ShowServerOnNetworks(e.Node.Nodes);
                    }

                    return;
                }

                if (RootFolders.GlobalDiscovery.Equals(e.Node.Tag))
                {
                    ServersTable.Rows.Clear();
                    ShowPanel(true);

                    if (e.Node.Nodes.Count == 1 && String.IsNullOrEmpty(e.Node.Nodes[0].Text))
                    {
                        e.Node.Nodes.Clear();

                        var servers = new ViewServersOnNetworkDialog(m_gds).ShowDialog(this, ref m_filters);

                        if (servers != null)
                        {
                            foreach (var server in servers)
                            {
                                TreeNode node = new TreeNode(String.Format("{0}", server.ServerName));
                                node.SelectedImageIndex = node.ImageIndex = ImageIndex.Server;
                                node.Tag = server;
                                node.Nodes.Add(new TreeNode());
                                e.Node.Nodes.Add(node);
                            }
                        }
                    }

                    ShowServerOnNetworks(e.Node.Nodes);

                    return;
                }

                if (RootFolders.CustomDiscovery.Equals(e.Node.Tag))
                {
                    ServersTable.Rows.Clear();
                    ShowPanel(true);
                    return;
                }

                if (e.Node.Tag is ApplicationDescription)
                {
                    EndpointsTable.Rows.Clear();
                    ShowPanel(false);

                    ApplicationDescription application = (ApplicationDescription)e.Node.Tag;

                    ApplicationNameTextBox.Text = (LocalizedText.IsNullOrEmpty(application.ApplicationName))?"---":application.ApplicationName.Text;
                    ApplicationTypeTextBox.Text = application.ApplicationType.ToString();
                    ApplicationUriTextBox.Text  = application.ApplicationUri;
                    ProductUriTextBox.Text      = application.ProductUri;

                    string discoveryUrl = SelectDiscoveryUrl(application);

                    if (discoveryUrl != null)
                    {
                        m_lds.BeginGetEndpoints(
                            discoveryUrl,
                            null,
                            OnGetEndpointsComplete,
                            new GetEndpointsData()
                        {
                            Parent = e.Node, Lds = m_lds
                        });
                    }
                }

                if (e.Node.Tag is ServerOnNetwork)
                {
                    EndpointsTable.Rows.Clear();
                    ShowPanel(false);

                    ServerOnNetwork server = (ServerOnNetwork)e.Node.Tag;

                    ApplicationNameTextBox.Text = server.ServerName;
                    ApplicationTypeTextBox.Text = "---";
                    ApplicationUriTextBox.Text  = "---";
                    ProductUriTextBox.Text      = "---";

                    try
                    {
                        Cursor = Cursors.WaitCursor;

                        m_lds.BeginGetEndpoints(
                            server.DiscoveryUrl,
                            null,
                            OnGetEndpointsComplete,
                            new GetEndpointsData()
                        {
                            Parent = e.Node, Lds = m_lds
                        });
                    }
                    finally
                    {
                        Cursor = Cursors.Default;
                    }
                }

                if (e.Node.Tag is ConfiguredEndpoint)
                {
                    EndpointsTable.Rows.Clear();
                    ShowPanel(false);

                    ConfiguredEndpoint server = (ConfiguredEndpoint)e.Node.Tag;

                    ApplicationNameTextBox.Text = "---";
                    ApplicationTypeTextBox.Text = "---";
                    ApplicationUriTextBox.Text  = "---";
                    ProductUriTextBox.Text      = "---";

                    m_lds.BeginGetEndpoints(
                        server.EndpointUrl.ToString(),
                        null,
                        OnGetEndpointsComplete,
                        new GetEndpointsData()
                    {
                        Parent = e.Node, Lds = m_lds
                    });
                }
            }
            catch (Exception ex)
            {
                Opc.Ua.Client.Controls.ExceptionDlg.Show(Text, ex);
            }
        }
        private void ServersCTRL_ItemsPicked(object sender, ListItemActionEventArgs e)
        {
            try
            {
                m_server = null;

                foreach (ServerOnNetwork server in e.Items)
                {
                    m_server = server;
                    break;
                }

                if (m_server != null)
                {
                    DialogResult = DialogResult.OK;
                }
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
        private void ServersCTRL_ItemsSelected(object sender, ListItemActionEventArgs e)
        {
            try
            {
                m_server = null;

                foreach (ServerOnNetwork server in e.Items)
                {
                    m_server = server;
                    break;
                }

                OkBTN.Enabled = m_server != null;
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
 private void HostNameCTRL_HostConnected(object sender, SelectHostCtrlEventArgs e)
 {
     try
     {
         m_hostname = e.Hostname;
         ServersCTRL.Initialize(m_hostname, this.StartingRecordUP, this.MaxRecordsUP, this.CapabilityFilterTB, m_configuration);
         m_server = null;
         OkBTN.Enabled = false;
     }
     catch (Exception exception)
     {
         GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
     }
 }