public async Task <IActionResult> LoginReject([FromBody] LoginReject.Request req) { var res = new LoginReject.Response { reset = req.reset.Value, list = new List <LoginReject.Info>(), }; foreach (var i in req.list) { var rec = await Common1DB.LoginRejects .Where(r => r.target == i.target && r.value == i.value).FirstOrDefaultAsync(); if (rec == null && !req.reset.Value) { await Common1DB.LoginRejects.AddAsync(new evolib.Databases.common1.LoginReject { target = i.target, value = i.value, }); res.list.Add(i); } else if (rec != null && req.reset.Value) { Common1DB.Remove(rec); res.list.Add(i); } } await Common1DB.SaveChangesAsync(); return(Ok(res)); }
public async Task <PutAccountPrivilegeLevelResponse> PutAccountPrivilegeLevel(long playerId, PutAccountPrivilegeLevelRequest request) { var player = await Common1DB.PlayerIds.FindAsync(playerId); if (player == null) { // todo: error message throw new NotFoundException("player not exist"); } var account = await Common1DB.Accounts.FindAsync(player.account, player.accountType); if (account == null) { // todo: error message throw new NotFoundException("account not exist"); } if (request.account.isCheatCommandAvailable) { account.privilegeLevel |= (1 << (int)evolib.Privilege.Type.CheatCommand); } else { account.privilegeLevel &= ~(1 << (int)evolib.Privilege.Type.CheatCommand); } await Common1DB.SaveChangesAsync(); var response = new PutAccountPrivilegeLevelResponse(); return(response); }
public async Task <PutVersionResponse> PutVersion(PutVersionRequest request) { var response = new PutVersionResponse(); var enabledVersions = await Common1DB.EnabledVersions.ToListAsync(); var loginVersion = enabledVersions.SingleOrDefault(r => r.checkTarget == evolib.VersionChecker.CheckTarget.Login && r.referenceSrc == evolib.VersionChecker.ReferenceSrc.PackageVersion); if (loginVersion == null) { // todo: error message throw new Exception("login version not registered"); } UpdatePackageVersion(loginVersion, request.loginVersion.packageVersion); var matchmakeVersion = enabledVersions.SingleOrDefault(r => r.checkTarget == evolib.VersionChecker.CheckTarget.Matchmake && r.referenceSrc == evolib.VersionChecker.ReferenceSrc.PackageVersion); if (matchmakeVersion == null) { // todo: error message throw new Exception("matchmake version not registered"); } UpdatePackageVersion(matchmakeVersion, request.matchmakeVersion.packageVersion); var replayPackageVersion = enabledVersions.SingleOrDefault(r => r.checkTarget == evolib.VersionChecker.CheckTarget.Replay && r.referenceSrc == evolib.VersionChecker.ReferenceSrc.PackageVersion); if (replayPackageVersion == null) { // todo: error message throw new Exception("replay package version not registered"); } UpdatePackageVersion(replayPackageVersion, request.replayVersion.packageVersion); var replayMasterDataVersion = enabledVersions.SingleOrDefault(r => r.checkTarget == evolib.VersionChecker.CheckTarget.Replay && r.referenceSrc == evolib.VersionChecker.ReferenceSrc.MasterDataVersion); if (replayMasterDataVersion == null) { // todo: error message throw new Exception("replay master data version not registered"); } UpdateMasterDataVersion(replayMasterDataVersion, request.replayVersion.masterDataVersion); await Common1DB.SaveChangesAsync(); return(response); }
public async Task <IActionResult> AddChat([FromBody] AddChat.Request req) { var newRec = new OpsNotice(); newRec.Push(req.desc); await Common1DB.OpsNotices.AddAsync(newRec); await Common1DB.SaveChangesAsync(); return(Ok(new AddChat.Response { addedNotice = (ChatNotice)newRec, })); }
public async Task <IActionResult> LimitPackageVersion(string target, int major, int minor, int patch, int build) { var notFound = true; var checkTarget = evolib.VersionChecker.CheckTarget.Login; foreach (evolib.VersionChecker.CheckTarget t in Enum.GetValues(typeof(evolib.VersionChecker.CheckTarget))) { if (t.ToString() == target) { checkTarget = t; notFound = false; break; } } if (notFound) { return(BadRequest()); } var ver = await Common1DB.EnabledVersions.FindAsync( checkTarget, evolib.VersionChecker.ReferenceSrc.PackageVersion); if (ver == null) { var tmp = await Common1DB.EnabledVersions.AddAsync(new evolib.Databases.common1.EnabledVersion { checkTarget = checkTarget, referenceSrc = evolib.VersionChecker.ReferenceSrc.PackageVersion, }); ver = tmp.Entity; } ver.major = major; ver.minor = minor; ver.patch = patch; ver.build = build; await Common1DB.SaveChangesAsync(); return(Ok("Succeeded!")); }
public async Task <IActionResult> EditChat([FromBody] EditChat.Request req) { var rec = await Common1DB.OpsNotices .Where(r => r.Id == req.notice.id && r.optNoticeType == OptNoticeType.Chat) .FirstOrDefaultAsync(); if (rec == null) { return(BadRequest()); } rec.Push(req.notice.desc); await Common1DB.SaveChangesAsync(); return(Ok(new EditChat.Response { editedNotice = (ChatNotice)rec, })); }
public async Task <IActionResult> Delete([FromBody] Delete.Request req) { var rec = await Common1DB.OpsNotices .Where(r => r.Id == req.id) .FirstOrDefaultAsync(); if (rec == null) { return(BadRequest()); } Common1DB.OpsNotices.Remove(rec); await Common1DB.SaveChangesAsync(); return(Ok(new Delete.Response { deletedId = req.id, })); }
public async Task <IActionResult> ChangePrivilege([FromBody] ChangePrivilege.Request req) { var account = await Common1DB.Accounts.FindAsync(req.account, req.type); if (account == null) { return(Ok(new ChangePrivilege.Response { account = "", privilegeLevel = 0, })); } foreach (evolib.Privilege.Type type in Enum.GetValues(typeof(evolib.Privilege.Type))) { if (type == req.privilegeType) { if (req.set.Value) { account.privilegeLevel |= (1 << (int)type); } else { account.privilegeLevel &= ~(1 << (int)type); } await Common1DB.SaveChangesAsync(); break; } } return(Ok(new ChangePrivilege.Response { account = account.account, privilegeLevel = account.privilegeLevel, })); }
public async Task <PutAccountResponse> PutAccount(long playerId, PutAccountRequest request) { var response = new PutAccountResponse(); var registeredAccount = await Common1DB.PlayerIds .Where(r => r.playerId == playerId) .Join(Common1DB.Accounts, p => new { AccountType = p.accountType, p.account }, a => new { AccountType = a.type, a.account }, (p, a) => a) .FirstOrDefaultAsync(); if (registeredAccount == null) { // todo: error message throw new NotFoundException("account not exist"); } registeredAccount.banExpiration = request.account.banExpiration; await Common1DB.SaveChangesAsync(); return(response); }
public async Task <PutResetAccountResponse> PutResetAccount(long playerId) { var response = new PutResetAccountResponse(); var registeredAccount = await Common1DB.PlayerIds .Where(r => r.playerId == playerId) .Join(Common1DB.Accounts, p => new { AccountType = p.accountType, p.account }, a => new { AccountType = a.type, a.account }, (p, a) => a) .FirstOrDefaultAsync(); if (registeredAccount == null) { // todo: error message throw new NotFoundException("account not exist"); } { //Personal var personalDB = PDBSM.PersonalDBContext(registeredAccount.playerId); //{ // var list = await personalDB.XXXX.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); // personalDB.XXXX.RemoveRange(list); //} { var list = await personalDB.PlayerBasicInformations.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); personalDB.PlayerBasicInformations.RemoveRange(list); } { var list = await personalDB.PlayerBattleInformations.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); personalDB.PlayerBattleInformations.RemoveRange(list); } { var list = await personalDB.OwnMobileSuitSettings.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); personalDB.OwnMobileSuitSettings.RemoveRange(list); } { var list = await personalDB.OwnVoicePackSettings.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); personalDB.OwnVoicePackSettings.RemoveRange(list); } { var list = await personalDB.ItemInventories.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); personalDB.ItemInventories.RemoveRange(list); } { var list = await personalDB.AssetsInventories.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); personalDB.AssetsInventories.RemoveRange(list); } { var list = await personalDB.FavoriteFriends.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); personalDB.FavoriteFriends.RemoveRange(list); } { var list = await personalDB.FriendRequests.Where(r => r.playerIdSrc == registeredAccount.playerId).ToListAsync(); personalDB.FriendRequests.RemoveRange(list); } { var list = await personalDB.MutePlayers.Where(r => r.playerIdSrc == registeredAccount.playerId).ToListAsync(); personalDB.MutePlayers.RemoveRange(list); } { var list = await personalDB.AppOptions.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); personalDB.AppOptions.RemoveRange(list); } { var list = await personalDB.MobileSuitOptions.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); personalDB.MobileSuitOptions.RemoveRange(list); } { var list = await personalDB.DateLogs.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); personalDB.DateLogs.RemoveRange(list); } { var list = await personalDB.ReplayUserHistory.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); personalDB.ReplayUserHistory.RemoveRange(list); } { var list = await personalDB.BattlePasses.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); personalDB.BattlePasses.RemoveRange(list); } { var list = await personalDB.CareerRecords.Where(r => r.playerId == registeredAccount.playerId).ToListAsync(); personalDB.CareerRecords.RemoveRange(list); } await personalDB.SaveChangesAsync(); } { //Common3 //await Common3DB.SaveChangesAsync(); } { //Common2 { var list = await Common2DB.Friends.Where(r => r.playerIdL == registeredAccount.playerId || r.playerIdR == registeredAccount.playerId).ToListAsync(); Common2DB.Friends.RemoveRange(list); } await Common2DB.SaveChangesAsync(); } { //Common1 { var rec = new evolib.Databases.common1.PlayerId { playerId = registeredAccount.playerId }; Common1DB.PlayerIds.Attach(rec); Common1DB.PlayerIds.Remove(rec); } { Common1DB.Accounts.Remove(registeredAccount); } await Common1DB.SaveChangesAsync(); } return(response); }