public void Initialize( ConfiguredEndpointCollection endpoints, LocalDiscoveryServerClient lds, GlobalDiscoveryServerClient gds, QueryServersFilter filters) { m_lds = lds; m_gds = gds; m_filters = filters; DiscoveryTreeView.Nodes.Clear(); TreeNode node = new TreeNode("Local Machine"); node.SelectedImageIndex = node.ImageIndex = ImageIndex.Computer; node.Tag = RootFolders.LocalMachine; node.Nodes.Add(new TreeNode()); DiscoveryTreeView.Nodes.Add(node); node = new TreeNode("Local Network"); node.SelectedImageIndex = node.ImageIndex = ImageIndex.LocalNetwork; node.Tag = RootFolders.LocalNetwork; node.Nodes.Add(new TreeNode()); DiscoveryTreeView.Nodes.Add(node); node = new TreeNode("Global Discovery"); node.SelectedImageIndex = node.ImageIndex = ImageIndex.GlobalNetwork; node.Tag = RootFolders.GlobalDiscovery; node.Nodes.Add(new TreeNode()); DiscoveryTreeView.Nodes.Add(node); if (endpoints != null) { m_endpoints = endpoints; node = new TreeNode("Custom Discovery"); node.SelectedImageIndex = node.ImageIndex = ImageIndex.ClosedFolder; node.Tag = RootFolders.CustomDiscovery; TreeNode child = new TreeNode("<double click to add server>"); child.SelectedImageIndex = child.ImageIndex = ImageIndex.Add; child.Tag = RootFolders.Add; node.Nodes.Add(child); DiscoveryTreeView.Nodes.Add(node); foreach (ConfiguredEndpoint ce in m_endpoints.Endpoints) { child = new TreeNode(Utils.Format("{0}", ce.ToString())); child.SelectedImageIndex = child.ImageIndex = (ce.Description.SecurityMode == MessageSecurityMode.None && ce.EndpointUrl.Scheme != Utils.UriSchemeHttps) ? ImageIndex.InSecure : ImageIndex.Secure; child.Tag = ce; node.Nodes.Add(child); } } }
public void DisconnectClient() { Console.WriteLine("Disconnect Session. Waiting for exit..."); if (_client != null) { GlobalDiscoveryServerClient gdsClient = _client; _client = null; gdsClient.Disconnect(); } }
public EndpointDescription ShowDialog( IWin32Window owner, ConfiguredEndpointCollection endpoints, LocalDiscoveryServerClient lds, GlobalDiscoveryServerClient gds, QueryServersFilter filters) { this.DiscoveryControl.Initialize(endpoints, lds, gds, filters); if (base.ShowDialog(owner) != System.Windows.Forms.DialogResult.OK) { return(null); } return(DiscoveryControl.SelectedEndpoint); }
public ViewServersOnNetworkDialog(GlobalDiscoveryServerClient gds) { InitializeComponent(); Icon = ClientUtils.GetAppIcon(); ServersDataGridView.AutoGenerateColumns = false; m_gds = gds; m_dataset = new DataSet(); m_dataset.Tables.Add("Servers"); m_dataset.Tables[0].Columns.Add("RecordId", typeof(uint)); m_dataset.Tables[0].Columns.Add("ServerName", typeof(string)); m_dataset.Tables[0].Columns.Add("DiscoveryUrl", typeof(string)); m_dataset.Tables[0].Columns.Add("ServerCapabilities", typeof(string)); m_dataset.Tables[0].Columns.Add("ServerOnNetwork", typeof(ServerOnNetwork)); ServersDataGridView.DataSource = m_dataset.Tables[0]; }
public ViewApplicationRecordsDialog(GlobalDiscoveryServerClient gds) { InitializeComponent(); Icon = ClientUtils.GetAppIcon(); ApplicationRecordDataGridView.AutoGenerateColumns = false; m_gds = gds; m_dataset = new DataSet(); m_dataset.Tables.Add("ApplicationRecords"); m_dataset.Tables[0].Columns.Add("ApplicationId", typeof(NodeId)); m_dataset.Tables[0].Columns.Add("ApplicationName", typeof(string)); m_dataset.Tables[0].Columns.Add("ApplicationType", typeof(ApplicationType)); m_dataset.Tables[0].Columns.Add("ProductUri", typeof(string)); m_dataset.Tables[0].Columns.Add("DiscoveryUrls", typeof(string)); m_dataset.Tables[0].Columns.Add("ServerCapabilities", typeof(string)); m_dataset.Tables[0].Columns.Add("ApplicationRecord", typeof(ApplicationRecordDataType)); ApplicationRecordDataGridView.DataSource = m_dataset.Tables[0]; }
public async Task LoadClientConfiguration(int port = -1) { ApplicationInstance.MessageDlg = new ApplicationMessageDlg(); ApplicationInstance application = new ApplicationInstance { ApplicationName = "Global Discovery Client", ApplicationType = ApplicationType.Client, ConfigSectionName = "Opc.Ua.GlobalDiscoveryTestClient" }; // load the application configuration. Config = await application.LoadApplicationConfiguration(false); // check the application certificate. bool haveAppCertificate = await application.CheckApplicationInstanceCertificate(false, 0); if (!haveAppCertificate) { throw new Exception("Application instance certificate invalid!"); } Config.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation); GlobalDiscoveryTestClientConfiguration gdsClientConfiguration = application.ApplicationConfiguration.ParseExtension <GlobalDiscoveryTestClientConfiguration>(); _client = new GlobalDiscoveryServerClient(application, gdsClientConfiguration.GlobalDiscoveryServerUrl) { EndpointUrl = TestUtils.PatchOnlyGDSEndpointUrlPort(gdsClientConfiguration.GlobalDiscoveryServerUrl, port) }; if (String.IsNullOrEmpty(gdsClientConfiguration.AppUserName)) { AppUser = new UserIdentity(new AnonymousIdentityToken()); } else { AppUser = new UserIdentity(gdsClientConfiguration.AppUserName, gdsClientConfiguration.AppPassword); } AdminUser = new UserIdentity(gdsClientConfiguration.AdminUserName, gdsClientConfiguration.AdminPassword); }
public string ShowDialog(IWin32Window owner, GlobalDiscoveryServerClient gds, IList <string> serverUrls) { m_gds = gds; ServersListBox.Items.Clear(); foreach (var serverUrl in serverUrls) { ServersListBox.Items.Add(serverUrl); } ServerUrlTextBox.Text = gds.EndpointUrl; UserNameCredentialsRB.Checked = true; OkButton.Enabled = Uri.IsWellFormedUriString(ServerUrlTextBox.Text.Trim(), UriKind.Absolute); if (base.ShowDialog(owner) != DialogResult.OK) { return(null); } return(ServerUrlTextBox.Text.Trim()); }
public async Task LoadClientConfiguration(int port = -1) { ApplicationInstance.MessageDlg = new ApplicationMessageDlg(); ApplicationInstance application = new ApplicationInstance { ApplicationName = "Global Discovery Client", ApplicationType = ApplicationType.Client, ConfigSectionName = "Opc.Ua.GlobalDiscoveryTestClient" }; #if USE_FILE_CONFIG // load the application configuration. Config = await application.LoadApplicationConfiguration(false).ConfigureAwait(false); #else string root = Path.Combine("%LocalApplicationData%", "OPC"); string pkiRoot = Path.Combine(root, "pki"); var clientConfig = new GlobalDiscoveryTestClientConfiguration() { GlobalDiscoveryServerUrl = "opc.tcp://localhost:58810/GlobalDiscoveryTestServer", AppUserName = "******", AppPassword = "******", AdminUserName = "******", AdminPassword = "******" }; // build the application configuration. Config = await application .Build( "urn:localhost:opcfoundation.org:GlobalDiscoveryTestClient", "http://opcfoundation.org/UA/GlobalDiscoveryTestClient") .AsClient() .AddSecurityConfiguration( "CN=Global Discovery Test Client, O=OPC Foundation, DC=localhost", pkiRoot) .SetAutoAcceptUntrustedCertificates(true) .SetRejectSHA1SignedCertificates(false) .SetRejectUnknownRevocationStatus(true) .SetMinimumCertificateKeySize(1024) .AddExtension <GlobalDiscoveryTestClientConfiguration>(null, clientConfig) .SetOutputFilePath(Path.Combine(root, "Logs", "Opc.Ua.Gds.Tests.log.txt")) .SetTraceMasks(519) .Create().ConfigureAwait(false); #endif // check the application certificate. bool haveAppCertificate = await application.CheckApplicationInstanceCertificate(true, 0).ConfigureAwait(false); if (!haveAppCertificate) { throw new Exception("Application instance certificate invalid!"); } Config.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation); GlobalDiscoveryTestClientConfiguration gdsClientConfiguration = application.ApplicationConfiguration.ParseExtension <GlobalDiscoveryTestClientConfiguration>(); m_client = new GlobalDiscoveryServerClient(application, gdsClientConfiguration.GlobalDiscoveryServerUrl) { EndpointUrl = TestUtils.PatchOnlyGDSEndpointUrlPort(gdsClientConfiguration.GlobalDiscoveryServerUrl, port) }; if (String.IsNullOrEmpty(gdsClientConfiguration.AppUserName)) { AppUser = new UserIdentity(new AnonymousIdentityToken()); } else { AppUser = new UserIdentity(gdsClientConfiguration.AppUserName, gdsClientConfiguration.AppPassword); } AdminUser = new UserIdentity(gdsClientConfiguration.AdminUserName, gdsClientConfiguration.AdminPassword); }