Example #1
0
        private void TimerTask(object StateObj)
        {
            TimerObjClass State = (TimerObjClass)StateObj;

            Interlocked.Increment(ref State.NumberCall);

            StatesClient stateClient = _queueRepository.GetStateClient(State.Queue.Id);

            if (stateClient != StatesClient.Welcom)
            {
                State.TimerReference.Dispose();
            }
            else
            {
                if (State.NumberCall > State.Queue.MaxNumberCall)
                {
                    State.TimerReference.Dispose();

                    _queueRepository.GetOut(State.Queue.Id, StatesClient.GetOut);

                    string connectionIdEmployee = _hub.GetConnectionIdByLogin(State.Queue.Employee.Login);
                    if (!string.IsNullOrEmpty(connectionIdEmployee))
                    {
                        State.Context.Clients.Client(connectionIdEmployee).addMessageEmployee("Клиент не принял приглашение");
                    }
                    ;
                    string connectionIdClient = _hub.GetConnectionIdByLogin(State.Queue.Client.Login);
                    if (!string.IsNullOrEmpty(connectionIdClient))
                    {
                        State.Context.Clients.Client(connectionIdClient).addMessageClient("Вы исключены из очереди");
                        State.Context.Clients.Client(connectionIdClient).changeClass("#BtnAccept", "noVisible");
                    }
                    ;

                    State.Context.Clients.All.removeClientFromQueue(State.Queue.Id);
                }
                else
                {
                    string connectionIdEmployee = _hub.GetConnectionIdByLogin(State.Queue.Employee.Login);
                    if (!string.IsNullOrEmpty(connectionIdEmployee))
                    {
                        State.Context.Clients.Client(connectionIdEmployee).changeNumberCall(State.NumberCall, State.Queue.MaxNumberCall, State.Queue.TimeCall);
                    }
                    ;
                    string connectionIdClient = _hub.GetConnectionIdByLogin(State.Queue.Client.Login);
                    if (!string.IsNullOrEmpty(connectionIdClient))
                    {
                        State.Context.Clients.Client(connectionIdClient).changeNumberCall(State.NumberCall, State.Queue.MaxNumberCall, State.Queue.TimeCall);
                    }
                    ;
                }
            }
        }