oiegrjoergojeroigjoeirgjoer
This commit is contained in:
+7
-1
@@ -22,6 +22,11 @@ public class Jobini
|
||||
private readonly string filePath;
|
||||
|
||||
//어떻게 이름이 ini ini t
|
||||
public Jobini(string filePath)
|
||||
{
|
||||
this.iniData = ReadSetting(filePath);
|
||||
this.filePath = filePath;
|
||||
}
|
||||
/// <summary>
|
||||
/// inijob클래스를 생성합니다. 생성전에 데이터를 전부 삭제합니다.
|
||||
/// </summary>
|
||||
@@ -36,6 +41,7 @@ public class Jobini
|
||||
//File.Delete(filePath);
|
||||
this.iniData = ReadSetting(filePath);
|
||||
this.filePath = filePath;
|
||||
//file file = new();
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +112,7 @@ public class Jobini
|
||||
return ivalue;
|
||||
}
|
||||
this.IniWrite(key, value);
|
||||
return "0";
|
||||
return value;
|
||||
}
|
||||
|
||||
public int IniCount()
|
||||
|
||||
+32
-23
@@ -3,8 +3,9 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Net.Sockets;
|
||||
using System.Timers;
|
||||
using static Jobini;
|
||||
//using static Jobini;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -16,11 +17,12 @@ var app = builder.Build();
|
||||
string filePath = "Setting.txt";
|
||||
string scoreDbPath = "Score.txt";
|
||||
|
||||
//ini클래스라 해놓고 정작 파일 확장자는 txt로 설정한게 어이없네
|
||||
Jobini settingini = new(filePath);
|
||||
Jobini scoreDBini = new(scoreDbPath);
|
||||
|
||||
//Dictionary<string, string> settingValues = [];
|
||||
//Dictionary<string, int> scoreDB = [];
|
||||
Dictionary<string, string> scoreDB = [];
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
@@ -29,24 +31,29 @@ if (!app.Environment.IsDevelopment())
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
//csp이슈 고쳐야함 브라우저에서 csp때문에 신호 자체를 안보냄 다행히 유니티에서 보내는것은 csp체크가 꺼져있는듯
|
||||
//그래서 어떻게 고침?
|
||||
//대충 프론트엔드 문제라 하고 떠넘기죠?
|
||||
//app.Use(async (context, next) =>
|
||||
//{
|
||||
// context.Response.Headers.Append("Content-Security-Policy", "base-uri 'self'; default-src 'self'; img-src data: https:; object-src 'none'; script-src 'self'; style-src 'self'; upgrade-insecure-requests;");
|
||||
// await next();
|
||||
//});
|
||||
|
||||
//Dictionary<string, int> scoreDB= [];
|
||||
//scoreDB = [];
|
||||
|
||||
//기록하기
|
||||
app.MapPost("submit", (string name, int score) =>
|
||||
{
|
||||
|
||||
var dbKey = scoreDBini.IniRead(name);
|
||||
if (dbKey != null)
|
||||
if (dbKey != null)//scoreDB.ContainsKey(name))
|
||||
{
|
||||
int value = int.Parse(dbKey);
|
||||
if (value < score)
|
||||
|
||||
if (value < score)//scoreDB[name] < score)
|
||||
{
|
||||
//scoreDB[name ] = score;
|
||||
scoreDBini.IniWrite(name, score.ToString());
|
||||
}
|
||||
return Results.Ok(new { Message = "A" });
|
||||
@@ -62,24 +69,25 @@ app.MapPost("submit", (string name, int score) =>
|
||||
List<int> weekArrow = [];
|
||||
|
||||
//weekly Jobs (dbReset, WeekArrowGen...)
|
||||
System.Timers.Timer resetTimer = new System.Timers.Timer(1000); // 10000ms = 10 seconds => 1week = ?ms mol ra si bal
|
||||
System.Timers.Timer resetTimer = new(10000); // 10000ms = 10 seconds => 1week = ?ms mol ra si bal
|
||||
resetTimer.Elapsed += (sender, e) =>
|
||||
{
|
||||
TimeOnly curTime = new(DateTime.Now.Hour, DateTime.Now.Minute);
|
||||
TimeOnly tarTime = new(0, 0); //아마 오전 12시?
|
||||
if (System.TimeOnly.Equals(curTime, tarTime))
|
||||
{
|
||||
weekArrow.Clear();
|
||||
}
|
||||
//TimeOnly curTime = new(DateTime.Now.Hour, DateTime.Now.Minute);
|
||||
//TimeOnly tarTime = new(0, 0); //아마 오전 12시?
|
||||
//if (System.TimeOnly.Equals(curTime, tarTime))
|
||||
//{
|
||||
// weekArrow.Clear();
|
||||
//}
|
||||
//weekArrow.Clear();
|
||||
// Log reset actio
|
||||
var logger = app.Services.GetRequiredService<ILogger<Program>>();
|
||||
logger.LogInformation("doWeekJobs");
|
||||
//logger.LogInformation("doWeekJobs");
|
||||
|
||||
// Clear the scoreDB
|
||||
scoreDBini.Clear();
|
||||
weekArrow.Clear();
|
||||
Random random = new();
|
||||
for (int i = 0; i < random.NextInt64(int.Parse(scoreDBini.NotNullableiniRead("minArrowNum")), int.Parse(scoreDBini.NotNullableiniRead("maxArrowNum"))); i++)
|
||||
for (int i = 0; i < random.NextInt64(int.Parse(settingini.NotNullableiniRead("minArrowNum","10")), int.Parse(settingini.NotNullableiniRead("maxArrowNum","30"))/*10,30*/); i++)
|
||||
{
|
||||
int rngNum = (int)random.NextInt64(0, 4);
|
||||
weekArrow.Add(rngNum/*(int)random.NextInt64(0, 4)*/);
|
||||
@@ -87,16 +95,16 @@ resetTimer.Elapsed += (sender, e) =>
|
||||
}
|
||||
|
||||
};
|
||||
Random random = new();
|
||||
for (int i = 0; i < random.NextInt64(int.Parse(scoreDBini.NotNullableiniRead("minArrowNum")), int.Parse(scoreDBini.NotNullableiniRead("maxArrowNum"))); i++)
|
||||
{
|
||||
int rngNum = (int)random.NextInt64(0, 4);
|
||||
weekArrow.Add(rngNum/*(int)random.NextInt64(0, 4)*/);
|
||||
//logger.LogInformation(rngNum.ToString());
|
||||
}//자기 자신이 읽고있다고 못 읽으면 난 뭐 어떻게 받아들여야함?
|
||||
//Random random = new();
|
||||
//for (int i = 0; i < random.NextInt64(10,30/*int.Parse(scoreDBini.NotNullableiniRead("minArrowNum")), int.Parse(scoreDBini.NotNullableiniRead("maxArrowNum"))*/); i++)
|
||||
//{
|
||||
// int rngNum = (int)random.NextInt64(0, 4);
|
||||
// weekArrow.Add(rngNum/*(int)random.NextInt64(0, 4)*/);
|
||||
// //logger.LogInformation(rngNum.ToString());
|
||||
//}//자기 자신이 읽고있다고 못 읽으면 난 뭐 어떻게 받아들여야함? => resetTimer가 메인 스레드가 아닌 다른 스레드에서 동작한다는 카더라가 있음
|
||||
resetTimer.Start();
|
||||
//기록된 점수 얻기
|
||||
app.MapGet("/", () => scoreDBini.ReadDictionary);
|
||||
app.MapGet("/", () => /*scoreDB);*/scoreDB = scoreDBini.ReadDictionary());//scoreDBini.ReadDictionary);
|
||||
|
||||
app.MapGet("WeekArrow", () => weekArrow
|
||||
);
|
||||
@@ -112,4 +120,5 @@ app.UseRouting();
|
||||
|
||||
app.MapRazorPages();
|
||||
|
||||
app.Run("http://localhost:5000");
|
||||
//이미minio에서 8000~8001사용중
|
||||
app.Run("http://localhost:8004");
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
minArrowNum = 10
|
||||
maxArrowNum = 304
|
||||
@@ -5,6 +5,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Platforms>AnyCPU;ARM64</Platforms>
|
||||
<PublishAot>False</PublishAot>
|
||||
<PublishTrimmed>False</PublishTrimmed>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
Reference in New Issue
Block a user