private void waitPay(object ParObject)
        {
            OrderModel om = (OrderModel)ParObject;
            AlipayBLL ab = new AlipayBLL();
            for (int i = 0; i < 60; i++)
            {
                WaiteMM++;
                string xml = ab.paystatus(om.Out_trade_no);
                try
                {
                    string is_success = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/is_success").InnerText;
                    if (is_success == "T")
                    {
                        Trade_status = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/trade_code").InnerText;

                        if (Trade_status == "success")
                        {
                            this.lblMsg1.Text = "请输入金额...";
                            this.btnOK.Enabled = true;
                            this.btnClear.Enabled = true;
                            this.timer1.Enabled = false;
                            this.paySuccess();
                            break;
                        }
                        if (i >= ESC1MM)
                        {
                            this.btnOK.Enabled = true;
                            this.timer1.Enabled = false;
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.lblMsg1.Text = "异常:" + ex.Message;
                }
                finally
                {
                    Thread.Sleep(1000);
                }
            }
        }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ConfigBLL configBll = new ConfigBLL();
            CashierBLL cashierBll = new CashierBLL();
            DeviceBLL deviceBll = new DeviceBLL();

            string path = System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Yunfu";

            //第一次启动
            if (!Directory.Exists(path))//不存在path路径
            {
                Directory.CreateDirectory(path);
            }
            if (!File.Exists(path + "\\Cashier.xml"))
            {
                StaticData.Cashier.cashier_id = "0";
                cashierBll.setConfig(StaticData.Cashier);
            }
            if (!File.Exists(path + "\\Device.xml"))
            {
                deviceBll.setConfig(StaticData.Device);
            }
            if (!File.Exists(path + "\\Config.xml"))
            {
                StaticData.Config.isPrint = "0";
                StaticData.Config.isVoice = "1";
                StaticData.Config.dualPrint = "1";
                StaticData.Config.userLptPrint = "0";
                StaticData.Config.LptName = "LPT1";
                StaticData.Config.printerName = new PrintDocument().PrinterSettings.PrinterName;
                configBll.setConfig(StaticData.Config);
            }    
               
            StaticData.Device = deviceBll.getConfig();
            StaticData.Config = configBll.getConfig();
            StaticData.Cashier = cashierBll.getConfig();

            AlipayBLL ab = new AlipayBLL();
            string xml = ab.verify();

            try
            {
                string is_success = XMLStrHelper.GetXmlNodeByXpath(xml,"Alipay/is_success").InnerText;
                if (is_success == "T")
                {
                    FormLogin frmLogin = new FormLogin();
                    frmLogin.ShowDialog();
                    if (frmLogin.DialogResult == DialogResult.OK)
                    {
                        Application.Run(new FormMain());
                    }
                    else
                    {
                        Application.Exit();
                    }
                }
                else
                {
                    try
                    {
                        string error_msg = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/error_msg").InnerText;
                        FormDevice frmDevice = new FormDevice(error_msg);
                        frmDevice.ShowDialog();
                    }
                    catch(Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageHelper.ShowError("异常" + ex.Message);
            }
        }
        private void payProcess()
        {
            ORDER = new OrderModel();
            string total_fee = txtTotal_fee.Text.Trim();
            string dym_id = txtDynamic_id.Text.Trim();
            ORDER.Total_fee = Convert.ToDecimal(total_fee);
            AlipayBLL ab = new AlipayBLL();

            string xml = ab.pay(dym_id,total_fee);

            try
            {
                string is_success = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/is_success").InnerText;
                if (is_success == "T")
                {
                    string result_code = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/result_code").InnerText;
                    ORDER.Out_trade_no = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/out_trade_no").InnerText;
                    ORDER.Buyer_email = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/buyer_email").InnerText;

                    if (result_code == "ORDER_SUCCESS_PAY_SUCCESS")
                    {
                        paySuccess();
                    }
                    else if (result_code == "ORDER_SUCCESS_PAY_INPROCESS")
                    {
                        WaiteMM = 0;
                        ESC1MM = 60;
                        this.timer1.Enabled = true;
                        this.btnClear.Enabled = false;
                        this.lblMsg2.Text = "待支付中...10秒后可按Esc退出";
                        Thread thread = new Thread(this.waitPay);
                        thread.IsBackground = true;
                        thread.Start(ORDER);
                        //payFinish();
                    }
                }
                else
                {
                    string error_msg = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/error_msg").InnerText;
                    MessageHelper.ShowWarning("失败:" + error_msg);
                    payFinish();
                }
            }
            catch (Exception ex)
            {
                MessageHelper.ShowError("异常:" + ex.Message);
                payFinish();
            }            
        }