[성현모] master모드 추가
This commit is contained in:
97
Projects/NetStandard/CIAMaster/CIAMasterService.cs
Normal file
97
Projects/NetStandard/CIAMaster/CIAMasterService.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using CIAMaster.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace CIAMaster
|
||||
{
|
||||
public class CIAMasterService
|
||||
{
|
||||
public static MasterTable MasterTable { get; set; } = new MasterTable();
|
||||
public static MasterReportTable MasterReportTable { get; set; } = new MasterReportTable();
|
||||
|
||||
public static string CIAMasterTableaPath { get; set; } = @"./";
|
||||
public static string CIAMasterReportTableaPath { get; set; } = @"./";
|
||||
|
||||
public CIAMasterService()
|
||||
{
|
||||
}
|
||||
|
||||
public static bool LoadCIAMasterTable()
|
||||
{
|
||||
try
|
||||
{
|
||||
string path = $"{CIAMasterTableaPath}/CIAMasterTable.json";
|
||||
|
||||
if (File.Exists(path) == true)
|
||||
{
|
||||
var ciaMasterTableJson = File.ReadAllText(path);
|
||||
MasterTable = JsonConvert.DeserializeObject<MasterTable>(ciaMasterTableJson);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"LoadCIAMasterTable Error::{e.Message}");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool SaveCIAMasterTable()
|
||||
{
|
||||
try
|
||||
{
|
||||
string ciaMasterTableJson = JsonConvert.SerializeObject(MasterTable, Formatting.Indented);
|
||||
File.WriteAllText($"{CIAMasterTableaPath}/CIAMasterTable.json", ciaMasterTableJson);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine($"SaveCIAMasterTable Error::{e.Message}");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static bool LoadCIAMasterReportTable()
|
||||
{
|
||||
try
|
||||
{
|
||||
string path = $"{CIAMasterReportTableaPath}/CIAMasterReportTable.json";
|
||||
if(File.Exists(path) == true)
|
||||
{
|
||||
var ciaMasterReportTableJson = File.ReadAllText(path);
|
||||
MasterReportTable = JsonConvert.DeserializeObject<MasterReportTable>(ciaMasterReportTableJson);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"LoadCIAMasterReportTable Error::{e.Message}");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool SaveCIAMasterReportTable()
|
||||
{
|
||||
try
|
||||
{
|
||||
string ciaMsterReportTableJson = JsonConvert.SerializeObject(MasterReportTable, Formatting.Indented);
|
||||
File.WriteAllText($"{CIAMasterReportTableaPath}/CIAMasterReportTable.json", ciaMsterReportTableJson);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine($"SaveCIAMasterReportTable Error::{e.Message}");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user