private int RmvSubDeviceToFile(SubDevicesInfo subDevicesInfo) { try { string content = ReadJsonFile(); SubDevInfo subDevInfo = JsonUtil.ConvertJsonStringToObject <SubDevInfo>(content); if (subDevInfo.subdevices == null) { return(0); } foreach (DeviceInfo dev in subDevicesInfo.devices) { subDevInfo.subdevices.Remove(dev.nodeId); subDevInfo.version = subDevicesInfo.version; } File.WriteAllText(path, JsonUtil.ConvertObjectToJsonString(subDevInfo)); } catch (Exception ex) { Log.Error("remove sub device fail in json file"); return(-1); } return(0); }
public SubDevicesFilePersistence() { string content = ReadJsonFile(); this.subDevInfoCache = JsonUtil.ConvertJsonStringToObject <SubDevInfo>(content); Log.Info("subDevInfo:" + subDevInfoCache.ToString()); }