public GdprService(IServicePack servicePack) { PDBSM = servicePack.PersonalDBShardManager; Common1DB = servicePack.Common1DBContext; Common2DB = servicePack.Common2DBContext; Common3DB = servicePack.Common3DBContext; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Databases~ var dbLoggerFactory = new LoggerFactory(new[] { new SqlLoggerProvider() }); services.AddDbContext <Common1DBContext>(opt => { opt.UseMySql(Configuration.GetSection("RdbConnections").GetSection("Common1").Value); opt.UseLoggerFactory(dbLoggerFactory); }); PersonalDBShardManager.AddService(services, Configuration, dbLoggerFactory); // ~Databases DbContextFactory.Initialize(Configuration); evolib.VersionChecker.Start(); var gm = new Matching.GeneralManager(); gm.Start(); services.AddSingleton(gm); services.AddScoped <evolib.Log.ILogObj, evolib.Log.LogObj>(); services.AddScoped <Services.IServicePack, Services.ServicePack>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
public static async Task <PlayerBasicInformation> ByAccount(string account, PersonalDBShardManager pdbsm, Common1DBContext common1DB) { var r = await common1DB.Accounts.FindAsync(account, evolib.Account.Type.Dev1); if (r == null) { return(null); } return(await pdbsm.PersonalDBContext(r.playerId).PlayerBasicInformations.FindAsync(r.playerId)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Databases~ var dbLoggerFactory = new LoggerFactory(new[] { new SqlLoggerProvider() }); services.AddDbContext <Common1DBContext>(opt => { opt.UseMySql(Configuration.GetSection("RdbConnections").GetSection("Common1").Value); opt.UseLoggerFactory(dbLoggerFactory); }); services.AddDbContext <Common2DBContext>(opt => { opt.UseMySql(Configuration.GetSection("RdbConnections").GetSection("Common2").Value); opt.UseLoggerFactory(dbLoggerFactory); }); services.AddDbContext <Common3DBContext>(opt => { opt.UseMySql(Configuration.GetSection("RdbConnections").GetSection("Common3").Value); opt.UseLoggerFactory(dbLoggerFactory); }); PersonalDBShardManager.AddService(services, Configuration, dbLoggerFactory); // ~Databases services.AddSession(opt => { opt.Cookie.Name = "evotool-session-id"; opt.Cookie.MaxAge = TimeSpan.MaxValue; }); services.AddAutoMapper(typeof(Startup)); services.AddScoped <evolib.Log.ILogObj, evolib.Log.LogObj>(); services.AddScoped <Services.IServicePack, Services.ServicePack>(); services.AddScoped <IAccountService, AccountService>(); services.AddScoped <IMiscService, MiscService>(); services.AddScoped <IOpsNoticeService, OpsNoticeService>(); services.AddScoped <IPlayerService, PlayerService>(); services.AddScoped <ITranslationService, TranslationService>(); services.AddScoped <IUnitService, UnitService>(); services.AddScoped <IVersionService, VersionService>(); services.AddScoped <IGdprService, GdprService>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
public static async Task <PlayerBasicInformation> ByPlayerName(string playerName, PersonalDBShardManager pdbsm, Common2DBContext common2DB) { var rec = await common2DB.PlayerNames.FindAsync(playerName); if (rec == null) { return(null); } var db = pdbsm.PersonalDBContext(rec.playerId); return(await db.PlayerBasicInformations.FindAsync(rec.playerId)); }
public async Task Init(PersonalDBShardManager pdbsm, List <long> playerIds, List <string> msIds = null) { MsList = new List <OwnMobileSuitSetting>(); VpList = new List <OwnVoicePackSetting>(); IiList = new List <ItemInventory>(); var dbMap = new Dictionary <PersonalDBContext, List <long> >(); playerIds.ForEach(id => { var db = pdbsm.PersonalDBContext(id); if (!dbMap.ContainsKey(db)) { dbMap[db] = new List <long>(); } dbMap[db].Add(id); }); foreach (var db in dbMap) { { var query = db.Key.OwnMobileSuitSettings.Where(r => db.Value.Contains(r.playerId)); if (msIds != null) { query.Where(r => msIds.Contains(r.mobileSuitId)); } MsList.AddRange(await query.ToListAsync()); } { var query = db.Key.OwnVoicePackSettings.Where(r => db.Value.Contains(r.playerId)); if (msIds != null) { query.Where(r => msIds.Contains(r.mobileSuitId)); } VpList.AddRange(await query.ToListAsync()); } { var query = db.Key.ItemInventories.Where(r => db.Value.Contains(r.playerId) && r.itemType == Item.Type.MobileSuit); IiList.AddRange(await query.ToListAsync()); } } }
public async Task AddToDb(PersonalDBShardManager pdbsm) { var db = pdbsm.PersonalDBContext(msRecord.playerId); if (msRecordNew) { await db.OwnMobileSuitSettings.AddAsync(msRecord); } for (int i = 0; i < vpRecords.Count; i++) { if (vpRecordsNew[i]) { await db.OwnVoicePackSettings.AddAsync(vpRecords[i]); } } }
public async Task <bool> Validate(PersonalDBShardManager pdbsm) { await FetchAsync(); if (!Model.validated) { var db = pdbsm.PersonalDBContext(playerId); var basic = await db.PlayerBasicInformations.FindAsync(playerId); if (basic == null) { return(false); } Model.validated = true; Model.playerName = basic.playerName; Model.playerIconItemId = basic.playerIconItemId; Model.pretendOffline = basic.pretendOffline; Model.openType = basic.openType; var playerPass = await db.BattlePasses.FindAsync(playerId, (int)BattlePass.PlayerLevelPassId); if (playerPass != null) { Model.playerLevel = playerPass.level; Model.exp = playerPass.levelExp; Model.nextLevelExp = playerPass.nextExp; } var battle = await db.PlayerBattleInformations.FindAsync(playerId); if (battle != null) { Model.battleRating = battle.rating; } else { Model.battleRating = Battle.InitialRating; } await SaveAsync(); } return(true); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Databases~ var dbLoggerFactory = new LoggerFactory(new[] { new SqlLoggerProvider() }); services.AddDbContext <Common2DBContext>(opt => { opt.UseMySql(Configuration.GetSection("RdbConnections").GetSection("Common2").Value); opt.UseLoggerFactory(dbLoggerFactory); }); PersonalDBShardManager.AddService(services, Configuration, dbLoggerFactory); // ~Databases services.AddScoped <evolib.Log.ILogObj, evolib.Log.LogObj>(); services.AddScoped <Services.IServicePack, Services.ServicePack>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // ---------------------- // Databases~ var dbLoggerFactory = new LoggerFactory(new[] { new SqlLoggerProvider() }); services.AddDbContext <Common1DBContext>(opt => { opt.UseMySql(Configuration.GetSection("RdbConnections").GetSection("Common1").Value); opt.UseLoggerFactory(dbLoggerFactory); }); services.AddDbContext <Common2DBContext>(opt => { opt.UseMySql(Configuration.GetSection("RdbConnections").GetSection("Common2").Value); opt.UseLoggerFactory(dbLoggerFactory); }); services.AddDbContext <Common3DBContext>(opt => { opt.UseMySql(Configuration.GetSection("RdbConnections").GetSection("Common3").Value); opt.UseLoggerFactory(dbLoggerFactory); }); PersonalDBShardManager.AddService(services, Configuration, dbLoggerFactory); // ~Databases // ---------------------- // services.AddDistributedRedisCache(opt => // { // opt.Configuration = Configuration.GetConnectionString("GameCacheConnection"); // opt.InstanceName = "EvoGame"; // }); //services.AddSession( opt=> //{ // opt.Cookie.Name = Configuration["Session:CookieName"]; //}); DbContextFactory.Initialize(Configuration); evolib.VersionChecker.Start(); evolib.OpsNoticeManager.Start(); evolib.DisabledMobileSuit.Start(); //services.AddSingleton<XXXX>(xxxx); services.AddScoped <evolib.Log.ILogObj, evolib.Log.LogObj>(); services.AddScoped <Services.IServicePack, Services.ServicePack>(); services.Configure <ForwardedHeadersOptions>(opt => { opt.ForwardedHeaders = Microsoft.AspNetCore.HttpOverrides.ForwardedHeaders.XForwardedFor; //default //opt.ForwardLimit = 1; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }