forked from Raphael/SCHALE.GameServer
Remove AutoMapper and Auto Generate Password
This commit is contained in:
parent
39316c95ff
commit
bdc7125d5f
|
@ -1,5 +1,4 @@
|
||||||
using AutoMapper;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using SCHALE.Common.Database;
|
using SCHALE.Common.Database;
|
||||||
using SCHALE.Common.Database.ModelExtensions;
|
using SCHALE.Common.Database.ModelExtensions;
|
||||||
using SCHALE.Common.FlatData;
|
using SCHALE.Common.FlatData;
|
||||||
|
@ -13,15 +12,13 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
ISessionKeyService _sessionKeyService,
|
ISessionKeyService _sessionKeyService,
|
||||||
SCHALEContext _context,
|
SCHALEContext _context,
|
||||||
ExcelTableService _excelTableService,
|
ExcelTableService _excelTableService,
|
||||||
ILogger<Echelon> _logger,
|
ILogger<Echelon> _logger
|
||||||
IMapper _mapper
|
|
||||||
) : ProtocolHandlerBase(protocolHandlerFactory)
|
) : ProtocolHandlerBase(protocolHandlerFactory)
|
||||||
{
|
{
|
||||||
private readonly ISessionKeyService sessionKeyService = _sessionKeyService;
|
private readonly ISessionKeyService sessionKeyService = _sessionKeyService;
|
||||||
private readonly SCHALEContext context = _context;
|
private readonly SCHALEContext context = _context;
|
||||||
private readonly ExcelTableService excelTableService = _excelTableService;
|
private readonly ExcelTableService excelTableService = _excelTableService;
|
||||||
private readonly ILogger<Echelon> logger = _logger;
|
private readonly ILogger<Echelon> logger = _logger;
|
||||||
private readonly IMapper mapper = _mapper;
|
|
||||||
|
|
||||||
[ProtocolHandler(Protocol.Echelon_List)]
|
[ProtocolHandler(Protocol.Echelon_List)]
|
||||||
public ResponsePacket ListHandler(EchelonListRequest req)
|
public ResponsePacket ListHandler(EchelonListRequest req)
|
||||||
|
@ -35,23 +32,11 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
public ResponsePacket SaveHandler(EchelonSaveRequest req)
|
public ResponsePacket SaveHandler(EchelonSaveRequest req)
|
||||||
{
|
{
|
||||||
var db = req.EchelonDB;
|
var db = req.EchelonDB;
|
||||||
var old = context.Echelons.FirstOrDefault(e =>
|
|
||||||
e.AccountServerId == db.AccountServerId
|
|
||||||
&& e.EchelonType == db.EchelonType
|
|
||||||
&& e.EchelonNumber == db.EchelonNumber
|
|
||||||
&& e.ExtensionType == db.ExtensionType
|
|
||||||
);
|
|
||||||
if (old == null)
|
|
||||||
context.Echelons.Add(db);
|
context.Echelons.Add(db);
|
||||||
else
|
|
||||||
{
|
|
||||||
// https://github.com/dotnet/efcore/issues/9156
|
|
||||||
context.Entry(old).State = EntityState.Detached;
|
|
||||||
mapper.Map(db, old);
|
|
||||||
context.Entry(old).State = EntityState.Modified;
|
|
||||||
}
|
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return new EchelonSaveResponse() { EchelonDB = db, };
|
|
||||||
|
return new EchelonSaveResponse() { EchelonDB = req.EchelonDB, };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
using System.Collections;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using AutoMapper;
|
using System.Text;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SCHALE.Common.Crypto;
|
||||||
using SCHALE.Common.Database;
|
using SCHALE.Common.Database;
|
||||||
using SCHALE.GameServer.Commands;
|
using SCHALE.GameServer.Commands;
|
||||||
using SCHALE.GameServer.Controllers.Api.ProtocolHandlers;
|
using SCHALE.GameServer.Controllers.Api.ProtocolHandlers;
|
||||||
|
@ -103,7 +105,6 @@ namespace SCHALE.GameServer
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
builder.Services.AddAutoMapper(typeof(GameServer));
|
|
||||||
builder.Services.AddProtocolHandlerFactory();
|
builder.Services.AddProtocolHandlerFactory();
|
||||||
builder.Services.AddMemorySessionKeyService();
|
builder.Services.AddMemorySessionKeyService();
|
||||||
builder.Services.AddExcelTableService();
|
builder.Services.AddExcelTableService();
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
|
||||||
<PackageReference Include="DotNetZip" Version="1.16.0" />
|
<PackageReference Include="DotNetZip" Version="1.16.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
using AutoMapper;
|
|
||||||
using SCHALE.Common.Database;
|
|
||||||
|
|
||||||
namespace SCHALE.GameServer.Services
|
|
||||||
{
|
|
||||||
public class MappingProfile : Profile
|
|
||||||
{
|
|
||||||
public MappingProfile()
|
|
||||||
{
|
|
||||||
CreateMap<EchelonDB, EchelonDB>().ForMember(x => x.ServerId, opt => opt.Ignore());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +1,12 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Google.FlatBuffers;
|
using Google.FlatBuffers;
|
||||||
using Ionic.Zip;
|
using Ionic.Zip;
|
||||||
using SCHALE.Common.Crypto;
|
using SCHALE.Common.Crypto;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace SCHALE.GameServer.Services
|
namespace SCHALE.GameServer.Services
|
||||||
{
|
{
|
||||||
|
@ -44,9 +46,11 @@ namespace SCHALE.GameServer.Services
|
||||||
|
|
||||||
private static async Task GetZip()
|
private static async Task GetZip()
|
||||||
{
|
{
|
||||||
|
|
||||||
string url = GetUrl();
|
string url = GetUrl();
|
||||||
string filePath = "TableBundles/Excel.zip";
|
string filePath = "TableBundles/Excel.zip";
|
||||||
string zipPath = Path.Combine(ResourcesFolder!, "download", filePath);
|
string zipPath = Path.Combine(ResourcesFolder!, "download", filePath);
|
||||||
|
|
||||||
ExcelFolder = zipPath[..^4];
|
ExcelFolder = zipPath[..^4];
|
||||||
if (File.Exists(zipPath))
|
if (File.Exists(zipPath))
|
||||||
return;
|
return;
|
||||||
|
@ -58,7 +62,9 @@ namespace SCHALE.GameServer.Services
|
||||||
byte[] content = await response.Content.ReadAsByteArrayAsync();
|
byte[] content = await response.Content.ReadAsByteArrayAsync();
|
||||||
File.WriteAllBytes(zipPath, content);
|
File.WriteAllBytes(zipPath, content);
|
||||||
using ZipFile zip = ZipFile.Read(zipPath);
|
using ZipFile zip = ZipFile.Read(zipPath);
|
||||||
zip.Password = "/wy5f3hIGGXLOIUDS9DZ";
|
//zip.Password = "/wy5f3hIGGXLOIUDS9DZ";
|
||||||
|
zip.Password = Convert.ToBase64String(TableService.CreatePassword(Path.GetFileName(filePath)));
|
||||||
|
|
||||||
foreach (ZipEntry e in zip)
|
foreach (ZipEntry e in zip)
|
||||||
{
|
{
|
||||||
e.Extract(ExcelFolder, ExtractExistingFileAction.OverwriteSilently);
|
e.Extract(ExcelFolder, ExtractExistingFileAction.OverwriteSilently);
|
||||||
|
|
Loading…
Reference in New Issue