Пример #1
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            String err = "";
            //throw new NotImplementedException();
            VNEPaymentPollingRequest vnePpReq = new VNEPaymentPollingRequest();

            vnePpReq.tipo   = "2";
            vnePpReq.id     = vneRspPay.id;
            vnePpReq.opName = "admin";
            try
            {
                var       baseAddress = "http://" + txtVNEip.Text + webapi;
                String    txtjson     = JsonConvert.SerializeObject(vnePpReq, Formatting.Indented);
                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();

                var response = http.GetResponse();

                var stream  = response.GetResponseStream();
                var sr      = new StreamReader(stream);
                var content = sr.ReadToEnd();
                vnePRep = new VNEPaymentPollingResponse();
                dynamic obj = JsonConvert.DeserializeObject(content);

                vnePRep.id             = obj.id;
                vnePRep.req_status     = obj.req_status;
                vnePRep.tipo           = obj.tipo;
                vnePRep.payment_status = obj.payment_status;
                //vnePRep.payment_detail = obj.payment_details.toString();
                String  aaa  = String.Concat(obj.payment_details);
                dynamic obj1 = JsonConvert.DeserializeObject(aaa);

                vnePRepd.amount   = obj1.amount;
                vnePRepd.inserted = obj1.inserted;
                vnePRepd.rest     = obj1.rest;
                vnePRepd.status   = obj1.status;

                label10.Text = "ID " + vnePRep.id + " amount " + vnePRepd.amount + " status " + vnePRepd.status;
                listBox1.Items.Add(content);
                if (vnePRepd.status.Equals("complete"))
                {
                    timer.Stop();
                }
            }
            catch (Exception ex)
            {
                listBox1.Items.Add(err + " " + ex.Message);
            }
        }
Пример #2
0
        private void BtnListPayment_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            setControlEnable(false);
            String err = "";
            VNEPaymentPendingListRequest  vnePplReq = new VNEPaymentPendingListRequest();
            VNEPaymentPendingListResponse vnePplRes = new VNEPaymentPendingListResponse();

            vnePplReq.tipo   = "5";
            vnePplReq.opName = "admin";
            try
            {
                var       baseAddress = "http://" + txtVNEip.Text + webapi;
                String    txtjson     = JsonConvert.SerializeObject(vnePplReq, Formatting.Indented);
                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();
                listBox1.Items.Add(txtjson);
                Byte[] bytes     = encoding.GetBytes(txtjson);
                Stream newStream = http.GetRequestStream();
                newStream.Write(bytes, 0, bytes.Length);
                newStream.Close();

                var response = http.GetResponse();

                var stream  = response.GetResponseStream();
                var sr      = new StreamReader(stream);
                var content = sr.ReadToEnd();
                listBox1.Items.Add(content);
                vnePRep = new VNEPaymentPollingResponse();
                dynamic obj = JsonConvert.DeserializeObject(content);

                vnePplRes.tipo        = obj.tipo;
                vnePplRes.list_length = obj.list_length;
                //vnePplRes.pending_list = obj.pending_list;
                if (vnePplRes.tipo.Equals("5"))
                {
                    VNEPaymentPendingListResponseDetail vnePplResd = new VNEPaymentPendingListResponseDetail();
                    dynamic obj1 = JsonConvert.DeserializeObject(String.Concat(obj.pending_list));
                    vnePplResd.id = obj1.id;
                    //vnePplResd.pending_list = obj1.pending_list;
                    String aaa = String.Concat(obj.pending_list);
                    cboPpl.Items.Clear();
                    vneC.setCboPaymentPendingList(cboPpl, vnePplRes.list_length, aaa);
                }
            }
            catch (Exception ex)
            {
                listBox1.Items.Add(err + " " + ex.Message);
            }
            setControlEnable(true);
        }
Пример #3
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();
        }