// 从磁盘读取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;
             }
         }
     }
 }
Beispiel #2
0
        // 从磁盘读取local.json反序列化为LocalJson对象
        private static void LocalJsonInit()
        {
            if (!_localJsonInited)
            {
                lock (_locker) {
                    if (!_localJsonInited)
                    {
                        string localJson = HomePath.ReadLocalJsonFile();
                        if (!string.IsNullOrEmpty(localJson))
                        {
                            LocalJsonDb data = VirtualRoot.JsonSerializer.Deserialize <LocalJsonDb>(localJson);
                            _localJson = data ?? new LocalJsonDb();
                        }
                        else
                        {
                            _localJson = new LocalJsonDb();
                        }

                        #region 因为是群控作业,将开机启动和自动挖矿设置为true
                        var repository = new LiteDbReadWriteRepository <MinerProfileData>(HomePath.LocalDbFileFullName);
                        MinerProfileData localProfile = repository.GetByKey(MinerProfileData.DefaultId);
                        if (localProfile != null)
                        {
                            MinerProfileData.CopyWorkIgnoreValues(localProfile, _localJson.MinerProfile);
                            // 如果是作业模式则必须设置为开机自动重启
                            if (localProfile.IsAutoStart == false || localProfile.IsAutoBoot == false)
                            {
                                localProfile.IsAutoBoot  = true;
                                localProfile.IsAutoStart = true;
                                repository.Update(localProfile);
                            }
                        }
                        _localJson.MinerProfile.IsAutoBoot  = true;
                        _localJson.MinerProfile.IsAutoStart = true;
                        #endregion

                        #region 矿机名
                        // 当用户使用群控作业但没有指定群控矿机名时使用从local.litedb中读取的矿工名
                        if (string.IsNullOrEmpty(_localJson.MinerProfile.MinerName))
                        {
                            if (localProfile != null)
                            {
                                _localJson.MinerProfile.MinerName = localProfile.MinerName;
                            }
                            // 如果local.litedb中也没有矿机名则使用去除了特殊符号的本机机器名作为矿机名
                            if (string.IsNullOrEmpty(_localJson.MinerProfile.MinerName))
                            {
                                string minerName = Environment.MachineName;
                                minerName = new string(minerName.ToCharArray().Where(a => !NTKeyword.InvalidMinerNameChars.Contains(a)).ToArray());
                                _localJson.MinerProfile.MinerName = minerName;
                            }
                        }
                        #endregion
                        _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;
             }
         }
     }
 }
 public static void ExportWorkJson(MineWorkData mineWorkData, out string localJson, out string serverJson)
 {
     localJson  = string.Empty;
     serverJson = string.Empty;
     try {
         LocalJsonDb  localJsonObj  = new LocalJsonDb(Instance, mineWorkData);
         ServerJsonDb serverJsonObj = new ServerJsonDb(Instance, localJsonObj);
         localJson  = VirtualRoot.JsonSerializer.Serialize(localJsonObj);
         serverJson = VirtualRoot.JsonSerializer.Serialize(serverJsonObj);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e.Message, e);
     }
 }
 public void ExportWorkJson(MineWorkData mineWorkData, out string localJson, out string serverJson)
 {
     localJson  = string.Empty;
     serverJson = string.Empty;
     try {
         LocalJsonDb  localJsonObj  = new LocalJsonDb(this, mineWorkData);
         ServerJsonDb serverJsonObj = new ServerJsonDb(this, localJsonObj);
         localJson  = VirtualRoot.JsonSerializer.Serialize(localJsonObj);
         serverJson = VirtualRoot.JsonSerializer.Serialize(serverJsonObj);
         mineWorkData.ServerJsonSha1 = HashUtil.Sha1(serverJson);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
     }
 }
Beispiel #6
0
 // 从磁盘读取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;
             }
         }
     }
 }
        private void EditJson(FormType?formType, WorkType workType, string json)
        {
            if (workType == WorkType.None)
            {
                throw new InvalidProgramException();
            }
            if (workType == WorkType.SelfWork)
            {
                if (!string.IsNullOrEmpty(json))
                {
                    File.WriteAllText(HomePath.SelfWorkLocalJsonFileFullName, json);
                }
                else
                {
                    File.Delete(HomePath.SelfWorkLocalJsonFileFullName);
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(json))
                {
                    File.WriteAllText(HomePath.MineWorkLocalJsonFileFullName, json);
                }
                else
                {
                    File.Delete(HomePath.MineWorkLocalJsonFileFullName);
                }
            }
            NTMinerContext.Instance.ReInitMinerProfile(workType);
            this.Sha1 = NTMinerContext.Instance.MinerProfile.GetSha1();
            MineWorkData mineWorkData  = new MineWorkData().Update(this);
            LocalJsonDb  localJsonObj  = new LocalJsonDb(NTMinerContext.Instance, mineWorkData);
            ServerJsonDb serverJsonObj = new ServerJsonDb(NTMinerContext.Instance, localJsonObj);
            var          serverJson    = VirtualRoot.JsonSerializer.Serialize(serverJsonObj);

            this.ServerJsonSha1 = HashUtil.Sha1(serverJson);
            VirtualRoot.Execute(new EditMineWorkCommand(formType ?? FormType.Edit, new MineWorkViewModel(this)));
        }
        // 从磁盘读取local.json反序列化为LocalJson对象
        private static void LocalJsonInit()
        {
            if (!_localJsonInited)
            {
                lock (_locker) {
                    if (!_localJsonInited)
                    {
                        string      localJson   = HomePath.ReadLocalJsonFile(_workType);
                        LocalJsonDb localJsonDb = null;
                        if (!string.IsNullOrEmpty(localJson))
                        {
                            localJsonDb = VirtualRoot.JsonSerializer.Deserialize <LocalJsonDb>(localJson);
                        }
                        if (localJsonDb == null)
                        {
                            if (ClientAppType.IsMinerClient)
                            {
                                localJsonDb = JsonDb.LocalJsonDb.ConvertFromNTMinerContext();
                                VirtualRoot.ThisLocalWarn(nameof(NTMinerContext), "当前作业由本机数据自动生成,因为本机没有作业记录,请先在群控端创建或编辑作业。", OutEnum.Warn, toConsole: true);
                            }
                            else
                            {
                                localJsonDb = new LocalJsonDb();
                            }
                        }
                        _localJsonDb = localJsonDb;

                        if (ClientAppType.IsMinerClient)
                        {
                            #region 因为是群控作业,将开机启动和自动挖矿设置为true
                            var repository = new LiteDbReadWriteRepository <MinerProfileData>(HomePath.LocalDbFileFullName);
                            MinerProfileData localProfile = repository.GetByKey(MinerProfileData.DefaultId);
                            if (localProfile != null)
                            {
                                MinerProfileData.CopyWorkIgnoreValues(localProfile, _localJsonDb.MinerProfile);
                                // 如果是作业模式则必须设置为开机自动重启
                                if (!localProfile.IsAutoBoot)
                                {
                                    localProfile.IsAutoBoot = true;
                                    repository.Update(localProfile);
                                }
                            }
                            _localJsonDb.MinerProfile.IsAutoBoot = true;
                            NTMinerRegistry.SetIsAutoStart(true);
                            #endregion

                            #region 矿机名
                            if (!string.IsNullOrEmpty(_workerName))
                            {
                                _localJsonDb.MinerProfile.MinerName = _workerName;
                            }
                            else
                            {
                                // 当用户使用群控作业但没有指定群控矿机名时使用从local.litedb中读取的矿工名
                                if (string.IsNullOrEmpty(_localJsonDb.MinerProfile.MinerName))
                                {
                                    if (localProfile != null)
                                    {
                                        _localJsonDb.MinerProfile.MinerName = localProfile.MinerName;
                                    }
                                    // 如果local.litedb中也没有矿机名则使用去除了特殊符号的本机机器名作为矿机名
                                    if (string.IsNullOrEmpty(_localJsonDb.MinerProfile.MinerName))
                                    {
                                        _localJsonDb.MinerProfile.MinerName = NTKeyword.GetSafeMinerName(ThisPcName);
                                    }
                                }
                            }
                            #endregion
                        }
                        _localJsonInited = true;
                    }
                }
            }
        }
        private void DoSave()
        {
            if (string.IsNullOrEmpty(this.Name))
            {
                VirtualRoot.Out.ShowError("作业名称是必须的", autoHideSeconds: 4);
            }
            bool isMinerProfileChanged = false;
            // 表示是否随后打开编辑界面,如果是新建的作业则保存后随即会打开作业编辑界面
            bool         isShowEdit   = false;
            MineWorkData mineWorkData = new MineWorkData().Update(this);

            if (MinerStudioRoot.MineWorkVms.TryGetMineWorkVm(this.Id, out MineWorkViewModel vm))
            {
                string sha1 = NTMinerContext.Instance.MinerProfile.GetSha1();
                // 如果作业设置变更了则一定变更了
                if (this.Sha1 != sha1)
                {
                    isMinerProfileChanged = true;
                }
                else
                {
                    // 如果作业设置没变更但作业引用的服务器数据库记录状态变更了则变更了
                    LocalJsonDb  localJsonObj  = new LocalJsonDb(NTMinerContext.Instance, mineWorkData);
                    ServerJsonDb serverJsonObj = new ServerJsonDb(NTMinerContext.Instance, localJsonObj);
                    var          serverJson    = VirtualRoot.JsonSerializer.Serialize(serverJsonObj);
                    sha1 = HashUtil.Sha1(serverJson);
                    if (sha1 != this.ServerJsonSha1)
                    {
                        isMinerProfileChanged = true;
                    }
                }
            }
            else
            {
                isMinerProfileChanged = true;
                isShowEdit            = true;
                NTMinerConsole.UserInfo("保存作业。");
            }
            if (RpcRoot.IsOuterNet)
            {
                if (!this.Id.IsSelfMineWorkId())
                {
                    RpcRoot.OfficialServer.UserMineWorkService.AddOrUpdateMineWorkAsync(new MineWorkData().Update(this), (r, ex) => {
                        if (r.IsSuccess())
                        {
                            if (isMinerProfileChanged)
                            {
                                NTMinerContext.Instance.ExportWorkJson(mineWorkData, out string localJson, out string serverJson);
                                if (!string.IsNullOrEmpty(localJson) && !string.IsNullOrEmpty(serverJson))
                                {
                                    RpcRoot.OfficialServer.UserMineWorkService.ExportMineWorkAsync(this.Id, localJson, serverJson, (response, e) => {
                                        if (response.IsSuccess())
                                        {
                                            if (isShowEdit)
                                            {
                                                VirtualRoot.RaiseEvent(new MineWorkAddedEvent(Guid.Empty, this));
                                            }
                                            else
                                            {
                                                VirtualRoot.RaiseEvent(new MineWorkUpdatedEvent(Guid.Empty, this));
                                            }
                                            if (isShowEdit)
                                            {
                                                this.Edit.Execute(FormType.Edit);
                                            }
                                        }
                                        else
                                        {
                                            VirtualRoot.Out.ShowError(response.ReadMessage(e), autoHideSeconds: 4);
                                        }
                                    });
                                }
                                if (mineWorkData.ServerJsonSha1 != this.ServerJsonSha1)
                                {
                                    this.ServerJsonSha1 = mineWorkData.ServerJsonSha1;
                                }
                            }
                        }
                        else
                        {
                            VirtualRoot.Out.ShowError(r.ReadMessage(ex), autoHideSeconds: 4);
                        }
                    });
Beispiel #10
0
 public MineWorkViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         if (string.IsNullOrEmpty(this.Name))
         {
             VirtualRoot.Out.ShowError("作业名称是必须的");
         }
         bool isMineWorkChanged     = false;
         bool isMinerProfileChanged = false;
         MineWorkData mineWorkData  = new MineWorkData(this);
         if (NTMinerRoot.Instance.MineWorkSet.TryGetMineWork(this.Id, out IMineWork entity))
         {
             string sha1 = NTMinerRoot.Instance.MinerProfile.GetSha1();
             // 如果作业设置变更了则一定变更了
             if (this.Sha1 != sha1)
             {
                 isMinerProfileChanged = true;
             }
             else
             {
                 // 如果作业设置没变更但作业引用的服务器数据库记录状态变更了则变更了
                 LocalJsonDb localJsonObj   = new LocalJsonDb(NTMinerRoot.Instance, mineWorkData);
                 ServerJsonDb serverJsonObj = new ServerJsonDb(NTMinerRoot.Instance, localJsonObj);
                 var serverJson             = VirtualRoot.JsonSerializer.Serialize(serverJsonObj);
                 sha1 = HashUtil.Sha1(serverJson);
                 if (sha1 != this.ServerJsonSha1)
                 {
                     isMinerProfileChanged = true;
                 }
             }
             if (entity.Name != this.Name || entity.Description != this.Description)
             {
                 isMineWorkChanged = true;
             }
         }
         else
         {
             isMinerProfileChanged = true;
             VirtualRoot.Execute(new AddMineWorkCommand(this));
             this.Edit.Execute(FormType.Edit);
         }
         if (isMinerProfileChanged)
         {
             Write.DevDebug("检测到MinerProfile状态变更");
             NTMinerRoot.ExportWorkJson(mineWorkData, out string localJson, out string serverJson);
             if (!string.IsNullOrEmpty(localJson) && !string.IsNullOrEmpty(serverJson))
             {
                 RpcRoot.Server.MineWorkService.ExportMineWorkAsync(this.Id, localJson, serverJson, callback: null);
             }
             if (mineWorkData.ServerJsonSha1 != this.ServerJsonSha1)
             {
                 this.ServerJsonSha1 = mineWorkData.ServerJsonSha1;
                 isMineWorkChanged   = true;
             }
         }
         if (isMineWorkChanged)
         {
             VirtualRoot.Execute(new UpdateMineWorkCommand(mineWorkData));
         }
     });
     this.Edit = new DelegateCommand <FormType?>((formType) => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         if (!AppContext.Instance.MineWorkVms.TryGetMineWorkVm(this.Id, out MineWorkViewModel mineWorkVm))
         {
             WpfUtil.ShowInputDialog("作业名称", string.Empty, workName => {
                 if (string.IsNullOrEmpty(workName))
                 {
                     return("作业名称是必须的");
                 }
                 return(string.Empty);
             }, onOk: workName => {
                 new MineWorkViewModel(this)
                 {
                     Name = workName
                 }.Save.Execute(null);
             });
         }
         else
         {
             // 编辑作业前切换上下文
             // 根据workId下载json保存到本地并调用LocalJson.Instance.ReInit()
             string json = RpcRoot.Server.MineWorkService.GetLocalJson(this.Id);
             if (!string.IsNullOrEmpty(json))
             {
                 File.WriteAllText(SpecialPath.LocalJsonFileFullName, json);
             }
             else
             {
                 File.Delete(SpecialPath.LocalJsonFileFullName);
             }
             NTMinerRoot.Instance.ReInitMinerProfile();
             this.Sha1 = NTMinerRoot.Instance.MinerProfile.GetSha1();
             VirtualRoot.Execute(new MineWorkEditCommand(formType ?? FormType.Edit, new MineWorkViewModel(this)));
         }
     }, formType => {
         if (this == PleaseSelect)
         {
             return(false);
         }
         return(true);
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         this.ShowSoftDialog(new DialogWindowViewModel(message: $"您确定删除吗?", title: "确认", onYes: () => {
             VirtualRoot.Execute(new RemoveMineWorkCommand(this.Id));
         }));
     }, () => {
         if (this == PleaseSelect)
         {
             return(false);
         }
         return(true);
     });
 }
Beispiel #11
0
 public MineWorkViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         if (string.IsNullOrEmpty(this.Name))
         {
             VirtualRoot.Out.ShowError("作业名称是必须的", autoHideSeconds: 4);
         }
         bool isMinerProfileChanged = false;
         bool isShowEdit            = false;
         MineWorkData mineWorkData  = new MineWorkData().Update(this);
         if (MinerStudioRoot.MineWorkVms.TryGetMineWorkVm(this.Id, out MineWorkViewModel vm))
         {
             string sha1 = NTMinerContext.Instance.MinerProfile.GetSha1();
             // 如果作业设置变更了则一定变更了
             if (this.Sha1 != sha1)
             {
                 isMinerProfileChanged = true;
             }
             else
             {
                 // 如果作业设置没变更但作业引用的服务器数据库记录状态变更了则变更了
                 LocalJsonDb localJsonObj   = new LocalJsonDb(NTMinerContext.Instance, mineWorkData);
                 ServerJsonDb serverJsonObj = new ServerJsonDb(NTMinerContext.Instance, localJsonObj);
                 var serverJson             = VirtualRoot.JsonSerializer.Serialize(serverJsonObj);
                 sha1 = HashUtil.Sha1(serverJson);
                 if (sha1 != this.ServerJsonSha1)
                 {
                     isMinerProfileChanged = true;
                 }
             }
         }
         else
         {
             isMinerProfileChanged = true;
             isShowEdit            = true;
         }
         if (RpcRoot.IsOuterNet)
         {
             RpcRoot.OfficialServer.UserMineWorkService.AddOrUpdateMineWorkAsync(new MineWorkData().Update(this), (r, ex) => {
                 if (r.IsSuccess())
                 {
                     if (isMinerProfileChanged)
                     {
                         Write.DevDebug("检测到MinerProfile状态变更");
                         NTMinerContext.ExportWorkJson(mineWorkData, out string localJson, out string serverJson);
                         if (!string.IsNullOrEmpty(localJson) && !string.IsNullOrEmpty(serverJson))
                         {
                             RpcRoot.OfficialServer.UserMineWorkService.ExportMineWorkAsync(this.Id, localJson, serverJson, (response, e) => {
                                 if (response.IsSuccess())
                                 {
                                     if (isShowEdit)
                                     {
                                         VirtualRoot.RaiseEvent(new MineWorkAddedEvent(Guid.Empty, this));
                                     }
                                     else
                                     {
                                         VirtualRoot.RaiseEvent(new MineWorkUpdatedEvent(Guid.Empty, this));
                                     }
                                     if (isShowEdit)
                                     {
                                         this.Edit.Execute(FormType.Edit);
                                     }
                                 }
                                 else
                                 {
                                     VirtualRoot.Out.ShowError(response.ReadMessage(e), autoHideSeconds: 4);
                                 }
                             });
                         }
                         if (mineWorkData.ServerJsonSha1 != this.ServerJsonSha1)
                         {
                             this.ServerJsonSha1 = mineWorkData.ServerJsonSha1;
                         }
                     }
                 }
 public static void ExportWorkJson(MineWorkData mineWorkData, out string localJson, out string serverJson)
 {
     localJson  = string.Empty;
     serverJson = string.Empty;
     try {
         var                    root            = Current;
         var                    minerProfile    = root.MinerProfile;
         CoinProfileData        mainCoinProfile = new CoinProfileData(minerProfile.GetCoinProfile(minerProfile.CoinId));
         List <CoinProfileData> coinProfiles    = new List <CoinProfileData> {
             mainCoinProfile
         };
         List <PoolProfileData> poolProfiles        = new List <PoolProfileData>();
         CoinKernelProfileData  coinKernelProfile   = new CoinKernelProfileData(minerProfile.GetCoinKernelProfile(mainCoinProfile.CoinKernelId));
         PoolProfileData        mainCoinPoolProfile = new PoolProfileData(minerProfile.GetPoolProfile(mainCoinProfile.PoolId));
         poolProfiles.Add(mainCoinPoolProfile);
         if (coinKernelProfile.IsDualCoinEnabled)
         {
             CoinProfileData dualCoinProfile = new CoinProfileData(minerProfile.GetCoinProfile(coinKernelProfile.DualCoinId));
             coinProfiles.Add(dualCoinProfile);
             PoolProfileData dualCoinPoolProfile = new PoolProfileData(minerProfile.GetPoolProfile(dualCoinProfile.DualCoinPoolId));
             poolProfiles.Add(dualCoinPoolProfile);
         }
         LocalJsonDb localJsonObj = new LocalJsonDb {
             MinerProfile = new MinerProfileData(minerProfile)
             {
                 MinerName = "{{MinerName}}"
             },
             MineWork           = mineWorkData,
             CoinProfiles       = coinProfiles.ToArray(),
             CoinKernelProfiles = new CoinKernelProfileData[] { coinKernelProfile },
             PoolProfiles       = poolProfiles.ToArray(),
             TimeStamp          = Timestamp.GetTimestamp(),
             Pools   = root.PoolSet.Where(a => poolProfiles.Any(b => b.PoolId == a.GetId())).Select(a => new PoolData(a)).ToArray(),
             Wallets = minerProfile.GetWallets().Select(a => new WalletData(a)).ToArray()
         };
         localJson = VirtualRoot.JsonSerializer.Serialize(localJsonObj);
         root.CoinKernelSet.TryGetCoinKernel(coinKernelProfile.CoinKernelId, out ICoinKernel coinKernel);
         root.KernelSet.TryGetKernel(coinKernel.KernelId, out IKernel kernel);
         var          coins         = root.CoinSet.Cast <CoinData>().Where(a => localJsonObj.CoinProfiles.Any(b => b.CoinId == a.Id)).ToArray();
         var          coinGroups    = root.CoinGroupSet.Cast <CoinGroupData>().Where(a => coins.Any(b => b.Id == a.CoinId)).ToArray();
         var          pools         = root.PoolSet.Cast <PoolData>().Where(a => localJsonObj.PoolProfiles.Any(b => b.PoolId == a.Id)).ToArray();
         ServerJsonDb serverJsonObj = new ServerJsonDb {
             Coins                   = coins,
             CoinGroups              = coinGroups,
             Pools                   = pools,
             TimeStamp               = Timestamp.GetTimestamp(),
             Groups                  = root.GroupSet.Cast <GroupData>().Where(a => coinGroups.Any(b => b.GroupId == a.Id)).ToArray(),
             KernelInputs            = root.KernelInputSet.Cast <KernelInputData>().Where(a => a.Id == kernel.KernelInputId).ToArray(),
             KernelOutputs           = root.KernelOutputSet.Cast <KernelOutputData>().Where(a => a.Id == kernel.KernelOutputId).ToArray(),
             KernelOutputFilters     = root.KernelOutputFilterSet.Cast <KernelOutputFilterData>().Where(a => a.KernelOutputId == kernel.KernelOutputId).ToArray(),
             KernelOutputTranslaters = root.KernelOutputTranslaterSet.Cast <KernelOutputTranslaterData>().Where(a => a.KernelOutputId == kernel.KernelOutputId).ToArray(),
             Kernels                 = new List <KernelData> {
                 (KernelData)kernel
             },
             CoinKernels = root.CoinKernelSet.Cast <CoinKernelData>().Where(a => localJsonObj.CoinKernelProfiles.Any(b => b.CoinKernelId == a.Id)).ToList(),
             PoolKernels = root.PoolKernelSet.Cast <PoolKernelData>().Where(a => !string.IsNullOrEmpty(a.Args) && pools.Any(b => b.Id == a.PoolId)).ToList(),
             SysDicItems = root.SysDicItemSet.Cast <SysDicItemData>().ToArray(),
             SysDics     = root.SysDicSet.Cast <SysDicData>().ToArray()
         };
         serverJson = VirtualRoot.JsonSerializer.Serialize(serverJsonObj);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e.Message, e);
     }
 }