Jobini클래스 일부 업데이트
ReadDictionary메서드를 대채할 GetiniData메서드 추가 에러 핸들링을 가진 새로운 메서드임 ReadDictionary는 이제 사용되지 않는 메서드임 ClearLocalDictionaryData라는 새로운 메서드 추가 로컬 스토리지에 저장된 데이터에 들어있는 값을 삭제할 때 사용함 즉 값의 삭제 변경사항에 대하여 메모리에만 반영이 아닌 로컬 데이터에도 영구적인 반영이 필요할때 사용 위의 클래스 변경사항에 맞춰 메인 프로그램 코드도 일부의 수정이 되었음
This commit is contained in:
@@ -148,8 +148,44 @@ public class Jobini
|
|||||||
iniData.Clear();
|
iniData.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete("use GetiniData instead.")]
|
||||||
public Dictionary<string, string> ReadDictionary()
|
public Dictionary<string, string> ReadDictionary()
|
||||||
{
|
{
|
||||||
return this.iniData;
|
return this.iniData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 딕셔너리 데이터가 저장되있는 파일의 내용을 싹 지웁니다. 결과에 따라 bool형 반환이 존재합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>true = 정상적으로 작업이 수행됨, false = 어떠한 오류로 작업에 실패함</returns>
|
||||||
|
public bool ClearLocalDictionaryData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(File.Exists(this.filePath))
|
||||||
|
{
|
||||||
|
File.WriteAllText(this.filePath, "");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, string>? GetiniData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return iniData;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+5
-2
@@ -22,7 +22,7 @@ Jobini settingini = new(filePath);
|
|||||||
Jobini scoreDBini = new(scoreDbPath);
|
Jobini scoreDBini = new(scoreDbPath);
|
||||||
|
|
||||||
//Dictionary<string, string> settingValues = [];
|
//Dictionary<string, string> settingValues = [];
|
||||||
Dictionary<string, string> scoreDB = [];
|
//Dictionary<string, string> scoreDB = [];
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (!app.Environment.IsDevelopment())
|
if (!app.Environment.IsDevelopment())
|
||||||
@@ -85,6 +85,7 @@ resetTimer.Elapsed += (sender, e) =>
|
|||||||
|
|
||||||
// Clear the scoreDB
|
// Clear the scoreDB
|
||||||
scoreDBini.Clear();
|
scoreDBini.Clear();
|
||||||
|
//scoreDBini.ClearLocalDictionaryData();
|
||||||
weekArrow.Clear();
|
weekArrow.Clear();
|
||||||
Random random = new();
|
Random random = new();
|
||||||
for (int i = 0; i < random.NextInt64(int.Parse(settingini.NotNullableiniRead("minArrowNum","10")), int.Parse(settingini.NotNullableiniRead("maxArrowNum","30"))/*10,30*/); i++)
|
for (int i = 0; i < random.NextInt64(int.Parse(settingini.NotNullableiniRead("minArrowNum","10")), int.Parse(settingini.NotNullableiniRead("maxArrowNum","30"))/*10,30*/); i++)
|
||||||
@@ -104,10 +105,12 @@ resetTimer.Elapsed += (sender, e) =>
|
|||||||
//}//자기 자신이 읽고있다고 못 읽으면 난 뭐 어떻게 받아들여야함? => resetTimer가 메인 스레드가 아닌 다른 스레드에서 동작한다는 카더라가 있음 => jobini클래스에서 메서드 하나 빼먹었다고 생긴 문제인듯? 아마 해결됨
|
//}//자기 자신이 읽고있다고 못 읽으면 난 뭐 어떻게 받아들여야함? => resetTimer가 메인 스레드가 아닌 다른 스레드에서 동작한다는 카더라가 있음 => jobini클래스에서 메서드 하나 빼먹었다고 생긴 문제인듯? 아마 해결됨
|
||||||
resetTimer.Start();
|
resetTimer.Start();
|
||||||
//기록된 점수 얻기
|
//기록된 점수 얻기
|
||||||
app.MapGet("/", () => /*scoreDB);*/scoreDB = scoreDBini.ReadDictionary());//scoreDBini.ReadDictionary);
|
app.MapGet("/", () => scoreDBini.GetiniData());//scoreDBini.ReadDictionary);
|
||||||
|
|
||||||
app.MapGet("WeekArrow", () => weekArrow);
|
app.MapGet("WeekArrow", () => weekArrow);
|
||||||
|
|
||||||
|
//app.MapGet("cleartest", () => scoreDBini.ClearLocalDictionaryData());
|
||||||
|
|
||||||
//app.UseHttpsRedirection();
|
//app.UseHttpsRedirection();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user