Exemplo n.º 1
0
        private void Server_KeepAlive(Session session, KeepAliveEventArgs e)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new KeepAliveEventHandler(Server_KeepAlive), session, e);
                return;
            }

            try
            {
                // check for events from discarded sessions.
                if (!Object.ReferenceEquals(session, m_server.Session))
                {
                    return;
                }

                // start reconnect sequence on communication error.
                if (ServiceResult.IsBad(e.Status))
                {
                    UpdateStatus(true, e.CurrentTime, "Communication Error ({0})", e.Status);
                    return;
                }

                // update status.
                UpdateStatus(false, e.CurrentTime, "Connected {0}", session.ConfiguredEndpoint);
            }
            catch (Exception exception)
            {
                ExceptionDlg.Show(this.Text, exception);
            }
        }
Exemplo n.º 2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);


            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "SharpNodeSettingsServer";

            try {
                // load the application configuration.
                application.LoadApplicationConfiguration(false).Wait();

                // check the application certificate.
                bool certOk = application.CheckApplicationInstanceCertificate(false, 0).Result;
                if (!certOk)
                {
                    throw new Exception("Application instance certificate invalid!");
                }

                // start the server.
                application.Start(new SharpNodeSettingsServer()).Wait();

                // run the application interactively.
                ServerForm serverForm = new ServerForm(application);
                serverForm.StartPosition = FormStartPosition.CenterScreen;
                Application.Run(serverForm);
            } catch (Exception e) {
                ExceptionDlg.Show(application.ApplicationName, e);
            }
        }
Exemplo n.º 3
0
        private async void ConnectButton_ClickAsync(object sender, EventArgs e)
        {
            try
            {
                ConfiguredEndpoint endpoint = (ConfiguredEndpoint)ServerUrlTextBox.Tag;

                if (endpoint == null)
                {
                    return;
                }

                if (endpoint.Description.Server.ApplicationUri == endpoint.Description.EndpointUrl)
                {
                    m_server.Connect(endpoint.Description.EndpointUrl);
                }
                else
                {
                    m_server.Connect(endpoint);
                }

                ServerStatusPanel.Initialize(m_server);
                await CertificatePanel.Initialize(m_configuration, m_gds, m_server, m_registeredApplication, false);
            }
            catch (Exception exception)
            {
                ExceptionDlg.Show(this.Text, exception);
            }
        }
Exemplo n.º 4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationName   = "UA Sample Client";
            application.ApplicationType   = ApplicationType.ClientAndServer;
            application.ConfigSectionName = "Opc.Ua.SampleClient";

            try
            {
                application.LoadApplicationConfiguration(false).Wait();

                // check the application certificate.
                bool certOK = application.CheckApplicationInstanceCertificate(false, 0).Result;
                if (!certOK)
                {
                    throw new Exception("Application instance certificate invalid!");
                }

                // start the server.
                application.Start(new SampleServer()).Wait();

                // run the application interactively.
                Application.Run(new SampleClientForm(application, null, application.ApplicationConfiguration));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
            }
        }
Exemplo n.º 5
0
        static void Main()
        {
            // Initialize the user interface.
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance
            {
                ApplicationType   = ApplicationType.Server,
                ConfigSectionName = "Opc.Ua.GlobalDiscoveryServer"
            };

            try
            {
                // load the application configuration.
                application.LoadApplicationConfiguration(false).Wait();

                // check the application certificate.
                application.CheckApplicationInstanceCertificate(false, 0).Wait();

                // start the server.
                var server = new GlobalDiscoverySampleServer(
                    new SqlApplicationsDatabase(),
                    new CertificateGroup());
                application.Start(server).Wait();

                // run the application interactively.
                System.Windows.Forms.Application.Run(new ServerForm(server, application.ApplicationConfiguration));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
            }
        }
Exemplo n.º 6
0
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "Quickstarts.ReferenceServer";

            try
            {
                // load the application configuration.
                application.LoadApplicationConfiguration(false).Wait();

                // check the application certificate.
                bool certOk = application.CheckApplicationInstanceCertificate(false, 0).Result;
                if (!certOk)
                {
                    throw new Exception("Application instance certificate invalid!");
                }

                // start the server.
                application.Start(new ReferenceServer()).Wait();

                // run the application interactively.
                Application.Run(new ServerForm(application));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// The async main entry point for the application.
        /// </summary>
        static async Task AsyncMain()
        {
            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationName   = "UA COM Server Wrapper";
            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "Opc.Ua.ComServerWrapper";

            try
            {
                // load the application configuration.
                await application.LoadApplicationConfiguration(false);

                // check the application certificate.
                await application.CheckApplicationInstanceCertificate(false, 0);

                // start the server.
                await application.Start(new ComWrapperServer());

                // run the application interactively.
                Application.Run(new ServerForm(application));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
            }
        }
Exemplo n.º 8
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationName   = "UA Server Test Tool";
            application.ApplicationType   = ApplicationType.Client;
            application.ConfigSectionName = "Opc.Ua.ServerTestTool";

            try
            {
                // process and command line arguments.
                if (application.ProcessCommandLine())
                {
                    return;
                }

                // run the application interactively.
                Application.Run(new MainForm());
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }
Exemplo n.º 9
0
    private void bt_connect_play_Click(object sender, RoutedEventArgs e)
    {
        List <string> allNameSpaces;

        if (m_OPCUA_client.IsConnected)
        {
            try
            {
                m_OPCUA_client.disconnect();
                List <string> str = new List <string>();
                lbx_Namspaces.ItemsSource = str;
            }
            catch (Exception exception)
            {
                ExceptionDlg.Show(null, exception);
                //throw exception;
            }
        }
        else
        {
            try
            {
                m_OPCUA_client.connect(txb_ServerURL.Text, Session_ServerConnectionStatusUpdate, out allNameSpaces);
                lbx_Namspaces.ItemsSource = allNameSpaces;
            }
            catch (Exception exception)
            {
                ExceptionDlg.Show("Connect failed", exception);
                //throw exception;
            }
        }
    }
Exemplo n.º 10
0
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Client;
            application.ConfigSectionName = "Opc.Ua.GdsClient";

            try
            {
                // load the application configuration.
                ApplicationConfiguration config = application.LoadApplicationConfiguration(false).Result;

                // check the application certificate.
                application.CheckApplicationInstanceCertificate(false, 0).Wait();

                // run the application interactively.
                Application.Run(new MainForm(application));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
            }
        }
Exemplo n.º 11
0
        static async Task MyMain()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "Quickstarts.AggregationServer";

            try
            {
                // load the application configuration.
                await application.LoadApplicationConfiguration(false);

                // check the application certificate.
                await application.CheckApplicationInstanceCertificate(false, 0);

                // start the server.
                await application.Start(new AggregationServer());

                // run the application interactively.
                Application.Run(new ServerForm(application));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
            }
        }
Exemplo n.º 12
0
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Client;
            application.ConfigSectionName = "HistoricalEventsClient";

            try
            {
                // process and command line arguments.
                if (application.ProcessCommandLine())
                {
                    return;
                }

                // load the application configuration.
                application.LoadApplicationConfiguration(false);

                // check the application certificate.
                application.CheckApplicationInstanceCertificate(false, 0);

                // run the application interactively.
                Application.Run(new MainForm(application.ApplicationConfiguration));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }
Exemplo n.º 13
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationName   = "UA Sample Server";
            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "Opc.Ua.SampleServer";

            try
            {
                // process and command line arguments.
                if (application.ProcessCommandLine())
                {
                    return;
                }

                // check if running as a service.
                if (!Environment.UserInteractive)
                {
#pragma warning disable CS0436 // The type 'SampleServer' in 'C:\Users\adam\Desktop\projects\Working OPCServer\SampleApplications\Samples\Server\SampleServer.cs' conflicts with the imported type 'SampleServer' in 'Opc.Ua.SampleServer, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\adam\Desktop\projects\Working OPCServer\SampleApplications\Samples\Server\SampleServer.cs'.
                    application.StartAsService(new Opc.Ua.Sample.SampleServer());
#pragma warning restore CS0436 // The type 'SampleServer' in 'C:\Users\adam\Desktop\projects\Working OPCServer\SampleApplications\Samples\Server\SampleServer.cs' conflicts with the imported type 'SampleServer' in 'Opc.Ua.SampleServer, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\adam\Desktop\projects\Working OPCServer\SampleApplications\Samples\Server\SampleServer.cs'.
                    return;
                }

                // load the application configuration.
                application.LoadApplicationConfiguration(false);

                // This call registers the certificate with HTTP.SYS
                // It must be called once after installation if the HTTPS endpoint is enabled.
                // HttpAccessRule.SetHttpsCertificate(c.SecurityConfiguration.ApplicationCertificate.Find(true), 51212, false);

                // check the application certificate.
                application.CheckApplicationInstanceCertificate(false, 0);

                // start the server.
#pragma warning disable CS0436 // The type 'SampleServer' in 'C:\Users\adam\Desktop\projects\Working OPCServer\SampleApplications\Samples\Server\SampleServer.cs' conflicts with the imported type 'SampleServer' in 'Opc.Ua.SampleServer, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\adam\Desktop\projects\Working OPCServer\SampleApplications\Samples\Server\SampleServer.cs'.
                application.Start(new Opc.Ua.Sample.SampleServer());
#pragma warning restore CS0436 // The type 'SampleServer' in 'C:\Users\adam\Desktop\projects\Working OPCServer\SampleApplications\Samples\Server\SampleServer.cs' conflicts with the imported type 'SampleServer' in 'Opc.Ua.SampleServer, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\adam\Desktop\projects\Working OPCServer\SampleApplications\Samples\Server\SampleServer.cs'.

                // run the application interactively.
#pragma warning disable CS0436 // The type 'ServerForms' in 'C:\Users\adam\Desktop\projects\Working OPCServer\SampleApplications\Samples\Server\ServerForm.cs' conflicts with the imported type 'ServerForms' in 'Opc.Ua.SampleServer, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\adam\Desktop\projects\Working OPCServer\SampleApplications\Samples\Server\ServerForm.cs'.
                Application.Run(new ServerForms(application));
#pragma warning restore CS0436 // The type 'ServerForms' in 'C:\Users\adam\Desktop\projects\Working OPCServer\SampleApplications\Samples\Server\ServerForm.cs' conflicts with the imported type 'ServerForms' in 'Opc.Ua.SampleServer, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\adam\Desktop\projects\Working OPCServer\SampleApplications\Samples\Server\ServerForm.cs'.
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }
Exemplo n.º 14
0
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "Quickstarts.ReferenceServer";

            try
            {
                // load the application configuration.
                ApplicationConfiguration config = application.LoadApplicationConfiguration(false).Result;

                LoggerConfiguration loggerConfiguration = new LoggerConfiguration();
#if DEBUG
                loggerConfiguration.WriteTo.Debug(restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Warning);
#endif
                SerilogTraceLogger.Create(loggerConfiguration, config);

                // check the application certificate.
                bool certOk = application.CheckApplicationInstanceCertificate(false, 0).Result;
                if (!certOk)
                {
                    throw new Exception("Application instance certificate invalid!");
                }

                // Create server, add additional node managers
                var server = new ReferenceServer();
                Quickstarts.Servers.Utils.AddDefaultNodeManagers(server);

                // start the server.
                application.Start(server).Wait();

                // check whether the invalid certificates dialog should be displayed.
                bool showCertificateValidationDialog = false;
                ReferenceServerConfiguration refServerconfiguration = application.ApplicationConfiguration.ParseExtension <ReferenceServerConfiguration>();

                if (refServerconfiguration != null)
                {
                    showCertificateValidationDialog = refServerconfiguration.ShowCertificateValidationDialog;
                }

                // run the application interactively.
                Application.Run(new ServerForm(application, showCertificateValidationDialog));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
            }
        }
 private void OkButton_Click(object sender, EventArgs e)
 {
     try
     {
         m_settings.SaveToTrustList = PermanentCheckBox.Checked;
         DialogResult = DialogResult.OK;
     }
     catch (Exception exception)
     {
         ExceptionDlg.Show(this.Text, exception);
     }
 }
Exemplo n.º 16
0
        static void Main()
        {
            ReportGenerator g = new ReportGenerator();

            g.Initialize();
            g.GenerateFluidLevelTestReport();
            g.GenerateFluidLevelTestReport();
            g.GenerateFluidLevelTestReport();

            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "HistoricalEventsServer";

            try
            {
                // process and command line arguments.
                if (application.ProcessCommandLine())
                {
                    return;
                }

                // check if running as a service.
                if (!Environment.UserInteractive)
                {
                    application.StartAsService(new HistoricalEventsServer());
                    return;
                }

                // load the application configuration.
                application.LoadApplicationConfiguration(false).Wait();

                // check the application certificate.
                application.CheckApplicationInstanceCertificate(false, 0).Wait();

                // start the server.
                application.Start(new HistoricalEventsServer()).Wait();

                // run the application interactively.
                Application.Run(new ServerForm(application));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }
Exemplo n.º 17
0
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "HistoricalAccessServer";

            try
            {
                // DoTests(false, false, "Quickstarts.HistoricalAccessServer.Data.Historian1.txt", "..\\..\\Data\\Historian1ExpectedData.csv");
                // DoTests(false, true, "Quickstarts.HistoricalAccessServer.Data.Historian2.txt", "..\\..\\Data\\Historian2ExpectedData.csv");
                // DoTests(true, true, "Quickstarts.HistoricalAccessServer.Data.Historian3.txt", "..\\..\\Data\\Historian3ExpectedData.csv");

                // process and command line arguments.
                if (application.ProcessCommandLine())
                {
                    return;
                }

                // check if running as a service.
                if (!Environment.UserInteractive)
                {
                    application.StartAsService(new HistoricalAccessServer());
                    return;
                }

                // load the application configuration.
                application.LoadApplicationConfiguration(false).Wait();

                // check the application certificate.
                application.CheckApplicationInstanceCertificate(false, 0).Wait();

                // start the server.
                application.Start(new HistoricalAccessServer()).Wait();

                // run the application interactively.
                Application.Run(new ServerForm(application));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "CollectorServer";

            try
            {
                CollectorServer server = new CollectorServer();

                // process and command line arguments.
                if (application.ProcessCommandLine())
                {
                    return;
                }

                // check if running as a service.
                if (!Environment.UserInteractive)
                {
                    application.StartAsService(server);
                    return;
                }
                // load the application configuration.
                //application.LoadApplicationConfiguration(false).Wait();
                application.LoadApplicationConfiguration(@"..\..\References\CollectorServer.Config.xml", false).Wait();

                // check the application certificate.
                application.CheckApplicationInstanceCertificate(false, 0).Wait();
                // start the server.
                application.Start(server).Wait();

                // run the application interactively.
                //Application.Run(new Opc.Ua.Server.Controls.ServerForm(application));
                Application.Run(new mainForm(application));
                //Console.ReadLine();
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                Console.WriteLine(e.Message);
                return;
            }
        }
Exemplo n.º 19
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (m_OPCUA_client.IsConnected)
     {
         try
         {
             m_OPCUA_client.disconnect();
         }
         catch (Exception exception)
         {
             ExceptionDlg.Show(null, exception);
             //throw exception;
         }
     }
 }
Exemplo n.º 20
0
    private void btn_write_Click(object sender, RoutedEventArgs e)
    {
        try
        {
            if (!testBasicConditions())
            {
                return;
            }

            int OperationTimeout = 1000;

            List <uint>   allStatusCode;
            List <string> valuesToWrite = new List <string>();
            valuesToWrite.Add(txb_write.Text);

            if (!(bool)ck_nodeIsNumeric.IsChecked)
            {
                // The nodeId.IdentifierType is string => call the appropriate method
                List <string> NodesIdentifiers = new List <string>();
                NodesIdentifiers.Add(txb_NodeId.Text);

                m_OPCUA_client.writeNodeValue(NodesIdentifiers, valuesToWrite, (ushort)lbx_Namspaces.SelectedIndex, OperationTimeout, out allStatusCode);
            }
            else
            {
                // The nodeId.IdentifierType is numeric => call the appropriate method
                List <uint> NodesIdentifiers = new List <uint>();
                NodesIdentifiers.Add(uint.Parse(txb_NodeId.Text));

                m_OPCUA_client.writeNodeValue(NodesIdentifiers, valuesToWrite, (ushort)lbx_Namspaces.SelectedIndex, OperationTimeout, out allStatusCode);
            }

            txb_ReadCode.Text = allStatusCode[0].ToString();

            if (allStatusCode[0] == 0)
            {
                ActiveButtonBT(btn_display_statusCode);
            }
            else
            {
                StopButtonBT(btn_display_statusCode);
            }
        }
        catch (Exception ex)
        {
            ExceptionDlg.Show("writing the node failed", ex);
        }
    }
Exemplo n.º 21
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationName   = "UA Sample Server";
            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "Opc.Ua.SampleServer";

            try
            {
                // process and command line arguments.
                if (application.ProcessCommandLine())
                {
                    return;
                }

                // check if running as a service.
                if (!Environment.UserInteractive)
                {
                    application.StartAsService(new SampleServer());
                    return;
                }

                // load the application configuration.
                application.LoadApplicationConfiguration(false);

                // This call registers the certificate with HTTP.SYS
                // It must be called once after installation if the HTTPS endpoint is enabled.
                // HttpAccessRule.SetHttpsCertificate(c.SecurityConfiguration.ApplicationCertificate.Find(true), 51212, false);

                // check the application certificate.
                application.CheckApplicationInstanceCertificate(false, 0);

                // start the server.
                application.Start(new SampleServer());

                // run the application interactively.
                Application.Run(new ServerForm(application));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }
Exemplo n.º 22
0
 private void DisconnectButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (m_server.IsConnected)
         {
             m_server.Disconnect();
             UpdateStatus(true, DateTime.UtcNow, "Disconnected {0}", m_server.Endpoint);
             ServerStatusPanel.Initialize(null);
         }
     }
     catch (Exception exception)
     {
         ExceptionDlg.Show(this.Text, exception);
     }
 }
Exemplo n.º 23
0
        private void Server_AdminCredentialsRequired(object sender, AdminCredentialsRequiredEventArgs e)
        {
            try
            {
                var identity = new Opc.Ua.Client.Controls.UserNamePasswordDlg().ShowDialog(e.Credentials, "Provide PushServer Administrator Credentials");

                if (identity != null)
                {
                    e.Credentials      = identity;
                    e.CacheCredentials = true;
                }
            }
            catch (Exception exception)
            {
                ExceptionDlg.Show(this.Text, exception);
            }
        }
Exemplo n.º 24
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void Subscribtion_DataChanged(Subscription sender, DataChangedEventArgs e)
    {
        // This method is called on the UI thread because it updates UI controls.
        if (!Dispatcher.CheckAccess()) // CheckAccess returns true if you're on the dispatcher thread
        {
            Dispatcher.BeginInvoke(new DataChangedEventHandler(Subscribtion_DataChanged), sender, e);
            return;
        }

        try
        {
            //// Check that the subscription has not changed.
            //if (!Object.ReferenceEquals(m_OPCUA_client.Subscription, sender))
            //{
            //    return;
            //}

            foreach (DataChange change in e.DataChanges)
            {
                // Get text box for displaying value from user data
                TextBox textBox = change.MonitoredItem.UserData as TextBox;

                if (textBox != null)
                {
                    // Print result for variable - check first the result code
                    if (StatusCode.IsGood(change.Value.StatusCode))
                    {
                        // The node succeeded - print the value as string
                        textBox.Text       = change.Value.WrappedValue.ToString();
                        textBox.Background = Brushes.White;
                    }
                    else
                    {
                        // The node failed - print the symbolic name of the status code
                        textBox.Text       = change.Value.StatusCode.ToString();
                        textBox.Background = Brushes.Red;
                    }
                }
            }
        }
        catch (Exception exception)
        {
            ExceptionDlg.Show("Error in DataChanged callback", exception);
            //throw exception;
        }
    }
Exemplo n.º 25
0
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "Quickstarts.UserAuthenticationServer";

            try
            {
                // process and command line arguments.
                if (application.ProcessCommandLine())
                {
                    return;
                }

                // check if running as a service.
                if (!Environment.UserInteractive)
                {
                    application.StartAsService(new UserAuthenticationServer());
                    return;
                }

                // load the application configuration.
                application.LoadApplicationConfiguration(false);

                // check the application certificate.
                application.CheckApplicationInstanceCertificate(false, 0);

                // start the server.
                application.Start(new UserAuthenticationServer());


                // run the application interactively.
                Application.Run(new Opc.Ua.Server.Controls.ServerForm(application));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }
Exemplo n.º 26
0
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Client;
            application.ConfigSectionName = "IAA_DataLogger";

            try
            {
                // load the application configuration.
                var installedConfigPath = Path.Combine(Environment.GetFolderPath(
                                                           Environment.SpecialFolder.CommonApplicationData), @"IAADL\App.Config.xml");
                if (File.Exists(installedConfigPath))
                {
                    application.LoadApplicationConfiguration(installedConfigPath, false).Wait();
                }
                else
                {
                    application.LoadApplicationConfiguration(false).Wait();
                }

                var logFilePath = application.ApplicationConfiguration.TraceConfiguration.OutputFilePath;
                if (!Path.IsPathRooted(logFilePath))
                {
                    application.ApplicationConfiguration.TraceConfiguration.OutputFilePath = Path.Combine(Directory.GetCurrentDirectory(), logFilePath);
                }
                application.ApplicationConfiguration.TraceConfiguration.ApplySettings();

                // check the application certificate.
                application.CheckApplicationInstanceCertificate(false, 0).Wait();

                // run the application interactively.
                Application.Run(new MainForm(application.ApplicationConfiguration));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }
Exemplo n.º 27
0
        private void Server_StatusNotification(MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs e)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new MonitoredItemNotificationEventHandler(Server_StatusNotification), monitoredItem, e);
                return;
            }

            try
            {
                MonitoredItemNotification notification = (MonitoredItemNotification)e.NotificationValue;
                ServerStatusPanel.SetServerStatus(notification.Value.GetValue <ServerStatusDataType>(null));
            }
            catch (Exception exception)
            {
                ExceptionDlg.Show(this.Text, exception);
            }
        }
Exemplo n.º 28
0
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "Quickstarts.ReferenceServer";

            try
            {
                // load the application configuration.
                application.LoadApplicationConfiguration(false).Wait();

                // check the application certificate.
                bool certOk = application.CheckApplicationInstanceCertificate(false, 0).Result;
                if (!certOk)
                {
                    throw new Exception("Application instance certificate invalid!");
                }

                // start the server.
                application.Start(new ReferenceServer()).Wait();

                // check whether the invalid certificates dialog should be displayed.
                bool showCertificateValidationDialog = false;
                ReferenceServerConfiguration refServerconfiguration = application.ApplicationConfiguration.ParseExtension <ReferenceServerConfiguration>();

                if (refServerconfiguration != null)
                {
                    showCertificateValidationDialog = refServerconfiguration.ShowCertificateValidationDialog;
                }

                // run the application interactively.
                Application.Run(new ServerForm(application, showCertificateValidationDialog));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
            }
        }
Exemplo n.º 29
0
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "ConnectorClient";

            ApplicationInstance applicationclient = new ApplicationInstance();

            applicationclient.ApplicationType   = ApplicationType.Client;
            applicationclient.ConfigSectionName = "Client";
            try
            {
                // process and command line arguments.
                if (application.ProcessCommandLine())
                {
                    return;
                }
                // load the application configuration.
                application.LoadApplicationConfiguration(false).Wait();
                applicationclient.LoadApplicationConfiguration(false).Wait();

                // check the application certificate.
                application.CheckApplicationInstanceCertificate(false, 0).Wait();
                applicationclient.CheckApplicationInstanceCertificate(false, 0).Wait();
                //application.ApplicationConfiguration = getConfiguration();

                // run the application interactively.
                connectorForm form = new connectorForm(applicationclient);
                Application.Run(form);
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }
Exemplo n.º 30
0
        static void Main()
        {
            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "PerfTestServer";

            try
            {
                // process and command line arguments.
                if (application.ProcessCommandLine())
                {
                    return;
                }

                // check if running as a service.
                if (!Environment.UserInteractive)
                {
                    application.StartAsService(new PerfTestServer());
                    return;
                }

                // load the application configuration.
                application.LoadApplicationConfiguration(false).Wait();

                // check the application certificate.
                application.CheckApplicationInstanceCertificate(false, 0).Wait();

                // start the server.
                application.Start(new PerfTestServer()).Wait();

                // run the application interactively.
                Application.Run(new Opc.Ua.Server.Controls.ServerForm(application));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }