Beispiel #1
0
        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);
            }
        }
Beispiel #2
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);
            }
        }
Beispiel #3
0
        public void onAutoId(RegisterationPacket packet)
        {
            try
            {
                using (SMSPortalDBEntities db = new SMSPortalDBEntities())
                {
                    var qp = (from x in db.Queue_Phone
                              where x.Phone.TFNumber == packet.Number && x.TFQueue_Id == queueId
                              select x).FirstOrDefault();
                    // if queue or queue phone is deleted by user during send process 'q' can be null.
                    // So, it must be checked wheter the value of q is null or not.
                    if (qp != null)
                    {
                        var sendBox = (from x in db.SendBoxes where x.TFQueue_Id == queueId select x).FirstOrDefault();


                        db.SendBox_Phone.Add(new SendBox_Phone
                        {
                            TFId             = Guid.NewGuid(),
                            TFPhone_Id       = qp.TFPhone_Id,
                            TFSendBox_Id     = sendBox.TFId,
                            TFSim_Id         = simId,
                            TFGSM_Id         = packet.Id,
                            TFDateTimeSend   = DateTime.Now,
                            TFDateTimeSendFA = SMSPortalCross.Utils.Date.CompleteGregorianToPersian(DateTime.Now),
                            TFIsDelivered    = false
                        });

                        db.SaveChanges();

                        int scheduleType = (from x in db.Queues where x.TFId == queueId select x.TFScheduleType).FirstOrDefault();

                        if (Enums.isOnceType(scheduleType))
                        {
                            db.Queue_Phone.Remove(qp);

                            Logger.Show(string.Format("Queue_Phone with QP_Id: {0} has been removed", qp.TFId), ConsoleColor.Yellow);
                        }
                        else
                        {
                            qp.TFActive        = false;
                            db.Entry(qp).State = EntityState.Modified;
                            Logger.Show(string.Format("Queue_Phone with QP_Id: {0} has been deactived", qp.TFId), ConsoleColor.Yellow);
                        }


                        var _qp = queueItems.FirstOrDefault(x => x.queue_phone.TFId == qp.TFId);

                        if (_qp != null)
                        {
                            queueItems.Remove(_qp);
                        }
                        else
                        {
                            Logger.ShowError(string.Format("Invalid Queue_Phone Id: {0}", qp.TFId));
                            Logger.Log(Messages.CONNECTOR_ON_SEND, new Exception("Invalid Queue_Phone Id"));
                        }
                    }
                    db.SaveChanges();

                    if (queueItems.Count != 0)
                    {
                        resetTimer();
                    }
                    else
                    {
                        finishWorks();
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Log(Messages.CONNECTOR_ON_SEND, e);
                resetTimer();
            }
        }
Beispiel #4
0
 public void onReadNumberRegister(RegisterationPacket packet)
 {
 }