public static List <AdgvRow> GetPlayerOrderbookAdgvRows(List <AdgvColumn> cols, world world) { string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + Utilities.smcSqlite; List <AdgvRow> rows = new List <AdgvRow>(); int shortcircuit = 0; // stop if the player doesn't exist List <int> existing_players = Utilities.GetAllPlayerIds(); using (var connection = new SqliteConnection("Data Source=" + folder)) { connection.Open(); var command = connection.CreateCommand(); command.CommandText = @"select s.order_id, s.is_ask, s.share_id, s.name, s.num, s.price, p.player_id, p.club_id, p.wages, p.fitness, p.morale, p.injured, p.injury_id, p.form, p.rating, p.banned, p.cup_tied, p.yellow_cards, p.red_cards, p.dob, p.foot, p.value, p.height, p.weight, p.country_id, p.agent_name, p.position from share_orders as s, players as p where share_type = ""player"" and s.share_id = p.player_id order by s.is_ask desc, p.rating desc, s.share_id, s.price desc, s.num, s.name, s.share_type" ; //0 order_id //1 is_ask //2 share_id //3 name //4 num //5 price //6 player_id //7 club_id //8 wages //9 fitness //10 morale //11 injured //12 injury_id //13 form //14 rating //15 banned //16 cup_tied //17 yellow_cards //18 red_cards //19 dob //20 foot //21 value //22 height //23 weight //24 country_id //25 agent_name //26 position int order_id = 0; string is_ask = string.Empty; int share_id = 0; string name = string.Empty; int num = 0; int price = 0; int player_id = 0; int club_id = 0; int wages = 0; //************ int fitness = 0; string morale = string.Empty; int injured = 0; int injury_id = 0; string form = string.Empty; int rating = 0; int banned = 0; int cup_tied = 0; int yellow_cards = 0; int red_cards = 0; DateTime dob = DateTime.Now; string foot = string.Empty; int value = 0;//************ int height = 0; int weight = 0; string country_id = string.Empty; string agent_name = string.Empty; string position = string.Empty; decimal value_wages = 0; using (var reader = command.ExecuteReader()) { while (reader.Read()) { order_id = reader.GetInt32(0); is_ask = reader.GetInt32(1) == 1 ? "ask" : "bid"; share_id = reader.GetInt32(2); name = reader.GetString(3); num = reader.GetInt32(4); price = reader.GetInt32(5); player_id = reader.GetInt32(6); // Stop if player doesn't exist if (!existing_players.Contains(player_id)) { continue; } club_id = reader.GetInt32(7); wages = reader.GetInt32(8); fitness = reader.GetInt32(9); morale = Utilities.MoraleString(reader.GetInt32(10)); injured = reader.GetInt32(11); injury_id = reader.GetInt32(12); form = reader.GetString(13); rating = reader.GetInt32(14); banned = reader.GetInt32(15); cup_tied = reader.GetInt32(16); yellow_cards = reader.GetInt32(17); red_cards = reader.GetInt32(18); dob = Utilities.UnixTimeStampToDateTime(reader.GetInt32(19)); foot = Utilities.FootString(reader.GetInt32(20)); value = reader.GetInt32(21) * 1000; height = reader.GetInt32(22); weight = reader.GetInt32(23); country_id = reader.GetString(24); agent_name = reader.IsDBNull(25) ? string.Empty : reader.GetString(25); position = Utilities.PositionString(reader.GetInt32(26)); value_wages = decimal.Round((decimal)value / (decimal)wages, 2); string player_name = Utilities.GetPlayerNameFromId(player_id, world); string club_name = Utilities.GetClubNameFromId(club_id, world); List <object> list = new List <object>(); list.Add(order_id); list.Add(is_ask); list.Add(share_id); list.Add(name); list.Add(num); list.Add(price); list.Add(player_id); list.Add(player_name); list.Add(club_id); list.Add(club_name); list.Add(position); list.Add(wages); list.Add(value); // add in ((float)(value * 1000) / (float)wages).ToString("0.0") list.Add(value_wages); list.Add(fitness); list.Add(morale); list.Add(injured); list.Add(injury_id); list.Add(form); list.Add(rating); list.Add(banned); list.Add(cup_tied); list.Add(yellow_cards); list.Add(red_cards); list.Add(dob); list.Add(foot); list.Add(height); list.Add(weight); list.Add(country_id); list.Add(agent_name); AdgvRow row = new AdgvRow(cols, list); rows.Add(row); //shortcircuit++; //if (shortcircuit >= 100) // break; } } } return(rows); }
public static List <AdgvRow> GetClubOrderbookAdgvRows(List <AdgvColumn> cols, world world) { string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + Utilities.smcSqlite; List <AdgvRow> rows = new List <AdgvRow>(); //Stop if club doesn't exist // List<int> existing_clubs = Utilities.Get #region get rows using (var connection = new SqliteConnection("Data Source=" + folder)) { connection.Open(); var command = connection.CreateCommand(); command.CommandText = @"select so.order_id, so.is_ask, so.share_type, so.share_id, so.name, so.num, so.price, (so.price * so.num) as total, c.club_id, c.balance, c.form, c.fans_start, c.fans_current, c.stadium_size_start, c.stadium_size_current, c.stadium_id, c.manager_name, c.chairman_name, c.home_colour, c.away_colour, c.value, c.default_formation, c.rating, c.country_id, -- c.committed_tactics, c.game_world_id, c.proposed_manager from share_orders as so, clubs as c where share_type = ""club"" and c.club_id = so.share_id -- and c.club_id = 45 order by so.price desc, c.value desc, c.club_id asc --c.committed_tactics, "; //0 order_id //1 is_ask //2 share_type //3 share_id //4 name //5 num //6 price //7 total //8 club_id //9 balance //10 form //11 fans_start //12 fans_current //13 stadium_size_start //14 stadium_size_current //15 stadium_id //16 manager_name //17 chairman_name //18 home_colour //19 away_colour //20 value //21 default_formation //22 rating //23 country_id //24 committed_tactics -- commented out... //24 game_world_id //25 proposed_manager int order_id = 0; string is_ask = "???"; string share_type = string.Empty; int share_id = 0; string name = string.Empty; int num = 0; int price = 0; int total = 0; int club_id = 0; int balance = 0; string form = string.Empty; int fans_start = 0; int fans_current = 0; int stadium_size_start = 0; int stadium_size_current = 0; int stadium_id = 0; string manager_name = string.Empty; string chairman_name = string.Empty; string home_colour = string.Empty; string away_colour = string.Empty; int value = 0; int default_formation = 0; int rating = 0; string country_id = string.Empty; //Byte[] committed_tactics; int game_world_id = 0; string proposed_manager = string.Empty; using (var reader = command.ExecuteReader()) { while (reader.Read()) { order_id = reader.GetInt32(0); is_ask = reader.GetInt32(1) == 1 ? "ask" : "bid"; share_id = reader.GetInt32(3); name = reader.GetString(4); num = reader.GetInt32(5); price = reader.GetInt32(6); total = reader.GetInt32(7); club_id = reader.GetInt32(8); // Stop if club doesn't exist //if (!existing_clubs.Contains(player_id)) // Still need to create method for this // continue; balance = reader.GetInt32(9); form = reader.GetString(10); fans_start = reader.GetInt32(11); fans_current = reader.GetInt32(12); stadium_size_start = reader.GetInt32(13); stadium_size_current = reader.GetInt32(14); stadium_id = reader.GetInt32(15); manager_name = reader.IsDBNull(16) ? string.Empty : reader.GetString(16); chairman_name = reader.IsDBNull(17) ? string.Empty : reader.GetString(17); home_colour = reader.GetString(18); away_colour = reader.GetString(19); value = reader.GetInt32(20); default_formation = reader.IsDBNull(21) ? -1 : reader.GetInt32(21); rating = reader.GetInt32(22); country_id = reader.GetString(23); // committed_tactics = reader.GetBytes .GetString(24); game_world_id = reader.GetInt32(24); proposed_manager = reader.IsDBNull(25) ? string.Empty : reader.GetString(25); string club_name = Utilities.GetClubNameFromId(club_id, world); List <object> list = new List <object>(); list.Add(order_id); list.Add(is_ask); //list.Add(share_type); list.Add(share_id); list.Add(club_name); list.Add(name); list.Add(num); list.Add(price); list.Add(total); //list.Add(club_id); //list.Add(club_name); list.Add(balance); list.Add(form); list.Add(fans_start); list.Add(fans_current); list.Add(stadium_size_start); list.Add(stadium_size_current); list.Add(stadium_id); list.Add(manager_name); list.Add(chairman_name); list.Add(home_colour); list.Add(away_colour); list.Add(value); list.Add(default_formation); list.Add(rating); list.Add(country_id); // list.Add(committed_tactics); list.Add(game_world_id); list.Add(proposed_manager); AdgvRow row = new AdgvRow(cols, list); rows.Add(row); //shortcircuit++; //if (shortcircuit >= 100) // break; } } } #endregion return(rows); }