Exemple #1
0
        //Stores champions information in a Json file alongside image files for items
        private void storeChampJsonData(Dictionary <uint, Champion> champions)
        {
            RestfulServices rest = new RestfulServices();

            foreach (var champ in champions)
            {
                JObject champData = rest.getChampionName(champ.Key);
                champ.Value.ChampionName = (string)champData["name"];
                champ.Value.deathRate    = Math.Round(champ.Value.averageDeathRate(), 2);
                champ.Value.killRate     = Math.Round(champ.Value.averageKillRate(), 2);
                champ.Value.banRate      = Math.Round(champ.Value.averageBanRate(), 2);
                champ.Value.AverageKDA   = Math.Round(champ.Value.averageKillDeathRate(), 2);
                if (champ.Value.itemStats.ContainsKey(0))
                {
                    champ.Value.itemStats.Remove(0);
                }
                foreach (var item in champ.Value.itemStats)
                {
                    item.Value.itemName  = (string)rest.getItemName(item.Value.ID)["name"];
                    item.Value.imagePath = rest.getImageFiles(item.Value.ID, item.Value.itemName);
                }
                string json = JsonConvert.SerializeObject(champ.Value);
                System.IO.File.WriteAllText(HttpRuntime.AppDomainAppPath + "\\JSON\\Champions\\" + champ.Value.ChampionName + ".json", json);
            }
        }
Exemple #2
0
        //Geta and writes Json files to IO from data set
        private void getAndWriteJsonFilesToIO(int count, JToken data)
        {
            RestfulServices rest = new RestfulServices();

            string[] systemFiles = Directory.GetFiles(HttpRuntime.AppDomainAppPath + "JSON\\DataSet\\");
            if (!systemFiles.Contains("C:\\Programming\\BlackMarketBrawlersBigData\\BlackMarketBrawlersBigData\\JSON\\DataSet\\" + (string)data + ".json"))
            {
                if (count % 10 == 0)
                {
                    System.Threading.Thread.Sleep(15000);
                    JObject temp = rest.getMatchHistory((int)data);
                    string  json = JsonConvert.SerializeObject(temp);
                    System.IO.File.WriteAllText(HttpRuntime.AppDomainAppPath + "\\JSON\\DataSet\\" + (string)data + ".json", json);
                    count++;
                }
                else
                {
                    JObject temp = rest.getMatchHistory((int)data);
                    string  json = JsonConvert.SerializeObject(temp);
                    System.IO.File.WriteAllText(HttpRuntime.AppDomainAppPath + "\\JSON\\DataSet\\" + (string)data + ".json", json);
                    count++;
                }
            }
        }
 //Stores champions information in a Json file alongside image files for items
 private void storeChampJsonData(Dictionary<uint, Champion> champions)
 {
     RestfulServices rest = new RestfulServices();
     foreach (var champ in champions)
     {
         JObject champData = rest.getChampionName(champ.Key);
         champ.Value.ChampionName = (string)champData["name"];
         champ.Value.deathRate = Math.Round(champ.Value.averageDeathRate(), 2);
         champ.Value.killRate = Math.Round(champ.Value.averageKillRate(), 2);
         champ.Value.banRate = Math.Round(champ.Value.averageBanRate(), 2);
         champ.Value.AverageKDA = Math.Round(champ.Value.averageKillDeathRate(), 2);
         if (champ.Value.itemStats.ContainsKey(0))
         {
             champ.Value.itemStats.Remove(0);
         }
         foreach (var item in champ.Value.itemStats)
         {
                 item.Value.itemName = (string)rest.getItemName(item.Value.ID)["name"];
                 item.Value.imagePath = rest.getImageFiles(item.Value.ID, item.Value.itemName);
         }
         string json = JsonConvert.SerializeObject(champ.Value);
         System.IO.File.WriteAllText(HttpRuntime.AppDomainAppPath + "\\JSON\\Champions\\" + champ.Value.ChampionName + ".json", json);
     }
 }
 //Geta and writes Json files to IO from data set
 private void getAndWriteJsonFilesToIO(int count, JToken data)
 {
     RestfulServices rest = new RestfulServices();
     string[] systemFiles = Directory.GetFiles(HttpRuntime.AppDomainAppPath + "JSON\\DataSet\\");
     if (!systemFiles.Contains("C:\\Programming\\BlackMarketBrawlersBigData\\BlackMarketBrawlersBigData\\JSON\\DataSet\\" + (string)data + ".json"))
     {
         if (count % 10 == 0)
         {
             System.Threading.Thread.Sleep(15000);
             JObject temp = rest.getMatchHistory((int)data);
             string json = JsonConvert.SerializeObject(temp);
             System.IO.File.WriteAllText(HttpRuntime.AppDomainAppPath + "\\JSON\\DataSet\\" + (string)data + ".json", json);
             count++;
         }
         else
         {
             JObject temp = rest.getMatchHistory((int)data);
             string json = JsonConvert.SerializeObject(temp);
             System.IO.File.WriteAllText(HttpRuntime.AppDomainAppPath + "\\JSON\\DataSet\\" + (string)data + ".json", json);
             count++;
         }
     }
 }