Пример #1
0
        private void BtnOk_Click(object sender, EventArgs e)
        {
            save_config();

            #region 检测是否需要启动检测手牌异常线程
            if (CheckDetect.Checked)
            {
                timeLimit = MConvert <int> .ToTypeOrDefault(TextTimeLimit.Text, -1);

                moneyLimit = MConvert <double> .ToTypeOrDefault(TextMoneyLimit.Text, -1);

                if (m_thread_detect == null)
                {
                    m_thread_detect = new Thread(new ThreadStart(detect_unnormal_seat_thread));
                    m_thread_detect.IsBackground = true;
                    m_thread_detect.Start();
                }
            }
            #endregion

            #region 检测是否需要启动自动滚消费线程
            if (CheckAuto.Checked)
            {
                if (m_thread_auto == null)
                {
                    m_thread_auto = new Thread(new ThreadStart(order_auto_add_thread));
                    m_thread_auto.IsBackground = true;
                    m_thread_auto.Start();
                }
            }
            #endregion

            #region 检测是否需要启动UDP服务器线程
            if (CheckServer.Checked)
            {
                if (udp_Server == null)
                {
                    try
                    {
                        udp_Server = new UdpListenerPlus(Constants.LocalUdpPort);
                        udp_Server.OnThreadTaskRequest += new UdpListenerPlus.ThreadTaskRequest(Handle_Udp_Msg);
                    }

                    catch (Exception)
                    {
                        if (udp_Server != null)
                        {
                            udp_Server.Stop();
                            udp_Server = null;
                        }
                        MessageBox.Show(this, "启动UDP服务器失败!", "信息");
                    }
                }
                else
                {
                    udp_Server.Stop();
                    udp_Server = null;
                }
            }
            #endregion

            #region 启动云服务器上传线程

            if (m_uploadCloud == null)
            {
                m_uploadCloud = new UploadCloud(connectionString);
                m_uploadCloud.start();
            }

            #endregion


            #region 检测是否启用短信操控
            if (CheckSMS.Checked)
            {
                BtnOk.Enabled = false;
                string port = IOUtil.get_config_by_key(ConfigKeys.KEY_SMSPORT);
                if (port != "")
                {
                    comport = MConvert <uint> .ToTypeOrDefault(port.Substring(3, port.Length - 3), 0);
                }
                string str_baudrate = IOUtil.get_config_by_key(ConfigKeys.KEY_SMSBAUD);
                baudrate = MConvert <uint> .ToTypeOrDefault(str_baudrate, 0);

                string mobileType     = "";
                string CopyRightToCOM = "";
                string CopyRight      = "//上海迅赛信息技术有限公司,网址www.xunsai.com//";
                if (SmsClass.Sms_Connection(CopyRight, comport, baudrate, out mobileType, out CopyRightToCOM) == 0)
                {
                    MessageBox.Show("短信猫打开失败,请重新配置!");
                    BtnOk.Enabled = true;
                    return;
                }
                m_thread_smsOpertion = new Thread(new ThreadStart(sms_operation_thread));
                m_thread_smsOpertion.IsBackground = true;
                m_thread_smsOpertion.Start();
            }


            #endregion


            this.WindowState = FormWindowState.Minimized;
            BtnOk.Enabled    = true;
        }
Пример #2
0
        private void BtnOk_Click(object sender, EventArgs e)
        {
            save_config();

            #region 检测是否需要启动检测手牌异常线程
            if (CheckDetect.Checked)
            {
                timeLimit = MConvert<int>.ToTypeOrDefault(TextTimeLimit.Text, -1);
                moneyLimit = MConvert<double>.ToTypeOrDefault(TextMoneyLimit.Text, -1);

                if (m_thread_detect == null)
                {
                    m_thread_detect = new Thread(new ThreadStart(detect_unnormal_seat_thread));
                    m_thread_detect.IsBackground = true;
                    m_thread_detect.Start();
                }
            }
            #endregion

            #region 检测是否需要启动自动滚消费线程
            if (CheckAuto.Checked)
            {
                if (m_thread_auto == null)
                {
                    m_thread_auto = new Thread(new ThreadStart(order_auto_add_thread));
                    m_thread_auto.IsBackground = true;
                    m_thread_auto.Start();
                }
            }
            #endregion

            #region 检测是否需要启动UDP服务器线程
            if (CheckServer.Checked)
            {
                if (udp_Server == null)
                {
                    try
                    {
                        udp_Server = new UdpListenerPlus(Constants.LocalUdpPort);
                        udp_Server.OnThreadTaskRequest += new UdpListenerPlus.ThreadTaskRequest(Handle_Udp_Msg);
                    }

                    catch (Exception)
                    {
                        if (udp_Server != null)
                        {
                            udp_Server.Stop();
                            udp_Server = null;
                        }
                        MessageBox.Show(this, "启动UDP服务器失败!", "信息");
                    }
                }
                else
                {
                    udp_Server.Stop();
                    udp_Server = null;
                }
            }
            #endregion

            #region 启动云服务器上传线程

            if (m_uploadCloud == null)
            {
                m_uploadCloud = new UploadCloud(connectionString);
                m_uploadCloud.start();
            }

            #endregion

            #region 检测是否启用短信操控
            if (CheckSMS.Checked)
            {
                BtnOk.Enabled = false;
                string port = IOUtil.get_config_by_key(ConfigKeys.KEY_SMSPORT);
                if (port!="")
                {
                    comport = MConvert<uint>.ToTypeOrDefault(port.Substring(3, port.Length - 3),0);
                }
                string str_baudrate=IOUtil.get_config_by_key(ConfigKeys.KEY_SMSBAUD);
                baudrate = MConvert<uint>.ToTypeOrDefault(str_baudrate, 0);
                string mobileType = "";
                string CopyRightToCOM = "";
                string CopyRight = "//上海迅赛信息技术有限公司,网址www.xunsai.com//";
                if (SmsClass.Sms_Connection(CopyRight, comport, baudrate, out mobileType, out CopyRightToCOM)==0)
                {
                    MessageBox.Show("短信猫打开失败,请重新配置!");
                    BtnOk.Enabled = true;
                    return;
                }
                m_thread_smsOpertion = new Thread(new ThreadStart(sms_operation_thread));
                m_thread_smsOpertion.IsBackground = true;
                m_thread_smsOpertion.Start();

            }

            #endregion

            this.WindowState = FormWindowState.Minimized;
            BtnOk.Enabled = true;
        }