Example #1
0
 /// <summary>
 ///     Creates Builds
 /// </summary>
 public static void GetBuildFromService()
 {
     try
     {
         try
         {
             var filename  = $"{Player.Instance.CleanChampionName()}.json";
             var WebClient = new WebClient();
             WebClient.DownloadStringTaskAsync($"https://raw.githubusercontent.com/plsfixrito/AramBuddy/master/DefaultBuilds/{Config.CurrentPatchUsed}/{filename}");
             WebClient.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs args)
             {
                 if (args.Cancelled || args.Error != null)
                 {
                     Logger.Send("External server bad response.", Logger.LogLevel.Error);
                     Setup.UseDefaultBuild();
                     return;
                 }
                 if (args.Result.Contains("data"))
                 {
                     var filepath = $"{Setup.BuildPath}/{Config.CurrentPatchUsed}/{filename}";
                     File.WriteAllText(filepath, args.Result);
                     Setup.Builds.Add(Player.Instance.CleanChampionName(), File.ReadAllText(filepath));
                     Logger.Send("Created Build for " + Player.Instance.ChampionName);
                     Setup.CustomBuildService();
                 }
                 else
                 {
                     Logger.Send("External server bad response.", Logger.LogLevel.Error);
                     Setup.UseDefaultBuild();
                 }
             };
         }
         catch (TargetInvocationException ex)
         {
             Logger.Send(ex?.InnerException?.Message, Logger.LogLevel.Error);
             Setup.UseDefaultBuild();
         }
     }
     catch (Exception ex)
     {
         // if faild to create build terminate the AutoShop
         Logger.Send("Failed to create Build from service " + Config.CurrentBuildService + " " + Config.CurrentPatchUsed + " for " + Player.Instance.ChampionName, Logger.LogLevel.Error);
         Logger.Send(ex.InnerException?.Message, Logger.LogLevel.Error);
         Logger.Send("Getting default build", Logger.LogLevel.Warn);
         Setup.UseDefaultBuild();
     }
 }
Example #2
0
 /// <summary>
 ///     Creates Builds
 /// </summary>
 public static void CreateDefaultBuild()
 {
     try
     {
         var filename  = $"{BuildName()}.json";
         var WebClient = new WebClient();
         WebClient.DownloadStringTaskAsync($"https://raw.githubusercontent.com/plsfixrito/AramBuddy/master/DefaultBuilds/{filename}");
         WebClient.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs args)
         {
             try
             {
                 if (args.Cancelled || args.Error != null)
                 {
                     Logger.Send(args.Error?.Message, Logger.LogLevel.Error);
                     Logger.Send("External server bad response.", Logger.LogLevel.Error);
                     Logger.Send("/!\\ NO BUILD IS CURRENTLY BEING USED /!\\", Logger.LogLevel.Error);
                     return;
                 }
                 if (args.Result.Contains("data"))
                 {
                     File.WriteAllText(Setup.BuildPath + "\\" + filename, args.Result);
                     Setup.Builds.Add(BuildName(), File.ReadAllText(Setup.BuildPath + "\\" + filename));
                     Logger.Send(BuildName() + " Build Created for " + Player.Instance.ChampionName + " - " + BuildName());
                     Setup.UseDefaultBuild();
                 }
                 else
                 {
                     Logger.Send("External server bad response.", Logger.LogLevel.Error);
                     Console.WriteLine(args.Result);
                 }
             }
             catch (TargetInvocationException ex)
             {
                 Logger.Send("Failed to create default build for " + Player.Instance.ChampionName, ex, Logger.LogLevel.Error);
                 Logger.Send("/!\\ NO BUILD IS CURRENTLY BEING USED /!\\", Logger.LogLevel.Error);
                 Logger.Send(ex?.InnerException?.Message, Logger.LogLevel.Error);
             }
         };
     }
     catch (Exception ex)
     {
         // if faild to create build terminate the AutoShop
         Logger.Send("Failed to create default build for " + Player.Instance.ChampionName, ex, Logger.LogLevel.Error);
         Logger.Send("/!\\ NO BUILD IS CURRENTLY BEING USED /!\\", Logger.LogLevel.Error);
     }
 }
Example #3
0
        /// <summary>
        ///     Creates Builds
        /// </summary>
        public static void GetBuildFromService()
        {
            try
            {
                var filename = CleanUpChampionName(Player.Instance.ChampionName) + ".json";

                using (var WebClient = new WebClient())
                {
                    using (var request = WebClient.DownloadStringTaskAsync("https://raw.githubusercontent.com/r3d4ilx3cdfxd/AramBuddyBuilds/master/" + Config.CurrentPatchUsed + "\\" + Config.CurrentBuildService + "/" + filename))
                    {
                        if (request != null && !request.IsCanceled && !request.IsFaulted)
                        {
                            if (request.Result.Contains("data"))
                            {
                                File.WriteAllText(Setup.BuildPath + "\\" + Config.CurrentPatchUsed + "\\" + Config.CurrentBuildService + "\\" + filename, request.Result);
                                Setup.Builds.Add(CleanUpChampionName(Player.Instance.ChampionName), File.ReadAllText(Setup.BuildPath + "\\" + Config.CurrentPatchUsed + "\\" + Config.CurrentBuildService + "\\" + filename));
                                Logger.Send("Created Build for " + Player.Instance.ChampionName);
                                Setup.CustomBuildService();
                            }
                            else
                            {
                                Logger.Send("Wrong Response, No Champion Build Created !", Logger.LogLevel.Warn);
                                Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn);
                                Setup.UseDefaultBuild();
                                //Console.WriteLine(args.Result);
                            }
                        }
                        else
                        {
                            Logger.Send("Failed Getting build, No Response !", Logger.LogLevel.Warn);
                            Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn);
                            Setup.UseDefaultBuild();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // if faild to create build terminate the AutoShop
                Logger.Send("Failed to create Build from service " + Config.CurrentBuildService + " " + Config.CurrentPatchUsed + " for " + Player.Instance.ChampionName, Logger.LogLevel.Error);
                Logger.Send(ex.InnerException?.Message, Logger.LogLevel.Error);
                Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn);
                Setup.UseDefaultBuild();
            }
        }
Example #4
0
        /// <summary>
        ///     Creates Builds
        /// </summary>
        public static void CreateDefualtBuild()
        {
            try
            {
                var filename  = $"{BuildName()}.json";
                var WebClient = new WebClient();
                WebClient.DownloadStringTaskAsync($"https://raw.githubusercontent.com/plsfixrito/AramBuddy/master/DefaultBuilds/{filename}");
                WebClient.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs args)
                {
                    try
                    {
                        if (args.Cancelled || args.Error != null)
                        {
                            Logger.Send(args.Error?.Message, Logger.LogLevel.Error);
                            Logger.Send("Wrong Response or was canceled, No Champion Build Created !", Logger.LogLevel.Warn);
                            Logger.Send("No Build is being used !", Logger.LogLevel.Warn);
                            return;
                        }
                        if (args.Result.Contains("data"))
                        {
                            File.WriteAllText(Setup.BuildPath + "\\" + filename, args.Result);
                            Setup.Builds.Add(BuildName(), File.ReadAllText(Setup.BuildPath + "\\" + filename));
                            Logger.Send(BuildName() + " Build Created for " + Player.Instance.ChampionName + " - " + BuildName());
                            Setup.UseDefaultBuild();
                        }
                        else
                        {
                            Logger.Send("Wrong Response, No Champion Build Created", Logger.LogLevel.Warn);
                            Console.WriteLine(args.Result);
                        }
                    }
                    catch (TargetInvocationException ex)
                    {
                        Logger.Send("Failed to create default build for " + Player.Instance.ChampionName, ex, Logger.LogLevel.Error);
                        Logger.Send("No build is currently being used!", Logger.LogLevel.Error);
                        Logger.Send(ex?.InnerException?.Message, Logger.LogLevel.Error);
                    }
                };

                /*
                 * using (var WebClient = new WebClient())
                 * {
                 *  using (var request = WebClient.DownloadStringTaskAsync("https://raw.githubusercontent.com/plsfixrito/AramBuddy/master/DefaultBuilds/" + filename))
                 *  {
                 *      if (request.IsFaulted || request.IsCanceled)
                 *      {
                 *          Logger.Send("Wrong Response, Or Request Was Cancelled", Logger.LogLevel.Warn);
                 *          Logger.Send(request.Exception?.InnerException?.Message, Logger.LogLevel.Warn);
                 *          Console.WriteLine(request.Result);
                 *      }
                 *      else
                 *      {
                 *          if (request.Result != null && request.Result.Contains("data"))
                 *          {
                 *              File.WriteAllText(Setup.BuildPath + "\\" + filename, request.Result);
                 *              Setup.Builds.Add(BuildName(), File.ReadAllText(Setup.BuildPath + "\\" + filename));
                 *              Logger.Send(BuildName() + " Build Created for " + Player.Instance.ChampionName + " - " + BuildName());
                 *              Setup.UseDefaultBuild();
                 *          }
                 *          else
                 *          {
                 *              Logger.Send("Wrong Response, No Champion Build Created", Logger.LogLevel.Warn);
                 *              Console.WriteLine(request.Result);
                 *          }
                 *      }
                 *  }
                 * }*/
            }
            catch (Exception ex)
            {
                // if faild to create build terminate the AutoShop
                Logger.Send("Failed to create default build for " + Player.Instance.ChampionName, ex, Logger.LogLevel.Error);
                Logger.Send("No build is currently being used!", Logger.LogLevel.Error);
            }
        }
Example #5
0
        /// <summary>
        ///     Creates Builds
        /// </summary>
        public static void GetBuildFromService()
        {
            try
            {
                try
                {
                    var filename  = $"{Player.Instance.CleanChampionName()}.json";
                    var WebClient = new WebClient();
                    WebClient.DownloadStringTaskAsync($"https://raw.githubusercontent.com/plsfixrito/AramBuddyBuilds/master/{Config.CurrentPatchUsed}/{Config.CurrentBuildService}/{filename}");
                    WebClient.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs args)
                    {
                        if (args.Cancelled || args.Error != null)
                        {
                            Logger.Send(args.Error?.Message, Logger.LogLevel.Error);
                            Logger.Send("Wrong Response or was canceled, No Champion Build Created !", Logger.LogLevel.Warn);
                            Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn);
                            Setup.UseDefaultBuild();
                            return;
                        }
                        if (args.Result.Contains("data"))
                        {
                            var filepath = $"{Setup.BuildPath}/{Config.CurrentPatchUsed}/{Config.CurrentBuildService}/{filename}";
                            File.WriteAllText(filepath, args.Result);
                            Setup.Builds.Add(Player.Instance.CleanChampionName(), File.ReadAllText(filepath));
                            Logger.Send("Created Build for " + Player.Instance.ChampionName);
                            Setup.CustomBuildService();
                        }
                        else
                        {
                            Logger.Send("Wrong Response or was canceled, No Champion Build Created !", Logger.LogLevel.Warn);
                            Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn);
                            Setup.UseDefaultBuild();
                        }
                    };
                }
                catch (TargetInvocationException ex)
                {
                    Logger.Send(ex?.InnerException?.Message, Logger.LogLevel.Error);
                    Setup.UseDefaultBuild();
                }

                /*
                 * using (var WebClient = new WebClient())
                 * {
                 *  using (var request = WebClient.DownloadStringTaskAsync("https://raw.githubusercontent.com/plsfixrito/AramBuddyBuilds/master/" + Config.CurrentPatchUsed + "\\" + Config.CurrentBuildService + "/" + filename))
                 *  {
                 *      if (request != null && !request.IsCanceled && !request.IsFaulted)
                 *      {
                 *          if (request.Result.Contains("data"))
                 *          {
                 *              File.WriteAllText(Setup.BuildPath + "\\" + Config.CurrentPatchUsed + "\\" + Config.CurrentBuildService + "\\" + filename, request.Result);
                 *              Setup.Builds.Add(Player.Instance.CleanChampionName(), File.ReadAllText(Setup.BuildPath + "\\" + Config.CurrentPatchUsed + "\\" + Config.CurrentBuildService + "\\" + filename));
                 *              Logger.Send("Created Build for " + Player.Instance.ChampionName);
                 *              Setup.CustomBuildService();
                 *          }
                 *          else
                 *          {
                 *              Logger.Send("Wrong Response, No Champion Build Created !", Logger.LogLevel.Warn);
                 *              Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn);
                 *              Setup.UseDefaultBuild();
                 *              //Console.WriteLine(args.Result);
                 *          }
                 *      }
                 *      else
                 *      {
                 *          Logger.Send("Failed Getting build, No Response !", Logger.LogLevel.Warn);
                 *          Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn);
                 *          Setup.UseDefaultBuild();
                 *      }
                 *  }
                 * }*/
            }
            catch (Exception ex)
            {
                // if faild to create build terminate the AutoShop
                Logger.Send("Failed to create Build from service " + Config.CurrentBuildService + " " + Config.CurrentPatchUsed + " for " + Player.Instance.ChampionName, Logger.LogLevel.Error);
                Logger.Send(ex.InnerException?.Message, Logger.LogLevel.Error);
                Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn);
                Setup.UseDefaultBuild();
            }
        }