public async Task <IActionResult> PutQueueModel([FromRoute] int id, [FromBody] QueueModel queueModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != queueModel.Id)
            {
                return(BadRequest());
            }

            _context.Entry(queueModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QueueModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task RemoveTimedoutQueueEntries(int queueId)
        {
            IEnumerable <QueueEntryModel> queueEntries = _context.QueueEntries.Where(entry => entry.QueueId == queueId &&
                                                                                     entry.WasReadyAt != null);

            QueueModel queue = await _context.Queues.FindAsync(queueId);

            foreach (QueueEntryModel entry in queueEntries)
            {
                TimeSpan timeSinceReady = (TimeSpan)(DateTime.Now - entry.WasReadyAt);
                if (timeSinceReady.TotalSeconds > queue.AtTheReadyTimeout)
                {
                    _context.Remove(entry);
                }
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                ExceptionHandler.LogException(ex.StackTrace, ExceptionHandler.ErrorLevel.WARNING, _context);
            }
        }
Esempio n. 3
0
        public JsonResult <short[]> WholeQueue()
        {
            var queueDao = new QueueModel(Context);

            return(Json(Context.GetAll()
                        .Select(o => o.OrderType.Value)
                        .ToArray()));
        }
Esempio n. 4
0
        /// <summary>
        /// Convert task <c>entity</c> into the task model.
        /// </summary>
        /// <param name="entity">The <see cref="QueueEntity"/> instance.</param>
        /// <returns>The <see cref="QueueModel"/> instance.</returns>
        public QueueModel Convert(QueueEntity entity)
        {
            QueueModel model = entity.Id > 0
                ? new QueueModel(entity.Id, entity.Name, entity.Description)
                : new QueueModel(entity.Name, entity.Description);

            return(model);
        }
Esempio n. 5
0
        private async void AddUpdateTask()
        {
            while (true)
            {
                if (ServerQueue.QueueA.Count == 0)
                {
                    await Task.Delay(100);

                    continue;
                }
                var request = ServerQueue.QueueA.Dequeue();
                if (request.Type == ERequestType.CREATE)
                {
                    ClientRequestCreate clientRequest = request as ClientRequestCreate;
                    if (queues.ContainsKey(clientRequest.QueueName))
                    {
                        ServerResponse response = new ServerResponseAS(clientRequest.UserId,
                                                                       EResponseType.Error,
                                                                       "Queue with given name alraedy excits",
                                                                       null);
                        ServerQueue.QueueB.Enqueue(response);
                    }
                    else
                    {
                        QueueModel queueModel = new QueueModel(clientRequest.QueueName);
                        queues.Add(clientRequest.QueueName, queueModel);
                        Task task = new Task(() => QueueTask(queueModel));
                        task.Start();
                        FirstQueue.QueueA.Enqueue(request);
                    }
                }
                else if (request.Type == ERequestType.SUBSCRIBE)
                {
                    ClientRequestSubscribe clientRequest = request as ClientRequestSubscribe;
                    if (queues.ContainsKey(clientRequest.QueueName))
                    {
                        ServerResponse response = new ServerResponseAS(clientRequest.UserId,
                                                                       EResponseType.Ok,
                                                                       "Subscribe succesfull",
                                                                       queues[clientRequest.QueueName]);

                        ServerQueue.QueueB.Enqueue(response);
                    }
                    else
                    {
                        ServerResponse response = new ServerResponseAS(clientRequest.UserId,
                                                                       EResponseType.Error,
                                                                       "Subscribe unsuccesfull",
                                                                       null);
                        ServerQueue.QueueB.Enqueue(response);
                    }
                }
                else
                {
                    throw new Exception("Request type not supported");
                }
            }
        }
Esempio n. 6
0
        public void TestModelForQueues(string queueNames)
        {
            QueueModel queueModel = new QueueModel(queueNames);

            Assert.IsNotNull(queueModel);
            Assert.IsNotNull(queueModel.QueueA);
            Assert.IsNotNull(queueModel.QueueB);
            Assert.AreEqual(queueModel.QueueName, queueNames);
        }
        protected override IndexWriter GetIndex(QueueModel state)
        {
            if (null != _config)
            {
                return(_config.Writer);
            }

            return(null);
        }
Esempio n. 8
0
        /// <summary>
        /// Get queues that available for current server.
        /// </summary>
        /// <returns><c>List</c> of <see cref="QueueModel"/>.</returns>
        public IReadOnlyCollection <QueueModel> GetAvailableQueues()
        {
            QueueModel queueModel = queueDataContext.GetQueueByName(defaultQueueName);
            IReadOnlyCollection <QueueModel> result = new List <QueueModel> {
                queueModel
            };

            return(result);
        }
Esempio n. 9
0
 public async Task Order(string sessionId)
 {
     if (SessionHandler.IsValidSession(sessionId))
     {
         QueueModel myQueue = SessionHandler.GetQueue(sessionId);
         myQueue.OrderQueue();
         await Clients.Group(sessionId).SendAsync("UpdateOrder", myQueue.GetOrderList());
     }
 }
 protected QueueDeclareOk CreateQueueDeclare(IModel channelModel, QueueModel queueModel)
 {
     return(channelModel.QueueDeclare(
                queueModel.QueueName,
                queueModel.Durable,
                queueModel.Exclusive,
                queueModel.AutoDelete,
                queueModel.Arguments));
 }
        public async Task <IActionResult> Create(QueueModel model)
        {
            if (ModelState.IsValid)
            {
                await Helper.CreateQueue(model.QueueName);

                return(RedirectToAction("Index"));
            }
            return(View());
        }
Esempio n. 12
0
        public bool ShowReleationRoom(QueueModel qm, QueueData queueData, IWin32Window owner)
        {
            _isOk      = false;
            _qm        = qm;
            _queueData = queueData;

            this.ShowDialog(owner);

            return(_isOk);
        }
Esempio n. 13
0
        public Server()
        {
            this.queues = new Dictionary <string, QueueModel>();
            ServerQueue = new QueueModel("serverQueue");
            Task addUpdateTask = new Task(() => AddUpdateTask());

            addUpdateTask.Start();
            FirstQueue     = new QueueModel("FirstQueue");
            clientQueueMap = new Dictionary <string, QueueModel>();
        }
Esempio n. 14
0
        public Client()
        {
            this.modelData    = new DataModel();
            this.modelData.Id = this.id + Guid.NewGuid().ToString();
            this.server       = new Server();
            this.queues       = new QueueModel("new");

            automaticReadFromServerQueue = new Task(() => AutomaticReadFromServerQueue());
            automaticReadFromServerQueue.Start();
        }
Esempio n. 15
0
 public async Task AddVote(string sessionId, int itemId)
 {
     if (SessionHandler.IsValidSession(sessionId))
     {
         QueueModel     myQueue = SessionHandler.GetQueue(sessionId);
         QueueItemModel myItem  = myQueue.Queue.Where(item => item.Id == itemId).First();
         myItem.Rating++;
         await Clients.Group(sessionId).SendAsync("SetRating", myItem.Rating, itemId);
     }
 }
        public IActionResult EditQueue(QueueModel Queue)
        {
            if (EmployeeIsAdmin == false)
            {
                return(Redirect("~/Queue/Close"));
            }
            Queue = QueueQuery.UpdateQueue(Queue);

            return(Redirect("~/Queue/Close"));
        }
Esempio n. 17
0
        public bool ShowQueueQuickDesign(QueueModel qm, string departmentId, QueueQuickModuleDesign queueQuickDesign, IWin32Window owner)
        {
            _isOk             = false;
            _departmentId     = departmentId;
            _queueQuickDesign = queueQuickDesign;
            _qm = qm;

            this.ShowDialog(owner);

            return(_isOk);
        }
Esempio n. 18
0
        /// <summary>
        /// 显示入队
        /// </summary>
        /// <param name="applyId"></param>
        /// <param name="patientId"></param>
        /// <param name="owner"></param>
        /// <returns>排队号码</returns>
        public LineUpData ShowIntoQueue(QueueModel qm, IStationInfo stationInfo, string applyId, IWin32Window owner)
        {
            _qm      = qm;
            _applyId = applyId;

            _stationInfo = stationInfo;

            this.ShowDialog(owner);

            return(_linuupData);
        }
Esempio n. 19
0
        /// <summary>
        /// Convert task <c>model</c> into the task entity.
        /// </summary>
        /// <param name="model">The <see cref="QueueModel"/> instance.</param>
        /// <returns>The <see cref="QueueEntity"/> instance.</returns>
        public QueueEntity Convert(QueueModel model)
        {
            QueueEntity entity = new QueueEntity
            {
                Id          = model.Id,
                Name        = model.Name,
                Description = model.Description
            };

            return(entity);
        }
Esempio n. 20
0
        public QueueView()
        {
            InitializeComponent();

            _mediaPlayerService = Container.ContainerInstance.Resolve <IMediaPlayerService>();
            _queueService       = ((MainPage)Application.Current.MainPage).QueueService;

            BindingContext = ViewModel = new QueueModel();

            InitQueue();
        }
Esempio n. 21
0
 public void Run()
 {
     for (int i = 0; i < 2; i++)
     {
         QueueModel m   = new QueueModel();
         Random     ran = new Random();
         m.id = ran.Next(0, 10001);
         m.p1 = Guid.NewGuid().ToString("N");
         QueueServicePool.Instacne.AddTask(m);
     }
 }
Esempio n. 22
0
        public bool ShowInsertQueue(QueueModel qm, LineUpData lineupInfo, IWin32Window owner)
        {
            _isOk = false;

            _qm         = qm;
            _lineupInfo = lineupInfo;

            this.ShowDialog(owner);

            return(_isOk);
        }
Esempio n. 23
0
        public RepositoryComponent()
        {
            dataBase         = new UserDB("UsersDataBase");
            RepositoryQueues = new QueueModel("repositoryQueues");

            repositoryQueues = new QueueModel("repositoryQueues");

            Task serverRequestTask = new Task(() => AutomaticReadServerRequest());

            serverRequestTask.Start();
        }
        public async Task <IActionResult> PostQueueModel([FromBody] QueueModel queueModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Queues.Add(queueModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetQueueModel", new { id = queueModel.Id }, queueModel));
        }
        public bool ShowQueueCallDesign(QueueModel queueModel, string departmentId, QueueHintModuleDesign queueCallDesign, IWin32Window owner)
        {
            _isOk = false;

            _departmentId    = departmentId;
            _qm              = queueModel;
            _queueCallDesign = queueCallDesign;

            this.ShowDialog(owner);

            return(_isOk);
        }
        public IActionResult AddQueue(QueueModel Queue)
        {
            if (EmployeeIsAdmin == false)
            {
                return(Redirect("~/Queue/Close"));
            }
            ViewData["Message"] = "Please enter the Queue information.";

            Queue = QueueQuery.CreateQueue(Queue);

            return(Redirect("~/Queue/Close"));
        }
Esempio n. 27
0
        public void QueueConverterModelToEntityTest()
        {
            QueueModel model = new QueueModel(23, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());

            IQueueConverter converter = new QueueConverter(LoggerFactory);

            QueueEntity actual = converter.Convert(model);

            Assert.AreEqual(model.Id, actual.Id);
            Assert.AreEqual(model.Name, actual.Name);
            Assert.AreEqual(model.Description, actual.Description);
        }
Esempio n. 28
0
        /// <summary>
        /// 更新索引库操作
        /// </summary>
        private void IndexDoWork()
        {
            //处理中
            queueInProcessing = true;

            while (indexQueue.Count > 0)
            {
                QueueModel model = indexQueue.Dequeue();

                if (null == model)
                {
                    continue;
                }

                var data = model.Data;

                if (model.ActionMode != ActionMode.Delete && data == null)
                {
                    continue;
                }

                //当前IndexWriter
                var writer = GetIndex(model);

                if (null == writer)
                {
                    continue;
                }

                switch (model.ActionMode)
                {
                case ActionMode.Delete:
                    DeleteIndex(writer, model.ID);
                    break;

                case ActionMode.Insert:
                    AddIndex(writer, data);
                    break;

                case ActionMode.Modify:
                    ModifyIndex(writer, data);
                    break;
                }
            }

            //优化并提交
            Commit();

            //释放资源
            Dispose();

            queueInProcessing = false;
        }
        public IActionResult Start(int id)
        {
            ViewData["Message"] = "Please enter the Queue information.";
            QueueModel Queue = new QueueModel
            {
                QueueId   = id,
                Employees = EmployeeQuery.GetEmployees(),
                Tasks     = TaskQuery.GetTasks()
            };


            return(PartialView("_Start", Queue));
        }
Esempio n. 30
0
 private static IModel DeclareRabbitQueue(IModel channel, QueueModel queueModel)
 {
     Console.WriteLine("Creating the Queue...");
     channel.QueueDeclare
     (
         queue: queueModel.Name,
         durable: queueModel.Durable,
         exclusive: queueModel.Exclusive,
         autoDelete: queueModel.AutoDelete,
         arguments: queueModel.Arguments
     );
     Console.WriteLine("Queue created!");
     return(channel);
 }