public ResponseBase StopMine([FromBody] SignatureRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { ResponseBase response; if (!IsNTMinerOpened()) { return(ResponseBase.Ok()); } try { using (HttpClient client = new HttpClient()) { Task <HttpResponseMessage> message = client.PostAsJsonAsync($"http://localhost:{Consts.MinerClientPort}/api/MinerClient/StopMine", request); response = message.Result.Content.ReadAsAsync <ResponseBase>().Result; return(response); } } catch (Exception e) { Logger.ErrorDebugLine(e); } return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase RestartNTMiner([FromBody] WorkRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } if (request.WorkId != Guid.Empty) { File.WriteAllText(SpecialPath.NTMinerLocalJsonFileFullName, request.LocalJson); File.WriteAllText(SpecialPath.NTMinerServerJsonFileFullName, request.ServerJson); } Task.Factory.StartNew(() => { try { if (IsNTMinerOpened()) { CloseNTMiner(); System.Threading.Thread.Sleep(1000); } string arguments = string.Empty; if (request.WorkId != Guid.Empty) { arguments = "--work"; } string location = NTMinerRegistry.GetLocation(); if (!string.IsNullOrEmpty(location) && File.Exists(location)) { Windows.Cmd.RunClose(location, arguments); } } catch (Exception e) { Logger.ErrorDebugLine(e); } }); return(ResponseBase.Ok()); }
public ResponseBase StartMine([FromBody] WorkRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { VirtualRoot.ThisLocalInfo(nameof(MinerClientController), $"通过群控开始挖矿", toConsole: true); WorkType workType = WorkType.None; if (request.WorkId != Guid.Empty) { workType = WorkType.MineWork; if (request.WorkId.IsSelfMineWorkId()) { workType = WorkType.SelfWork; } } NTMinerContext.Instance.RestartMine(workType, request.WorkerName); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase StopMine([FromBody] SignRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { Logger.InfoDebugLine("停止挖矿"); ResponseBase response; if (!IsNTMinerOpened()) { return(ResponseBase.Ok()); } try { using (HttpClient client = RpcRoot.CreateHttpClient()) { Task <HttpResponseMessage> getHttpResponse = client.PostAsJsonAsync($"http://localhost:{NTKeyword.MinerClientPort.ToString()}/api/MinerClient/StopMine", request); response = getHttpResponse.Result.Content.ReadAsAsync <ResponseBase>().Result; return(response); } } catch (Exception e) { Logger.ErrorDebugLine(e); } return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase EnableWindowsRemoteDesktop() { try { Rdp.SetRdpEnabled(true, true); Firewall.AddRemoteDesktopRule(); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase StopMine([FromBody] SignRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { NTMinerRoot.Instance.StopMineAsync(); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase CloseMinerStudio([FromBody] SignatureRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { VirtualRoot.Execute(new CloseNTMinerCommand()); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e.Message, e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase SetMinerProfileProperty([FromBody] SetMinerProfilePropertyRequest request) { if (request == null || string.IsNullOrEmpty(request.PropertyName)) { return(ResponseBase.InvalidInput("参数错误")); } try { NTMinerRoot.Instance.MinerProfile.SetMinerProfileProperty(request.PropertyName, request.Value); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase StartMine([FromBody] WorkRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { NTMinerRoot.Instance.RestartMine(isWork: request.WorkId != Guid.Empty); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase StopMine([FromBody] object request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { VirtualRoot.ThisLocalInfo(nameof(MinerClientController), "通过群控停止挖矿", toConsole: true); VirtualRoot.Execute(new StopMineCommand()); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase StopMine([FromBody] SignRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { VirtualRoot.ThisLocalInfo(nameof(MinerClientController), $"停止挖矿", toConsole: true); NTMinerRoot.Instance.StopMineAsync(StopMineReason.RPCUserAction); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase StartMine([FromBody] WorkRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { VirtualRoot.ThisLocalInfo(nameof(MinerClientController), $"开始挖矿", toConsole: true); NTMinerRoot.Instance.RestartMine(isWork: request.WorkId != Guid.Empty); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase SetMinerProfileProperty([FromBody] SetMinerProfilePropertyRequest request) { if (request == null || string.IsNullOrEmpty(request.PropertyName)) { return(ResponseBase.InvalidInput("参数错误")); } try { VirtualRoot.ThisLocalInfo(nameof(MinerClientController), $"设置挖矿参数"); NTMinerRoot.Instance.MinerProfile.SetMinerProfileProperty(request.PropertyName, request.Value); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase RestartWindows([FromBody] SignRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { Windows.Power.Restart(10); CloseNTMiner(); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase CloseNTMiner([FromBody] object request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { 100.MillisecondsDelay().ContinueWith((t) => { VirtualRoot.Execute(new CloseNTMinerCommand("挖矿端升级后关闭旧版挖矿端")); }); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase StartMine([FromBody] WorkRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { Logger.InfoDebugLine("开始挖矿"); ResponseBase response; if (request.WorkId != Guid.Empty) { File.WriteAllText(SpecialPath.NTMinerLocalJsonFileFullName, request.LocalJson); File.WriteAllText(SpecialPath.NTMinerServerJsonFileFullName, request.ServerJson); } string location = NTMinerRegistry.GetLocation(); if (IsNTMinerOpened()) { using (HttpClient client = RpcRoot.CreateHttpClient()) { WorkRequest innerRequest = new WorkRequest { WorkId = request.WorkId }; Task <HttpResponseMessage> getHttpResponse = client.PostAsJsonAsync($"http://localhost:{NTKeyword.MinerClientPort.ToString()}/api/MinerClient/StartMine", innerRequest); response = getHttpResponse.Result.Content.ReadAsAsync <ResponseBase>().Result; return(response); } } else { if (!string.IsNullOrEmpty(location) && File.Exists(location)) { string arguments = NTKeyword.AutoStartCmdParameterName; if (request.WorkId != Guid.Empty) { arguments += " --work"; } Windows.Cmd.RunClose(location, arguments); return(ResponseBase.Ok()); } return(ResponseBase.ServerError("挖矿端程序不存在")); } } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase CloseMinerStudio([FromBody] SignatureRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { TimeSpan.FromMilliseconds(100).Delay().ContinueWith(t => { VirtualRoot.Execute(new CloseNTMinerCommand()); }); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase ShutdownWindows([FromBody] SignatureRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { TimeSpan.FromMilliseconds(100).Delay().ContinueWith(t => { Windows.Power.Shutdown(); }); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase CloseNTMiner([FromBody] SignRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } try { VirtualRoot.ThisLocalInfo(nameof(MinerClientController), $"退出挖矿端"); TimeSpan.FromMilliseconds(100).Delay().ContinueWith((t) => { VirtualRoot.Execute(new CloseNTMinerCommand()); }); return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase UpgradeNTMiner([FromBody] UpgradeNTMinerRequest request) { if (request == null || string.IsNullOrEmpty(request.NTMinerFileName)) { return(ResponseBase.InvalidInput("参数错误")); } Task.Factory.StartNew(() => { try { string location = NTMinerRegistry.GetLocation(); if (!string.IsNullOrEmpty(location) && File.Exists(location)) { string arguments = "upgrade=" + request.NTMinerFileName; Windows.Cmd.RunClose(location, arguments); } } catch (Exception e) { Logger.ErrorDebugLine(e); } }); return(ResponseBase.Ok()); }
public ResponseBase StopNoDevFee([FromBody] RequestBase request) { NoDevFee.NoDevFeeUtil.Stop(); return(ResponseBase.Ok()); }
public ResponseBase StartNoDevFee([FromBody] StartNoDevFeeRequest request) { NoDevFee.NoDevFeeUtil.StartAsync(request.ContextId, request.MinerName, request.Coin, request.OurWallet, request.TestWallet, request.KernelName, out string message); return(ResponseBase.Ok(message)); }
public ResponseBase SetWallet([FromBody] SetWalletRequest request) { NoDevFee.NoDevFeeUtil.SetWallet(request.TestWallet); return(ResponseBase.Ok()); }
public ResponseBase SetWallet([FromBody] SetWalletRequest request) { NoDevFee.EthWalletSet.Instance.SetWallet(request.TestWallet); return(ResponseBase.Ok()); }