private void ValidateSessionsAsync()
        {
            ThreadPool.QueueUserWorkItem(async(object o) =>
            {
                ITerminalServicesManager manager = new TerminalServicesManager();
                using (ITerminalServer server = manager.GetLocalServer())
                {
                    server.Open();

                    var localSessions = server.GetSessions().Where(s => s.SessionId > 0 && (s.ConnectionState == Cassia.ConnectionState.Active));
                    var messages      = await _msgReader.GetAllMessages();

                    if (messages.Count(m => m.Command.Type == WinGuard.Domain.Enumaretions.ClientCommandType.LOGOUT) > 0 &&
                        localSessions.Any(s => messages.Any(m => m.Command.ClientIdentifier == s.SessionId.ToString())))
                    {
                        foreach (var session in localSessions.Where(s => messages.Any(m => m.Command.ClientIdentifier == s.SessionId.ToString())))
                        {
                            session.Logoff();
                        }
                        return;
                    }
                    foreach (ITerminalServicesSession session in localSessions)
                    {
                        await _authService.Login(_encryptService.EncryptMessage(session.SessionId.ToString()),
                                                 _encryptService.EncryptMessage(session.UserName));
                    }
                }
            });
        }
        public async Task <bool> Login(string clientId, string userName)
        {
            await _service.Login(_encryptService.DecryptMessage(clientId),
                                 _encryptService.DecryptMessage(userName));

            return(true);
        }