コード例 #1
0
        private void BtnConnect_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            String          sql = "", err = "";
            MySqlConnection conn;

            conn = new MySqlConnection();
            conn = new MySqlConnection();
            conn = new MySqlConnection();
            conn = new MySqlConnection();

            conn.ConnectionString = "Server=" + txthostDB.Text + ";Database=" + txtnameDB.Text + ";Uid=" + txtuserDB.Text + ";Pwd=" + txtpassDB.Text +
                                    ";port = " + txtportDB.Text + "; Connection Timeout = 300;default command timeout=0; CharSet=utf8;SslMode=none;";
            try
            {
                err = "00";
                var baseAddress       = "http://" + txtVNEip.Text + webapi;
                VNErequestPayment vne = new VNErequestPayment();
                vne.tipo      = "1";
                vne.importo   = txtAmount.Text;
                vne.opname    = "admin";
                vne.operatore = "";
                String txtjson = JsonConvert.SerializeObject(vne, Formatting.Indented);
                listBox1.Items.Add(txtjson);
                err = "01";
                WebClient webClient = new WebClient();
                var       http      = (HttpWebRequest)WebRequest.Create(new Uri(baseAddress));
                http.Accept      = "application/json";
                http.ContentType = "application/json";
                http.Method      = "POST";
                ASCIIEncoding encoding  = new ASCIIEncoding();
                Byte[]        bytes     = encoding.GetBytes(txtjson);
                Stream        newStream = http.GetRequestStream();
                newStream.Write(bytes, 0, bytes.Length);
                newStream.Close();
                err = "02";
                var response = http.GetResponse();
                err = "03";
                var stream = response.GetResponseStream();
                err = "04";
                var sr      = new StreamReader(stream);
                var content = sr.ReadToEnd();
                err = "05";
                listBox1.Items.Add(content);
                vneRspPay = new VNEresponsePayment();
                dynamic obj = JsonConvert.DeserializeObject(content);
                vneRspPay.id         = obj.id;
                vneRspPay.importo    = obj.importo;
                vneRspPay.tipo       = obj.tipo;
                vneRspPay.req_status = obj.req_status;
                //vneRspPay = (VNEresponsePayment)JsonConvert.DeserializeObject(content);
                err = "06";
                sql = "Insert Into vne_response_payment Set " +
                      "id='" + vneRspPay.id + "'" +
                      ",importo='" + vneRspPay.importo + "'" +
                      ",tipo='" + vneRspPay.tipo + "'" +
                      ",req_status='" + vneRspPay.importo + "'" +
                      ",active='1'" +
                      ",date_Create=now()" +
                      ",user_create='" + vne.opname + "'"
                ;
                MySqlCommand com = new MySqlCommand();
                com.CommandText = sql;
                com.CommandType = CommandType.Text;
                com.Connection  = conn;
                conn.Open();
                int chk = com.ExecuteNonQuery();
                conn.Close();
                com.Dispose();
                timer.Enabled = true;
                timer.Start();
                label9.Text = "Start waiting payment";
                listBox1.Items.Add("insert payment OK");
            }
            catch (Exception ex)
            {
                listBox1.Items.Add(err + " " + ex.Message);
            }
        }
コード例 #2
0
        private void initConfig()
        {
            int timerOnline = 5;

            int.TryParse(txtTimerOnLine.Text, out timerOnline);
            vneC = new VNEControl();

            timer          = new Timer();
            timer.Interval = 5000;
            timer.Tick    += Timer_Tick;
            timer.Enabled  = false;

            timerOnLine          = new Timer();
            timerOnLine.Interval = timerOnline * 1000;
            timerOnLine.Tick    += TimerOnLine_Tick;
            timerOnLine.Enabled  = false;

            vneRspPay = new VNEresponsePayment();
            vnePRep   = new VNEPaymentPollingResponse();
            vnePRepd  = new VNEPaymentPollingResponsePaymentDetail();

            ComboBoxItem item = new ComboBoxItem();

            item.Value = "1";
            item.Text  = "Payment";
            cboCommand.Items.Add(item);
            item       = new ComboBoxItem();
            item.Value = "2";
            item.Text  = "Pooling to Check the status of the Payment";
            cboCommand.Items.Add(item);
            item       = new ComboBoxItem();
            item.Value = "3";
            item.Text  = "Delete pending payment";
            cboCommand.Items.Add(item);
            item       = new ComboBoxItem();
            item.Value = "5";
            item.Text  = "List of pending payments";
            cboCommand.Items.Add(item);
            item       = new ComboBoxItem();
            item.Value = "10";
            item.Text  = "Operator withdrawal request";
            cboCommand.Items.Add(item);
            label9.Text  = "";
            label10.Text = "";

            txtCloseDay.Text         = DateTime.Now.Year + "-" + DateTime.Now.ToString("MM-dd");
            txtPaymentStartDate.Text = DateTime.Now.Year + "-" + DateTime.Now.ToString("MM-dd");
            txtPaymentEndDate.Text   = DateTime.Now.Year + "-" + DateTime.Now.ToString("MM-dd");

            btnConnect.Click           += BtnConnect_Click;
            btnListPayment.Click       += BtnListPayment_Click;
            btnDelPay.Click            += BtnDelPay_Click;
            btnCloseDay.Click          += BtnCloseDay_Click;
            txtTimerOnLine.TextChanged += TxtTimerOnLine_TextChanged;
            txtTimerOnLine.KeyPress    += TxtTimerOnLine_KeyPress;
            btnStacker.Click           += BtnStacker_Click;
            btnDoorOpen.Click          += BtnDoorOpen_Click;
            txtWaitTime.KeyPress       += TxtWaitTime_KeyPress;
            btnPayment.Click           += BtnPayment_Click;
            btnRestart.Click           += BtnRestart_Click;
            btnShutdown.Click          += BtnShutdown_Click;
            //cboPpl.SelectedValueChanged += CboPpl_SelectedValueChanged;

            //cboCommand.Items.Insert(0, "");
            //cboCommand.Items.Insert(1, "Payment");
            //cboCommand.Items.Insert(2, "Pooling to Check the status of the Payment");
            //cboCommand.Items.Insert(3, "Delete pending payment");
            //cboCommand.Items.Insert(5, "List of pending payments");
            //cboCommand.Items.Insert(10, "Operator withdrawal request");
            //cboCommand.Items.Insert(11, "Polling ot check the status of the operator withdrawal");
            //cboCommand.Items.Insert(12, "End of operatoe withdrawal");
            //cboCommand.Items.Insert(20, "");
            //cboCommand.Items.Insert(30, "");
            //cboCommand.Items.Insert(31, "");
            //cboCommand.Items.Insert(40, "");
            int i = 0;

            timerOnLine.Start();
        }