Exemplo n.º 1
0
        private void buttonSend_Click(object sender, EventArgs e)
        {
            string boperator = topup_ussd;
            //string mobile_no = tbMobileNo.Text;
            //string amount = tbAmount.Text;
            string mobile_no = g_Topup_Number;

            int    l_amt  = (int)Math.Round(float.Parse(g_Topup_Amount));
            string amount = l_amt.ToString();

            string pin = tbPIN.Text;

            try
            {
                tB_monitor.AppendText("USSD Code Running\r\n");
                if (crnt_port.IsOpen == false)
                {
                    crnt_port.Open();
                }
                Thread.Sleep(1000);
                crnt_port.WriteLine("AT\r");
                Thread.Sleep(1000);
                //serialPort1.WriteLine("ATD01717096211\r");
                //crnt_port.WriteLine("AT+CUSD=1,\"*124#\",15\r");
                //crnt_port.WriteLine("AT+COPS=?\r");
                crnt_port.WriteLine("AT+CUSD=1,\"" + boperator + mobile_no + "*" + amount + "*" + pin + "#" + "\",15" + "\r");
                Thread.Sleep(10000);

                //while (serialPort1.BytesToRead > 0)
                //{
                string message = crnt_port.ReadExisting();
                //  string message = "+CUSD: 2,\"SUCCESSFUL, Recharge of 10Tk for 8801992245543, TXN number R180220.1730.2600bd\",15";
                //  string message = "+CUSD: 2,\"Shuvo vai successful, Recharge of 10Tk for 8801992245543, TXN number R180220.1730.2600bd\",15";
                tB_monitor.AppendText(message + "\r\n");
                tB_monitor.AppendText("Topup Response request sent" + "\r\n");
                API_helper.func_ProcessAPI("", 2, message);
                tB_monitor.AppendText("Status : " + API_helper.status_str + "\r\n");
                tB_monitor.AppendText("Transaction No : " + API_helper.tr_id_str + "\r\n");
                tB_monitor.AppendText("Requested URL : " + API_helper.trim_str + "\r\n");

                crnt_port.Close();

                //// Update recharge id
                //string request_url = "http://139.59.18.48/quickload/apis/new_request_message/?userid=opmodem&apikey=20170729190020597c86e4d6bfe2906874467&recharge_id=" + "154" + "&transaction_id=" + "R123" + "&message=Hello" + "&sms=Hello" + "&status=" + "Success";
                //tB_monitor.AppendText("Requested URL : " + request_url + "\r\n");
                ////Thread.Sleep(5000);
                //r_request = WebRequest.Create(request_url);
                //string return_r = API_helper.func_GetResponse(r_request);
                //tB_monitor.AppendText("Request sent successful" + "\r\n");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
Exemplo n.º 2
0
        public void func_fetchData()
        {
            //if ((GlobalVars.g_API_request_flag == true) && (GlobalVars.g_TopupCmd_StepCtr == 0) && (GlobalVars.g_Response_Topup_flag == false) && (GlobalVars.g_QueryCmd_Topup_flag == false))
            //{
            //    if ((GlobalVars.g_FetchRequest_flag == true) && (GlobalVars.g_NextTopup_flag == false))
            //    {
            g_request = WebRequest.Create("http://139.59.18.48/quickload/apis/new_request?userid=opmodem&apikey=20170729190020597c86e4d6bfe2906874467");
            // g_request = WebRequest.Create("https://logicbd.000webhostapp.com/getdata.php");
            string l_resp = API_helper.func_GetResponse(g_request);

            //GlobalVars.g_ussd_log_sw.WriteLine("Response : " + l_resp);
            tB_monitor.AppendText("Response : " + l_resp + "\r\n");
            l_resp = l_resp.Replace("\"", " ").Trim();
            API_helper.func_ProcessAPI(l_resp, 1, "");  // Response string and Mode ie Pending request
                                                        //tB_monitor.AppendText(API_helper.trim_str + "\r\n");
            tB_monitor.AppendText("Topup Number : " + g_Topup_Number + "\r\n");
            tB_monitor.AppendText("Topup Amount : " + g_Topup_Amount + "\r\n");
            tB_monitor.AppendText("Topup Operator : " + g_Topup_Operator + "\r\n");
            //txt_Log.AppendText("Topup Pin : " + GlobalVars.g_QueryCmd_PIN + "\r\n");

            //if ((crnt_port.IsOpen == true) /*&& (GlobalVars.g_Topup_Operator.Contains("Robi") == true)*/)
            //{
            //    if ((GlobalVars.g_Topup_Number.Length >= 10) && (GlobalVars.g_Topup_Amount.Length >= 1))
            //    {
            //        GlobalVars.g_NextTopup_flag = true;
            //        GlobalVars.g_NextTopup_ctr = 0;
            //        GlobalVars.g_QueryCmd_Topup_flag = true;
            //        GlobalVars.g_TopupCmd_StepCtr = 1;
            //        //at + CUSD = 1,"*8383*2*01848236297*10*8094#",15
            //        //at + cusd = 1,"*444*1*01610005003*10*8094* #",15
            //        //GlobalVars.g_serialport.WriteLine("AT+STSF=1\r");
            //        int l_amt = (int)Math.Round(float.Parse(g_Topup_Amount));
            //        string l_topup_str = "AT+CUSD=1,\"*999*" + g_Topup_Number + "*" + l_amt.ToString() + "*" + GlobalVars.g_QueryCmd_PIN + "#\", 15\r";
            //        tB_monitor.AppendText("AT+CUSD=1,\"*999*" + g_Topup_Number + "*" + l_amt.ToString() + "*" + "\r\n");
            //        //GlobalVars.g_ussd_log_sw.WriteLine(l_topup_str);
            //        //GlobalVars.g_serialport.WriteLine("AT + CUSD = 1, \"*222*01727623404*10*8094#\", 15\r");
            //        Thread.Sleep(5000);
            //        tB_monitor.AppendText("Request Sent" + "\r\n");
            //        crnt_port.WriteLine(l_topup_str);
            //    }
            //}
            //}
            //}
        }