Exemplo n.º 1
0
 void BtnQueryLic_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string strLicID = TxtLicID.Text;
         long   licID;
         if (!long.TryParse(strLicID, out licID))
         {
             AppendMessage(string.Format("LicID invalid"));
             return;
         }
         mLicID = licID;
         if (mLicChecker != null)
         {
             mLicChecker.Close();
             mLicChecker = null;
         }
         mLicChecker        = new LicConnector();
         mLicChecker.Debug += (client, mode, msg) => AppendMessage(string.Format("{0}\t{1}", client, msg));
         mLicChecker.ServerConnectionEvent += LicChecker_ConnectionEvent;
         mLicChecker.MessageReceivedEvent  += LicChecker_MessageReceiveEvent;
         mLicChecker.EncryptObject          = this;
         mLicChecker.Client = "LicChecker - 0";
         mLicChecker.Host   = "192.168.4.182";
         mLicChecker.Port   = 3070;
         mLicChecker.Connect();
     }
     catch (Exception ex)
     {
         AppendMessage(string.Format("Fail.\t{0}", ex.Message));
     }
 }
Exemplo n.º 2
0
        private void BtnConnect_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!CheckInput())
                {
                    return;
                }
                if (mIsConnected)
                {
                    DisConnect();
                    BtnConnect.IsEnabled    = true;
                    BtnDisconnect.IsEnabled = false;
                    mIsConnected            = false;
                    CbServer.IsChecked      = true;
                    CheckBoxView_OnClick(null, null);
                }
                else
                {
                    CreateLicensePoolItems();
                    if (mLicConnector != null)
                    {
                        mLicConnector.Close();
                        mLicConnector = null;
                    }
                    mLicConnector        = new LicConnector();
                    mLicConnector.Debug += LicConnector_Debug;
                    mLicConnector.ServerConnectionEvent += LicConnector_ServerConnectionEvent;
                    mLicConnector.MessageReceivedEvent  += LicConnector_MessageReceivedEvent;
                    mLicConnector.EncryptObject          = this;
                    mLicConnector.Client       = TxtName.Text;
                    mLicConnector.ModuleTypeID = 7692;    //作为监控端
                    mLicConnector.Host         = TxtServer.Text;
                    mLicConnector.Port         = int.Parse(TxtPort.Text);
                    mLicConnector.Connect();
                    //mLicConnector.BeginConnect();

                    BtnConnect.IsEnabled    = false;
                    BtnDisconnect.IsEnabled = true;
                    mIsConnected            = true;
                    CbServer.IsChecked      = false;
                    CheckBoxView_OnClick(null, null);
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex.Message);
            }
        }