コード例 #1
0
ファイル: Connector.cs プロジェクト: eabasir/sms-portal
        public void onMessageTextWrite()
        {
            try
            {
                resetTimer();

                using (SMSPortalDBEntities db = new SMSPortalDBEntities())
                {
                    Guid qp_id = queueItems[0].queue_phone.TFId;

                    string number = (from x in db.Queue_Phone
                                     where x.TFId == qp_id
                                     select x.Phone.TFNumber).FirstOrDefault();

                    AbstractPacket packetToSend = new RegisterationPacket(sim_number, number, 0);
                    Logger.Show(packetToSend.ToString(), ConsoleColor.White);
                    byte[] byteToSend = packetToSend.toRaw();
                    networkManager.Send(byteToSend);
                }
            }
            catch (Exception e)
            {
                Logger.ShowError(e.Message);
            }
        }
コード例 #2
0
ファイル: Connector.cs プロジェクト: eabasir/sms-portal
        /// <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);
            }
        }