Update to support custom rank update interval.
Add support for accurate tenpo score rank.
This commit is contained in:
parent
64da380363
commit
48956e758f
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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;
|
||||
|
@ -3,7 +3,7 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Application.Game.Card.Write;
|
||||
|
||||
public record WriteCardDetailCommand(long CardId, string Data) : IRequestWrapper<string>;
|
||||
public record WriteCardDetailCommand(long CardId, string TenpoId, string Data) : IRequestWrapper<string>;
|
||||
|
||||
public class WriteDetailCommandHandler : RequestHandlerBase<WriteCardDetailCommand, string>
|
||||
{
|
||||
@ -28,6 +28,7 @@ public class WriteDetailCommandHandler : RequestHandlerBase<WriteCardDetailComma
|
||||
var detail = dto.DtoToCardDetail();
|
||||
detail.CardId = request.CardId;
|
||||
detail.LastPlayTime = DateTime.Now;
|
||||
detail.LastPlayTenpoId = request.TenpoId;
|
||||
await CardDbContext.CardDetails.Upsert(detail).RunAsync(cancellationToken);
|
||||
|
||||
await CardDbContext.SaveChangesAsync(cancellationToken);
|
||||
|
@ -16,11 +16,13 @@ public class GetGlobalScoreRankQueryHandler : IRequestHandlerWrapper<GetGlobalSc
|
||||
public async Task<ServiceResult<string>> Handle(GetGlobalScoreRankQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var param = request.Param.DeserializeCardData<RankParam>();
|
||||
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<string>(ServiceError.ValidationFormat)
|
||||
};
|
||||
}
|
||||
|
||||
private async Task<ServiceResult<string>> GetCardRank(long cardId,
|
||||
@ -80,6 +82,42 @@ public class GetGlobalScoreRankQueryHandler : IRequestHandlerWrapper<GetGlobalSc
|
||||
|
||||
return new ServiceResult<string>(container.SerializeCardData());
|
||||
}
|
||||
|
||||
private async Task<ServiceResult<string>> 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<string>(container.SerializeCardData());
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot("root")]
|
||||
|
@ -77,7 +77,7 @@ public class GetTenpoScoreRankQueryHandler : IRequestHandlerWrapper<GetTenpoScor
|
||||
Ranks = dtoList,
|
||||
Status = new RankStatus
|
||||
{
|
||||
TableName = "TenpoScoreRank",
|
||||
TableName = "CardTenpoScoreRank",
|
||||
StartDate = TimeHelper.DateToString(DateTime.Today),
|
||||
EndDate = TimeHelper.DateToString(DateTime.Today),
|
||||
Rows = dtoList.Count,
|
||||
@ -87,16 +87,4 @@ public class GetTenpoScoreRankQueryHandler : IRequestHandlerWrapper<GetTenpoScor
|
||||
|
||||
return new ServiceResult<string>(container.SerializeCardData());
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot("root")]
|
||||
public class TenpoScoreRankContainer
|
||||
{
|
||||
[XmlArray(ElementName = "t_score_rank")]
|
||||
[XmlArrayItem(ElementName = "record")]
|
||||
// ReSharper disable once UnusedAutoPropertyAccessor.Global
|
||||
public List<ScoreRankDto> Ranks { get; init; } = new();
|
||||
|
||||
[XmlElement("ranking_status")]
|
||||
public RankStatus Status { get; set; } = new();
|
||||
}
|
||||
}
|
61
Application/Game/Rank/GetWPlayNumRankQuery.cs
Normal file
61
Application/Game/Rank/GetWPlayNumRankQuery.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System.Diagnostics;
|
||||
using Application.Common.Helpers;
|
||||
|
||||
namespace Application.Game.Rank;
|
||||
|
||||
public record GetWPlayNumRankQuery(): IRequestWrapper<string>;
|
||||
|
||||
public class GetWPlayNumRankQueryHandler : IRequestHandlerWrapper<GetWPlayNumRankQuery, string>
|
||||
{
|
||||
private readonly ICardDbContext cardDbContext;
|
||||
|
||||
public GetWPlayNumRankQueryHandler(ICardDbContext cardDbContext)
|
||||
{
|
||||
this.cardDbContext = cardDbContext;
|
||||
}
|
||||
|
||||
public async Task<ServiceResult<string>> 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<string>(result);
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot("root")]
|
||||
public class WPlayNumRankContainer
|
||||
{
|
||||
[XmlArray(ElementName = "w_play_num_rank")]
|
||||
[XmlArrayItem(ElementName = "record")]
|
||||
// ReSharper disable once UnusedAutoPropertyAccessor.Global
|
||||
public List<PlayNumRankDto> Ranks { get; init; } = new();
|
||||
|
||||
[XmlElement("ranking_status")]
|
||||
public RankStatus Status { get; set; } = new();
|
||||
}
|
||||
|
96
Application/Game/Rank/GetWScoreRankQuery.cs
Normal file
96
Application/Game/Rank/GetWScoreRankQuery.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using Application.Common.Helpers;
|
||||
|
||||
namespace Application.Game.Rank;
|
||||
|
||||
public record GetWScoreRankQuery(string Param) : IRequestWrapper<string>;
|
||||
|
||||
public class GetWScoreRankQueryHandler : IRequestHandlerWrapper<GetWScoreRankQuery, string>
|
||||
{
|
||||
private readonly ICardDbContext cardDbContext;
|
||||
|
||||
public GetWScoreRankQueryHandler(ICardDbContext cardDbContext)
|
||||
{
|
||||
this.cardDbContext = cardDbContext;
|
||||
}
|
||||
|
||||
public async Task<ServiceResult<string>> Handle(GetWScoreRankQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var param = request.Param.DeserializeCardData<RankParam>();
|
||||
if (param.CardId == 0)
|
||||
{
|
||||
return await GetAllRanks(cancellationToken);
|
||||
}
|
||||
return await GetCardRank(param.CardId, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task<ServiceResult<string>> GetCardRank(long cardId,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var rank = await cardDbContext.GlobalScoreRanks.FirstOrDefaultAsync(scoreRank => scoreRank.CardId == cardId,
|
||||
cancellationToken: cancellationToken);
|
||||
var container = new GlobalScoreRankContainer
|
||||
{
|
||||
Ranks = new List<ScoreRankDto>(),
|
||||
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<string>(container.SerializeCardData());
|
||||
}
|
||||
|
||||
var dto = rank.ScoreRankToDto();
|
||||
dto.Id = 0;
|
||||
container.Ranks.Add(dto);
|
||||
container.Status.Rows++;
|
||||
return new ServiceResult<string>(container.SerializeCardData());
|
||||
}
|
||||
|
||||
private async Task<ServiceResult<string>> 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<string>(container.SerializeCardData());
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot("root")]
|
||||
public class WScoreRankContainer
|
||||
{
|
||||
[XmlArray(ElementName = "w_score_rank")]
|
||||
[XmlArrayItem(ElementName = "record")]
|
||||
// ReSharper disable once UnusedAutoPropertyAccessor.Global
|
||||
public List<ScoreRankDto> Ranks { get; init; } = new();
|
||||
|
||||
[XmlElement("ranking_status")]
|
||||
public RankStatus Status { get; set; } = new();
|
||||
}
|
||||
|
102
Application/Game/Rank/GetWTenpoScoreRankQuery.cs
Normal file
102
Application/Game/Rank/GetWTenpoScoreRankQuery.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using Application.Common.Helpers;
|
||||
|
||||
namespace Application.Game.Rank;
|
||||
|
||||
public record GetWTenpoScoreRankQuery(int TenpoId, string Param) : IRequestWrapper<string>;
|
||||
|
||||
public class GetWTenpoScoreRankQueryHandler : IRequestHandlerWrapper<GetWTenpoScoreRankQuery, string>
|
||||
{
|
||||
private readonly ICardDbContext cardDbContext;
|
||||
|
||||
public GetWTenpoScoreRankQueryHandler(ICardDbContext cardDbContext)
|
||||
{
|
||||
this.cardDbContext = cardDbContext;
|
||||
}
|
||||
|
||||
public async Task<ServiceResult<string>> Handle(GetWTenpoScoreRankQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var param = request.Param.DeserializeCardData<RankParam>();
|
||||
if (param.CardId == 0)
|
||||
{
|
||||
return await GetAllRanks(request.TenpoId, cancellationToken);
|
||||
}
|
||||
return await GetCardRank(param.CardId, request.TenpoId, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task<ServiceResult<string>> 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<ScoreRankDto>(),
|
||||
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<string>(container.SerializeCardData());
|
||||
}
|
||||
|
||||
var dto = rank.ScoreRankToDto();
|
||||
dto.Id = 0;
|
||||
container.Ranks.Add(dto);
|
||||
container.Status.Rows++;
|
||||
return new ServiceResult<string>(container.SerializeCardData());
|
||||
}
|
||||
|
||||
private async Task<ServiceResult<string>> 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<string>(container.SerializeCardData());
|
||||
}
|
||||
}
|
||||
|
||||
[XmlRoot("root")]
|
||||
public class WTenpoScoreRankContainer
|
||||
{
|
||||
[XmlArray(ElementName = "w_t_score_rank")]
|
||||
[XmlArrayItem(ElementName = "record")]
|
||||
// ReSharper disable once UnusedAutoPropertyAccessor.Global
|
||||
public List<ScoreRankDto> Ranks { get; init; } = new();
|
||||
|
||||
[XmlElement("ranking_status")]
|
||||
public RankStatus Status { get; set; } = new();
|
||||
}
|
@ -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; }
|
||||
}
|
13
Application/Game/Rank/TenpoScoreRankContainer.cs
Normal file
13
Application/Game/Rank/TenpoScoreRankContainer.cs
Normal file
@ -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<ScoreRankDto> Ranks { get; init; } = new();
|
||||
|
||||
[XmlElement("ranking_status")]
|
||||
public RankStatus Status { get; set; } = new();
|
||||
}
|
@ -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<UpdateGlobalScoreRankJob> logger, ICardDbContext cardDbContext)
|
||||
public UpdateGlobalScoreRankJob(ILogger<UpdateGlobalScoreRankJob> logger,
|
||||
ICardDbContext cardDbContext,
|
||||
IOptions<AuthConfig> 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,
|
||||
|
@ -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<UpdateMonthlyScoreRankJob> logger, ICardDbContext cardDbContext)
|
||||
public UpdateMonthlyScoreRankJob(ILogger<UpdateMonthlyScoreRankJob> logger,
|
||||
ICardDbContext cardDbContext,
|
||||
IOptions<AuthConfig> 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());
|
||||
|
8
Domain/Config/RankConfig.cs
Normal file
8
Domain/Config/RankConfig.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Domain.Config;
|
||||
|
||||
public class RankConfig
|
||||
{
|
||||
public const string RANK_SECTION = "Rank";
|
||||
|
||||
public int RefreshIntervalHours { get; set; } = 24;
|
||||
}
|
@ -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,
|
||||
|
||||
|
@ -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
|
||||
}
|
@ -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;
|
||||
|
||||
|
5
MainServer/Configurations/rank.json
Normal file
5
MainServer/Configurations/rank.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"Rank": {
|
||||
"RefreshIntervalHours" : 12
|
||||
}
|
||||
}
|
@ -63,7 +63,7 @@ public class CardController : BaseController<CardController>
|
||||
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,
|
||||
|
@ -19,12 +19,15 @@ public class RankingController : BaseController<RankingController>
|
||||
|
||||
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)
|
||||
|
@ -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<EventConfig>(
|
||||
@ -50,6 +52,8 @@ try
|
||||
builder.Configuration.GetSection(GameConfig.GAME_SECTION));
|
||||
builder.Services.Configure<AuthConfig>(
|
||||
builder.Configuration.GetSection(AuthConfig.AUTH_SECTION));
|
||||
builder.Services.Configure<RankConfig>(
|
||||
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<int>("RefreshIntervalHours");
|
||||
builder.Services.AddApplication(refreshIntervalHours);
|
||||
builder.Services.AddInfrastructure(builder.Configuration);
|
||||
|
||||
builder.Services.AddResponseCompression(options =>
|
||||
|
Loading…
Reference in New Issue
Block a user