Beispiel #1
0
        private void rasDialer1_DialCompleted(object sender, DotRas.DialCompletedEventArgs e)
        {
            BeginInvoke((MethodInvoker) delegate()
            {
                if (e.Cancelled)
                {
                    addConnectionLog("Cancelled!");
                }
                else if (e.TimedOut)
                {
                    addConnectionLog("Timeout!");
                }
                else if (e.Error != null)
                //    addConnectionLog(e.Error.ToString());  //"DotRas.RasDialException: Exception of type 'DotRas.RasDialException' was thrown." Right.
                {
                    addConnectionLog("Unable to connect to your '{0}' VPN!", this.connectionName);
                    addConnectionLog("Use Windows directly to check you can connect to '{0}'", this.connectionName);
                    //TODO rationalize setting title more centrally?
                    setTitle("connect to " + this.connectionName);
                }
                else if (e.Connected)
                {
                    //this.Visible = false;
                    hideForm();
                }


                btnConnect.Enabled = !e.Connected;
            });
        }
Beispiel #2
0
        private void dialer_DialCompleted(object sender, DialCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                this.StatusTextBox.AppendText("Cancelled!");
            }
            else if (e.TimedOut)
            {
                this.StatusTextBox.AppendText("Connection attempt timed out!");
            }
            else if (e.Error != null)
            {
                this.StatusTextBox.AppendText(e.Error.ToString());
            }
            else if (e.Connected)
            {
                this.StatusTextBox.AppendText("Connected!");
            }

            this.StatusTextBox.ScrollToEnd();

            if (!e.Connected)
            {
                // The connection was not connected, disable the disconnect button.
                this.DisconnectButton.IsEnabled = false;
            }

            this.DialButton.IsEnabled = true;
        }
Beispiel #3
0
 void client_ClientDialCompleted(object sender, DialCompletedEventArgs e)
 {
     if (e.Cancelled)
     {
         AppendText("操作已取消");
     }
     else if (e.TimedOut)
     {
         AppendText("操作超时");
     }
     else if (e.Error != null)
     {
         if (client.macAdd != client.macAddress)
         {
             AppendText("绑定到本机当前MAC的试用许可已过期。");
             AppendText("将本机MAC地址修改为" + client.macAddress.Replace(":", "").ToUpper() + "以绕过版本许可限制。");
         }
         else
         {
             AppendText("ERROR: " + e.Error.Message);
         }
     }
     else if (e.Connected)
     {
         AppendText("[" + DateTime.Now.ToShortTimeString() + "] " + "VPN已连接,更新IP...");
         if (client.updateIpaddress())
         {
             AppendText("[" + DateTime.Now.ToShortTimeString() + "] " + "当前IP地址:" + client.publicIpAddress);
         }
         else
             AppendText("[" + DateTime.Now.ToShortTimeString() + "] " + "更新IP失败,请访问http://ip138.com查看");
         this.Invoke(new Action(() =>
         {
             UIDisconnect.Text = "断开" + client.lastServerUsed;
             UIConnect.Enabled = true;
             UIDisconnect.Enabled = true;
         }));
     }
     if (!e.Connected)
     {
         this.Invoke(new Action(() =>
         {
             UIConnect.Enabled = true;
             UIDisconnect.Text = "断开";
             UIDisconnect.Enabled = false;
         }));
     }
     Application.DoEvents();
 }
Beispiel #4
0
        private void Dialer_DialCompleted(object sender, DialCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                this.StatusTextBox.AppendText("Cancelled!");
            }
            else if (e.Connected)
            {
                this.StatusTextBox.AppendText("Connected!");
            }
            else if (e.Error != null)
            {
                this.AppendException(e.Error);
            }
            else if (e.TimedOut)
            {
                this.StatusTextBox.AppendText("The connection attempt has timed out!");
            }

            this.CancelButton.Enabled = false;
            this.DialButton.Enabled = true;
        }
Beispiel #5
0
        private void DialCompleted(object sender, DialCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                connectionErrorLabel.ForeColor = Color.Red;
                connectionErrorLabel.Text = "Error: Connection Cancelled";
                loginBTN.Text = "Login";
                loginBTN.Enabled = true;
                currentVPN.DialCompleted -= DialCompleted;
            }
            else if (e.TimedOut)
            {
                connectionErrorLabel.ForeColor = Color.Red;
                connectionErrorLabel.Text = "Error: Timed Out";
                loginBTN.Text = "Login";
                loginBTN.Enabled = true;
                currentVPN.DialCompleted -= DialCompleted;
            }

            else if (e.Connected)
            {
                //Show Disconnect Button
                disconnectBtn.Enabled = true;
                disconnectBtn.Show();

                //Hide Login Button
                loginBTN.Text = "Connecting";
                loginBTN.Enabled = false;
                loginBTN.Hide();

                //DO GET REQUEST

                string ipRegUrl = string.Format("REDACTED", this.userName);

                try
                {
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ipRegUrl);
                    request.Timeout = 4000;
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    Stream stream = response.GetResponseStream();
                }
                catch
                {
                    //MessageBox.Show("Error")
                }

                //Switch Window Title to Connected
                this.Text = string.Format("OracleNet Client : Connected - {0}", GetOracleIP());

                //Show MessageBox
               // if (MessageBox.Show("Proceed?", "Confirm", MessageBoxButtons.ok))
                MessageBox.Show("Connected! Launch ElDewrito Now!", "Success!", MessageBoxButtons.OK);
                currentVPN.DialCompleted -= DialCompleted;
            }
            else if(e.Error != null)
            {
                loginBTN.Text = "Login";
                MessageBox.Show(e.Error.ToString(), "Error!", MessageBoxButtons.OK);
                loginBTN.Enabled = true;
                currentVPN.DialCompleted -= DialCompleted;
            }
        }
Beispiel #6
0
        private void Target_DialCompleted(object sender, DialCompletedEventArgs e)
        {
            this.cancelled = e.Cancelled;
            this.connected = e.Connected;
            this.timedOut = e.TimedOut;
            this.error = e.Error;

            this.waitHandle.Set();
        }
Beispiel #7
0
        private void rasDialer_DialCompleted(object sender, DialCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                if (rasProperties != null)
					rasProperties.Info("The RAS connection has been cancelled.");
            }
            else if (e.TimedOut)
            {
                if (rasProperties != null)
					rasProperties.Info("The RAS connection attempt timed out.");
            }
            else if (e.Error != null)
            {
                if (rasProperties != null)
                    rasProperties.Info(e.Error.ToString());
            }
            else if (e.Connected)
            {
                this.connected = true;

                if (rasProperties != null)
					rasProperties.Info("RAS connection has been created successfully.");
            }

            if (!e.Connected)
            {
                // The connection was not connected, disable the disconnect button.
                this.connected = false;
            }
        }
Beispiel #8
0
 static void dialer_DialCompleted(object sender, DialCompletedEventArgs e)
 {
     rasDone = true;
 }
 public void OnClientDialCompleted(object sender, DialCompletedEventArgs e)
 {
     if (ClientDialCompleted != null)
     {
         ClientDialCompleted(sender, e);
     }
 }
Beispiel #10
0
 private void Dialer_DialCompleted(object sender, DialCompletedEventArgs e)
 {
     if (e.Cancelled)
     {
         connectSatuts = false;
     }
     else if (e.TimedOut)
     {
         connectSatuts = false;
     }
     else if (e.Error != null)
     {
         connectSatuts = false;
     }
     else if (e.Connected)
     {
         connectSatuts = true;
     }
     eventX.Set();
 }
Beispiel #11
0
 /// <summary>
 /// Raises the <see cref="RasDialer.DialCompleted"/> event.
 /// </summary>
 /// <param name="e">An <see cref="DotRas.DialCompletedEventArgs"/> containing event data.</param>
 private void OnDialCompleted(DialCompletedEventArgs e)
 {
     this.RaiseEvent<DialCompletedEventArgs>(this.DialCompleted, e);
 }
Beispiel #12
0
        /// <summary>
        /// Occurs when the dialer has completed a dialing operation.
        /// </summary>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">An <see cref="DotRas.DialCompletedEventArgs"/> containing event data.</param>
        private void Dialer_DialCompleted(object sender, DialCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                this.tMessage.AppendText("连接取消!\r\n");
            }
            else if (e.TimedOut)
            {
                this.tMessage.AppendText("连接超时!\r\n");
            }
            else if (e.Error != null)
            {
                this.tMessage.AppendText("请检查网络连接或者账户是否异常.\r\n");
            }
            else if (e.Connected)
            {
                this.tMessage.AppendText("连接成功!\r\n");
                bConnect.Enabled = false;
                bDisconnect.Enabled = true;

                //Account state changed.
                
            }

            if (!e.Connected)
            {
                // The connection was not connected, disable the disconnect button.
                this.tMessage.AppendText("连接失败!\r\n");

            }
        }
        private void dialer_DialCompleted(object sender, DialCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                this.AppendStatusText("Cancelled!");
            }
            else if (e.Connected)
            {
                this.AppendStatusText("Connected!");
            }
            else if (e.TimedOut)
            {
                this.AppendStatusText("Connection attempt timed out!");
            }
            else if (e.Error != null)
            {
                this.AppendStatusText(e.Error.ToString());
            }

            this.IsConnectionsComboBoxEnabled = true;
            this.IsDisconnectButtonEnabled = false;
            this.IsDialButtonEnabled = true;
        }
 private void Dialer_DialCompleted(object sender, DialCompletedEventArgs e)
 {
     if (e.Cancelled)
     {
         this.flagConnected = false;
     }
     else if (e.TimedOut)
     {
         this.flagConnected = false;
     }
     else if (e.Error != null)
     {
         this.flagConnected = false;
     }
     else if (e.Connected)
     {
         this.flagConnected = true;
     }
     if (!e.Connected)
     {
         this.flagConnected = false;
     }
     OnClientDialCompleted(sender, e);
 }
Beispiel #15
0
 /// <summary>
 /// Raises the <see cref="RasDialer.DialCompleted"/> event.
 /// </summary>
 /// <param name="e">An <see cref="DotRas.DialCompletedEventArgs"/> containing event data.</param>
 private void OnDialCompleted(DialCompletedEventArgs e)
 {
     this.RaiseEvent <DialCompletedEventArgs>(this.DialCompleted, e);
 }
Beispiel #16
0
        /// <summary>
        /// Signaled by the asynchronous operation when the operation has completed.
        /// </summary>
        /// <param name="state">The object passed to the delegate.</param>
        private void DialCompletedCallback(object state)
        {
            DialCompletedEventArgs e = (DialCompletedEventArgs)state;

            this.OnDialCompleted(e);
        }
Beispiel #17
0
 void dialer_DialCompleted(object sender, DialCompletedEventArgs e)
 {
     DialComplete(e);
 }
Beispiel #18
0
        private void dial_DialCompleted(object sender, DialCompletedEventArgs e)
        {
            while (proBarMain.Value < 100)
            {
                proBarMain.Value += 1;
            }

            cmbServerChoice.Enabled = false;
            btnConnect.Visible = false;
            btnDisconnect.Visible = true;
        }
Beispiel #19
0
        private void _rasDialer_DialCompleted(object sender, DialCompletedEventArgs e)
        {
            Console.WriteLine("Dial completed");

            if (e.Cancelled)
            {
                Console.WriteLine("\tConnection canceled");
            }
            else if (e.TimedOut)
            {
                Console.WriteLine("\tConnection timeout");
            }
            else if (e.Error != null)
            {
                this._taskCompletionSource.SetException(e.Error);

                //if (this._rasDialer.IsBusy)
                //{
                //    Console.WriteLine("\trasDialer is BUSY");
                //}
            }
            else
            {
                // Start monitoring the connection
                var rasConnection = this.IpSecActiveConnectionGet(this._vpnConnectionName);
                if (rasConnection != null)
                {
                    RasIPInfo rasInfo = (RasIPInfo)rasConnection.GetProjectionInfo(RasProjectionType.IP);

                    this._rasConnectionWatcher.Handle = rasConnection.Handle;
                    this._rasConnectionWatcher.EnableRaisingEvents = true;
                }

                Console.WriteLine("\tConnection established");
                this._taskCompletionSource.SetResult(null);
            }
        }