public ActionResult WindowSaveClick(JoinModel mo, string PanelID, string ParentVariable)
        {
            GetParentVariable(ParentVariable);
            string keyWord = ParentVar.KeyWords;

            if (ParentVar.KeyWords.Contains(CosValue.SPLITOPERATOR2))
            {
                keyWord = ParentVar.KeyWords.Split(CosValue.SPLITOPERATOR2)[1];
            }
            OriginTableManage man = new OriginTableManage();

            man.JoinRecords(mo, keyWord);
            SetHiddenValue(PanelID + "_ExitCode", "1");
            return(this.Direct());
        }
Ejemplo n.º 2
0
        public ActionResult Join(JoinModel model)
        {
            var theGame = Game.GetGame(model.GameId);

            if (model.Name == null)
            {
                throw new Exception("Tried to join with null name?");
            }
            var existing = theGame.Players.Where(p => p.Name == model.Name).FirstOrDefault();

            if (existing != null)
            {
                return(View("Interface", new StartGameModel()
                {
                    PlayerId = existing.Id,
                    GameId = model.GameId,
                    DebugAllowed = theGame.DebugAllowed
                }));
            }

            if (theGame.HasStarted)
            {
                return(Content("Game has already started"));
            }
            var player = new Player()
            {
                Game     = theGame,
                Bites    = 0,
                Name     = model.Name,
                Strategy = StrategyEnum.Human,
                Id       = Guid.NewGuid().ToString()
            };

            player.AI = new AI()
            {
                Me = player
            };
            theGame.Players.Add(player);

            player.SetColour();
            return(View("Interface", new StartGameModel()
            {
                PlayerId = player.Id,
                GameId = model.GameId,
                DebugAllowed = theGame.DebugAllowed
            }));
        }
Ejemplo n.º 3
0
        public async Task <IEnumerable <Player> > JoinGame(JoinModel model)
        {
            var nameTaken = await _gameService.IsNameTaken(model.Player.Name, model.GameCode);

            if (nameTaken)
            {
                Clients.Client(Context.ConnectionId).ErrorMessage("Name already taken");
                return(null);
            }
            await _gameService.AddPlayer(model.Player, Context.ConnectionId, model.GameCode);

            await Groups.Add(Context.ConnectionId, model.GameCode);

            PlayerJoined(model.GameCode, model.Player);

            // return playernames for group
            return(await _gameService.GetPlayersByCode(model.GameCode));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> Join(JoinModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var response = await client.GetMeetingInfoAsync(new GetMeetingInfoRequest
            {
                meetingID = model.Id
            });

            if (response.returncode == Returncode.FAILED)
            {
                ModelState.AddModelError("", "The meeting is not running.");
                return(View(model));
            }
            if (response.running == false)
            {
                if (response.hasUserJoined == true)
                {
                    ModelState.AddModelError("", "The meeting is ended.");
                }
                else
                {
                    ModelState.AddModelError("", "The meeting is not started.");
                }

                return(View(model));
            }
            var url = client.GetJoinMeetingUrl(new JoinMeetingRequest
            {
                meetingID = model.Id,
                fullName  = model.Name,
                password  = response.attendeePW
            });

            return(Redirect(url));
        }
Ejemplo n.º 5
0
        private async Task JoinClientAsync(JoinModel model)
        {
            try
            {
                Guid userGuid = await JoinUserAsync(model, nameof(Client));

                Client client = new Client
                {
                    Age        = model.Age,
                    UserIp     = _contextAcessor.HttpContext.Connection.RemoteIpAddress.ToString(),
                    UserUserId = userGuid
                };

                _db.Clients.Add(client);


                await _db.SaveChangesAsync();

                _logger.LogInformation($"Client email {client.User.Email} has been joined");
            }catch (DbUpdateException e)
            {
                _logger.LogError(e.HResult, (Exception)e, e.Message);
            }
        }
Ejemplo n.º 6
0
        private async Task <Guid> JoinUserAsync(JoinModel model, string type)
        {
            var localHash    = _cryptoProvider.GetRandomSaltString();
            var passwordHash = _cryptoProvider.GetPasswordHash(model.PasswordString, localHash);

            User user = new User
            {
                UserId       = Guid.NewGuid(),
                Email        = model.Email,
                Phone        = model.Phone,
                LocalHash    = localHash,
                PasswordHash = passwordHash,
                LastName     = model.LastName,
                FirstName    = model.FirstName,
                Role         = _db.Roles.FirstOrDefault(x => x.Name == type.ToUpper())
            };

            var tt = user;

            _db.Users.Add(user);
            await _db.SaveChangesAsync();

            return(user.UserId);
        }
Ejemplo n.º 7
0
 public JoinViewModel()
 {
     model         = new JoinModel();
     joinCommand   = new RelayCommand(joinExecuteMethod);
     returnCommand = new RelayCommand(returnExecuteMethod);
 }
Ejemplo n.º 8
0
 public async Task UpdatePlayer(JoinModel model)
 {
     await LevelChanged(model.GameCode, model.Player);
 }
Ejemplo n.º 9
0
        public async Task Join(JoinModel model)
        {
            var userId = Context.User.GetUserId();
            var user   = await _db.Users.FindAsync(userId);

            var channel = await _db.Channels.Include(i => i.Owner)
                          .Include(i => i.Users)
                          .ThenInclude(i => i.User)
                          .FirstOrDefaultAsync(i => i.Id == model.ChannelId);

            var userEngage = await _db.ChannelUsers.FirstOrDefaultAsync(i => i.ChannelId.Equals(model.ChannelId) && i.UserId.Equals(userId));

            if (user != null && channel != null)
            {
                if (!userId.Equals(channel.OwnerId))
                {
                    if (userEngage != null)
                    {
                        if (userEngage.State == (int)UserStates.Blocked)
                        {
                            await Clients.Client(Context.ConnectionId).InvokeAsync("Disconnect");

                            return;
                        }
                    }
                    else
                    {
                        await Clients.Client(Context.ConnectionId).InvokeAsync("Disconnect");
                    }
                }

                // online users
                var users = (await _tracker.All(model.ChannelId.ToString())).ToList();

                if (users.Any(i => i.UserId.Equals(userId)))
                {
                    await Clients.Client(Context.ConnectionId).InvokeAsync("AlreadyConnnected");

                    return;
                }

                await Groups.AddAsync(Context.ConnectionId, model.ChannelId.ToString());

                var userDetail = new UserDetail(Context.ConnectionId, user.UserName, model.ChannelId.ToString(), userId,
                                                channel.OwnerId == userId ? (int)UserStates.Authorize : userEngage.State);

                users.Add(userDetail);
                _tracker.Add(Context.Connection, userDetail);
                #region User List
                // load user list
                var engagedUsers = channel.Users
                                   .Where(i => i.ChannelId.Equals(model.ChannelId))
                                   .Select(i => new UserDetail(string.Empty,
                                                               i.User.UserName,
                                                               model.ChannelId.ToString(),
                                                               i.UserId,
                                                               i.State)
                                           )
                                   .ToList();

                // add the owner
                engagedUsers.Add(new UserDetail(string.Empty, channel.Owner.UserName, model.ChannelId.ToString(),
                                                channel.OwnerId,
                                                (int)UserStates.Authorize));


                // if users online take the connection ids
                foreach (var item in users)
                {
                    var temp = engagedUsers.FirstOrDefault(i => i.UserId.Equals(item.UserId));
                    if (temp != null)
                    {
                        temp.ConnectionId = item.ConnectionId;
                    }
                }

                // send user
                await Clients.Client(Context.ConnectionId).InvokeAsync("UserList", engagedUsers);

                #endregion
                // broadcast the user join
                await Clients.Group(model.ChannelId.ToString()).InvokeAsync("UserJoined", userDetail);


                #region Load messages
                var currentUser = await _tracker.Find(Context.ConnectionId);

                var messages = _redis_db.ListRange(userDetail.GroupId.ToString(), 0, -1);
                foreach (var message in messages)
                {
                    TextModel text = JsonConvert.DeserializeObject <TextModel>(message);

                    await Clients.Client(Context.ConnectionId).InvokeAsync("Receive", text);
                }
                #endregion
            }
        }
Ejemplo n.º 10
0
        public IActionResult RoomJoin(JoinModel Joined)
        {
            // Joining to ScrumPoker room
            if (ModelState.IsValid)
            {
                int _nullablepassword;
                try
                {
                    using (var _context = new PokerPlanningContext())
                    {
                        _nullablepassword = PasswordEncrypt.GetPassword(Joined.Password);
                        var Room = _context.PokerRooms.Where(m => m.Id == Joined.RoomId).SingleOrDefault();

                        if (Equals(Room.Password, _nullablepassword))//Проверка пароля, регистр важен
                        {
                            var NewPlayer = new Player()
                            {
                                Name        = Joined.Name,
                                Role        = 1,
                                PokerRoomId = Joined.RoomId.Value,
                                IsOnline    = false
                            };

                            var Checker = _context.Players
                                          .Where(m => m.PokerRoomId == NewPlayer.PokerRoomId &&
                                                 string.Compare(NewPlayer.Name, m.Name, true) == 0).ToList().Count;

                            if (Checker == 0)//Создать нового пользователя
                            {
                                _context.Players.Add(NewPlayer);
                                _context.SaveChanges();
                                return(RedirectToAction("RoomDiscussion", "ScrumRoom", new { PokerRoomId = Room.Id, PlayerId = NewPlayer.Id, password = _nullablepassword }));//переход в комнату
                            }
                            else //Такой пользователь уже есть, зайти под ним
                            {
                                var player = _context.Players.Where(p => p.PokerRoomId == Joined.RoomId && p.Name == NewPlayer.Name).SingleOrDefault();
                                if (player.Role == 2)
                                {
                                    return(RedirectToAction("RoomEntrance", "ScrumRoom", new { PokerRoomId = Room.Id, PlayerId = player.Id, password = _nullablepassword }));//переход в комнату
                                }
                                else
                                {
                                    return(RedirectToAction("RoomDiscussion", "ScrumRoom", new { PokerRoomId = Room.Id, PlayerId = player.Id, password = _nullablepassword }));
                                }
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("Password", "Неверный пароль");
                            return(View(Joined));
                        }
                    }
                }
                catch (NullReferenceException)
                {
                    ModelState.AddModelError("RoomId", "Неверный ID Комнаты");
                    return(View(Joined));
                }
            }
            else
            {
                return(View(Joined));
            }
        }
Ejemplo n.º 11
0
 public IActionResult Index(CreateModel Create, JoinModel Join)
 {
     return(View((Create, Join)));
 }
Ejemplo n.º 12
0
 public Task JoinClient(JoinModel model)
 {
     return(Task.Run(() => JoinClientAsync(model)));
 }
Ejemplo n.º 13
0
        private async Task <bool> canJoinAsync(JoinModel model)
        {
            var user = await _db.Users.FirstOrDefaultAsync(x => x.Email == model.Email || x.Phone == model.Phone);

            return(user == null);
        }
Ejemplo n.º 14
0
 public Task <bool> canJoin(JoinModel model)
 {
     return(Task.Run(() => canJoinAsync(model)));
 }