コード例 #1
0
        private MinerClientsWindowViewModel()
        {
            if (Design.IsInDesignMode)
            {
                return;
            }
            var  appSettings   = NTMinerRoot.Current.AppSettingSet;
            Guid columnsShowId = ColumnsShowData.PleaseSelect.Id;

            if (appSettings.TryGetAppSetting("ColumnsShowId", out IAppSetting columnsShowAppSetting) && columnsShowAppSetting.Value != null)
            {
                if (Guid.TryParse(columnsShowAppSetting.Value.ToString(), out Guid guid))
                {
                    columnsShowId = guid;
                }
            }
            if (appSettings.TryGetAppSetting("FrozenColumnCount", out IAppSetting frozenColumnCountAppSetting) && frozenColumnCountAppSetting.Value != null)
            {
                if (int.TryParse(frozenColumnCountAppSetting.Value.ToString(), out int frozenColumnCount))
                {
                    _frozenColumnCount = frozenColumnCount;
                }
            }
            if (appSettings.TryGetAppSetting("MaxTemp", out IAppSetting maxTempAppSetting) && maxTempAppSetting.Value != null)
            {
                if (uint.TryParse(maxTempAppSetting.Value.ToString(), out uint maxTemp))
                {
                    _maxTemp = maxTemp;
                }
            }
            if (appSettings.TryGetAppSetting("MinTemp", out IAppSetting minTempAppSetting) && minTempAppSetting.Value != null)
            {
                if (uint.TryParse(minTempAppSetting.Value.ToString(), out uint minTemp))
                {
                    _minTemp = minTemp;
                }
            }
            if (appSettings.TryGetAppSetting("RejectPercent", out IAppSetting rejectPercentAppSetting) && rejectPercentAppSetting.Value != null)
            {
                if (int.TryParse(rejectPercentAppSetting.Value.ToString(), out int rejectPercent))
                {
                    _rejectPercent = rejectPercent;
                }
            }
            this._columnsShow = this.ColumnsShows.List.FirstOrDefault(a => a.Id == columnsShowId);
            if (this._columnsShow == null)
            {
                this._columnsShow = this.ColumnsShows.List.FirstOrDefault();
            }
            this._mineStatusEnumItem = AppStatic.MineStatusEnumItems.FirstOrDefault(a => a.Value == MineStatus.All);
            this._coinVm             = CoinViewModel.PleaseSelect;
            this._selectedMineWork   = MineWorkViewModel.PleaseSelect;
            this._selectedMinerGroup = MinerGroupViewModel.PleaseSelect;
            this._pool         = string.Empty;
            this._poolVm       = _coinVm.OptionPools.First();
            this._wallet       = string.Empty;
            this.OneKeySetting = new DelegateCommand(() => {
                MinerClientSetting.ShowWindow(new MinerClientSettingViewModel(this.SelectedMinerClients));
            }, CanCommand);
            this.OneKeyMinerNames = new DelegateCommand(() => {
                if (this.SelectedMinerClients.Length == 1)
                {
                    var selectedMinerClient = this.SelectedMinerClients[0];
                    InputWindow.ShowDialog("作业矿工名 注意:重新开始挖矿时生效", selectedMinerClient.MinerName, null, minerName => {
                        selectedMinerClient.MinerName = minerName;
                        NotiCenterWindowViewModel.Current.Manager.ShowSuccessMessage("设置作业矿工名成功,重新开始挖矿时生效。");
                    });
                    return;
                }
                MinerNamesSeterViewModel vm = new MinerNamesSeterViewModel(
                    prefix: "miner",
                    suffix: "01",
                    namesByObjectId: this.SelectedMinerClients.Select(a => new Tuple <string, string>(a.Id, string.Empty)).ToList());
                MinerNamesSeter.ShowWindow(vm);
                if (vm.IsOk)
                {
                    this.CountDown = 10;
                    Server.ControlCenterService.UpdateClientsAsync(nameof(MinerClientViewModel.MinerName), vm.NamesByObjectId.ToDictionary(a => a.Item1, a => (object)a.Item2), callback: (response, e) => {
                        if (!response.IsSuccess())
                        {
                            if (response != null)
                            {
                                Write.UserLine(response.Description, ConsoleColor.Red);
                            }
                        }
                        else
                        {
                            foreach (var kv in vm.NamesByObjectId)
                            {
                                var item = this.SelectedMinerClients.FirstOrDefault(a => a.Id == kv.Item1);
                                if (item != null)
                                {
                                    item.UpdateMinerName(kv.Item2);
                                }
                            }
                            QueryMinerClients();
                        }
                    });
                }
            }, CanCommand);
            this.RemoteDesktop = new DelegateCommand(() => {
                if (this.SelectedMinerClients != null && this.SelectedMinerClients.Length == 1)
                {
                    this.SelectedMinerClients[0].RemoteDesktop.Execute(null);
                }
            }, OnlySelectedOne);
            this.EditMineWork = new DelegateCommand(() => {
                this.SelectedMinerClients[0].SelectedMineWork.Edit.Execute(null);
            }, () => OnlySelectedOne() && this.SelectedMinerClients[0].SelectedMineWork != null &&
                                                    this.SelectedMinerClients[0].SelectedMineWork != MineWorkViewModel.PleaseSelect);
            this.OneKeyWork = new DelegateCommand <MineWorkViewModel>((work) => {
                foreach (var item in SelectedMinerClients)
                {
                    item.SelectedMineWork = work;
                }
            });
            this.OneKeyGroup = new DelegateCommand <MinerGroupViewModel>((group) => {
                foreach (var item in SelectedMinerClients)
                {
                    item.SelectedMinerGroup = group;
                }
            });
            this.OneKeyOverClock = new DelegateCommand(() => {
                if (this.SelectedMinerClients.Length == 1)
                {
                    GpuProfilesPage.ShowWindow(this);
                }
            }, OnlySelectedOne);
            this.OneKeyUpgrade = new DelegateCommand <NTMinerFileData>((ntminerFileData) => {
                DialogWindow.ShowDialog(message: "确定升级到该版本吗?", title: "确认", onYes: () => {
                    foreach (var item in SelectedMinerClients)
                    {
                        Server.MinerClientService.UpgradeNTMinerAsync(item, ntminerFileData.FileName, (response, e) => {
                            if (!response.IsSuccess())
                            {
                                if (response != null)
                                {
                                    Write.UserLine($"{item.MinerName} {item.MinerIp} {response.Description}", ConsoleColor.Red);
                                }
                            }
                        });
                    }
                }, icon: IconConst.IconConfirm);
            }, (ntminerFileData) => {
                return(this.SelectedMinerClients != null && this.SelectedMinerClients.Length != 0);
            });
            this.AddMinerClient = new DelegateCommand(() => {
                MinerClientAdd.ShowWindow();
            });
            this.RemoveMinerClients = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    DialogWindow.ShowDialog(message: $"确定删除选中的矿机吗?", title: "确认", onYes: () => {
                        this.CountDown = 10;
                        Server.ControlCenterService.RemoveClientsAsync(SelectedMinerClients.Select(a => a.Id).ToList(), (response, e) => {
                            if (!response.IsSuccess())
                            {
                                if (response != null)
                                {
                                    Write.UserLine(response.Description, ConsoleColor.Red);
                                }
                            }
                            else
                            {
                                QueryMinerClients();
                            }
                        });
                    }, icon: IconConst.IconConfirm);
                }
            }, CanCommand);
            this.RefreshMinerClients = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    Server.ControlCenterService.RefreshClientsAsync(SelectedMinerClients.Select(a => a.Id).ToList(), (response, e) => {
                        if (!response.IsSuccess())
                        {
                            if (response != null)
                            {
                                Write.UserLine(response.Description, ConsoleColor.Red);
                            }
                        }
                        else
                        {
                            foreach (var data in response.Data)
                            {
                                var item = MinerClients.FirstOrDefault(a => a.Id == data.Id);
                                if (item != null)
                                {
                                    item.Update(data);
                                }
                            }
                        }
                    });
                }
            }, CanCommand);
            this.RestartWindows = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    DialogWindow.ShowDialog(message: $"确定重启选中的电脑吗?", title: "确认", onYes: () => {
                        foreach (var item in SelectedMinerClients)
                        {
                            Server.MinerClientService.RestartWindowsAsync(item, (response, e) => {
                                if (!response.IsSuccess())
                                {
                                    if (response != null)
                                    {
                                        Write.UserLine(response.Description, ConsoleColor.Red);
                                    }
                                }
                            });
                        }
                    }, icon: IconConst.IconConfirm);
                }
            }, CanCommand);
            this.ShutdownWindows = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    DialogWindow.ShowDialog(message: $"确定关闭选中的电脑吗?", title: "确认", onYes: () => {
                        foreach (var item in SelectedMinerClients)
                        {
                            Server.MinerClientService.ShutdownWindowsAsync(item, (response, e) => {
                                if (!response.IsSuccess())
                                {
                                    if (response != null)
                                    {
                                        Write.UserLine(response.Description, ConsoleColor.Red);
                                    }
                                }
                            });
                        }
                    }, icon: IconConst.IconConfirm);
                }
            }, CanCommand);
            this.RestartNTMiner = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    DialogWindow.ShowDialog(message: $"确定重启选中的挖矿客户端吗?", title: "确认", onYes: () => {
                        foreach (var item in SelectedMinerClients)
                        {
                            Server.MinerClientService.RestartNTMinerAsync(item, (response, e) => {
                                if (!response.IsSuccess())
                                {
                                    if (response != null)
                                    {
                                        Write.UserLine(response.Description, ConsoleColor.Red);
                                    }
                                }
                            });
                        }
                    }, icon: IconConst.IconConfirm);
                }
            }, CanCommand);
            this.StartMine = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    foreach (var item in SelectedMinerClients)
                    {
                        item.IsMining = true;
                        Server.MinerClientService.StartMineAsync(item, item.WorkId, (response, e) => {
                            if (!response.IsSuccess())
                            {
                                string message = $"{item.MinerIp} {response?.Description}";
                                Write.UserLine(message, ConsoleColor.Red);
                            }
                        });
                        Server.ControlCenterService.UpdateClientAsync(item.Id, nameof(item.IsMining), item.IsMining, null);
                    }
                }
            }, CanCommand);
            this.StopMine = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    DialogWindow.ShowDialog(message: $"确定停止挖矿选中的挖矿端吗?", title: "确认", onYes: () => {
                        foreach (var item in SelectedMinerClients)
                        {
                            item.IsMining = false;
                            Server.MinerClientService.StopMineAsync(item, (response, e) => {
                                if (!response.IsSuccess())
                                {
                                    string message = $"{item.MinerIp} {response?.Description}";
                                    Write.UserLine(message, ConsoleColor.Red);
                                }
                            });
                            Server.ControlCenterService.UpdateClientAsync(item.Id, nameof(item.IsMining), item.IsMining, null);
                        }
                    }, icon: IconConst.IconConfirm);
                }
            }, CanCommand);
            this.PageUp = new DelegateCommand(() => {
                this.MinerClientPageIndex = this.MinerClientPageIndex - 1;
            });
            this.PageDown = new DelegateCommand(() => {
                this.MinerClientPageIndex = this.MinerClientPageIndex + 1;
            });
            this.PageFirst = new DelegateCommand(() => {
                this.MinerClientPageIndex = 1;
            });
            this.PageLast = new DelegateCommand(() => {
                this.MinerClientPageIndex = MinerClientPageCount;
            });
            this.PageRefresh = new DelegateCommand(QueryMinerClients);
        }
コード例 #2
0
        public MinerClientsWindowViewModel(bool isInDesignMode = true)
        {
            if (WpfUtil.IsInDesignMode || isInDesignMode)
            {
                return;
            }
            var  appSettings   = NTMinerRoot.Instance.ServerAppSettingSet;
            Guid columnsShowId = ColumnsShowData.PleaseSelect.Id;

            if (appSettings.TryGetAppSetting(NTKeyword.ColumnsShowIdAppSettingKey, out IAppSetting columnsShowAppSetting) && columnsShowAppSetting.Value != null)
            {
                if (Guid.TryParse(columnsShowAppSetting.Value.ToString(), out Guid guid))
                {
                    columnsShowId = guid;
                }
            }
            if (appSettings.TryGetAppSetting(NTKeyword.FrozenColumnCountAppSettingKey, out IAppSetting frozenColumnCountAppSetting) && frozenColumnCountAppSetting.Value != null)
            {
                if (int.TryParse(frozenColumnCountAppSetting.Value.ToString(), out int frozenColumnCount))
                {
                    _frozenColumnCount = frozenColumnCount;
                }
            }
            if (appSettings.TryGetAppSetting(NTKeyword.MaxTempAppSettingKey, out IAppSetting maxTempAppSetting) && maxTempAppSetting.Value != null)
            {
                if (uint.TryParse(maxTempAppSetting.Value.ToString(), out uint maxTemp))
                {
                    _maxTemp = maxTemp;
                }
            }
            if (appSettings.TryGetAppSetting(NTKeyword.MinTempAppSettingKey, out IAppSetting minTempAppSetting) && minTempAppSetting.Value != null)
            {
                if (uint.TryParse(minTempAppSetting.Value.ToString(), out uint minTemp))
                {
                    _minTemp = minTemp;
                }
            }
            if (appSettings.TryGetAppSetting(NTKeyword.RejectPercentAppSettingKey, out IAppSetting rejectPercentAppSetting) && rejectPercentAppSetting.Value != null)
            {
                if (int.TryParse(rejectPercentAppSetting.Value.ToString(), out int rejectPercent))
                {
                    _rejectPercent = rejectPercent;
                }
            }
            this._columnsShow = this.ColumnsShows.List.FirstOrDefault(a => a.Id == columnsShowId);
            if (this._columnsShow == null)
            {
                this._columnsShow = this.ColumnsShows.List.FirstOrDefault();
            }
            this._mineStatusEnumItem = NTMinerRoot.MineStatusEnumItems.FirstOrDefault(a => a.Value == MineStatus.All);
            this._coinVm             = CoinViewModel.PleaseSelect;
            this._selectedMineWork   = MineWorkViewModel.PleaseSelect;
            this._selectedMinerGroup = MinerGroupViewModel.PleaseSelect;
            this._pool = string.Empty;
            // 至少会有一个PleaseSelect所以可以First
            this._poolVm       = _coinVm.OptionPools.First();
            this._wallet       = string.Empty;
            this.OneKeySetting = new DelegateCommand(() => {
                VirtualRoot.Execute(new ShowMinerClientSettingCommand(new MinerClientSettingViewModel(this.SelectedMinerClients)));
            }, CanCommand);
            this.OneKeyMinerNames = new DelegateCommand(() => {
                if (this.SelectedMinerClients.Length == 1)
                {
                    var selectedMinerClient = this.SelectedMinerClients[0];
                    WpfUtil.ShowInputDialog("群控矿工名 注意:重新开始挖矿时生效", selectedMinerClient.MinerName, null, minerName => {
                        selectedMinerClient.MinerName = minerName;
                        VirtualRoot.Out.ShowSuccess("设置群控矿工名成功,重新开始挖矿时生效。");
                    });
                    return;
                }
                MinerNamesSeterViewModel vm = new MinerNamesSeterViewModel(
                    prefix: "miner",
                    suffix: "01",
                    namesByObjectId: this.SelectedMinerClients.Select(a => new Tuple <string, string>(a.Id, string.Empty)).ToList());
                VirtualRoot.Execute(new ShowMinerNamesSeterCommand(vm));
                if (vm.IsOk)
                {
                    this.CountDown = 10;
                    RpcRoot.Server.ClientService.UpdateClientsAsync(nameof(MinerClientViewModel.MinerName), vm.NamesByObjectId.ToDictionary(a => a.Item1, a => (object)a.Item2), callback: (response, e) => {
                        if (!response.IsSuccess())
                        {
                            VirtualRoot.Out.ShowError(response.ReadMessage(e), autoHideSeconds: 4);
                        }
                        else
                        {
                            foreach (var kv in vm.NamesByObjectId)
                            {
                                var item = this.SelectedMinerClients.FirstOrDefault(a => a.Id == kv.Item1);
                                if (item != null)
                                {
                                    item.UpdateMinerName(kv.Item2);
                                }
                            }
                            QueryMinerClients();
                        }
                    });
                }
            }, CanCommand);
            this.OneKeyWindowsLoginName = new DelegateCommand(() => {
                WpfUtil.ShowInputDialog("远程桌面用户名", string.Empty, null, loginName => {
                    foreach (var item in SelectedMinerClients)
                    {
                        item.WindowsLoginName = loginName;
                    }
                    VirtualRoot.Out.ShowSuccess("设置远程桌面用户名成功,双击矿机可打开远程桌面。");
                });
            }, CanCommand);
            this.OneKeyWindowsLoginPassword = new DelegateCommand(() => {
                WpfUtil.ShowInputDialog("远程桌面密码", string.Empty, null, password => {
                    foreach (var item in SelectedMinerClients)
                    {
                        item.WindowsPassword = password;
                    }
                    VirtualRoot.Out.ShowSuccess("设置远程桌面密码成功,双击矿机可打开远程桌面。");
                });
            }, CanCommand);
            this.EditMineWork = new DelegateCommand(() => {
                this.SelectedMinerClients[0].SelectedMineWork.Edit.Execute(null);
            }, () => OnlySelectedOne() && this.SelectedMinerClients[0].SelectedMineWork != null &&
                                                    this.SelectedMinerClients[0].SelectedMineWork != MineWorkViewModel.PleaseSelect);
            this.OneKeyWork = new DelegateCommand <MineWorkViewModel>((work) => {
                foreach (var item in SelectedMinerClients)
                {
                    item.SelectedMineWork = work;
                }
            });
            this.OneKeyGroup = new DelegateCommand <MinerGroupViewModel>((group) => {
                foreach (var item in SelectedMinerClients)
                {
                    item.SelectedMinerGroup = group;
                }
            });
            this.OneKeyOverClock = new DelegateCommand(() => {
                if (this.SelectedMinerClients.Length == 1)
                {
                    VirtualRoot.Execute(new ShowGpuProfilesPageCommand(this));
                }
            }, OnlySelectedOne);
            this.OneKeyUpgrade = new DelegateCommand <NTMinerFileData>((ntminerFileData) => {
                this.ShowSoftDialog(new DialogWindowViewModel(message: "确定升级到该版本吗?", title: "确认", onYes: () => {
                    foreach (var item in SelectedMinerClients)
                    {
                        RpcRoot.Server.MinerClientService.UpgradeNTMinerAsync(item, ntminerFileData.FileName, (response, e) => {
                            if (!response.IsSuccess())
                            {
                                VirtualRoot.Out.ShowError($"{item.MinerName} {item.MinerIp} {response.ReadMessage(e)}");
                            }
                        });
                    }
                }));
            }, (ntminerFileData) => this.SelectedMinerClients != null && this.SelectedMinerClients.Length != 0);
            this.AddMinerClient = new DelegateCommand(() => {
                VirtualRoot.Execute(new ShowMinerClientAddCommand());
            });
            this.RemoveMinerClients = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定删除选中的矿机吗?", title: "确认", onYes: () => {
                        this.CountDown = 10;
                        RpcRoot.Server.ClientService.RemoveClientsAsync(SelectedMinerClients.Select(a => a.Id).ToList(), (response, e) => {
                            if (!response.IsSuccess())
                            {
                                VirtualRoot.Out.ShowError(response.ReadMessage(e), autoHideSeconds: 4);
                            }
                            else
                            {
                                QueryMinerClients();
                            }
                        });
                    }));
                }
            }, CanCommand);
            this.RefreshMinerClients = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    RpcRoot.Server.ClientService.RefreshClientsAsync(SelectedMinerClients.Select(a => a.Id).ToList(), (response, e) => {
                        if (!response.IsSuccess())
                        {
                            VirtualRoot.Out.ShowError(response.ReadMessage(e), autoHideSeconds: 4);
                        }
                        else
                        {
                            foreach (var data in response.Data)
                            {
                                var item = MinerClients.FirstOrDefault(a => a.Id == data.Id);
                                if (item != null)
                                {
                                    item.Update(data);
                                }
                            }
                        }
                    });
                }
            }, CanCommand);
            this.RestartWindows = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定重启选中的电脑吗?", title: "确认", onYes: () => {
                        foreach (var item in SelectedMinerClients)
                        {
                            RpcRoot.Server.MinerClientService.RestartWindowsAsync(item, (response, e) => {
                                if (!response.IsSuccess())
                                {
                                    VirtualRoot.Out.ShowError($"{item.MinerName} {item.MinerIp} {response.ReadMessage(e)}");
                                }
                            });
                        }
                    }));
                }
            }, CanCommand);
            this.ShutdownWindows = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定关闭选中的电脑吗?", title: "确认", onYes: () => {
                        foreach (var item in SelectedMinerClients)
                        {
                            RpcRoot.Server.MinerClientService.ShutdownWindowsAsync(item, (response, e) => {
                                if (!response.IsSuccess())
                                {
                                    VirtualRoot.Out.ShowError($"{item.MinerName} {item.MinerIp} {response.ReadMessage(e)}");
                                }
                            });
                        }
                    }));
                }
            }, CanCommand);
            this.RestartNTMiner = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定重启选中的挖矿客户端吗?", title: "确认", onYes: () => {
                        foreach (var item in SelectedMinerClients)
                        {
                            RpcRoot.Server.MinerClientService.RestartNTMinerAsync(item, (response, e) => {
                                if (!response.IsSuccess())
                                {
                                    VirtualRoot.Out.ShowError($"{item.MinerName} {item.MinerIp} {response.ReadMessage(e)}");
                                }
                            });
                        }
                    }));
                }
            }, CanCommand);
            this.StartMine = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    foreach (var item in SelectedMinerClients)
                    {
                        item.IsMining = true;
                        RpcRoot.Server.MinerClientService.StartMineAsync(item, item.WorkId, (response, e) => {
                            if (!response.IsSuccess())
                            {
                                VirtualRoot.Out.ShowError($"{item.MinerName} {item.MinerIp} {response.ReadMessage(e)}");
                            }
                        });
                        RpcRoot.Server.ClientService.UpdateClientAsync(item.Id, nameof(item.IsMining), item.IsMining, (response, e) => {
                            if (!response.IsSuccess())
                            {
                                VirtualRoot.Out.ShowError(response.ReadMessage(e), autoHideSeconds: 4);
                            }
                        });
                    }
                }
            }, CanCommand);
            this.StopMine = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定将选中的矿机停止挖矿吗?", title: "确认", onYes: () => {
                        foreach (var item in SelectedMinerClients)
                        {
                            item.IsMining = false;
                            RpcRoot.Server.MinerClientService.StopMineAsync(item, (response, e) => {
                                if (!response.IsSuccess())
                                {
                                    VirtualRoot.Out.ShowError($"{item.MinerName} {item.MinerIp} {response.ReadMessage(e)}");
                                }
                            });
                            RpcRoot.Server.ClientService.UpdateClientAsync(item.Id, nameof(item.IsMining), item.IsMining, (response, e) => {
                                if (!response.IsSuccess())
                                {
                                    VirtualRoot.Out.ShowError($"{item.MinerName} {item.MinerIp} {response.ReadMessage(e)}");
                                }
                            });
                        }
                    }));
                }
            }, CanCommand);
            this.PageUp = new DelegateCommand(() => {
                this.MinerClientPageIndex -= 1;
            });
            this.PageDown = new DelegateCommand(() => {
                this.MinerClientPageIndex += 1;
            });
            this.PageFirst = new DelegateCommand(() => {
                this.MinerClientPageIndex = 1;
            });
            this.PageLast = new DelegateCommand(() => {
                this.MinerClientPageIndex = MinerClientPageCount;
            });
            this.PageRefresh = new DelegateCommand(QueryMinerClients);
        }
コード例 #3
0
 public bool TryGetMineWorkVm(Guid id, out MinerGroupViewModel minerGroupVm)
 {
     return(_dicById.TryGetValue(id, out minerGroupVm));
 }