public GetGeneralResponse <IEnumerable <QueueLocalPhoneStoreView> > GetAllQueueLocalPhones(int pageSize,
                                                                                                   int pageNumber,
                                                                                                   IList <FilterData> filter, IList <Sort> sort)
        {
            GetGeneralResponse <IEnumerable <QueueLocalPhoneStoreView> > response = new GetGeneralResponse <IEnumerable <QueueLocalPhoneStoreView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;

                string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "QueueLocalPhoneStore", sort);
                Response <QueueLocalPhoneStore> queueLocalPhoneStores = _queueLocalPhoneStoreRepository.FindAll(query,
                                                                                                                index, count);

                response.data       = queueLocalPhoneStores.data.ConvertToQueueLocalPhoneViews();
                response.totalCount = queueLocalPhoneStores.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Exemple #2
0
        public GeneralResponse GetQueuesFromAsterisk()
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                var    monitoring = new MonitoringControllerService();
                string Token      = monitoring.login("saman", "102030");

                List <QueueWSDL> queues      = monitoring.getQueue(Token).ToList <QueueWSDL>();
                List <Queue>     savedQueues = _queueRepository.FindAll().ToList <Queue>();

                foreach (var item in queues)
                {
                    foreach (var _item in savedQueues)
                    {
                        if (item.id == _item.AsteriskID)
                        {
                            _item.QueueName = item.name;
                            _queueRepository.Save(_item);
                        }
                    }
                }

                if (queues.Count() > savedQueues.Count())
                {
                    var result = queues.Where(x => savedQueues.All(s => s.AsteriskID != x.id));

                    foreach (var item in result)
                    {
                        var queue = new Queue();
                        queue.AsteriskID = item.id;
                        queue.ID         = Guid.NewGuid();
                        queue.QueueName  = item.name;

                        _queueRepository.Add(queue);
                    }
                }

                if (queues.Count() < savedQueues.Count())
                {
                    IEnumerable <QueueLocalPhoneStore> queueLocalPhone = _queueLocalPhoneRepository.FindAll();

                    var result1 = queueLocalPhone.Where(x => queues.All(s => s.id != x.Queue.AsteriskID));

                    foreach (var item in result1)
                    {
                        _queueLocalPhoneRepository.Remove(item);
                    }
                }

                _uow.Commit();
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }
            return(response);
        }