コード例 #1
0
ファイル: MainForm.cs プロジェクト: yuriik83/UA-.NET
        void TestClient_TestSequenceEvent(TestClient client, TestSequenceEventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(new TestSequenceEventHandler(TestClient_TestSequenceEvent), client, e);
                return;
            }
            
            try
            {
                if (e.TestCaseName == "Done")
                {
                    TestCancelMI.Enabled = false;

                    if (!m_client.Cancel)
                    {
                        if (m_endpointsToTest.Count > 0)
                        {
                            Connect(m_endpointsToTest.Dequeue(), m_currentOptions.UseAnsiCStack, m_currentOptions.KeySize);
                            return;
                        }

                        if (m_clientsToTest.Count > 0)
                        {
                            StartTest(m_clientsToTest.Dequeue());
                            return;
                        }
                    }

                    m_endpointsToTest.Clear();
                    m_clientsToTest.Clear();

                    TestEvent e1 = new TestEvent();

                    e1.Timestamp = DateTime.Now;
                    e1.TestId = 0;
                    e1.Iteration = 0;
                    e1.EventType = TestEventType.Completed;
                    e1.Details = Utils.Format("Completed all tests.");

                    TestEventsCTRL.AddEvent(e1);
                }

                TestCaseTB.Text  = e.TestCaseName;
                TestIdTB.Text    = String.Format("{0}", e.TestId);
                IterationTB.Text = String.Format("{0}", e.Iteration);
            }
            catch (Exception exception)
            {
				GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }     
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: yuriik83/UA-.NET
        /// <summary>
        /// Creates the client that can connect to the server.
        /// </summary>
        private void CreateClient(bool useAnsiCStack, ushort keySize)
        {
            ApplicationConfiguration configuration = ApplicationConfiguration.Load("Opc.Ua.Client", ApplicationType.Client);

            configuration.ApplicationName = Utils.Format("UA StackTest Client ({0}-{1})", (useAnsiCStack) ? "AnsiC" : "C#", keySize);
            configuration.ApplicationUri = Utils.Format("http://{0}/{1}", System.Net.Dns.GetHostName(), configuration.ApplicationName);

            string subjectName = Utils.Format("CN={1}/DC={0}", System.Net.Dns.GetHostName(), configuration.ApplicationName);

            configuration.SecurityConfiguration.ApplicationCertificate.RawData = null;
            configuration.SecurityConfiguration.ApplicationCertificate.Thumbprint = null;
            configuration.SecurityConfiguration.ApplicationCertificate.SubjectName = subjectName;

            // check if UA TCP implementation explicitly specified.
            configuration.UseNativeStack = useAnsiCStack;

            // check for certificate.
            GuiUtils.CheckApplicationInstanceCertificate(configuration, keySize, false, false);
            
            m_configuration = configuration;

            m_client = new TestClient(m_configuration);
            m_client.TestSequenceEvent += new TestSequenceEventHandler(TestClient_TestSequenceEvent);
            m_client.TestLogEventHandler += new TestLogEventHandler(TestClient_TestLogEventHandler);

            if (TestCasesCTRL.SequenceToExecute != null)
            {
                m_client.SequenceToExecute = TestCasesCTRL.SequenceToExecute;
            }

            m_client.QuickTest = QuickTestMI.Checked;
        }