Esempio n. 1
0
 /// <summary>
 /// Called to connect to a target.
 /// </summary>
 public void OnConnectTarget(Opc.Server server)
 {
     if (m_target != null)
     {
         m_target.Disconnect();
         m_target.Dispose();
         m_target = null;
     }
     // use the specified server object directly.
     m_target = (Server)server;
     Cursor   = Cursors.WaitCursor;
     try
     {
         NetworkCredential credentials = null;
         do
         {
             try
             {
                 m_target.Connect(new Opc.ConnectData(credentials, m_proxy));
                 break;
             }
             catch (Exception e)
             {
                 MessageBox.Show(e.Message);
             }
             credentials = new NetworkCredentialsDlg().ShowDialog(credentials);
         }while (credentials != null);
         // select all filters by default.
         m_target.SetResultFilters((int)OpcDa::ResultFilter.All);
         // initialize controls.
         //SelectTargetCTRL.AddServerURL( m_target.Url );
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
         m_target = null;
     }
     Cursor = Cursors.Default;
 }
Esempio n. 2
0
        /// <summary>
        /// Prompts the user to set the network connectData for the node.
        /// </summary>
        private void TSM_SetLogin_Click(object sender, System.EventArgs e)
        {
            var node = m_BrowseTV.SelectedNode as IConnectDataNode;

            switch (node.GetNodeType)
            {
            case NodeType.Computer:
            case NodeType.Network:
            case NodeType.OPCServer:
                Opc.ConnectData cd = node.ConnectDataObject == null ? new Opc.ConnectData(null) : node.ConnectDataObject;
                using (NetworkCredentialsDlg dial = new NetworkCredentialsDlg())
                {
                    NetworkCredential res = dial.ShowDialog(cd.Credentials);
                    if (dial.DialogResult == DialogResult.OK)
                    {
                        node.ConnectDataObject = new Opc.ConnectData(res);
                    }
                }
                break;

            default:
                break;
            }
        }