diff --git a/Application/DependencyInjection.cs b/Application/DependencyInjection.cs index 3c5cfd6..3e69604 100644 --- a/Application/DependencyInjection.cs +++ b/Application/DependencyInjection.cs @@ -10,7 +10,7 @@ namespace Application; public static class DependencyInjection { - public static IServiceCollection AddApplication(this IServiceCollection services) + public static IServiceCollection AddApplication(this IServiceCollection services, int refreshIntervalHours = 24) { services.AddMediatR(configuration => configuration.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly())); @@ -28,7 +28,7 @@ public static class DependencyInjection .StartNow() .WithSimpleSchedule(x => { - x.WithIntervalInHours(24).RepeatForever(); + x.WithIntervalInHours(refreshIntervalHours).RepeatForever(); }); }); @@ -40,7 +40,7 @@ public static class DependencyInjection .StartNow() .WithSimpleSchedule(x => { - x.WithIntervalInHours(24).RepeatForever(); + x.WithIntervalInHours(refreshIntervalHours).RepeatForever(); }); }); @@ -52,7 +52,7 @@ public static class DependencyInjection .StartNow() .WithSimpleSchedule(x => { - x.WithIntervalInHours(24).RepeatForever(); + x.WithIntervalInHours(refreshIntervalHours).RepeatForever(); }); }); @@ -64,7 +64,7 @@ public static class DependencyInjection .StartNow() .WithSimpleSchedule(x => { - x.WithIntervalInHours(24).RepeatForever(); + x.WithIntervalInHours(refreshIntervalHours).RepeatForever(); }); }); }); diff --git a/Application/Game/Card/CardRequest.cs b/Application/Game/Card/CardRequest.cs index 8d6e864..78dbbc1 100644 --- a/Application/Game/Card/CardRequest.cs +++ b/Application/Game/Card/CardRequest.cs @@ -15,6 +15,9 @@ public class CardRequest [ModelBinder(Name = "card_no")] public long CardId { get; set; } + + [ModelBinder(Name = "tenpo_id")] + public string TenpoId { get; set; } = "1337"; [ModelBinder(Name = "data")] public string Data { get; set; } = string.Empty; diff --git a/Application/Game/Card/Write/WriteCardDetailCommand.cs b/Application/Game/Card/Write/WriteCardDetailCommand.cs index ab861ff..7c406a9 100644 --- a/Application/Game/Card/Write/WriteCardDetailCommand.cs +++ b/Application/Game/Card/Write/WriteCardDetailCommand.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.Logging; namespace Application.Game.Card.Write; -public record WriteCardDetailCommand(long CardId, string Data) : IRequestWrapper; +public record WriteCardDetailCommand(long CardId, string TenpoId, string Data) : IRequestWrapper; public class WriteDetailCommandHandler : RequestHandlerBase { @@ -28,6 +28,7 @@ public class WriteDetailCommandHandler : RequestHandlerBase> Handle(GetGlobalScoreRankQuery request, CancellationToken cancellationToken) { var param = request.Param.DeserializeCardData(); - if (param.CardId == 0) + return param switch { - return await GetAllRanks(cancellationToken); - } - return await GetCardRank(param.CardId, cancellationToken); + { CardId: 0, TenpoId: 0 } => await GetAllRanks(cancellationToken), + { CardId: > 0, TenpoId: 0 } => await GetCardRank(param.CardId, cancellationToken), + { CardId: 0, TenpoId: > 0 } => await GetTenpoRanks(param.TenpoId, cancellationToken), + _ => ServiceResult.Failed(ServiceError.ValidationFormat) + }; } private async Task> GetCardRank(long cardId, @@ -80,6 +82,42 @@ public class GetGlobalScoreRankQueryHandler : IRequestHandlerWrapper(container.SerializeCardData()); } + + private async Task> GetTenpoRanks(int tenpoId, CancellationToken cancellationToken) + { + var ranks = await cardDbContext.GlobalScoreRanks.Where(rank => rank.LastPlayTenpoId == tenpoId) + .OrderByDescending(rank => rank.TotalScore) + .Take(30) + .ToListAsync(cancellationToken: cancellationToken); + ranks = ranks.Select((rank, i) => + { + rank.Rank = i + 1; + return rank; + }).ToList(); + + var dtoList = ranks.Select((rank, i) => + { + var dto = rank.ScoreRankToDto(); + dto.Id = i; + dto.Rank2 = dto.Rank; + return dto; + }).ToList(); + + var container = new GlobalScoreRankContainer + { + Ranks = dtoList, + Status = new RankStatus + { + TableName = "TenpoScoreRank", + StartDate = TimeHelper.DateToString(DateTime.Today), + EndDate = TimeHelper.DateToString(DateTime.Today), + Rows = dtoList.Count, + Status = 1 + } + }; + + return new ServiceResult(container.SerializeCardData()); + } } [XmlRoot("root")] diff --git a/Application/Game/Rank/GetTenpoScoreRankQuery.cs b/Application/Game/Rank/GetTenpoScoreRankQuery.cs index c82d873..7489df1 100644 --- a/Application/Game/Rank/GetTenpoScoreRankQuery.cs +++ b/Application/Game/Rank/GetTenpoScoreRankQuery.cs @@ -77,7 +77,7 @@ public class GetTenpoScoreRankQueryHandler : IRequestHandlerWrapper(container.SerializeCardData()); } -} - -[XmlRoot("root")] -public class TenpoScoreRankContainer -{ - [XmlArray(ElementName = "t_score_rank")] - [XmlArrayItem(ElementName = "record")] - // ReSharper disable once UnusedAutoPropertyAccessor.Global - public List Ranks { get; init; } = new(); - - [XmlElement("ranking_status")] - public RankStatus Status { get; set; } = new(); -} +} \ No newline at end of file diff --git a/Application/Game/Rank/GetWPlayNumRankQuery.cs b/Application/Game/Rank/GetWPlayNumRankQuery.cs new file mode 100644 index 0000000..4016f2a --- /dev/null +++ b/Application/Game/Rank/GetWPlayNumRankQuery.cs @@ -0,0 +1,61 @@ +using System.Diagnostics; +using Application.Common.Helpers; + +namespace Application.Game.Rank; + +public record GetWPlayNumRankQuery(): IRequestWrapper; + +public class GetWPlayNumRankQueryHandler : IRequestHandlerWrapper +{ + private readonly ICardDbContext cardDbContext; + + public GetWPlayNumRankQueryHandler(ICardDbContext cardDbContext) + { + this.cardDbContext = cardDbContext; + } + + public async Task> Handle(GetWPlayNumRankQuery request, CancellationToken cancellationToken) + { + var ranks = await cardDbContext.PlayNumRanks.OrderBy(rank => rank.Rank) + .Take(30).ToListAsync(cancellationToken: cancellationToken); + + var status = new RankStatus + { + TableName = "PlayNumRank", + StartDate = TimeHelper.DateToString(Process.GetCurrentProcess().StartTime.Date), + EndDate = TimeHelper.DateToString(DateTime.Today), + Rows = ranks.Count, + Status = 1 + }; + + var dtoList = ranks.Select((rank, i) => + { + var dto = rank.PlayNumRankToDto(); + dto.Id = i; + return dto; + }).ToList(); + + var container = new WPlayNumRankContainer + { + Ranks = dtoList, + Status = status + }; + + var result = container.SerializeCardData(); + + return new ServiceResult(result); + } +} + +[XmlRoot("root")] +public class WPlayNumRankContainer +{ + [XmlArray(ElementName = "w_play_num_rank")] + [XmlArrayItem(ElementName = "record")] + // ReSharper disable once UnusedAutoPropertyAccessor.Global + public List Ranks { get; init; } = new(); + + [XmlElement("ranking_status")] + public RankStatus Status { get; set; } = new(); +} + diff --git a/Application/Game/Rank/GetWScoreRankQuery.cs b/Application/Game/Rank/GetWScoreRankQuery.cs new file mode 100644 index 0000000..a0cee85 --- /dev/null +++ b/Application/Game/Rank/GetWScoreRankQuery.cs @@ -0,0 +1,96 @@ +using Application.Common.Helpers; + +namespace Application.Game.Rank; + +public record GetWScoreRankQuery(string Param) : IRequestWrapper; + +public class GetWScoreRankQueryHandler : IRequestHandlerWrapper +{ + private readonly ICardDbContext cardDbContext; + + public GetWScoreRankQueryHandler(ICardDbContext cardDbContext) + { + this.cardDbContext = cardDbContext; + } + + public async Task> Handle(GetWScoreRankQuery request, CancellationToken cancellationToken) + { + var param = request.Param.DeserializeCardData(); + if (param.CardId == 0) + { + return await GetAllRanks(cancellationToken); + } + return await GetCardRank(param.CardId, cancellationToken); + } + + private async Task> GetCardRank(long cardId, + CancellationToken cancellationToken) + { + var rank = await cardDbContext.GlobalScoreRanks.FirstOrDefaultAsync(scoreRank => scoreRank.CardId == cardId, + cancellationToken: cancellationToken); + var container = new GlobalScoreRankContainer + { + Ranks = new List(), + Status = new RankStatus + { + TableName = "GlobalScoreRank", + StartDate = TimeHelper.DateToString(DateTime.Today), + EndDate = TimeHelper.DateToString(DateTime.Today), + Rows = 0, + Status = 1 + } + }; + if (rank is null) + { + return new ServiceResult(container.SerializeCardData()); + } + + var dto = rank.ScoreRankToDto(); + dto.Id = 0; + container.Ranks.Add(dto); + container.Status.Rows++; + return new ServiceResult(container.SerializeCardData()); + } + + private async Task> GetAllRanks(CancellationToken cancellationToken) + { + var ranks = await cardDbContext.GlobalScoreRanks.OrderBy(rank => rank.Rank) + .Take(30).ToListAsync(cancellationToken: cancellationToken); + + var dtoList = ranks.Select((rank, i) => + { + var dto = rank.ScoreRankToDto(); + dto.Id = i; + dto.Rank2 = dto.Rank; + return dto; + }).ToList(); + + var container = new WScoreRankContainer + { + Ranks = dtoList, + Status = new RankStatus + { + TableName = "GlobalScoreRank", + StartDate = TimeHelper.DateToString(DateTime.Today), + EndDate = TimeHelper.DateToString(DateTime.Today), + Rows = dtoList.Count, + Status = 1 + } + }; + + return new ServiceResult(container.SerializeCardData()); + } +} + +[XmlRoot("root")] +public class WScoreRankContainer +{ + [XmlArray(ElementName = "w_score_rank")] + [XmlArrayItem(ElementName = "record")] + // ReSharper disable once UnusedAutoPropertyAccessor.Global + public List Ranks { get; init; } = new(); + + [XmlElement("ranking_status")] + public RankStatus Status { get; set; } = new(); +} + diff --git a/Application/Game/Rank/GetWTenpoScoreRankQuery.cs b/Application/Game/Rank/GetWTenpoScoreRankQuery.cs new file mode 100644 index 0000000..dd44cb3 --- /dev/null +++ b/Application/Game/Rank/GetWTenpoScoreRankQuery.cs @@ -0,0 +1,102 @@ +using Application.Common.Helpers; + +namespace Application.Game.Rank; + +public record GetWTenpoScoreRankQuery(int TenpoId, string Param) : IRequestWrapper; + +public class GetWTenpoScoreRankQueryHandler : IRequestHandlerWrapper +{ + private readonly ICardDbContext cardDbContext; + + public GetWTenpoScoreRankQueryHandler(ICardDbContext cardDbContext) + { + this.cardDbContext = cardDbContext; + } + + public async Task> Handle(GetWTenpoScoreRankQuery request, CancellationToken cancellationToken) + { + var param = request.Param.DeserializeCardData(); + if (param.CardId == 0) + { + return await GetAllRanks(request.TenpoId, cancellationToken); + } + return await GetCardRank(param.CardId, request.TenpoId, cancellationToken); + } + + private async Task> GetCardRank(long cardId, int tenpoId, CancellationToken cancellationToken) + { + var rank = await cardDbContext.GlobalScoreRanks.FirstOrDefaultAsync(scoreRank => scoreRank.CardId == cardId && + scoreRank.LastPlayTenpoId == tenpoId, + cancellationToken: cancellationToken); + var container = new TenpoScoreRankContainer + { + Ranks = new List(), + Status = new RankStatus + { + TableName = "TenpoScoreRank", + StartDate = TimeHelper.DateToString(DateTime.Today), + EndDate = TimeHelper.DateToString(DateTime.Today), + Rows = 0, + Status = 1 + } + }; + if (rank is null) + { + return new ServiceResult(container.SerializeCardData()); + } + + var dto = rank.ScoreRankToDto(); + dto.Id = 0; + container.Ranks.Add(dto); + container.Status.Rows++; + return new ServiceResult(container.SerializeCardData()); + } + + private async Task> GetAllRanks(int tenpoId, CancellationToken cancellationToken) + { + var ranks = await cardDbContext.GlobalScoreRanks.Where(rank => rank.LastPlayTenpoId == tenpoId) + .OrderByDescending(rank => rank.TotalScore) + .Take(30) + .ToListAsync(cancellationToken: cancellationToken); + ranks = ranks.Select((rank, i) => + { + rank.Rank = i + 1; + return rank; + }).ToList(); + + var dtoList = ranks.Select((rank, i) => + { + var dto = rank.ScoreRankToDto(); + dto.Id = i; + dto.Rank2 = dto.Rank; + return dto; + }).ToList(); + + var container = new WTenpoScoreRankContainer + { + Ranks = dtoList, + Status = new RankStatus + { + TableName = "TenpoScoreRank", + StartDate = TimeHelper.DateToString(DateTime.Today), + EndDate = TimeHelper.DateToString(DateTime.Today), + Rows = dtoList.Count, + Status = 1 + } + }; + + return new ServiceResult(container.SerializeCardData()); + } +} + +[XmlRoot("root")] +public class WTenpoScoreRankContainer +{ + [XmlArray(ElementName = "w_t_score_rank")] + [XmlArrayItem(ElementName = "record")] + // ReSharper disable once UnusedAutoPropertyAccessor.Global + public List Ranks { get; init; } = new(); + + [XmlElement("ranking_status")] + public RankStatus Status { get; set; } = new(); +} diff --git a/Application/Game/Rank/RankParam.cs b/Application/Game/Rank/RankParam.cs index 11b6b3f..27cf391 100644 --- a/Application/Game/Rank/RankParam.cs +++ b/Application/Game/Rank/RankParam.cs @@ -7,4 +7,8 @@ public class RankParam [XmlElement(ElementName = "card_id")] [DefaultValue("0")] public long CardId { get; set; } + + [XmlElement(ElementName = "tenpo_id")] + [DefaultValue("0")] + public int TenpoId { get; set; } } \ No newline at end of file diff --git a/Application/Game/Rank/TenpoScoreRankContainer.cs b/Application/Game/Rank/TenpoScoreRankContainer.cs new file mode 100644 index 0000000..852de2e --- /dev/null +++ b/Application/Game/Rank/TenpoScoreRankContainer.cs @@ -0,0 +1,13 @@ +namespace Application.Game.Rank; + +[XmlRoot("root")] +public class TenpoScoreRankContainer +{ + [XmlArray(ElementName = "t_score_rank")] + [XmlArrayItem(ElementName = "record")] + // ReSharper disable once UnusedAutoPropertyAccessor.Global + public List Ranks { get; init; } = new(); + + [XmlElement("ranking_status")] + public RankStatus Status { get; set; } = new(); +} \ No newline at end of file diff --git a/Application/Jobs/UpdateGlobalScoreRankJob.cs b/Application/Jobs/UpdateGlobalScoreRankJob.cs index 8161ad9..902d8c7 100644 --- a/Application/Jobs/UpdateGlobalScoreRankJob.cs +++ b/Application/Jobs/UpdateGlobalScoreRankJob.cs @@ -1,6 +1,8 @@ using System.Diagnostics.CodeAnalysis; +using Domain.Config; using Domain.Entities; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Quartz; namespace Application.Jobs; @@ -11,12 +13,17 @@ public class UpdateGlobalScoreRankJob : IJob private readonly ICardDbContext cardDbContext; + private readonly AuthConfig authConfig; + public static readonly JobKey KEY = new("UpdateGlobalScoreRankJob"); - public UpdateGlobalScoreRankJob(ILogger logger, ICardDbContext cardDbContext) + public UpdateGlobalScoreRankJob(ILogger logger, + ICardDbContext cardDbContext, + IOptions authConfig) { this.logger = logger; this.cardDbContext = cardDbContext; + this.authConfig = authConfig.Value; } [SuppressMessage("ReSharper.DPA", "DPA0007: Large number of DB records", @@ -54,6 +61,20 @@ public class UpdateGlobalScoreRankJob : IJob var detail = avatarAndTitles.First(detail => detail.CardId == cardId); + var pref = "nesys"; + var lastPlayTenpoId = 1337; + var tenpoName = "GCLocalServer"; + if (authConfig.Enabled) + { + var result = int.TryParse(detail.LastPlayTenpoId, out lastPlayTenpoId); + if (!result) + { + lastPlayTenpoId = 1337; + } + pref = authConfig.Machines.FirstOrDefault(m => m.TenpoId == detail.LastPlayTenpoId)?.Pref ?? "nesys"; + tenpoName = authConfig.Machines.FirstOrDefault(m => m.TenpoId == detail.LastPlayTenpoId)?.TenpoName ?? "GCLocalServer"; + } + var globalRank = new GlobalScoreRank { CardId = cardId, @@ -61,10 +82,10 @@ public class UpdateGlobalScoreRankJob : IJob Fcol1 = detail.Fcol1, Area = "Local", AreaId = 1, - Pref = "nesys", + Pref = pref, PrefId = 1337, - LastPlayTenpoId = 1337, - TenpoName = "GCLocalServer", + LastPlayTenpoId = lastPlayTenpoId, + TenpoName = tenpoName, AvatarId = (int)detail.ScoreI1, Title = "Title", TitleId = detail.Fcol2, diff --git a/Application/Jobs/UpdateMonthlyScoreRankJob.cs b/Application/Jobs/UpdateMonthlyScoreRankJob.cs index ce01ccb..63be41b 100644 --- a/Application/Jobs/UpdateMonthlyScoreRankJob.cs +++ b/Application/Jobs/UpdateMonthlyScoreRankJob.cs @@ -1,5 +1,7 @@ -using Domain.Entities; +using Domain.Config; +using Domain.Entities; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Quartz; namespace Application.Jobs; @@ -10,12 +12,17 @@ public class UpdateMonthlyScoreRankJob : IJob private readonly ICardDbContext cardDbContext; + private readonly AuthConfig authConfig; + public static readonly JobKey KEY = new JobKey("UpdateMonthlyScoreRankJob"); - public UpdateMonthlyScoreRankJob(ILogger logger, ICardDbContext cardDbContext) + public UpdateMonthlyScoreRankJob(ILogger logger, + ICardDbContext cardDbContext, + IOptions authConfig) { this.logger = logger; this.cardDbContext = cardDbContext; + this.authConfig = authConfig.Value; } public async Task Execute(IJobExecutionContext context) @@ -51,24 +58,38 @@ public class UpdateMonthlyScoreRankJob : IJob var detail = avatarAndTitles.First(detail => detail.CardId == cardId); - var globalRank = new MonthlyScoreRank + var pref = "nesys"; + var lastPlayTenpoId = 1337; + var tenpoName = "GCLocalServer"; + if (authConfig.Enabled) + { + var result = int.TryParse(detail.LastPlayTenpoId, out lastPlayTenpoId); + if (!result) + { + lastPlayTenpoId = 1337; + } + pref = authConfig.Machines.FirstOrDefault(m => m.TenpoId == detail.LastPlayTenpoId)?.Pref ?? "nesys"; + tenpoName = authConfig.Machines.FirstOrDefault(m => m.TenpoId == detail.LastPlayTenpoId)?.TenpoName ?? "GCLocalServer"; + } + + var monthlyScoreRank = new MonthlyScoreRank { CardId = cardId, PlayerName = card.PlayerName, Fcol1 = detail.Fcol1, Area = "Local", AreaId = 1, - Pref = "nesys", + Pref = pref, PrefId = 1337, - LastPlayTenpoId = 1337, - TenpoName = "GCLocalServer", + LastPlayTenpoId = lastPlayTenpoId, + TenpoName = tenpoName, AvatarId = (int)detail.ScoreI1, Title = "Title", TitleId = detail.Fcol2, TotalScore = score }; - ranks.Add(globalRank); + ranks.Add(monthlyScoreRank); } ranks.AddRange(GetFakeRanks()); diff --git a/Domain/Config/RankConfig.cs b/Domain/Config/RankConfig.cs new file mode 100644 index 0000000..b72623d --- /dev/null +++ b/Domain/Config/RankConfig.cs @@ -0,0 +1,8 @@ +namespace Domain.Config; + +public class RankConfig +{ + public const string RANK_SECTION = "Rank"; + + public int RefreshIntervalHours { get; set; } = 24; +} \ No newline at end of file diff --git a/Domain/Enums/CardRequestType.cs b/Domain/Enums/CardRequestType.cs index b19c0ed..5c1fd75 100644 --- a/Domain/Enums/CardRequestType.cs +++ b/Domain/Enums/CardRequestType.cs @@ -13,8 +13,10 @@ public enum CardRequestType ReadSkin = 422, ReadTitle = 424, ReadMusic = 428, + ReadMusicDetail = 428, ReadEventReward = 441, ReadNavigator = 443, + ReadWMusicDetail = 428, ReadMusicExtra = 465, ReadMusicAou = 467, ReadCoin = 468, @@ -42,11 +44,13 @@ public enum CardRequestType WriteCardBData = 776, WriteAvatar = 929, WriteItem = 931, + WriteSkin = 933, WriteTitle = 935, + WriteMusic = 939, WriteMusicDetail = 941, + WriteWMusicDetail = 961, WriteNavigator = 954, WriteCoin = 980, - WriteSkin = 933, WriteUnlockKeynum = 1020, WriteSoundEffect = 8969, diff --git a/Domain/Enums/RankingCommandType.cs b/Domain/Enums/RankingCommandType.cs index ae7e7a4..696710e 100644 --- a/Domain/Enums/RankingCommandType.cs +++ b/Domain/Enums/RankingCommandType.cs @@ -2,9 +2,12 @@ public enum RankingCommandType { - GlobalRank = 4119, - PlayNumRank = 6657, - EventRank = 6661, - MonthlyRank = 6666, - ShopRank = 4098 + ShopRank = 4098, + GlobalRank = 4119, + PlayNumRank = 6657, + EventRank = 6661, + WScoreRank = 6663, + WPlayNumRank = 6664, + WShopRank = 6665, + MonthlyRank = 6666 } \ No newline at end of file diff --git a/Infrastructure/Common/CertificateService.cs b/Infrastructure/Common/CertificateService.cs index 39588f1..812ac7e 100644 --- a/Infrastructure/Common/CertificateService.cs +++ b/Infrastructure/Common/CertificateService.cs @@ -264,7 +264,7 @@ public class CertificateService { var store = new X509Store(StoreName.My, StoreLocation.LocalMachine); store.Open(OpenFlags.ReadOnly); - var result = store.Certificates.Find(X509FindType.FindByIssuerName, ROOT_CA_CN, true); + var result = store.Certificates.Find(X509FindType.FindByIssuerName, ROOT_CA_CN, false); certificateExists = result.Count != 0; diff --git a/MainServer/Configurations/rank.json b/MainServer/Configurations/rank.json new file mode 100644 index 0000000..a8797ed --- /dev/null +++ b/MainServer/Configurations/rank.json @@ -0,0 +1,5 @@ +{ + "Rank": { + "RefreshIntervalHours" : 12 + } +} \ No newline at end of file diff --git a/MainServer/Controllers/Game/CardController.cs b/MainServer/Controllers/Game/CardController.cs index 936712b..063d815 100644 --- a/MainServer/Controllers/Game/CardController.cs +++ b/MainServer/Controllers/Game/CardController.cs @@ -63,7 +63,7 @@ public class CardController : BaseController CardRequestType.WriteCard => await Mediator.Send(new WriteCardCommand(request.CardId, request.Data)), CardRequestType.WriteCardDetail => await Mediator.Send( - new WriteCardDetailCommand(request.CardId, request.Data)), + new WriteCardDetailCommand(request.CardId, request.TenpoId, request.Data)), CardRequestType.WriteCardBData => await Mediator.Send( new WriteCardBDataCommand(request.CardId, request.Data)), CardRequestType.WriteAvatar => await Mediator.Send(new WriteAvatarCommand(request.CardId, diff --git a/MainServer/Controllers/Game/RankingController.cs b/MainServer/Controllers/Game/RankingController.cs index 0601dff..e71ebcc 100644 --- a/MainServer/Controllers/Game/RankingController.cs +++ b/MainServer/Controllers/Game/RankingController.cs @@ -19,12 +19,15 @@ public class RankingController : BaseController var result = type switch { - RankingCommandType.GlobalRank => await Mediator.Send(new GetGlobalScoreRankQuery(param)), - RankingCommandType.PlayNumRank => await Mediator.Send(new GetPlayNumRankQuery()), - RankingCommandType.EventRank => await Mediator.Send(new GetEventRankQuery()), - RankingCommandType.MonthlyRank => await Mediator.Send(new GetMonthlyScoreRankQuery()), - RankingCommandType.ShopRank => await Mediator.Send(new GetTenpoScoreRankQuery(tenpoId, param)), - _ => throw new ArgumentOutOfRangeException(nameof(type), type, "Should not happen!") + RankingCommandType.GlobalRank => await Mediator.Send(new GetGlobalScoreRankQuery(param)), + RankingCommandType.PlayNumRank => await Mediator.Send(new GetPlayNumRankQuery()), + RankingCommandType.EventRank => await Mediator.Send(new GetEventRankQuery()), + RankingCommandType.MonthlyRank => await Mediator.Send(new GetMonthlyScoreRankQuery()), + RankingCommandType.ShopRank => await Mediator.Send(new GetTenpoScoreRankQuery(tenpoId, param)), + RankingCommandType.WScoreRank => await Mediator.Send(new GetWScoreRankQuery(param)), + RankingCommandType.WPlayNumRank => await Mediator.Send(new GetWPlayNumRankQuery()), + RankingCommandType.WShopRank => await Mediator.Send(new GetWTenpoScoreRankQuery(tenpoId, param)), + _ => throw new ArgumentOutOfRangeException(nameof(type), type, "Should not happen!") }; if (result.Succeeded) diff --git a/MainServer/Program.cs b/MainServer/Program.cs index 091ddac..9dbb298 100644 --- a/MainServer/Program.cs +++ b/MainServer/Program.cs @@ -1,3 +1,4 @@ +using System.Net.Security; using System.Reflection; using System.Security.Authentication; using System.Text; @@ -30,7 +31,7 @@ try Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); ChoETLFrxBootstrap.IsSandboxEnvironment = true; var builder = WebApplication.CreateBuilder(args); - + // Add services to the container. const string configurationsDirectory = "Configurations"; builder.Configuration @@ -40,6 +41,7 @@ try .AddJsonFile($"{configurationsDirectory}/events.json", optional: true, reloadOnChange: false) .AddJsonFile($"{configurationsDirectory}/matching.json", optional: true, reloadOnChange: false) .AddJsonFile($"{configurationsDirectory}/auth.json", optional: true, reloadOnChange: false) + .AddJsonFile($"{configurationsDirectory}/rank.json", optional: true, reloadOnChange: false) .AddJsonFile($"{configurationsDirectory}/server.json", optional: true, reloadOnChange: false); builder.Services.Configure( @@ -50,6 +52,8 @@ try builder.Configuration.GetSection(GameConfig.GAME_SECTION)); builder.Services.Configure( builder.Configuration.GetSection(AuthConfig.AUTH_SECTION)); + builder.Services.Configure( + builder.Configuration.GetSection(RankConfig.RANK_SECTION)); var serverIp = builder.Configuration["ServerIp"] ?? "127.0.0.1"; var certificateManager = new CertificateService(serverIp, new SerilogLoggerFactory(Log.Logger).CreateLogger("")); @@ -76,7 +80,9 @@ try builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); - builder.Services.AddApplication(); + var refreshIntervalHours = builder.Configuration.GetSection(RankConfig.RANK_SECTION). + GetValue("RefreshIntervalHours"); + builder.Services.AddApplication(refreshIntervalHours); builder.Services.AddInfrastructure(builder.Configuration); builder.Services.AddResponseCompression(options =>