Exemplo n.º 1
0
        protected void LoadAccountInfo()
        {
            AccountData account = new AccountData("E3FB0351-32DC-4D4D-8902-181DD9666AB2");

            SqlDataReader rdr = account.GetAccountData();

            if (rdr.HasRows)
            {

                Response.Write("<div class='row'>");
                Response.Write("<div class='col-md-2 product-table-hdr'><p class='active'>Product Name</p></div>");
                Response.Write("<div class='col-md-2 product-table-hdr'><p>Start Date</p></div>");
                Response.Write("<div class='col-md-2 product-table-hdr'><p>End Date</p></div>");

                Response.Write("</div>");
                while (rdr.Read())
                {
                    Response.Write("<div class='row'>");
                    Response.Write("<div class='col-md-2 product-table-row'>" + rdr.GetValue(1) + "</div>");
                    Response.Write("<div class='col-md-2 product-table-row'>" + rdr.GetDateTime(2).ToString("d") + "</div>");
                    Response.Write("<div class='col-md-2 product-table-row'>" + rdr.GetDateTime(3).ToString("d") + "</div>");

                }
                Response.Write("</div>");
            }
            else
            {
                Console.WriteLine("No rows found.");
            }
            rdr.Close();
        }
Exemplo n.º 2
0
        public bool Execute(PlayerDetails playerDetails)
        {
            bool                 executed  = false;
            DbAccountsData       account   = null;
            List <CharacterData> charsList = null;

            try
            {
                if (String.IsNullOrWhiteSpace(playerDetails.Login))
                {
                    CommandHandler.Send(new InfoCmdBuilder("You're not logged in!"), playerDetails);
                    throw new Exception("player is not logged in!");
                }

                if (playerDetails.CharId > -1)
                {
                    playerDetails.CharId = -1;
                    _logger.UpdateLog($"Player's char ID set to -1 by executing char list method for TCP client ID [{playerDetails.TcpClientId}]");
                }

                account = _accountData.GetAccountData(playerDetails.Login);
                if (account == null)
                {
                    CommandHandler.Send(new InfoCmdBuilder("An error occured on the server."), playerDetails);
                    throw new Exception("cannot get db account data (NULL)!");
                }

                charsList = _characterInfo.GetCharactersByAccId(account.AccId);

                foreach (CharacterData charData in charsList)
                {
                    //LOBBY CHARACTER DETAILS
                    CommandHandler.Send(new CharLobbyInfoCmdBuilder(false, charData), playerDetails);
                }

                //LIST CONFIRMATION
                CommandHandler.Send(new CharLobbyInfoCmdBuilder(true), playerDetails);

                executed = true;
            }
            catch (Exception exception)
            {
                _logger.UpdateLog($"Account characters getting error for TCP client ID [{playerDetails.TcpClientId}]: {exception.Message}");
            }

            return(executed);
        }
Exemplo n.º 3
0
        public bool Execute(PlayerDetails playerDetails)
        {
            bool                 executed  = false;
            DbAccountsData       account   = null;
            List <CharacterData> charsList = null;
            int charId = -1;

            try
            {
                if (String.IsNullOrWhiteSpace(playerDetails.Login))
                {
                    CommandHandler.Send(new InfoCmdBuilder("You're not logged in!"), playerDetails);
                    throw new Exception("player is not logged in!");
                }

                if (_cmdElements.Length != 2)
                {
                    CommandHandler.Send(new InfoCmdBuilder("Character choosing - wrong command!"), playerDetails);
                    throw new Exception($"wrong command element count [{_cmdElements.Length}]");
                }

                if (String.IsNullOrWhiteSpace(_cmdElements[1]) || !Int32.TryParse(_cmdElements[1], out charId))
                {
                    CommandHandler.Send(new InfoCmdBuilder("Character choosing - wrong ID, must be numeric value!"), playerDetails);
                    throw new Exception($"cannot convert character ID from element [{_cmdElements[1]}]");
                }

                if (charId < 0)
                {
                    CommandHandler.Send(new InfoCmdBuilder("Character choosing - wrong ID, cannot be less than 0!"), playerDetails);
                    throw new Exception($"wrong character ID [{charId}] (less than 0)");
                }

                account = _accountData.GetAccountData(playerDetails.Login);

                if (_playerHandler.GetPlayerCharacterId(account.Login) > -1)
                {
                    CommandHandler.Send(new InfoCmdBuilder("You have already chosen your character (character in use)!"), playerDetails);
                    throw new Exception("other character in use!");
                }

                if (account == null)
                {
                    CommandHandler.Send(new InfoCmdBuilder("An error occured on the server."), playerDetails);
                    throw new Exception("cannot get db account data (NULL)!");
                }

                charsList = _characterInfo.GetCharactersByAccId(account.AccId);

                foreach (CharacterData charData in charsList)
                {
                    if (charData.CharId == charId)
                    {
                        _playerHandler.SetPlayerCharacter(charId, account.Login);
                        _logger.UpdateLog($"Character set to char. ID [{charId}] for player [{account.Login}]");
                        executed = true;
                    }
                }
            }
            catch (Exception exception)
            {
                _logger.UpdateLog($"Character choosing execution error for player with TCP client ID [{playerDetails.TcpClientId}]: {exception.Message}");
            }
            finally
            {
                //CHARACTER CHOOSING RESULT
                CommandHandler.Send(new CharChoosingSuccessCmdBuilder(executed), playerDetails);
            }

            return(executed);
        }