Exemple #1
0
        private void buttonCRT_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            switch (btn.Name)
            {
            case "btn_CRTa_Open":
                MyLog.Info("尝试连接--瑞信丰...");

                ClientAPP.Server_CRTa_Return.ServerIP   = ConfigurationManager.AppSettings["Server_CRTa_Ip"];
                ClientAPP.Server_CRTa_Return.ServerPORT = ConfigurationManager.AppSettings["Server_CRTa_Port2"];
                ClientAPP.Connect(ref ClientAPP.Server_CRTa_Return);
                if (ClientAPP.Server_CRTa_Return.IsConnected)
                {
                    DealCRT_On(ref Data.DealCRTa);
                    MyLog.Info("连接成功--" + Data.DealCRTa.CRTName + "--3070端口");
                    new Thread(() => { Fun_RecvFromCRT_Return(ref Data.DealCRTa, ref ClientAPP.Server_CRTa_Return); }).Start();
                }
                else
                {
                    DealCRT_Off(ref Data.DealCRTa);
                    return;
                }
                btn_CRTa_Open.Enabled  = false;
                btn_CRTa_Close.Enabled = true;

                break;

            case "btn_CRTa_Close":
                ClientAPP.Disconnect(ref ClientAPP.Server_CRTa);
                ClientAPP.Disconnect(ref ClientAPP.Server_CRTa_Return);
                btn_CRTa_Open.Enabled  = true;
                btn_CRTa_Close.Enabled = false;
                Data.DealCRTa.LedOff();
                MyLog.Info("关闭连接--瑞信丰");
                break;

            default:
                break;
            }
        }
Exemple #2
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (btn_ZK1_Close.Enabled)
                {
                    btn_ZK1_Close_Click(sender, e);
                }
                if (btn_ZK1_YC_Close.Enabled)
                {
                    btn_ZK1_YC_Close_Click(sender, e);
                }

                if (btn_CRTa_Open.Enabled == false)
                {
                    ClientAPP.Disconnect(ref ClientAPP.Server_CRTa);
                    ClientAPP.Disconnect(ref ClientAPP.Server_CRTa_Return);
                    btn_CRTa_Open.Enabled  = true;
                    btn_CRTa_Close.Enabled = false;
                    Data.DealCRTa.LedOff();
                    MyLog.Info("关闭连接--USB应答机A");
                }

                Thread.Sleep(100);
                mySaveFileThread.FileClose();

                ServerLedThreadTag  = false;
                ServerLedThreadTag2 = false;
                Data.ServerConnectEvent.Set();
                Data.ServerConnectEvent2.Set();

                Data.AllThreadTag = false;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }