コード例 #1
0
        private void LoadUserLicensesFromDatabase(Client player, int userId)
        {
            MySqlCommand getUserDataCommand = TTRPG.Mysql.Conn.CreateCommand();

            getUserDataCommand.CommandText = "SELECT * FROM user_licenses WHERE UserID = @id";
            getUserDataCommand.Parameters.AddWithValue("id", userId);
            DataTable result = new DataTable();

            result.Load(getUserDataCommand.ExecuteReader());

            List <ILicense> userLicenses = new List <ILicense>();

            foreach (DataRow row in result.Rows)
            {
                ILicense license = Licenses.GetLicenseByIdentifier((string)row["LicenseKey"]);
                if (license != null)
                {
                    userLicenses.Add(license);
                }
            }

            player.setData("UserLicenses", userLicenses);
        }