namespace IStation.Service
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class Scada
|
{
|
Model.Scada _model = null;
|
readonly string _filePath = Path.Combine(Settings.ParasHelper.LocalFile.DataFolderDirectory, Settings.ParasHelper.LocalFile.ScadaFile);
|
|
/// <summary>
|
/// 获取
|
/// </summary>
|
public Model.Scada Get()
|
{
|
if (_model == null)
|
{
|
if (!File.Exists(_filePath))
|
return default;
|
var json = File.ReadAllText(_filePath);
|
_model = JsonHelper.Json2Object<Model.Scada>(json);
|
}
|
return _model;
|
}
|
|
/// <summary>
|
/// 保存
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public bool Save(Model.Scada model)
|
{
|
_model = model;
|
if (model == null)
|
return false;
|
var json = JsonHelper.Object2Json(model);
|
File.WriteAllText(_filePath, json);
|
return true;
|
}
|
|
|
}
|
}
|