Ejemplo n.º 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();
     }
 }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
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();
            }
        }