Пример #1
0
        private int CheckOperatorModemPorts()
        {
            _operatorModemPorts = ModemPortAllocation.GetOperatorModemPorts();

            foreach (var omp in _operatorModemPorts.ToList())
            {
                SerialPort serialPort = new SerialPort
                {
                    PortName  = omp.ComPort,
                    BaudRate  = 115200,
                    StopBits  = StopBits.One,
                    DataBits  = 8,
                    Parity    = Parity.None,
                    Handshake = Handshake.RequestToSend
                };
                serialPort.DataReceived  += ModemPortDataReceived;
                serialPort.ErrorReceived += ModemErrorReceived;

                try
                {
                    serialPort.Open();
                    var command = Ussdcmd.MobileNumberCommand(omp.OperatorName);

                    serialPort.Write(command);

                    while (serialPort.BytesToRead < 0)
                    {
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            while (_dataReceived != _operatorModemPorts.Count)
            {
            }
            return(1);
        }
Пример #2
0
 public void RechargeMoney(string mobileNumber, double amount, int times)
 {
     Console.WriteLine(Ussdcmd.RechargeCommand(_operatorName, mobileNumber, amount, "1234"));
 }