public bool SaveConfig(SummaryCountModel model) { try { if (model == null) { return(false); } if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } string path = configPath + fileName; //把配置信息写入文件 string json = JsonConvert.SerializeObject(model); File.WriteAllText(path, json); return(true); } catch (Exception) { return(false); } }
public SummaryCountModel GetHistory() { SummaryCountModel model; string path = configPath + fileName; try { if (File.Exists(path)) { string config = File.ReadAllText(path); model = JsonConvert.DeserializeObject <SummaryCountModel>(config); } else { model = new SummaryCountModel(); } return(model); } catch (Exception) { return(null); } }