using System; using System.Collections.Generic; using System.Data.SQLite; using System.Linq; using System.Text; using System.Threading.Tasks; using WindowsFormsApp1.entity; namespace WindowsFormsApp1.utils { //采集设置 class CollectSettingUtil { //获取采集时间 public static CollectSettings GetCollectTime() { Config config = SQLiteDataBaseUtil.getInstance().GetConfig("collect_settings_time_own"); if (config == null)//设置默认值 { return new CollectSettings(10, "00:00", "23:59", false, true); } else { //解析 return Newtonsoft.Json.JsonConvert.DeserializeObject( config.Value); } } //设置采集时间 public static void setCollectTime(CollectSettings setting) { Config config = new Config(); config.Key = "collect_settings_time_own"; config.Value = Newtonsoft.Json.JsonConvert.SerializeObject(setting) ; SQLiteDataBaseUtil.getInstance().AddConfig(config); } } class CollectSettings { private int timeSpan; private String startTime; private String endTime; private bool timeValid; private bool open; public CollectSettings(int timeSpan, string startTime, string endTime, bool timeValid, bool open) { this.timeSpan = timeSpan; this.startTime = startTime; this.endTime = endTime; this.timeValid = timeValid; this.open = open; } public CollectSettings() { } public int TimeSpan { get { return timeSpan; } set { this.timeSpan = value; } } public String StartTime { get { return startTime; } set { this.startTime = value; } } public String EndTime { get { return endTime; } set { this.endTime = value; } } public bool TimeValid { get { return timeValid; } set { this.timeValid = value; } } public bool Open { get { return open; } set { this.open = value; } } } }