// 从磁盘读取local.json反序列化为LocalJson对象 private static void LocalJsonInit() { if (!_localJsonInited) { lock (_localJsonlocker) { if (!_localJsonInited) { string localJson = SpecialPath.ReadLocalJsonFile(); if (!string.IsNullOrEmpty(localJson)) { try { LocalJsonDb data = VirtualRoot.JsonSerializer.Deserialize <LocalJsonDb>(localJson); _localJson = data; } catch (Exception e) { Logger.ErrorDebugLine(e.Message, e); } } else { _localJson = new LocalJsonDb(); } _localJsonInited = true; } } } }
// 从磁盘读取local.json反序列化为LocalJson对象 private static void LocalJsonInit() { if (!_localJsonInited) { lock (_localJsonlocker) { if (!_localJsonInited) { string localJson = SpecialPath.ReadLocalJsonFile(); if (!string.IsNullOrEmpty(localJson)) { try { LocalJsonDb data = VirtualRoot.JsonSerializer.Deserialize <LocalJsonDb>(localJson); _localJson = data ?? new LocalJsonDb(); } catch (Exception e) { Logger.ErrorDebugLine(e); } } else { _localJson = new LocalJsonDb(); } // 因为是群控作业,将开机启动和自动挖矿设置为true var repository = new LiteDbReadWriteRepository <MinerProfileData>(VirtualRoot.LocalDbFileFullName); MinerProfileData localProfile = repository.GetByKey(MinerProfileData.DefaultId); if (localProfile != null) { if (localProfile.IsAutoStart == false || localProfile.IsAutoBoot == false) { localProfile.IsAutoBoot = true; localProfile.IsAutoStart = true; repository.Update(localProfile); } } _localJson.MinerProfile.IsAutoBoot = true; _localJson.MinerProfile.IsAutoStart = true; // 这里的逻辑是,当用户在主界面填写矿工名时,矿工名会被交换到注册表从而当用户使用群控但没有填写群控矿工名时作为缺省矿工名 // 但是旧版本的挖矿端并没有把矿工名交换到注册表去所以当注册表中没有矿工名时需读取local.litedb中的矿工名 if (string.IsNullOrEmpty(_localJson.MinerProfile.MinerName)) { _localJson.MinerProfile.MinerName = NTMinerRegistry.GetMinerName(); if (string.IsNullOrEmpty(_localJson.MinerProfile.MinerName)) { if (localProfile != null) { _localJson.MinerProfile.MinerName = localProfile.MinerName; } } } _localJsonInited = true; } } } }
// 从磁盘读取local.json反序列化为LocalJson对象 private static void LocalJsonInit() { if (!_localJsonInited) { lock (_localJsonlocker) { if (!_localJsonInited) { string localJson = SpecialPath.ReadLocalJsonFile(); if (!string.IsNullOrEmpty(localJson)) { try { LocalJsonDb data = VirtualRoot.JsonSerializer.Deserialize <LocalJsonDb>(localJson); _localJson = data ?? new LocalJsonDb(); } catch (Exception e) { Logger.ErrorDebugLine(e); } } else { _localJson = new LocalJsonDb(); } // 这里的逻辑是,当用户在主界面填写矿工名时,矿工名会被交换到注册表从而当用户使用群控但没有填写群控矿工名时作为缺省矿工名 // 但是旧版本的挖矿端并没有把矿工名交换到注册表去所以当注册表中没有矿工名时需读取local.litedb中的矿工名 if (string.IsNullOrEmpty(_localJson.MinerProfile.MinerName)) { _localJson.MinerProfile.MinerName = GetMinerName(); if (string.IsNullOrEmpty(_localJson.MinerProfile.MinerName)) { var repository = CreateLocalRepository <Profile.MinerProfileData>(isUseJson: false); Profile.MinerProfileData data = repository.GetByKey(Profile.MinerProfileData.DefaultId); if (data != null) { _localJson.MinerProfile.MinerName = data.MinerName; } } } _localJsonInited = true; } } } }