Ejemplo n.º 1
0
        /// <summary>
        /// Called to connect to a server.
        /// </summary>
        public void OnConnect()
        {
            if (server_ == null)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            try
            {
                OpcUserIdentity credentials = null;

                do
                {
                    try
                    {
                        server_.ForceDa20Usage = forceDa20Usage_;
                        server_.Connect(new OpcConnectData(credentials, mProxy_));
                        break;
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }

                    credentials = new NetworkCredentialsDlg().ShowDialog(credentials);
                }while (credentials != null);

                // select all filters by default.
                server_.SetResultFilters((int)TsCDaResultFilter.All);

                // initialize controls.
                statusCtrl_.Start(server_);
                updatesCtrl_.Initialize(server_);
                subscriptionCtrl_.Initialize(server_);
                selectServerCtrl_.OnConnect(server_);

                // register for shutdown events.
                server_.ServerShutdownEvent += Server_ServerShutdown;

                // save settings.
                SaveSettings();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                TsCCpxComplexTypeCache.Server = server_ = null;
            }

            Cursor = Cursors.Default;
        }
        /// <summary>
        /// Called to connect to a server.
        /// </summary>
        public void OnConnect()
        {
            if (server_ == null)
            {
                return;
            }
            Cursor = Cursors.WaitCursor;

            try
            {
                OpcUserIdentity credentials = null;

                do
                {
                    try
                    {
                        server_.Connect(new OpcConnectData(credentials, proxy_));
                        break;
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }

                    credentials = new NetworkCredentialsDlg().ShowDialog(credentials);
                }while (credentials != null);

                // initialize controls.
                statusCtrl_.Start(server_);
                selectServerCtrl_.OnConnect(server_);
                trendsCtrl_.Initialize(server_);

                // register for shutdown events.
                server_.ServerShutdownEvent += new OpcServerShutdownEventHandler(Server_ServerShutdown);

                // save settings.
                SaveSettings();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                server_ = null;
            }

            Cursor = Cursors.Default;
        }