public BaseUnit() { var cultureInfo = new CultureInfo("en-GB"); cultureInfo.NumberFormat.CurrencySymbol = "£"; CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; SurvivorStaticData.LoadStatics(); MissionsStaticData.LoadStatics(); Api = new EpicApi(); Api.StartVerifier().Wait(); FriendsApi = new EpicFriendListApi(); FriendsApi.StartVerifier().Wait(); Global.DIManager.BuildService(Service => { Service.AddTransient <BotContext>(); Service.AddSingleton <IJsonStringLocalizer, JsonStringLocalizer>(); Service.AddTransient <IUnitOfWork, UnitOfWork>(); Service.AddTransient <IFTNPowerRepository, FTNPowerRepository>(); Service.AddSingleton <IConfiguration>(new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) #if RELEASE .AddJsonFile("appsettings.Production.json", optional: true) #elif DEBUG .AddJsonFile("appsettings.Development.json", optional: true) #endif .AddEnvironmentVariables() .Build()); }); }
public void Grant_Token_RestSharp_Bot() { EpicApi api = new EpicApi(); api.SetIdentity(DIManager.Services.EpicApiConfigs().UserName, DIManager.Services.EpicApiConfigs().Password); var token = api.DeviceToken(DIManager.Services.EpicApiConfigs().DeviceId, DIManager.Services.EpicApiConfigs().AccountId, DIManager.Services.EpicApiConfigs().DeviceSecret); var verify = api.Verify(); //api.KillOtherSessions(); Assert.NotNull(token); Assert.NotNull(verify.Value); }
private bool LoadCatalog() { IsCatalogReady = false; Catalog catalog = EpicApi.GetCatalog().Value; if (catalog != null) { // MyLogger.Log.Information("{lt}: Catalog is loading", "Service"); Catalog = catalog; SetCooldowns(); IsCatalogReady = true; Global.Log.Information("{lt}: Catalog is successfuly loaded", "Service"); return(true); } Global.Log.Error("{lt}: Catalog is not loaded", "Service"); return(false); }
private bool LoadWorld() { IsWorldReady = false; MissionsList = null; WorldInfo world = EpicApi.GetWorldInfo().Value; if (world != null) { // MyLogger.Log.Information("{lt}: WorldInfo is loading", "Service"); List <World> worlds = GetWorlds(world.theaters).ToList(); AllMissions allmisions = GetMissions(world, worlds); MissionsList = MissionMaping(worlds, allmisions); Top10MissionsList = TopMissions().Take(10); worlds = null; allmisions = null; SetCooldowns(); IsWorldReady = true; Global.Log.Information("{lt}: WorldInfo is successfuly loaded", "Service"); return(true); } Global.Log.Error("{lt}: WorldInfo is not loaded", "Service"); return(false); }
private void Worker() { while (true) { try { IQueryable <string> PremiumServers = GetPremiumDiscords(); foreach (string discordId in PremiumServers) { IQueryable <ReadyToUpdate> ReadyToUpdateList = RetriewGuildUsers(discordId); foreach (var arg in ReadyToUpdateList) { try { var guild = DiscordApi.GetApi.GetGuildAsync(arg.GUid).Result; var guser = guild?.GetUserAsync(arg.Uid)?.Result; if (guild == null || guser == null) { continue; } KeyValuePair <string, IQueryProfile> responsePve = new KeyValuePair <string, IQueryProfile>(); KeyValuePair <string, BattleRoyaleStats> responsePvp = new KeyValuePair <string, BattleRoyaleStats>(); if (arg.GameUserMode == GameUserMode.PVE) { responsePve = EpicApi.GetPVEProfileById(arg.EpicId).Result; } else { responsePvp = EpicApi.GetPVPProfileById(arg.EpicId).Result; if (responsePvp.Value == null || responsePvp.Value.IsPrivate) { continue; } } if (responsePve.Value == null && responsePvp.Value == null) { continue; } if (arg.GameUserMode == GameUserMode.PVE) { Repo.UpdateDatabasePVEProfileAsync(responsePve, guser, null, arg.NameTag, false, arg.PVEDecimals).Wait(); } else if (arg.GameUserMode == GameUserMode.PVP_WIN_ALL) { Repo.UpdateDatabasePVPProfileAsync(responsePvp, guser, null, arg.NameTag, false).Wait(); } Thread.Sleep(new TimeSpan(0, 0, 1)); } catch (Exception ex) { continue; } } } Global.Log.Information("{lt}: {RedisServiceName} has been ended", "Service", GetType().Name); Thread.Sleep(new TimeSpan(6, 0, 0)); } catch (Exception e) { Global.Log.Exception(e, exceptionNote: "error while updating the discord users"); Thread.Sleep(new TimeSpan(0, 2, 0)); } finally { } } }