コード例 #1
0
        private void btnxImMatchInfo_Click(object sender, EventArgs e)
        {
            string strImportPath = tbImportPath.Text;
            string strPort       = tbTcpPort.Text == "" ? "2102" : tbTcpPort.Text;

            if (strImportPath == "")
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("Please select an import path first!");
                return;
            }
            if (m_tsTTconfig.ImportType == "1")
            {
                if (m_exchangeFile == null)
                {
                    m_exchangeFile = TSDataExchangeTT_File.GetDataExchangeTT_File(BDCommon.g_adoDataBase.strConnection, strImportPath);
                }
            }
            else
            {
                if (m_exchangeTcp == null)
                {
                    m_exchangeTcp = TSDataExchangeTT_TCP.GetDataExchangeTT_TCP(BDCommon.g_adoDataBase.strConnection, Convert.ToInt32(strPort));
                }
            }
            frmImportMatchInfo frm = new frmImportMatchInfo(strImportPath, XmlTypeEnum.XmlTypeMatchInfo);

            frm.ShowDialog();
        }
コード例 #2
0
        private void btnStartTcpListener_Click(object sender, EventArgs e)
        {
            string btnText = btnStartTcpListener.Text;

            if (btnText == "Start Server")
            {
                tbTcpPort.Text = tbTcpPort.Text.Trim();
                if (tbTcpPort.Text == "")
                {
                    MessageBox.Show("Please input port number!");
                    return;
                }
                if (Regex.IsMatch(tbTcpPort.Text, "[^0-9]"))
                {
                    DevComponents.DotNetBar.MessageBoxEx.Show("Please input number!");
                    tbTcpPort.SelectAll();
                    tbTcpPort.Focus();
                    return;
                }

                if (radModeTCP.Checked)
                {
                    m_exchangeTcp = TSDataExchangeTT_TCP.GetDataExchangeTT_TCP(BDCommon.g_adoDataBase.strConnection, Convert.ToInt32(tbTcpPort.Text));
                    if (!m_exchangeTcp.StartServer())
                    {
                        MessageBox.Show(m_exchangeTcp.LastErrMsg);
                        return;
                    }
                    else
                    {
                        if (m_tsTTconfig != null)
                        {
                            m_tsTTconfig.TcpPort = tbTcpPort.Text;
                            m_tsTTconfig.SaveConfig();
                        }
                    }
                }
                else if (radModeUDP.Checked)
                {
                    m_exchangeUdp = TSDataExchangeTT_UDP.GetDataExchangeTT_UDP(BDCommon.g_adoDataBase.strConnection, Convert.ToInt32(tbTcpPort.Text));
                    if (!m_exchangeUdp.StartServer())
                    {
                        MessageBox.Show(m_exchangeUdp.LastErrMsg);
                        return;
                    }
                    else
                    {
                        if (m_tsTTconfig != null)
                        {
                            m_tsTTconfig.TcpPort = tbTcpPort.Text;
                            m_tsTTconfig.SaveConfig();
                        }
                    }
                }
                else
                {
                    DevComponents.DotNetBar.MessageBoxEx.Show("Please select communication mode first!");
                    return;
                }

                btnStartTcpListener.Text = "Stop Server";
                tbTcpPort.ReadOnly       = true;
                radModeTCP.Enabled       = false;
                radModeUDP.Enabled       = false;
            }
            else
            {
                if (MessageBox.Show("Are you sure to close the server?", "OVR", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    return;
                }
                if (radModeTCP.Checked)
                {
                    m_exchangeTcp.CloseServer();
                }
                else if (radModeUDP.Checked)
                {
                    m_exchangeUdp.CloseServer();
                    lstboxClients.Items.Clear();
                    lbClientForControl.Items.Clear();
                }
                btnStartTcpListener.Text = "Start Server";
                tbTcpPort.ReadOnly       = false;
                radModeTCP.Enabled       = true;
                radModeUDP.Enabled       = true;
            }
        }