A class that install, configures and runs a UA application.
Esempio n. 1
2
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance application = new ApplicationInstance();
            application.ApplicationType   = ApplicationType.Client;
            application.ConfigSectionName = "TutorialClient";

            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;
            }
        }
Esempio n. 2
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;
            }
        }
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance application = new ApplicationInstance();
            application.ApplicationType   = ApplicationType.Client;
            application.ConfigSectionName = "Quickstarts.ReferenceClient";

            try
            {
                
                // 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)
            {
                string text = "Exception: " + e.Message;
                if (e.InnerException != null)
                {
                    text += "\r\nInner exception: ";
                    text += e.InnerException.Message;
                }
                MessageBox.Show(text, application.ApplicationName);
                return;
            }
        }
        /// <summary>
        /// The async main entry point for the application.
        /// </summary>
        static async Task AsyncMain()
        {

            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)
            {
                Utils.Trace("App {0} failed to start with exception {1}.", application.ApplicationName, e.Message);
                return;
            }
        }
Esempio n. 5
0
        public PublisherForm(
            ServiceMessageContext context,
            ApplicationInstance application,
            PublisherForm masterForm,
            ApplicationConfiguration configuration)
        {
            InitializeComponent();
            this.Icon = ClientUtils.GetAppIcon();

            m_masterForm = masterForm;
            m_context = context;
            m_application = application;
            m_server = application.Server as Opc.Ua.Server.StandardServer;

            if (m_masterForm == null)
            {
                m_forms = new List<PublisherForm>();
            }

            SessionsCTRL.Configuration  = m_configuration = configuration;
            SessionsCTRL.MessageContext = context;

            // get list of cached endpoints.
            m_endpoints = m_configuration.LoadCachedEndpoints(true);
            m_endpoints.DiscoveryUrls = configuration.ClientConfiguration.WellKnownDiscoveryUrls;
            EndpointSelectorCTRL.Initialize(m_endpoints, m_configuration);

            // initialize control state.
            Disconnect();
            //lth: initial MassTransit Publisher
            m_massTransitPublisher = new MassTransitPublisher();

            this.NotificationsCTRL.ItemsAdded += NotificationsCTRL_ItemsAdded;
        }
        public ClientPage(
           ServiceMessageContext context,
           ApplicationInstance application,
           ClientPage masterPage,
           ApplicationConfiguration configuration)
        {
            InitializeComponent();

            if (!configuration.SecurityConfiguration.AutoAcceptUntrustedCertificates)
            {
                configuration.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation);
            }
        
            m_masterPage = masterPage;
            m_context = context;
            m_application = application;
            m_server = application.Server as Opc.Ua.Server.StandardServer;

            if (m_masterPage == null)
            {
                m_pages = new List<ClientPage>();
            }

            m_configuration = configuration;
            
            SessionsCTRL.Configuration = configuration;
            SessionsCTRL.MessageContext = context;
            SessionsCTRL.AddressSpaceCtrl = BrowseCTRL;
            SessionsCTRL.NodeSelected += SessionCtrl_NodeSelected;

            // get list of cached endpoints.
            m_endpoints = m_configuration.LoadCachedEndpoints(true);
            m_endpoints.DiscoveryUrls = configuration.ClientConfiguration.WellKnownDiscoveryUrls;
            
            // hook up endpoint selector
            EndpointSelectorCTRL.Initialize(m_endpoints, m_configuration);
            EndpointSelectorCTRL.ConnectEndpoint += EndpointSelectorCTRL_ConnectEndpoint;
            EndpointSelectorCTRL.EndpointsChanged += EndpointSelectorCTRL_OnChange;

            BrowseCTRL.SessionTreeCtrl = SessionsCTRL;
            BrowseCTRL.NodeSelected += BrowseCTRL_NodeSelected;

            // exception dialog
            GuiUtils.ExceptionMessageDlg += ExceptionMessageDlg;

            ServerUrlTB.Text = "None";

            m_publishers = AmqpConnectionCollection.Load(configuration);

            foreach (var publisher in m_publishers)
            {
                Task t = publisher.OpenAsync();
            }

            m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
        }
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();
            application.ApplicationName = "UA Sample Client";
            application.ApplicationType = ApplicationType.ClientAndServer;
            application.ConfigSectionName = "Opc.Ua.SampleClient";

            // set empty page for MessageDlg
            Window.Current.Content = new ClientPage();

            // Ensure the current window is active
            Window.Current.Activate();

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

                // allow UA servers to use the same certificate for HTTPS validation.
                ApplicationInstance.SetUaValidationForHttps(application.ApplicationConfiguration.CertificateValidator);

                // run the application interactively.
                Window.Current.Content = new ClientPage(application.ApplicationConfiguration.CreateMessageContext(), application, null, application.ApplicationConfiguration);

                // Ensure the current window is active
                Window.Current.Activate();

            }
            catch (ServiceResultException ex)
            {
                Utils.Trace("ServiceResultException:" + ex.Message);
                MessageDlg dialog = new MessageDlg("Client not started. Exit.\r\n" + ex.Message);
                await dialog.ShowAsync();
                Application.Current.Exit();
                return;
            }

            try
            { 

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

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

            }
            catch (ServiceResultException ex)
            {
                Utils.Trace("ServiceResultException:" + ex.Message);
                MessageDlg dialog = new MessageDlg("Client ok but Server has not started.\r\n" + ex.Message);
                await dialog.ShowAsync();
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Creates a form which displays the status for a UA server.
        /// </summary>
        public ServerForm(ApplicationInstance application)
        {
            InitializeComponent();

            m_application = application;
            m_server = application.Server as StandardServer;
            m_configuration = application.ApplicationConfiguration;
            this.ServerDiagnosticsCTRL.Initialize(m_server, m_configuration);

            TrayIcon.Text = this.Text = m_configuration.ApplicationName;
            this.Icon = TrayIcon.Icon = ConfigUtils.GetAppIcon();
        }
        /// <summary>
        /// Creates a form which displays the status for a UA server.
        /// </summary>
        public ServerForm(ApplicationInstance application)
        {
            InitializeComponent();

            m_application = application;
            m_server = application.Server as StandardServer;
            m_configuration = application.ApplicationConfiguration;
            this.ServerDiagnosticsCTRL.Initialize(m_server, m_configuration);

            TrayIcon.Text = this.Text = m_configuration.ApplicationName;

            ComponentResourceManager resources = new ComponentResourceManager(typeof(ServerForm));
            TrayIcon.Icon = (Icon)(resources.GetObject("App.ico"));
        }
        public SampleClientForm(
            ApplicationInstance application, 
            ClientForm masterForm, 
            ApplicationConfiguration configuration)
        :
            base(configuration.CreateMessageContext(), application, masterForm, configuration)
        {
            InitializeComponent();

            if (!configuration.SecurityConfiguration.AutoAcceptUntrustedCertificates)
            {
                configuration.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation);
            }
        }
Esempio n. 11
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 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);

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

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

                // run the application interactively.
                Application.Run(new ServerForm(application));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }
Esempio n. 12
0
        public SamplePublisherForm(
            ApplicationInstance application,
            Opc.Ua.Sample.Controls.PublisherForm masterForm,
            ApplicationConfiguration configuration)
            : base(configuration.CreateMessageContext(), application, masterForm, configuration)
        {
            InitializeComponent();

            base.BrowseCTRL.MethodCalled += new Opc.Ua.Sample.Controls.MethodCalledEventHandler(BrowseCTRL_MethodCalled);

            if (!configuration.SecurityConfiguration.AutoAcceptUntrustedCertificates)
            {
                configuration.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Creates a form which displays the status for a UA server.
        /// </summary>
        public ServerForm(ApplicationInstance application)
        {
            InitializeComponent();
            this.Icon = ConfigUtils.GetAppIcon();

            m_application = application;

            if (application.Server is StandardServer)
            {
                this.ServerDiagnosticsCTRL.Initialize((StandardServer)application.Server, application.ApplicationConfiguration);
            }

            TrayIcon.Text = this.Text = application.ApplicationName;
            TrayIcon.Icon = GetAppIcon();
        }
Esempio n. 14
0
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            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);

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

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

                // run the application interactively.
                Application.Run(new ServerForm(application));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }
Esempio n. 15
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;
            }
        }
        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";

            // use a custom transport channel
            WcfChannelBase.g_CustomTransportChannel = new CustomTransportChannelFactory();

            try
            {
                Task<ApplicationConfiguration> task = application.LoadApplicationConfiguration(false);
                task.Wait();

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

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

                // run the application interactively.
                Application.Run(new SampleClientForm(application, null, application.ApplicationConfiguration));
            }
            catch (Exception e)
            {
                string text = "Exception: " + e.Message;
                if (e.InnerException != null)
                {
                    text += "\r\nInner exception: ";
                    text += e.InnerException.Message;
                }
                MessageBox.Show(text, application.ApplicationName);
            }
        }
        /// <summary>
        /// Creates a form which displays the status for a UA server.
        /// </summary>
        public ServerPage(ApplicationInstance application)
        {
            InitializeComponent();

            m_application = application;

            if (application.Server is StandardServer)
            {
                ServerDiagnosticsCTRL.Initialize((StandardServer)application.Server, application.ApplicationConfiguration);
            }

            if (!application.ApplicationConfiguration.SecurityConfiguration.AutoAcceptUntrustedCertificates)
            {
                application.ApplicationConfiguration.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation);
            }

        }
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance application = new ApplicationInstance();
            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "Quickstarts.ReferenceServer";

            try
            {

                // load the application configuration.
                Task<ApplicationConfiguration> task = application.LoadApplicationConfiguration(false);

                // check the application certificate.
                Task<bool> task2 = application.CheckApplicationInstanceCertificate(false, 0);

                task2.Wait();
                bool certOK = task2.Result;
                if (!certOK)
                {
                    throw new Exception("Application instance certificate invalid!");
                }

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


                // run the application interactively.
                Application.Run(new ServerForm(application));
            }
            catch (Exception e)
            {
                string text = "Exception: " + e.Message;
                if (e.InnerException != null)
                {
                    text += "\r\nInner exception: ";
                    text += e.InnerException.Message;
                }
                MessageBox.Show(text, application.ApplicationName);
            }
        }
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();
            application.ApplicationName = "UA Sample Client";
            application.ApplicationType = ApplicationType.ClientAndServer;
            application.ConfigSectionName = "Opc.Ua.SampleClient";

            // helper to let Opc.Ua Utils find the localFolder in the environment
            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            Utils.DefaultLocalFolder = localFolder.Path;

            // set empty page for MessageDlg
            Window.Current.Content = new ClientPage();

            // Ensure the current window is active
            Window.Current.Activate();

            // Allow the current window to activate since the stack initialization below can take some time
            // and the app can be terminated by the runtime if this takes too long
            await Task.Delay(1);

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

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

                // run the application interactively.
                Window.Current.Content = new ClientPage(application.ApplicationConfiguration.CreateMessageContext(), application, null, application.ApplicationConfiguration);

                // start the server.
                await application.Start(new SampleServer());
            }
            catch (Exception ex)
            {
                Utils.Trace("Exception:" + ex.Message);
                MessageDlg dialog = new MessageDlg(ex.Message);
                await dialog.ShowAsync();
                Application.Current.Exit();
            }
        }
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();
            application.ApplicationName = "UA Sample Server";
            application.ApplicationType = ApplicationType.Server;
            application.ConfigSectionName = "Opc.Ua.SampleServer";

            // set empty page for MessageDlg
            Window.Current.Content = new ServerPage();

            // Ensure the current window is active
            Window.Current.Activate();

            try
            {
                // load the application configuration.
                await 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.
                await application.CheckApplicationInstanceCertificate(false, 0);

                // start the server.
                await application.Start(new Opc.Ua.Sample.SampleServer());

                // run the application interactively.
                Window.Current.Content = new ServerPage(application);

                // Ensure the current window is active
                Window.Current.Activate();
            }
            catch (ServiceResultException ex)
            {
                Utils.Trace("ServiceResultException:" + ex.Message);
                MessageDlg dialog = new MessageDlg("Server not started. Exit.\r\n"+ex.Message);
                await dialog.ShowAsync();
                Application.Current.Exit();
            }
        }
Esempio n. 21
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance application = new ApplicationInstance();
            application.ApplicationName   = "UA COM Server Wrapper";
            application.ApplicationType   = ApplicationType.Server;
            application.ConfigSectionName = "Opc.Ua.ComServerWrapper";

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

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

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

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

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

                // run the application interactively.
                Application.Run(new ServerForm(application));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Creates a form which displays the status for a UA server.
        /// </summary>
        public ServerForm(ApplicationInstance application)
        {
            InitializeComponent();

            m_application = application;

            if (application.Server is StandardServer)
            {
                this.ServerDiagnosticsCTRL.Initialize((StandardServer)application.Server, application.ApplicationConfiguration);
            }

            if (!application.ApplicationConfiguration.SecurityConfiguration.AutoAcceptUntrustedCertificates)
            {
                application.ApplicationConfiguration.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation);
            }

            TrayIcon.Text = this.Text = application.ApplicationName;
            TrayIcon.Icon = GetAppIcon();
        }
        /// <summary>
        /// Creates a form which displays the status for a UA server.
        /// </summary>
        public ServerForm(ApplicationInstance application)
        {
            InitializeComponent();

            m_application = application;

            if (application.Server is StandardServer)
            {
                this.ServerDiagnosticsCTRL.Initialize((StandardServer)application.Server, application.ApplicationConfiguration);
            }

            if (!application.ApplicationConfiguration.SecurityConfiguration.AutoAcceptUntrustedCertificates)
            {
                application.ApplicationConfiguration.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation);
            }

            TrayIcon.Text = this.Text = application.ApplicationName;

            ComponentResourceManager resources = new ComponentResourceManager(typeof(ServerForm));
            TrayIcon.Icon = (Icon)(resources.GetObject("App.ico"));
        }
Esempio n. 24
0
        static void Main()
        {
            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);

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

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

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

            ApplicationInstance application = new ApplicationInstance();
            application.ApplicationName   = "UA Publisher";
            application.ApplicationType   = ApplicationType.ClientAndServer;
            application.ConfigSectionName = "Opc.Ua.Publisher";

            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);

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

                // allow UA servers to use the same certificate for HTTPS validation.
                ApplicationInstance.SetUaValidationForHttps(application.ApplicationConfiguration.CertificateValidator);

                // run the application interactively.
                Application.Run(new SamplePublisherForm(application, null, application.ApplicationConfiguration));
            }
            catch (Exception e)
            {
                ExceptionDlg.Show(application.ApplicationName, e);
                return;
            }
        }
Esempio n. 26
0
        public OPCRead(String s_serverURL, String sXML)
        {
            ApplicationInstance application = new ApplicationInstance();
            application.ApplicationType = ApplicationType.Client;
            application.ConfigSectionName = "OPCReader";

            m_ServerUrl = s_serverURL;
            m_XML = sXML;


            try
            {
                
                application.LoadApplicationConfiguration(GetMyDir()+"\\DrvOPC.Config.xml",   false);
                m_configuration = application.ApplicationConfiguration;
            }
            catch (Exception e)
            {
                
                return;
            }

    
        }
Esempio n. 27
0
        static void Main()
        {
            // Initialize the user interface.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationInstance application = new ApplicationInstance();
            application.ApplicationType   = ApplicationType.Client;
            application.ConfigSectionName = "DataTypesClient";

            try
            {
                // process and command line arguments.
                if (application.ProcessCommandLine())
                {
                    return;
                }
                
                // load the application configuration.
                application.LoadApplicationConfiguration(false);

                // add the encodable types defined in the shared information model library.
                application.ApplicationConfiguration.MessageContext.Factory.AddEncodeableTypes(typeof(Quickstarts.DataTypes.Types.Namespaces).Assembly);

                // 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;
            }
        }
        private async Task ConsoleSampleServer()
        {
            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationName = "Quickstart Reference Server";
            application.ApplicationType = ApplicationType.Server;
            application.ConfigSectionName = "Quickstarts.ReferenceServer";

            // load the application configuration.
            ApplicationConfiguration config = await application.LoadApplicationConfiguration(false);

            // check the application certificate.
            bool haveAppCertificate = await application.CheckApplicationInstanceCertificate(false, CertificateFactory.defaultKeySize);
            if (!haveAppCertificate)
            {
                throw new Exception("Application instance certificate invalid!");
            }

            if (!config.SecurityConfiguration.AutoAcceptUntrustedCertificates)
            {
                config.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation);
            }

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

            // start the status thread
            status = Task.Run(new Action(StatusThread));

            // print notification on session events
            server.CurrentInstance.SessionManager.SessionActivated += EventStatus;
            server.CurrentInstance.SessionManager.SessionClosing += EventStatus;
            server.CurrentInstance.SessionManager.SessionCreated += EventStatus;

        }
 /// <summary>
 /// Creates a form which displays the status for a UA server.
 /// </summary>
 public ServerForm(ApplicationInstance application) : base(application)
 {
 }
Esempio n. 30
0
 /// <summary>
 /// Create the application instance builder.
 /// </summary>
 public ApplicationConfigurationBuilder(ApplicationInstance applicationInstance)
 {
     ApplicationInstance = applicationInstance;
 }
Esempio n. 31
0
 public Form2(ApplicationInstance application) : base(application)
 {
     InitializeComponent();
     new MonitoredItemEventLogDlg().Display();
 }