Exemple #1
0
		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 ();
		}
Exemple #2
0
		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);
				}
			}

		}
Exemple #3
0
		public async Task<Player> GetPlayerAPI(long steamId)
		{
			long id64 = ConvertSteamId32To64 (steamId);
			string url = 
				"https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=6A9C411A88D047DA4C9E843EDF0B02F5&format=json&" +
				"language=en_us&"+"steamids="+id64;
			APIRequest ApiReq = new APIRequest ();
			JToken temp = await ApiReq.FetchJsonAsync (url);
			JToken playerJS = (JToken)temp.SelectToken("response.players[0]");
			var newPlayer = new Player ();
			newPlayer.SteamId32 = steamId;
			newPlayer.SteamId64 = id64;
			newPlayer.Name = (string)playerJS.SelectToken("personaname");
			newPlayer.ProfileUrl = (string)playerJS.SelectToken("profileurl");
			newPlayer.Avatar = (string) playerJS.SelectToken("avatarmedium");
			//newPlayer.TeamID = teamID;

			System.Console.Out.WriteLine (newPlayer.SteamId64);
			return newPlayer;
		}
Exemple #4
0
		public async Task<byte[]> GetTeamLogoAPI (string LogoUGCId)
		{

			byte[] byteArray = null;
			var ApiReq = new APIRequest ();
			string url = 
				"https://api.steampowered.com/ISteamRemoteStorage/GetUGCFileDetails/v1/?key=6A9C411A88D047DA4C9E843EDF0B02F5&format=json&" +
				"language=en_us&"+
				"ugcid="+LogoUGCId+"&appid=570";
			try 
			{
				JToken temp = await ApiReq.FetchJsonAsync (url);
				string logoUrl = (string)temp.SelectToken ("data.url");
				byte[] imgByte = await ApiReq.FetchByteArrAsync (logoUrl);
				Bitmap b = BitmapFactory.DecodeByteArray(imgByte, 0, imgByte.Length);
				Bitmap b1=Bitmap.CreateScaledBitmap(b, 150, 90, false);
				MemoryStream  stream = new MemoryStream ();
				b1.Compress(Bitmap.CompressFormat.Png, 0, stream);
				byteArray = stream.ToArray();
			}
			catch {
			}
			return byteArray;
		}
Exemple #5
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);
			}
		}