public async void AddGameItemToSQL() { string url = "https://api.steampowered.com/IEconDOTA2_570/GetGameItems/v1/?key=6A9C411A88D047DA4C9E843EDF0B02F5&format=json&" + "language=en_us"; var ApiReq = new APIRequest (); var comm = new DBComm (); var temp = (JToken)await ApiReq.FetchJsonAsync (url); var jItems = (JToken)temp.SelectToken ("result.items"); foreach (JToken jItem in jItems) { var item = new Item (); string cdnUrl = "http://cdn.dota2.com/apps/dota2/images/items/"; item.ItemId = (int)jItem.SelectToken ("id"); item.Name = (string)jItem.SelectToken ("name"); item.LocalName = (string)jItem.SelectToken ("localized_name"); string itemName = item.Name; itemName=itemName.Substring(itemName.IndexOf("_")+1); item.ImageUrl = cdnUrl+itemName+"_lg.png"; try { comm.Connect.Insert(item); Console.Out.WriteLine (item.LocalName); } catch (SQLiteException e) { Console.Out.WriteLine (e.Message); } } comm.Connect.Dispose (); }
public async void AddGameHeroToSQl () { string url = "https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v1/?key=6A9C411A88D047DA4C9E843EDF0B02F5&format=json&" + "language=en_us&itemizedonly=0"; var ApiReq = new APIRequest (); var comm = new DBComm (); var temp = (JToken)await ApiReq.FetchJsonAsync (url); var jHeroes = (JToken)temp.SelectToken ("result.heroes"); foreach (JToken jHero in jHeroes) { var hero = new Hero (); string cdnUrl = "http://cdn.dota2.com/apps/dota2/images/heroes/"; hero.HeroId =(int) jHero.SelectToken ("id"); hero.Name = (string)jHero.SelectToken ("name"); hero.LocalName = (string)jHero.SelectToken ("localized_name"); string heroName = hero.Name; heroName = heroName.Substring (14); hero.SHorImgUrl = cdnUrl+heroName+"_sb.png"; hero.LHorImgUrl = cdnUrl+heroName+"_lg.png"; hero.FHorImgUrl = cdnUrl+heroName+"_full.png"; hero.FVerImgUrl = cdnUrl+heroName+"_vert.jpg"; try { comm.Connect.Insert(hero); Console.Out.WriteLine (hero.LocalName); } catch (SQLiteException e) { Console.Out.WriteLine (e.Message); } } }
public Hero GetHeroFromSQL(int id) { DBComm comm = new DBComm (); //using (var conn= new SQLiteConnection var hero = comm.Connect.Table<Hero>().Where (i => i.HeroId == id).ToList(); comm.Connect.Dispose(); return hero [0]; }
public async Task<CSMap> GetMap(int id) { DBComm command = new DBComm ("CSGO"); var temp = command.Connect.Table<CSMap> ().Where (x => x.MapId == id).ToList (); command.Connect.Dispose(); if (temp.Count == 0) { var deck=await AddMap (id); return deck; } return temp [0]; }
public League GetLeagueFromSQL(int leagueId) { if (leagueId == 0) return new League(); DBComm comm = new DBComm (); //using (var conn= new SQLiteConnection var league = comm.Connect.Table<League>().Where (i => i.LeagueId == leagueId).ToList(); //Console.Out.WriteLine ("id: {0}" + " \nName: {1}", team[0].TeamId, team[0].Name); comm.Connect.Dispose(); if (league.Count == 0) return new League (); return league [0]; }
public async Task<League> AddLeague(int id,string gameName) { string url = SettingsDB.ServerAPIAddress+gameName+"/GetLeague?league_id="+id; var ApiReq = new APIRequest (); var comm = new DBComm (); JToken temp = await ApiReq.GetJsonAsync (url); var league = JsonConvert.DeserializeObject<League> (temp.ToString ()); if (temp.ToString () != "") { comm.Connect.Insert (league); comm.Connect.Dispose (); } return league; }
public async Task<League> GetLeague(int leagueId,string gameName) { if (leagueId == 0) return null; DBComm comm = new DBComm (gameName); var league = comm.Connect.Table<League>().Where (i => i.LeagueId == leagueId).ToList(); comm.Connect.Dispose(); if (league.Count == 0) { var temp = await AddLeague (leagueId,gameName); return temp; } return league[0]; }
public async Task<CSMap> AddMap(int id) { string url = SettingsDB.ServerAPIAddress+"CSGO/GetMap?map_id="+id; var ApiReq = new APIRequest (); DBComm command = new DBComm ("CSGO"); JToken temp = await ApiReq.GetJsonAsync (url); var map = JsonConvert.DeserializeObject<CSMap> (temp.ToString ()); if (temp.ToString () != "") { command.Connect.Insert (map); command.Connect.Dispose (); } return map; }
public List<EnemyHero> FindEnemies(List<int> listFriendsHero,List<int> listEnemiesHero) { DBComm Command = new DBComm (); List<EnemyHero> listEnemies = new List<EnemyHero> (); //FriendsHero friends; for (var i = 0; i < listFriendsHero.Count; i++) { var id = listFriendsHero [i]; for (var j = i; j < listEnemiesHero.Count; j++) { var id1 = listEnemiesHero [j]; var temp = Command.Connect.Table<EnemyHero> ().Where (enemy => enemy.HeroId == id && enemy.EnemyHeroId == id1).ToList (); listEnemies.AddRange (temp); } } return listEnemies; }
public async Task<Player> GetPlayerFromSQL(long steamId) { var player = new Player (); DBComm comm = new DBComm (); //using (var conn= new SQLiteConnection //var id = Convert.ToInt32 (teamId); var players = comm.Connect.Table<Player>().Where (i => i.SteamId32 == steamId).ToList(); if (players.Count == 0) { player = await GetPlayerAPI (steamId); //player = comm.Connect.Table<Player>().Where (i => i.SteamId32 == steamId).ToList(); return player; } else { return players [0]; } }
public Item GetItemFromSQL(int id) { Item item1 = new Item(); item1.ImageByte=new byte[256]; if (id == 0) { return item1; } DBComm comm = new DBComm (); var item = comm.Connect.Table<Item>().Where (i => i.ItemId == id).ToList(); comm.Connect.Dispose(); if (item.Count == 0) { return item1; } else { return item [0]; } }
public List<League> GetLastLeague(int unixDtStop) { DBComm comm = new DBComm (); //DateTime dtNow = DateTime.UtcNow; //var dtStop = dtNow.AddDays (-3); //var unixDtStop=(int)(dtStop - new DateTime (1970, 1, 1,0,0,0,System.DateTimeKind.Utc)).TotalSeconds; var leaguePremium = comm.Connect.Table<League> ().Where (i => i.Tier == "premium").ToList(); leaguePremium = leaguePremium.GetRange (leaguePremium.Count-10, 10).ToList (); var listleaguePremium=new List<League>(); foreach (var leag in leaguePremium) { if (leag.StopTime > unixDtStop || leag.StopTime==0) { listleaguePremium.Add (leag); } } var leagueProfessional = comm.Connect.Table<League>().Where (i => i.Tier == "professional").ToList(); var listleagueProfessional = leagueProfessional.GetRange (leagueProfessional.Count-10, 10).ToList (); listleaguePremium.AddRange (listleagueProfessional); return listleaguePremium; }
protected override void OnCreate (Bundle bundle) { //RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate (bundle); Density.GetDensity (this); DBComm comm = new DBComm (true); comm.CopyDatabase (this.ApplicationContext); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); CheckFirstRun (); //pb.Visibility=ViewStates.Visible; ActionBarTitle.SetTitle (this,Resource.Layout.ActionBarLayout,Resources.GetString(Resource.String.app_name),"DOTA 2"); int resId = Resources.GetIdentifier("action_bar_container", "id", "android"); var view = FindViewById<View> (resId); buttonRefresh=view.FindViewById<Button>(Resource.Id.buttonRefreshActionBar); buttonRefresh.Click += ButtonRefreshClick; Button buttonGame = view.FindViewById<Button> (Resource.Id.buttonChangeGame); buttonGame.Click += buttomGameChangeClick; pb=view.FindViewById<ProgressBar> (Resource.Id.progressBar3); //pb.Visibility= ViewStates.Gone; //mActionBar.SetDisplayShowCustomEnabled(true); //You can now use and reference the ActionBar ActionBar.NavigationMode = ActionBarNavigationMode.Tabs; cts = new CancellationTokenSource (); SettingsApp.GameName="DOTA2"; SettingsApp.ResourceId=Resource.Drawable.dota2_icon; fragmentsTab = new Fragment[] { new FragmentTabRecent (cts,this), new FragmentTabLive (cts,this), new FragmentTabUpcoming (cts,this) }; AddTabToActionBar (Resource.String.tabRecent, 0); AddTabToActionBar (Resource.String.tabLive, 0); AddTabToActionBar (Resource.String.tabUpcoming, 0); }
public async Task<Team> AddTeam(int id,string gameName) { string url = SettingsDB.ServerAPIAddress + gameName + "/GetTeam?team_id=" + id; var ApiReq = new APIRequest (); //var PlayerReq = new Player (); var comm = new DBComm (gameName); JToken temp = await ApiReq.GetJsonAsync (url); var team = JsonConvert.DeserializeObject<Team> (temp.ToString ()); if (temp.ToString () != "") { comm.Connect.Insert (team); comm.Connect.Dispose (); } return team; }
public async Task<Team> GetTeam(int teamId,string gameName) { if (teamId == 0) return null; DBComm comm = new DBComm (gameName); var id = Convert.ToInt32 (teamId); var team = comm.Connect.Table<Team>().Where (i => i.TeamId == id).ToList(); comm.Connect.Dispose(); if (team.Count == 0) { //return new Team(); var temp = await AddTeam (id, gameName); return temp; } return team [0]; }
public Team GetGGTeamFromSQL(string teamName, string key) { DBComm command = new DBComm (key); Team team = null; var temp = command.Connect.Table<Team> ().Where (x => x.Name == teamName).ToList (); command.Connect.Dispose(); if (temp.Count == 0) return team; return temp [0]; }
public async Task AddGGTeamToSQL(Match teamInfo,string key) { APIRequest ApiReq = new APIRequest (); DBComm command = new DBComm (key); Team team = new Team (); team.Name= teamInfo.Groups [2].Value; string logoUrl="http://www.gosugamers.net/"+teamInfo.Groups [1].Value; string tag=teamInfo.Groups [2].Value; team.Tag = tag; if (tag.Length > 10) { team.Tag = tag.Substring (0, 10); } team.LogoByte = await ApiReq.FetchByteArrAsync (logoUrl); command.Connect.Insert (team); command.Connect.Dispose(); }
public async Task<Team> GetGGTeamFromSQL(Match teamInfo,string key) { DBComm command = new DBComm (key); string name= teamInfo.Groups [2].Value; var temp = command.Connect.Table<Team> ().Where (x => x.Name == name).ToList (); if (temp.Count == 0) { await AddGGTeamToSQL (teamInfo, key); temp = command.Connect.Table<Team> ().Where (x => x.Name == name).ToList (); } command.Connect.Dispose(); return temp [0]; }
public async Task AddTeamDotaToSQL(int id) { string url = "https://api.steampowered.com/IDOTA2Match_570/GetTeamInfoByTeamID/v1/?key=6A9C411A88D047DA4C9E843EDF0B02F5&" + "format=json&language=en_us&start_at_team_id="+id+"&teams_requested=1"; var ApiReq = new APIRequest (); //var PlayerReq = new Player (); var comm = new DBComm (); JToken temp = await ApiReq.FetchJsonAsync (url); //JObject jt = JObject.Parse (temp); string status = (string)temp.SelectToken("result.status"); JToken teams = (JToken)temp.SelectToken("result.teams"); if ((int)temp.SelectToken("result.teams[0].team_id")==id){ JToken teamJS = teams[0]; var newTeam = new Team (); newTeam.TeamId = (int)teamJS.SelectToken("team_id"); newTeam.Name = (string)teamJS.SelectToken("name"); newTeam.Tag = (string)teamJS.SelectToken("tag"); newTeam.LogoUGCId = (string)teamJS.SelectToken("logo"); newTeam.LogoByte = await GetTeamLogoAPI (newTeam.LogoUGCId); comm.Connect.Insert(newTeam); comm.Connect.Dispose (); /* for(int i=0;i<10;i++) { if ((teamJS.SelectToken("player_" + i + "_account_id"))!=null) { var newPlayer = new Player (); int playerId = (int)teamJS.SelectToken("player_" + i + "_account_id"); newPlayer=await newPlayer.GetPlayerAPI (Convert.ToInt64(playerId), newTeam.TeamId); comm.Connect.Insert (newPlayer); } else { comm.Connect.Dispose (); break; } }*/ System.Console.Out.WriteLine ("ID {0}", newTeam.ID); } }
public void UpdateTeamDotaToSQL(int teamId) { DBComm comm = new DBComm (); }
public async Task<Team> GetTeamDotaFromSQL(JToken teamId) { if (teamId == null) return new Team(); DBComm comm = new DBComm (); //using (var conn= new SQLiteConnection var id = Convert.ToInt32 (teamId); var team = comm.Connect.Table<Team>().Where (i => i.TeamId == id).ToList(); if (team.Count == 0) { await AddTeamDotaToSQL (id); team = comm.Connect.Table<Team>().Where (i => i.TeamId == id).ToList(); } System.Console.Out.WriteLine ("id: {0}" + " \nName: {1}", team[0].TeamId, team[0].Name); comm.Connect.Dispose(); return team [0]; }
public List<FriendHero> FindFriends(List<int> listHeroes) { DBComm Command = new DBComm (); List<FriendHero> listFriends = new List<FriendHero> (); //FriendsHero friends; for (var i = 0; i < listHeroes.Count-1; i++) { var id = listHeroes [i]; for (var j = i+1; j < listHeroes.Count; j++) { var id1 = listHeroes [j]; var temp = Command.Connect.Table<FriendHero> ().Where (friend => friend.HeroId== id && friend.FriendHeroId == id1).ToList (); listFriends.AddRange (temp); } } return listFriends; }
public int QualityPick(List<int> listHeroes) { var quality = 0; DBComm Command = new DBComm (); for (var i = 0; i < listHeroes.Count; i++) { var id = listHeroes [i]; if (id != 0) { var temp = Command.Connect.Table<HeroDescription> ().Where (hero => hero.HeroId == id).ToList (); quality += temp [0].AOE; quality += temp [0].Support; quality += temp [0].ThroughImmunity; quality += temp [0].Ranged; quality += temp [0].Disabler; quality += temp [0].Durable; quality += temp [0].Escape; quality += temp [0].Healer; quality += temp [0].Initiator; quality += temp [0].Nuker; quality += temp [0].Pusher; } } return quality; }
public Team GetOnlyTeamDotaFromSQL(JToken teamId) { if (teamId == null||teamId.ToString()=="") return new Team(); DBComm comm = new DBComm (); //using (var conn= new SQLiteConnection var id = Convert.ToInt32 (teamId); var team = comm.Connect.Table<Team>().Where (i => i.TeamId == id).ToList(); //Console.Out.WriteLine ("id: {0}" + " \nName: {1}", team[0].TeamId, team[0].Name); comm.Connect.Dispose(); return team [0]; }