Пример #1
0
        /// <summary>
        /// This listener is called when GSM error occures and activation status is read.
        /// for reactive numbers after error, the start index must be set as equal as last working index +1 (to skipp error number)
        /// </summary>
        /// <param name="packet"></param>
        public void onReadActivate(ActivationPacket packet)
        {
            try
            {
                resetTimer();


                if (packet.WorkingIndex + 1 <= packet.Finish)
                {
                    Logger.Show(string.Format("Re-Active numbers => Last index: {0} , Current Index: {1}", packet.WorkingIndex, packet.WorkingIndex + 1), ConsoleColor.Green);


                    byte[]         byteToSend   = null;
                    AbstractPacket packetToSend = null;

                    packetToSend = new ActivationPacket(sim_number, packet.WorkingIndex + 1, finish);
                    byteToSend   = packetToSend.toRaw();
                    networkManager.Send(byteToSend);
                }
                else
                {
                    finishWorks();
                }
            }
            catch (Exception e)
            {
                Logger.ShowError(e.Message);
            }
        }
Пример #2
0
        public void onGSMSendingError()
        {
            try
            {
                resetTimer();

                Logger.ShowError("Error Occured... try re-active numbers by skipping current number");

                try
                {
                    using (SMSPortalDBEntities db = new SMSPortalDBEntities())
                    {
                    }
                }
                catch { }

                Thread.Sleep(5000);
                AbstractPacket packetToSend = new ActivationPacket(sim_number);
                packetToSend.Cmd = AbstractPacket.READ_CMD;
                byte[] byteToSend = packetToSend.toRaw();
                networkManager.Send(byteToSend);
            }
            catch (Exception e)
            {
                Logger.ShowError(e.Message);
            }
        }
Пример #3
0
        /// <summary>
        /// Itterate on gridview numbers based on registeration answer of modem and register new number
        /// After all numbers are registered, activation of numbers will be done
        /// </summary>
        /// <param name="registeredPacket">Registerd packet (answer of modem)</param>
        public void onWriteNumberRegister(RegisterationPacket registeredPacket)
        {
            try
            {
                resetTimer();

                int            cIndex       = registeredPacket.Index + 1;
                byte[]         byteToSend   = null;
                AbstractPacket packetToSend = null;
                if (cIndex < queueItems.Count)
                {
                    using (SMSPortalDBEntities db = new SMSPortalDBEntities())
                    {
                        Guid qp_id = queueItems[cIndex].queue_phone.TFId;

                        string number = (from x in db.Queue_Phone
                                         where x.TFId == qp_id
                                         select x.Phone.TFNumber).FirstOrDefault();
                        packetToSend = new RegisterationPacket(sim_number, number, cIndex);
                        Logger.Show(packetToSend.ToString(), ConsoleColor.White);
                        byteToSend = packetToSend.toRaw();
                        networkManager.Send(byteToSend);
                    }
                }
                else
                {
                    Logger.Show("All numbers are registered", ConsoleColor.White);

                    packetToSend = new ActivationPacket(sim_number, start, finish);
                    byteToSend   = packetToSend.toRaw();
                    networkManager.Send(byteToSend);
                }
            }

            catch (Exception e)
            {
                Logger.ShowError(e.Message);
            }
        }