Exemplo n.º 1
0
        public void PushBySchedule(User user, Guid _sendBoxId)
        {
            try
            {
                using (SMSPortalDBEntities db = new SMSPortalDBEntities())
                {
                    SendBox sendBox = (from x in db.SendBoxes where x.TFId == _sendBoxId select x).FirstOrDefault();
                    Queue   queue   = (from x in db.Queues where x.TFId == sendBox.TFQueue_Id select x).FirstOrDefault();

                    var lstQP = (from x in db.Queue_Phone where x.TFQueue_Id == queue.TFId && x.TFActive == false select x).ToList();

                    foreach (var q in lstQP)
                    {
                        q.TFActive = true;

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

                        if (Enums.isOnceType(scheduleType))
                        {
                            try
                            {
                                SMSPortalCross.Utils.Scheduler scheduler = new SMSPortalCross.Utils.Scheduler();
                                scheduler.removeSchedule(queue.TFId);
                            }
                            catch (Exception e)
                            {
                                Logger.Log(Messages.GSM_HANDLER_PUSH_BY_SCHEDULE, e);
                            }
                        }
                    }

                    db.SaveChanges();
                }
            }


            catch (Exception e)
            {
                Logger.Log(Messages.GSM_HANDLER_PUSH_BY_SCHEDULE, e);
            }
        }
Exemplo n.º 2
0
        public void AddQueuePhone(User _user, Queue _queue, SendBox _sendBox, List <Phone> lstPhone, Enums.Schedule _scheduleType, DateTime _dtSend)
        {
            try
            {
                using (SMSPortalDBEntities db = new SMSPortalDBEntities())
                {
                    db.Configuration.AutoDetectChangesEnabled = false;

                    string message = (from x in db.Messages where x.TFId == _queue.TFMessage_Id select x.TFContent).FirstOrDefault();
                    foreach (Phone phone in lstPhone)
                    {
                        Guid        qp_Id = Guid.NewGuid();
                        Queue_Phone qp    = new Queue_Phone()
                        {
                            TFId             = qp_Id,
                            TFPhone_Id       = phone.TFId,
                            TFQueue_Id       = _queue.TFId,
                            TFIsUnderProcess = false,
                            TFActive         = Enums.getDefultActiveState((int)_scheduleType),
                            TFEnable         = true,
                            TFError          = false
                        };
                        db.Queue_Phone.Add(qp);
                    }

                    db.SaveChanges();


                    if (_scheduleType != Enums.Schedule.None)
                    {
                        SMSPortalCross.Utils.Scheduler scheduler = new SMSPortalCross.Utils.Scheduler();
                        scheduler.makeNewSchedule(_queue.TFId, _user.TFId, _sendBox.TFId, Global.File_Scheduler, _scheduleType, _dtSend);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Log(Messages.GSM_HANDLER_ADD_QUEUE_PHONE, e);
            }
        }