public T ExecuteDaemon <T>(string parameters, bool disableTrace = false) { if (this.Machine == null) { throw new ArgumentNullException("The Machine object is not initialized in MinerClient. " + this.MachineFullName); } TargetMachineExecutor executor = TargetMachineExecutor.GetExecutor(this.Machine, disableTrace); string daemonFullPath = Path.Combine(this.BinaryPath, WinMinerReleaseBinary.DaemonExecutionFileName); return(executor.ExecuteCommandAndThrow <T>(daemonFullPath, parameters)); }
private void StepThree_RetrieveDeviceList() { logger.Trace("Start StepThree_RetrieveDeviceList."); txtWalletAddress.Text = ManagerConfig.Current.DefaultXDagger.WalletAddress; txtXDaggerPoolAddress.Text = ManagerConfig.Current.DefaultXDagger.PoolAddress; txtWalletAddressEth.Text = ManagerConfig.Current.DefaultEth.WalletAddress; txtEmailAddressEth.Text = ManagerConfig.Current.DefaultEth.EmailAddress; txtEthWorkerName.Text = ManagerConfig.Current.DefaultEth.WorkerName; if (ManagerConfig.Current.DefaultEth.PoolIndex != null) { cBxTargetEthPool.SelectedIndex = ManagerConfig.Current.DefaultEth.PoolIndex.GetHashCode(); } if (ManagerConfig.Current.DefaultEth.PoolHostIndex != null) { cBxTargetEthPoolHost.SelectedIndex = ManagerConfig.Current.DefaultEth.PoolHostIndex.Value; } MinerMachine existingMachine = ManagerInfo.Current.Machines.FirstOrDefault(m => m.FullName.Equals(createdClient.MachineFullName)); if (existingMachine != null && existingMachine.Devices != null && existingMachine.Devices.Count > 0) { // This machine has been queried before and the devices are saved in the ManagerInfo cache, read it displayedDeviceList = existingMachine.Devices; cBxTargetDevice.Items.Clear(); cBxTargetDeviceEth.Items.Clear(); logger.Trace("Got Devices from ManagerInfo cache. Count: " + displayedDeviceList.Count); foreach (MinerDevice device in displayedDeviceList) { cBxTargetDevice.Items.Add(device.DisplayName); cBxTargetDeviceEth.Items.Add(device.DisplayName); } } else { // Didn't find the machine in cache, use Executor to retrieve it TargetMachineExecutor executor = TargetMachineExecutor.GetExecutor(createdClient.Machine); string daemonFullPath = IO.Path.Combine(createdClient.BinaryPath, WinMinerReleaseBinary.DaemonExecutionFileName); BackgroundWork <List <DeviceOutput> > .CreateWork( this, () => { ShowProgressIndicator("正在获取硬件信息", btnStepThreeNext, btnStepThreeBack); }, () => { return(executor.ExecuteCommandAndThrow <List <DeviceOutput> >(daemonFullPath, "-l")); }, (taskResult) => { HideProgressIndicator(); if (taskResult.HasError) { MessageBox.Show("查询系统硬件信息错误:" + taskResult.Exception.Message); logger.Error("ExecuteCommand failed: " + taskResult.Exception.ToString()); return; } List <DeviceOutput> devices = taskResult.Result; if (devices == null || devices.Count == 0) { MessageBox.Show("没有找到任何满足条件的硬件,请检查目标机器配置"); logger.Warning("没有找到任何满足条件的硬件,请检查目标机器配置"); return; } cBxTargetDevice.Items.Clear(); cBxTargetDeviceEth.Items.Clear(); logger.Trace("Got Devices count: " + devices.Count); foreach (DeviceOutput deviceOut in devices) { MinerDevice device = new MinerDevice(deviceOut.DeviceId, deviceOut.DisplayName, deviceOut.DeviceVersion, deviceOut.DriverVersion); displayedDeviceList.Add(device); cBxTargetDevice.Items.Add(device.DisplayName); cBxTargetDeviceEth.Items.Add(device.DisplayName); createdClient.Machine.Devices.Add(device); } } ).Execute(); } }