public void GetGpuProfilesJsonAsync(IMinerData client) { JsonRpcRoot.PostAsync <string>(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.GetGpuProfilesJson), null, (json, e) => { GpuProfilesJsonDb data = VirtualRoot.JsonSerializer.Deserialize <GpuProfilesJsonDb>(json) ?? new GpuProfilesJsonDb(); VirtualRoot.RaiseEvent(new GetGpuProfilesResponsedEvent(client.ClientId, data)); }, timeountMilliseconds: 3000); }
public ResponseBase StartMine(WorkRequest request) { ResponseBase response; if (request == null) { response = ResponseBase.InvalidInput("参数错误"); } else { try { // 单机作业的localJson和serverJson是在编辑单机作业时提前传递到挖矿端的所以不需要在开始挖矿时再传递 if (request.WorkId != Guid.Empty && !request.WorkId.IsSelfMineWorkId()) { SpecialPath.WriteMineWorkLocalJsonFile(request.LocalJson); SpecialPath.WriteMineWorkServerJsonFile(request.ServerJson); } if (IsNTMinerOpened()) { WorkRequest innerRequest = new WorkRequest { WorkId = request.WorkId, WorkerName = request.WorkerName }; JsonRpcRoot.PostAsync <ResponseBase>(NTKeyword.Localhost, NTKeyword.MinerClientPort, _minerClientControllerName, nameof(IMinerClientController.StartMine), innerRequest, callback: null, timeountMilliseconds: 3000); response = ResponseBase.Ok("开始挖矿"); } else { string location = NTMinerRegistry.GetLocation(NTMinerAppType.MinerClient); if (!string.IsNullOrEmpty(location) && File.Exists(location)) { string arguments = NTKeyword.AutoStartCmdParameterName; if (request.WorkId != Guid.Empty) { if (request.WorkId.IsSelfMineWorkId()) { arguments = "--selfWork " + arguments; } else { arguments = "--work " + arguments; } } Windows.Cmd.RunClose(location, arguments); response = ResponseBase.Ok("开始挖矿"); } else { response = ResponseBase.ServerError("开始挖矿,未找到挖矿端程序"); } } } catch (Exception e) { Logger.ErrorDebugLine(e); response = ResponseBase.ServerError(e.Message); } } VirtualRoot.OperationResultSet.Add(response.ToOperationResult()); return(response); }
/// <summary> /// 本机同步网络调用 /// </summary> public void CloseMinerStudioAsync(Action callback) { string location = NTMinerRegistry.GetLocation(NTMinerAppType.MinerStudio); if (string.IsNullOrEmpty(location) || !File.Exists(location)) { callback?.Invoke(); return; } string processName = Path.GetFileNameWithoutExtension(location); if (Process.GetProcessesByName(processName).Length == 0) { callback?.Invoke(); return; } JsonRpcRoot.PostAsync <ResponseBase>(NTKeyword.Localhost, NTKeyword.MinerStudioPort, _controllerName, nameof(IMinerStudioController.CloseMinerStudio), new object(), (response, e) => { if (!response.IsSuccess()) { try { Windows.TaskKill.Kill(processName, waitForExit: true); } catch (Exception ex) { Logger.ErrorDebugLine(ex); } } callback?.Invoke(); }, timeountMilliseconds: 2000); }
// ReSharper disable once InconsistentNaming public void UpgradeNTMinerAsync(IMinerData client, string ntminerFileName) { UpgradeNTMinerRequest request = new UpgradeNTMinerRequest { NTMinerFileName = ntminerFileName }; JsonRpcRoot.PostAsync <ResponseBase>(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.UpgradeNTMiner), request, null, timeountMilliseconds: 3000); }
public void GetServerMessagesAsync(DateTime timestamp, Action <DataResponse <List <ServerMessageData> >, Exception> callback) { ServerMessagesRequest request = new ServerMessagesRequest { Timestamp = Timestamp.GetTimestamp(timestamp) }; JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IServerMessageController.ServerMessages), request, callback); }
public void GetPackageUrlAsync(string package, Action <string, Exception> callback) { PackageUrlRequest request = new PackageUrlRequest { Package = package }; JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IFileUrlController.PackageUrl), request, callback); }
// ReSharper disable once InconsistentNaming public void GetNTMinerUrlAsync(string fileName, Action <string, Exception> callback) { NTMinerUrlRequest request = new NTMinerUrlRequest { FileName = fileName }; JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IFileUrlController.NTMinerUrl), request, callback); }
public void GetNodeAddressAsync(Guid clientId, string outerUserId, Action <DataResponse <string>, Exception> callback) { var data = new GetWsServerNodeAddressRequest { ClientId = clientId, UserId = outerUserId }; JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IWsServerNodeController.GetNodeAddress), data, callback, timeountMilliseconds: 8000); }
public void GetJsonFileVersionAsync(string key, Action <ServerStateResponse> callback) { AppSettingRequest request = new AppSettingRequest { Key = key }; JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IAppSettingController.GetJsonFileVersion), request, (string line, Exception e) => { callback?.Invoke(ServerStateResponse.FromLine(line)); }, timeountMilliseconds: 10 * 1000); }
public void GetCalcConfigsAsync(Action <List <CalcConfigData> > callback) { JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(ICalcConfigController.CalcConfigs), null, (DataResponse <List <CalcConfigData> > response, Exception e) => { if (response.IsSuccess()) { callback?.Invoke(response.Data); } else { callback?.Invoke(new List <CalcConfigData>()); } }, timeountMilliseconds: 10 * 1000); }
// ReSharper disable once InconsistentNaming public void GetNTMinerFilesAsync(NTMinerAppType appType, Action <List <NTMinerFileData> > callback) { JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IFileUrlController.NTMinerFiles), callback: (List <NTMinerFileData> data, Exception e) => { if (data != null) { data = data.Where(a => a.AppType == appType).ToList(); } else { data = new List <NTMinerFileData>(); } callback?.Invoke(data); }); }
public void StartMineAsync(IMinerData client, Guid workId) { string localJson = string.Empty, serverJson = string.Empty; if (workId != Guid.Empty) { localJson = MinerStudioPath.ReadMineWorkLocalJsonFile(workId).Replace(NTKeyword.MinerNameParameterName, client.WorkerName); serverJson = MinerStudioPath.ReadMineWorkServerJsonFile(workId); } WorkRequest request = new WorkRequest { WorkId = workId, WorkerName = client.WorkerName, LocalJson = localJson, ServerJson = serverJson }; JsonRpcRoot.PostAsync <ResponseBase>(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.StartMine), request, null, timeountMilliseconds: 3000); }
private static void CloseNTMiner() { JsonRpcRoot.PostAsync <ResponseBase>(NTKeyword.Localhost, NTKeyword.MinerClientPort, _minerClientControllerName, nameof(IMinerClientController.CloseNTMiner), new object { }, (response, e) => { bool isClosed = response.IsSuccess(); if (!isClosed) { try { string location = NTMinerRegistry.GetLocation(NTMinerAppType.MinerClient); if (!string.IsNullOrEmpty(location) && File.Exists(location)) { string processName = Path.GetFileNameWithoutExtension(location); Windows.TaskKill.Kill(processName); } } catch (Exception ex) { Logger.ErrorDebugLine(ex); } } }, timeountMilliseconds: 3000); }
public ResponseBase StopMine() { ResponseBase response; try { if (!IsNTMinerOpened()) { response = ResponseBase.Ok(); } else { JsonRpcRoot.PostAsync <ResponseBase>(NTKeyword.Localhost, NTKeyword.MinerClientPort, _minerClientControllerName, nameof(IMinerClientController.StopMine), new object(), callback: null, timeountMilliseconds: 3000); response = ResponseBase.Ok("停止挖矿"); } } catch (Exception e) { Logger.ErrorDebugLine(e); response = ResponseBase.ServerError(e.Message); } VirtualRoot.OperationResultSet.Add(response.ToOperationResult()); return(response); }
public void GetNTMinerWalletsAsync(Action <DataResponse <List <NTMinerWalletData> >, Exception> callback) { JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(INTMinerWalletController.NTMinerWallets), null, callback); }
public void GetSelfWorkLocalJsonAsync(IMinerData client, Action <string, Exception> callback) { JsonRpcRoot.PostAsync(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _controllerName, nameof(INTMinerDaemonController.GetSelfWorkLocalJson), callback, timeountMilliseconds: 3000); }
public void GetSelfWorkLocalJsonAsync(IMinerData client) { JsonRpcRoot.PostAsync <string>(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.GetSelfWorkLocalJson), null, (json, e) => { VirtualRoot.RaiseEvent(new GetSelfWorkLocalJsonResponsedEvent(client.ClientId, json)); }, timeountMilliseconds: 3000); }
public void SetLocalIpsAsync(IMinerData client, List <LocalIpInput> data) { JsonRpcRoot.PostAsync <ResponseBase>(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.SetLocalIps), new DataRequest <List <LocalIpInput> > { Data = data }, null, timeountMilliseconds: 3000); }
public void GetLocalIpsAsync(IMinerData client) { JsonRpcRoot.PostAsync <List <LocalIpDto> >(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.GetLocalIps), null, (data, e) => { VirtualRoot.RaiseEvent(new GetLocalIpsResponsedEvent(client.ClientId, data)); }, timeountMilliseconds: 3000); }
public void SetVirtualMemoryAsync(IMinerData client, Dictionary <string, int> data) { JsonRpcRoot.PostAsync <ResponseBase>(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.SetVirtualMemory), new DataRequest <Dictionary <string, int> > { Data = data }, null, timeountMilliseconds: 3000); }
public void SignUpAsync(SignUpRequest data, Action <ResponseBase, Exception> callback) { JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IUserController.SignUp), data, callback); }
public void SwitchRadeonGpuAsync(IMinerData client, bool on) { JsonRpcRoot.PostAsync <ResponseBase>(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.SwitchRadeonGpu), new Dictionary <string, string> { ["on"] = on.ToString() }, null, null, timeountMilliseconds: 3000); }
public void GetLiteDbExplorerUrlAsync(Action <string, Exception> callback) { JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IFileUrlController.LiteDbExplorerUrl), callback); }
public void GetSwitchRadeonGpuUrlAsync(Action <string, Exception> callback) { JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IFileUrlController.SwitchRadeonGpuUrl), callback); }
public void ReportSpeedAsync(SpeedDto speedDto, Action <ReportResponse, Exception> callback) { JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IReportController.ReportSpeed), speedDto, callback, timeountMilliseconds: 5000); }
public void StopMineAsync(IMinerData client) { JsonRpcRoot.PostAsync <ResponseBase>(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.StopMine), new object(), null, timeountMilliseconds: 3000); }
public void GetKernelOutputKeywords(Action <KernelOutputKeywordsResponse, Exception> callback) { object request = new object(); JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IKernelOutputKeywordController.KernelOutputKeywords), request, callback); }
public void LoginAsync(string loginName, string password, Action <DataResponse <LoginedUser>, Exception> callback) { JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IUserController.Login), RpcUser.GetSignData(loginName, password), new object(), callback); }
public void GetMinerClientFinderUrlAsync(Action <string, Exception> callback) { JsonRpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IFileUrlController.MinerClientFinderUrl), callback, timeountMilliseconds: 5000); }
public void EnableRemoteDesktopAsync(IMinerData client) { JsonRpcRoot.PostAsync <ResponseBase>(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.EnableRemoteDesktop), null, null, timeountMilliseconds: 3000); }