Ejemplo n.º 1
0
 private MineWorkViewModels()
 {
     if (WpfUtil.IsInDesignMode)
     {
         return;
     }
     foreach (var item in NTMinerContext.MinerStudioContext.MineWorkSet.AsEnumerable())
     {
         if (!_dicById.ContainsKey(item.Id))
         {
             _dicById.Add(item.Id, new MineWorkViewModel(item));
         }
     }
     AppRoot.AddEventPath <MineWorkSetInitedEvent>("作业集初始化后初始化Vm内存", LogEnum.DevConsole, action: message => {
         _dicById.Clear();
         foreach (var item in NTMinerContext.MinerStudioContext.MineWorkSet.AsEnumerable())
         {
             if (!_dicById.ContainsKey(item.Id))
             {
                 _dicById.Add(item.Id, new MineWorkViewModel(item));
             }
         }
         OnPropertyChangeds();
         MinerClientsWindowViewModel.Instance.RefreshMinerClientsSelectedMineWork(MinerClientsWindowViewModel.Instance.MinerClients.ToArray());
     }, this.GetType());
     this.Add = new DelegateCommand(() => {
         new MineWorkViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
     });
     AppRoot.AddEventPath <MineWorkAddedEvent>("添加作业后刷新VM内存", LogEnum.DevConsole,
                                               action: message => {
         if (!_dicById.TryGetValue(message.Source.GetId(), out MineWorkViewModel vm))
         {
             vm = new MineWorkViewModel(message.Source);
             _dicById.Add(message.Source.GetId(), vm);
             OnPropertyChangeds();
             if (message.Source.GetId() == MinerClientsWindowVm.SelectedMineWork.GetId())
             {
                 MinerClientsWindowVm.SelectedMineWork = MineWorkViewModel.PleaseSelect;
             }
         }
     }, location: this.GetType());
     AppRoot.AddEventPath <MineWorkUpdatedEvent>("添加作业后刷新VM内存", LogEnum.DevConsole,
                                                 action: message => {
         if (_dicById.TryGetValue(message.Source.GetId(), out MineWorkViewModel vm))
         {
             vm.Update(message.Source);
         }
     }, location: this.GetType());
     AppRoot.AddEventPath <MineWorkRemovedEvent>("移除了作业后刷新Vm内存", LogEnum.DevConsole, action: message => {
         if (_dicById.TryGetValue(message.Source.Id, out MineWorkViewModel vm))
         {
             _dicById.Remove(vm.Id);
             OnPropertyChangeds();
             if (vm.Id == MinerClientsWindowVm.SelectedMineWork.GetId())
             {
                 MinerClientsWindowVm.SelectedMineWork = MineWorkViewModel.PleaseSelect;
             }
         }
     }, this.GetType());
 }
            private NTMinerWalletViewModels()
            {
#if DEBUG
                NTStopwatch.Start();
#endif
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
                Init(refresh: false);
                AppRoot.AddEventPath <NTMinerWalletSetInitedEvent>("NTMiner钱包集初始化后", LogEnum.DevConsole,
                                                                   action: message => {
                    Init(refresh: true);
                }, location: this.GetType());
                this.Add = new DelegateCommand(() => {
                    new NTMinerWalletViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
                });
                AppRoot.AddEventPath <NTMinerWalletAddedEvent>("添加NTMiner钱包后刷新VM内存", LogEnum.DevConsole,
                                                               action: message => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById.Add(message.Source.GetId(), new NTMinerWalletViewModel(message.Source));
                        if (AppRoot.CoinVms.TryGetCoinVm(message.Source.CoinCode, out CoinViewModel coinVm))
                        {
                            coinVm.OnPropertyChanged(nameof(coinVm.NTMinerWallets));
                        }
                    }
                }, location: this.GetType());
                AppRoot.AddEventPath <NTMinerWalletUpdatedEvent>("更新NTMiner钱包后刷新VM内存", LogEnum.DevConsole,
                                                                 action: message => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out NTMinerWalletViewModel vm))
                    {
                        vm.Update(message.Source);
                    }
                }, location: this.GetType());
                AppRoot.AddEventPath <NTMinerWalletRemovedEvent>("删除NTMiner钱包后刷新VM内存", LogEnum.DevConsole,
                                                                 action: message => {
                    _dicById.Remove(message.Source.GetId());
                    if (AppRoot.CoinVms.TryGetCoinVm(message.Source.CoinCode, out CoinViewModel coinVm))
                    {
                        coinVm.OnPropertyChanged(nameof(coinVm.NTMinerWallets));
                    }
                }, location: this.GetType());
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
Ejemplo n.º 3
0
            private OverClockDataViewModels()
            {
#if DEBUG
                NTStopwatch.Start();
#endif
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
                Init(refresh: false);
                AppRoot.AddEventPath <OverClockDataSetInitedEvent>("超频菜谱集初始化后", LogEnum.DevConsole,
                                                                   action: message => {
                    Init(refresh: true);
                }, location: this.GetType());
                AppRoot.AddEventPath <OverClockDataAddedEvent>("添加超频菜谱后刷新VM内存", LogEnum.DevConsole,
                                                               action: message => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById.Add(message.Source.GetId(), new OverClockDataViewModel(message.Source));
                        if (AppRoot.CoinVms.TryGetCoinVm(message.Source.CoinId, out CoinViewModel coinVm))
                        {
                            coinVm.OnPropertyChanged(nameof(coinVm.OverClockDatas));
                        }
                    }
                }, location: this.GetType());
                AppRoot.AddEventPath <OverClockDataUpdatedEvent>("更新超频菜谱后刷新VM内存", LogEnum.DevConsole,
                                                                 action: message => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out OverClockDataViewModel vm))
                    {
                        vm.Update(message.Source);
                    }
                }, location: this.GetType());
                AppRoot.AddEventPath <OverClockDataRemovedEvent>("删除超频菜谱后刷新VM内存", LogEnum.DevConsole,
                                                                 action: message => {
                    _dicById.Remove(message.Source.GetId());
                    if (AppRoot.CoinVms.TryGetCoinVm(message.Source.CoinId, out CoinViewModel coinVm))
                    {
                        coinVm.OnPropertyChanged(nameof(coinVm.OverClockDatas));
                    }
                }, location: this.GetType());
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
Ejemplo n.º 4
0
 private NTMinerWalletViewModels()
 {
     if (WpfUtil.IsInDesignMode)
     {
         return;
     }
     Init(refresh: false);
     AppRoot.AddEventPath <NTMinerWalletSetInitedEvent>("NTMiner钱包集初始化后", LogEnum.DevConsole,
                                                        action: message => {
         Init(refresh: true);
     }, location: this.GetType());
     this.Add = new DelegateCommand(() => {
         new NTMinerWalletViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
     });
     AppRoot.AddEventPath <NTMinerWalletAddedEvent>("添加NTMiner钱包后刷新VM内存", LogEnum.DevConsole,
                                                    action: message => {
         if (!_dicById.ContainsKey(message.Source.GetId()))
         {
             _dicById.Add(message.Source.GetId(), new NTMinerWalletViewModel(message.Source));
             if (AppRoot.CoinVms.TryGetCoinVm(message.Source.CoinCode, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.NTMinerWallets));
             }
         }
     }, location: this.GetType());
     AppRoot.AddEventPath <NTMinerWalletUpdatedEvent>("更新NTMiner钱包后刷新VM内存", LogEnum.DevConsole,
                                                      action: message => {
         if (_dicById.TryGetValue(message.Source.GetId(), out NTMinerWalletViewModel vm))
         {
             vm.Update(message.Source);
         }
     }, location: this.GetType());
     AppRoot.AddEventPath <NTMinerWalletRemovedEvent>("删除NTMiner钱包后刷新VM内存", LogEnum.DevConsole,
                                                      action: message => {
         _dicById.Remove(message.Source.GetId());
         if (AppRoot.CoinVms.TryGetCoinVm(message.Source.CoinCode, out CoinViewModel coinVm))
         {
             coinVm.OnPropertyChanged(nameof(coinVm.NTMinerWallets));
         }
     }, location: this.GetType());
 }
Ejemplo n.º 5
0
 private OverClockDataViewModels()
 {
     if (WpfUtil.IsInDesignMode)
     {
         return;
     }
     Init(refresh: false);
     AppRoot.AddEventPath <OverClockDataSetInitedEvent>("超频菜谱集初始化后", LogEnum.DevConsole,
                                                        action: message => {
         Init(refresh: true);
     }, location: this.GetType());
     AppRoot.AddEventPath <OverClockDataAddedEvent>("添加超频菜谱后刷新VM内存", LogEnum.DevConsole,
                                                    action: message => {
         if (!_dicById.ContainsKey(message.Source.GetId()))
         {
             _dicById.Add(message.Source.GetId(), new OverClockDataViewModel(message.Source));
             if (AppRoot.CoinVms.TryGetCoinVm(message.Source.CoinId, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.OverClockDatas));
             }
         }
     }, location: this.GetType());
     AppRoot.AddEventPath <OverClockDataUpdatedEvent>("更新超频菜谱后刷新VM内存", LogEnum.DevConsole,
                                                      action: message => {
         if (_dicById.TryGetValue(message.Source.GetId(), out OverClockDataViewModel vm))
         {
             vm.Update(message.Source);
         }
     }, location: this.GetType());
     AppRoot.AddEventPath <OverClockDataRemovedEvent>("删除超频菜谱后刷新VM内存", LogEnum.DevConsole,
                                                      action: message => {
         _dicById.Remove(message.Source.GetId());
         if (AppRoot.CoinVms.TryGetCoinVm(message.Source.CoinId, out CoinViewModel coinVm))
         {
             coinVm.OnPropertyChanged(nameof(coinVm.OverClockDatas));
         }
     }, location: this.GetType());
 }
Ejemplo n.º 6
0
            private ColumnsShowViewModels()
            {
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
                this.Add = new DelegateCommand(() => {
                    WpfUtil.ShowInputDialog("列分组名称", string.Empty, string.Empty, columnsShowName => {
                        if (string.IsNullOrEmpty(columnsShowName))
                        {
                            return("列分组名称是必须的");
                        }
                        return(string.Empty);
                    }, onOk: columnsShowName => {
                        ColumnsShowData entity = new ColumnsShowData {
                            ColumnsShowName   = columnsShowName,
                            LastActivedOnText = true,
                            BootTimeSpanText  = true,
                            MineTimeSpanText  = true,
                            Work                      = true,
                            MinerGroup                = true,
                            MinerName                 = true,
                            WorkerName                = true,
                            LocalIp                   = true,
                            MinerIp                   = true,
                            GpuType                   = true,
                            MainCoinCode              = true,
                            MainCoinSpeedText         = true,
                            MainCoinRejectPercentText = true
                        };
                        NTMinerContext.MinerStudioContext.ColumnsShowSet.AddOrUpdate(entity);
                    });
                });
                AppRoot.AddEventPath <ColumnsShowAddedOrUpdatedEvent>("添加或修改了列分组后刷新VM内存", LogEnum.DevConsole,
                                                                      action: message => {
                    if (!_dicById.TryGetValue(message.Source.GetId(), out ColumnsShowViewModel vm))
                    {
                        vm = new ColumnsShowViewModel(message.Source);
                        _dicById.Add(message.Source.GetId(), vm);
                        OnPropertyChanged(nameof(List));
                        MinerClientsWindowVm.ColumnsShow = vm;
                    }
                    else
                    {
                        vm.Update(message.Source);
                    }
                }, location: this.GetType());
                AppRoot.AddEventPath <ColumnsRemovedEvent>("删除了列分组后刷新Vm内存", LogEnum.DevConsole, action: message => {
                    if (_dicById.ContainsKey(message.Source.Id))
                    {
                        _dicById.Remove(message.Source.Id);
                        OnPropertyChanged(nameof(List));
                        if (_dicById.TryGetValue(ColumnsShowData.PleaseSelect.Id, out ColumnsShowViewModel vm))
                        {
                            MinerClientsWindowVm.ColumnsShow = vm;
                        }
                    }
                }, this.GetType());

                foreach (var item in NTMinerContext.MinerStudioContext.ColumnsShowSet.GetAll())
                {
                    _dicById.Add(item.Id, new ColumnsShowViewModel(item));
                }
            }
Ejemplo n.º 7
0
        public MinerProfileViewModel()
        {
            if (WpfUtil.IsInDesignMode)
            {
                return;
            }
            if (Instance != null)
            {
                throw new InvalidProgramException();
            }
            if (this.IsCreateShortcut)
            {
                CreateShortcut();
            }
            this.Up = new DelegateCommand <string>(propertyName => {
                WpfUtil.Up(this, propertyName);
            });
            this.Down = new DelegateCommand <string>(propertyName => {
                WpfUtil.Down(this, propertyName);
            });
            this.WsRetry = new DelegateCommand(() => {
                RpcRoot.Client.NTMinerDaemonService.StartOrStopWsAsync(isResetFailCount: true);
                IsConnecting = true;
            });
            if (ClientAppType.IsMinerClient)
            {
                VirtualRoot.AddCmdPath <SetAutoStartCommand>(message => {
                    this.IsAutoStart = message.IsAutoStart;
                    this.IsAutoBoot  = message.IsAutoBoot;
                }, this.GetType(), LogEnum.None);
                VirtualRoot.AddEventPath <StartingMineFailedEvent>("开始挖矿失败", LogEnum.DevConsole,
                                                                   action: message => {
                    IsMining = false;
                    NTMinerConsole.UserError(message.Message);
                }, location: this.GetType());
                // 群控客户端已经有一个执行RefreshWsStateCommand命令的路径了
                VirtualRoot.AddCmdPath <RefreshWsStateCommand>(message => {
                    #region
                    if (message.WsClientState != null)
                    {
                        this.IsWsOnline = message.WsClientState.Status == WsClientStatus.Open;
                        if (message.WsClientState.ToOut)
                        {
                            VirtualRoot.Out.ShowWarn(message.WsClientState.Description, autoHideSeconds: 3);
                        }
                        if (!message.WsClientState.ToOut || !this.IsWsOnline)
                        {
                            this.WsDescription = message.WsClientState.Description;
                        }
                        if (!this.IsWsOnline)
                        {
                            if (message.WsClientState.LastTryOn != DateTime.MinValue)
                            {
                                this.WsLastTryOn = message.WsClientState.LastTryOn;
                            }
                            if (message.WsClientState.NextTrySecondsDelay > 0)
                            {
                                WsNextTrySecondsDelay = message.WsClientState.NextTrySecondsDelay;
                            }
                        }
                    }
                    #endregion
                }, this.GetType(), LogEnum.DevConsole);
                VirtualRoot.AddEventPath <Per1SecondEvent>("外网群控重试秒表倒计时", LogEnum.None, action: message => {
                    if (IsOuterUserEnabled && !IsWsOnline)
                    {
                        if (WsNextTrySecondsDelay > 0)
                        {
                            WsNextTrySecondsDelay--;
                        }
                        else if (WsLastTryOn == DateTime.MinValue)
                        {
                            this.RefreshWsDaemonState();
                        }
                        OnPropertyChanged(nameof(WsLastTryOnText));
                    }
                }, this.GetType());
                VirtualRoot.AddEventPath <WsServerOkEvent>("服务器Ws服务已可用", LogEnum.DevConsole, action: message => {
                    if (IsOuterUserEnabled && !IsWsOnline)
                    {
                        StartOrStopWs();
                    }
                }, this.GetType());
            }
            NTMinerContext.SetRefreshArgsAssembly((reason) => {
                NTMinerConsole.DevDebug(() => $"RefreshArgsAssembly" + reason, ConsoleColor.Cyan);
                #region 确保双挖权重在合法的范围内
                if (CoinVm != null && CoinVm.CoinKernel != null && CoinVm.CoinKernel.Kernel != null)
                {
                    var coinKernelProfile = CoinVm.CoinKernel.CoinKernelProfile;
                    var kernelInput       = CoinVm.CoinKernel.Kernel.KernelInputVm;
                    if (coinKernelProfile != null && kernelInput != null)
                    {
                        if (coinKernelProfile.IsDualCoinEnabled && !kernelInput.IsAutoDualWeight)
                        {
                            if (coinKernelProfile.DualCoinWeight > kernelInput.DualWeightMax)
                            {
                                coinKernelProfile.DualCoinWeight = kernelInput.DualWeightMax;
                            }
                            else if (coinKernelProfile.DualCoinWeight < kernelInput.DualWeightMin)
                            {
                                coinKernelProfile.DualCoinWeight = kernelInput.DualWeightMin;
                            }
                            NTMinerContext.Instance.MinerProfile.SetCoinKernelProfileProperty(coinKernelProfile.CoinKernelId, nameof(coinKernelProfile.DualCoinWeight), coinKernelProfile.DualCoinWeight);
                        }
                    }
                }
                #endregion
                NTMinerContext.Instance.CurrentMineContext = NTMinerContext.Instance.CreateMineContext();
                if (NTMinerContext.Instance.CurrentMineContext != null)
                {
                    this.ArgsAssembly = NTMinerContext.Instance.CurrentMineContext.CommandLine;
                }
                else
                {
                    this.ArgsAssembly = string.Empty;
                }
            });
            AppRoot.AddCmdPath <RefreshAutoBootStartCommand>("刷新开机启动和自动挖矿的展示", LogEnum.DevConsole,
                                                             action: message => {
                this.OnPropertyChanged(nameof(IsAutoBoot));
                this.OnPropertyChanged(nameof(IsAutoStart));
            }, location: this.GetType());
            AppRoot.AddEventPath <MinerProfilePropertyChangedEvent>("MinerProfile设置变更后刷新VM内存", LogEnum.DevConsole,
                                                                    action: message => {
                OnPropertyChanged(message.PropertyName);
            }, location: this.GetType());

            VirtualRoot.AddEventPath <LocalContextReInitedEventHandledEvent>("本地上下文视图模型集刷新后刷新界面", LogEnum.DevConsole,
                                                                             action: message => {
                AllPropertyChanged();
                if (CoinVm != null)
                {
                    CoinVm.OnPropertyChanged(nameof(CoinVm.Wallets));
                    CoinVm.CoinKernel?.CoinKernelProfile.SelectedDualCoin?.OnPropertyChanged(nameof(CoinVm.Wallets));
                    CoinVm.CoinProfile?.OnPropertyChanged(nameof(CoinVm.CoinProfile.SelectedWallet));
                    CoinVm.CoinKernel?.CoinKernelProfile.SelectedDualCoin?.CoinProfile?.OnPropertyChanged(nameof(CoinVm.CoinProfile.SelectedDualCoinWallet));
                }
            }, location: this.GetType());
            VirtualRoot.AddEventPath <CoinVmAddedEvent>("Vm集添加了新币种后刷新MinerProfileVm内存", LogEnum.DevConsole, action: message => {
                OnPropertyChanged(nameof(CoinVm));
            }, this.GetType());
            VirtualRoot.AddEventPath <CoinVmRemovedEvent>("Vm集删除了新币种后刷新MinerProfileVm内存", LogEnum.DevConsole, action: message => {
                OnPropertyChanged(nameof(CoinVm));
            }, this.GetType());
        }
Ejemplo n.º 8
0
            private MinerGroupViewModels()
            {
#if DEBUG
                NTStopwatch.Start();
#endif
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
                foreach (var item in NTMinerContext.Instance.MinerStudioContext.MinerGroupSet.AsEnumerable())
                {
                    if (!_dicById.ContainsKey(item.Id))
                    {
                        _dicById.Add(item.Id, new MinerGroupViewModel(item));
                    }
                }
                AppRoot.AddEventPath <MinerGroupSetInitedEvent>("矿工组集初始化后初始化Vm内存", LogEnum.DevConsole, action: message => {
                    foreach (var item in NTMinerContext.Instance.MinerStudioContext.MinerGroupSet.AsEnumerable())
                    {
                        if (!_dicById.ContainsKey(item.Id))
                        {
                            _dicById.Add(item.Id, new MinerGroupViewModel(item));
                        }
                    }
                    this.OnPropertyChangeds();
                    MinerClientsWindowViewModel.Instance.RefreshMinerClientsSelectedMinerGroup(MinerClientsWindowViewModel.Instance.MinerClients.ToArray());
                }, this.GetType());
                this.Add = new DelegateCommand(() => {
                    new MinerGroupViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
                });
                AppRoot.AddEventPath <MinerGroupAddedEvent>("添加矿机分组后刷新VM内存", LogEnum.DevConsole,
                                                            action: message => {
                    if (!_dicById.TryGetValue(message.Source.GetId(), out MinerGroupViewModel vm))
                    {
                        vm = new MinerGroupViewModel(message.Source);
                        _dicById.Add(message.Source.GetId(), vm);
                        OnPropertyChangeds();
                        MinerClientsWindowVm.OnPropertyChanged(nameof(MinerClientsWindowViewModel.SelectedMinerGroup));
                    }
                }, location: this.GetType());
                AppRoot.AddEventPath <MinerGroupUpdatedEvent>("添加矿机分组后刷新VM内存", LogEnum.DevConsole,
                                                              action: message => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out MinerGroupViewModel vm))
                    {
                        vm.Update(message.Source);
                    }
                }, location: this.GetType());
                AppRoot.AddEventPath <MinerGroupRemovedEvent>("移除了矿机组后刷新Vm内容", LogEnum.DevConsole, action: message => {
                    if (_dicById.TryGetValue(message.Source.Id, out MinerGroupViewModel vm))
                    {
                        _dicById.Remove(vm.Id);
                        OnPropertyChangeds();
                        MinerClientsWindowVm.OnPropertyChanged(nameof(MinerClientsWindowViewModel.SelectedMinerGroup));
                    }
                }, this.GetType());
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
Ejemplo n.º 9
0
        public MinerProfileViewModel()
        {
#if DEBUG
            NTStopwatch.Start();
#endif
            if (WpfUtil.IsInDesignMode)
            {
                return;
            }
            if (Instance != null)
            {
                throw new InvalidProgramException();
            }
            if (this.IsCreateShortcut)
            {
                CreateShortcut();
            }
            this.Up = new DelegateCommand <string>(propertyName => {
                #region
                if (!_propertyInfos.TryGetValue(propertyName, out PropertyInfo propertyInfo))
                {
                    propertyInfo = this.GetType().GetProperty(propertyName);
                    if (propertyInfo == null)
                    {
                        Write.DevError(() => $"类型{this.GetType().FullName}不具有名称为{propertyName}的属性");
                        return;
                    }
                    _propertyInfos.Add(propertyName, propertyInfo);
                }
                if (propertyInfo.PropertyType == typeof(int))
                {
                    propertyInfo.SetValue(this, (int)propertyInfo.GetValue(this, null) + 1, null);
                }
                else if (propertyInfo.PropertyType == typeof(double))
                {
                    propertyInfo.SetValue(this, Math.Round((double)propertyInfo.GetValue(this, null) + 0.1, 2), null);
                }
                #endregion
            });
            this.Down = new DelegateCommand <string>(propertyName => {
                #region
                if (!_propertyInfos.TryGetValue(propertyName, out PropertyInfo propertyInfo))
                {
                    propertyInfo = this.GetType().GetProperty(propertyName);
                    if (propertyInfo == null)
                    {
                        Write.DevError(() => $"类型{this.GetType().FullName}不具有名称为{propertyName}的属性");
                        return;
                    }
                    _propertyInfos.Add(propertyName, propertyInfo);
                }
                if (propertyInfo.PropertyType == typeof(int))
                {
                    int value = (int)propertyInfo.GetValue(this, null);
                    if (value > 0)
                    {
                        propertyInfo.SetValue(this, value - 1, null);
                    }
                }
                else if (propertyInfo.PropertyType == typeof(double))
                {
                    double value = (double)propertyInfo.GetValue(this, null);
                    if (value > 0.1)
                    {
                        propertyInfo.SetValue(this, Math.Round(value - 0.1, 2), null);
                    }
                }
                #endregion
            });
            this.WsRetry = new DelegateCommand(() => {
                RpcRoot.Client.NTMinerDaemonService.StartOrStopWsAsync(isResetFailCount: true);
                IsConnecting = true;
            });
            bool isRefreshed = false;
            if (ClientAppType.IsMinerClient)
            {
                VirtualRoot.AddEventPath <StartingMineFailedEvent>("开始挖矿失败", LogEnum.DevConsole,
                                                                   action: message => {
                    IsMining = false;
                    Write.UserError(message.Message);
                }, location: this.GetType());
                // 群控客户端已经有一个执行RefreshWsStateCommand命令的路径了
                VirtualRoot.AddCmdPath <RefreshWsStateCommand>(message => {
                    #region
                    if (message.WsClientState != null)
                    {
                        isRefreshed     = true;
                        this.IsWsOnline = message.WsClientState.Status == WsClientStatus.Open;
                        if (message.WsClientState.ToOut)
                        {
                            VirtualRoot.Out.ShowWarn(message.WsClientState.Description, autoHideSeconds: 3);
                        }
                        if (!message.WsClientState.ToOut || !this.IsWsOnline)
                        {
                            this.WsDescription = message.WsClientState.Description;
                        }
                        if (!this.IsWsOnline)
                        {
                            if (message.WsClientState.LastTryOn != DateTime.MinValue)
                            {
                                this.WsLastTryOn = message.WsClientState.LastTryOn;
                            }
                            if (message.WsClientState.NextTrySecondsDelay > 0)
                            {
                                WsNextTrySecondsDelay = message.WsClientState.NextTrySecondsDelay;
                            }
                        }
                    }
                    #endregion
                }, this.GetType(), LogEnum.DevConsole);
                VirtualRoot.AddEventPath <Per1SecondEvent>("外网群控重试秒表倒计时", LogEnum.None, action: message => {
                    if (IsOuterUserEnabled && !IsWsOnline)
                    {
                        if (WsNextTrySecondsDelay > 0)
                        {
                            WsNextTrySecondsDelay--;
                        }
                        OnPropertyChanged(nameof(WsLastTryOnText));
                    }
                }, this.GetType());
                VirtualRoot.AddEventPath <WsServerOkEvent>("服务器Ws服务已可用", LogEnum.DevConsole, action: message => {
                    if (IsOuterUserEnabled && !IsWsOnline)
                    {
                        StartOrStopWs();
                    }
                }, this.GetType());
                if (IsOuterUserEnabled)
                {
                    RpcRoot.Client.NTMinerDaemonService.GetWsDaemonStateAsync((WsClientState state, Exception e) => {
                        if (state != null && !isRefreshed)
                        {
                            this.IsWsOnline    = state.Status == WsClientStatus.Open;
                            this.WsDescription = state.Description;
                            if (state.NextTrySecondsDelay > 0)
                            {
                                this.WsNextTrySecondsDelay = state.NextTrySecondsDelay;
                            }
                            this.WsLastTryOn = state.LastTryOn;
                        }
                    });
                }
            }
            NTMinerContext.SetRefreshArgsAssembly((reason) => {
                Write.DevDebug(() => $"RefreshArgsAssembly" + reason, ConsoleColor.Cyan);
#if DEBUG
                NTStopwatch.Start();
#endif
                #region 确保双挖权重在合法的范围内
                if (CoinVm != null && CoinVm.CoinKernel != null && CoinVm.CoinKernel.Kernel != null)
                {
                    var coinKernelProfile = CoinVm.CoinKernel.CoinKernelProfile;
                    var kernelInput       = CoinVm.CoinKernel.Kernel.KernelInputVm;
                    if (coinKernelProfile != null && kernelInput != null)
                    {
                        if (coinKernelProfile.IsDualCoinEnabled && !kernelInput.IsAutoDualWeight)
                        {
                            if (coinKernelProfile.DualCoinWeight > kernelInput.DualWeightMax)
                            {
                                coinKernelProfile.DualCoinWeight = kernelInput.DualWeightMax;
                            }
                            else if (coinKernelProfile.DualCoinWeight < kernelInput.DualWeightMin)
                            {
                                coinKernelProfile.DualCoinWeight = kernelInput.DualWeightMin;
                            }
                            NTMinerContext.Instance.MinerProfile.SetCoinKernelProfileProperty(coinKernelProfile.CoinKernelId, nameof(coinKernelProfile.DualCoinWeight), coinKernelProfile.DualCoinWeight);
                        }
                    }
                }
                #endregion
                NTMinerContext.Instance.CurrentMineContext = NTMinerContext.Instance.CreateMineContext();
                if (NTMinerContext.Instance.CurrentMineContext != null)
                {
                    this.ArgsAssembly = NTMinerContext.Instance.CurrentMineContext.CommandLine;
                }
                else
                {
                    this.ArgsAssembly = string.Empty;
                }
#if DEBUG
                var milliseconds = NTStopwatch.Stop();
                if (milliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{milliseconds} {this.GetType().Name}.SetRefreshArgsAssembly");
                }
#endif
            });
            VirtualRoot.AddEventPath <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                                     action: message => {
                OnPropertyChanged(nameof(CoinVm));
            }, location: this.GetType());
            AppRoot.AddCmdPath <RefreshAutoBootStartCommand>("刷新开机启动和自动挖矿的展示", LogEnum.DevConsole,
                                                             action: message => {
                MinerProfileData data = NTMinerContext.Instance.ServerContext.CreateLocalRepository <MinerProfileData>().GetByKey(this.Id);
                if (data != null)
                {
                    this.IsAutoBoot  = data.IsAutoBoot;
                    this.IsAutoStart = data.IsAutoStart;
                }
            }, location: this.GetType());
            AppRoot.AddEventPath <MinerProfilePropertyChangedEvent>("MinerProfile设置变更后刷新VM内存", LogEnum.DevConsole,
                                                                    action: message => {
                OnPropertyChanged(message.PropertyName);
            }, location: this.GetType());

            VirtualRoot.AddEventPath <LocalContextVmsReInitedEvent>("本地上下文视图模型集刷新后刷新界面", LogEnum.DevConsole,
                                                                    action: message => {
                AllPropertyChanged();
                if (CoinVm != null)
                {
                    CoinVm.OnPropertyChanged(nameof(CoinVm.Wallets));
                    CoinVm.CoinKernel?.CoinKernelProfile.SelectedDualCoin?.OnPropertyChanged(nameof(CoinVm.Wallets));
                    CoinVm.CoinProfile?.OnPropertyChanged(nameof(CoinVm.CoinProfile.SelectedWallet));
                    CoinVm.CoinKernel?.CoinKernelProfile.SelectedDualCoin?.CoinProfile?.OnPropertyChanged(nameof(CoinVm.CoinProfile.SelectedDualCoinWallet));
                }
            }, location: this.GetType());
            VirtualRoot.AddEventPath <CoinVmAddedEvent>("Vm集添加了新币种后刷新MinerProfileVm内存", LogEnum.DevConsole, action: message => {
                OnPropertyChanged(nameof(CoinVm));
            }, this.GetType());
            VirtualRoot.AddEventPath <CoinVmRemovedEvent>("Vm集删除了新币种后刷新MinerProfileVm内存", LogEnum.DevConsole, action: message => {
                OnPropertyChanged(nameof(CoinVm));
            }, this.GetType());
#if DEBUG
            var elapsedMilliseconds = NTStopwatch.Stop();
            if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
            {
                Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
            }
#endif
        }