From cafabbdb38695d81e05989ba57632519516d8662 Mon Sep 17 00:00:00 2001 From: a4plane Date: Fri, 13 Dec 2024 14:33:15 +0900 Subject: [PATCH] oiegrjoergojeroigjoeirgjoer --- rtjiory/Jobini.cs | 8 +++++- rtjiory/Program.cs | 55 ++++++++++++++++++++++++------------------ rtjiory/Setting.txt | 2 ++ rtjiory/rtjiory.csproj | 2 ++ 4 files changed, 43 insertions(+), 24 deletions(-) diff --git a/rtjiory/Jobini.cs b/rtjiory/Jobini.cs index 3535770..ded1ece 100644 --- a/rtjiory/Jobini.cs +++ b/rtjiory/Jobini.cs @@ -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; + } /// /// inijob클래스를 생성합니다. 생성전에 데이터를 전부 삭제합니다. /// @@ -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() diff --git a/rtjiory/Program.cs b/rtjiory/Program.cs index b49beb3..15a3c4d 100644 --- a/rtjiory/Program.cs +++ b/rtjiory/Program.cs @@ -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 settingValues = []; -//Dictionary scoreDB = []; +Dictionary 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 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 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>(); - 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"); diff --git a/rtjiory/Setting.txt b/rtjiory/Setting.txt index e69de29..c1f145e 100644 --- a/rtjiory/Setting.txt +++ b/rtjiory/Setting.txt @@ -0,0 +1,2 @@ +minArrowNum = 10 +maxArrowNum = 304 \ No newline at end of file diff --git a/rtjiory/rtjiory.csproj b/rtjiory/rtjiory.csproj index 24b8f63..1245750 100644 --- a/rtjiory/rtjiory.csproj +++ b/rtjiory/rtjiory.csproj @@ -5,6 +5,8 @@ enable enable AnyCPU;ARM64 + False + False