Esempio n. 1
0
        public bool SaveGpuProfilesJson(string json)
        {
            bool   isSuccess   = false;
            string description = "超频";

            try {
                SpecialPath.SaveGpuProfilesJsonFile(json);
                if (IsNTMinerOpened())
                {
                    JsonRpcRoot.FirePostAsync(NTKeyword.Localhost, NTKeyword.MinerClientPort, _minerClientControllerName, nameof(IMinerClientController.OverClock), null, data: null);
                }
                else
                {
                    description = "超频,挖矿端未启动,下次启动时生效";
                }
                isSuccess = true;
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
            }
            VirtualRoot.OperationResultSet.Add(new OperationResultData {
                Timestamp    = Timestamp.GetTimestamp(),
                StateCode    = isSuccess ? 200 : 500,
                ReasonPhrase = isSuccess ? "Ok" : "Fail",
                Description  = description
            });
            return(isSuccess);
        }
Esempio n. 2
0
 public void SetAutoBootStartAsync(IMinerData client, SetAutoBootStartRequest request)
 {
     JsonRpcRoot.FirePostAsync(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.SetAutoBootStart), new Dictionary <string, string> {
         ["autoBoot"]  = request.AutoBoot.ToString(),
         ["autoStart"] = request.AutoStart.ToString()
     }, data: null, callback: null, timeountMilliseconds: 3000);
 }
Esempio n. 3
0
        public void ReportStateAsync(Guid clientId, bool isMining)
        {
            ReportState request = new ReportState {
                ClientId = clientId,
                IsMining = isMining
            };

            JsonRpcRoot.FirePostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IReportController.ReportState), null, request, null, 5000);
        }
Esempio n. 4
0
 protected override void UpdateWsStateAsync(string description, bool toOut)
 {
     if (VirtualRoot.DaemonOperation.IsNTMinerOpened())
     {
         var state = base.GetState();
         if (!string.IsNullOrEmpty(description))
         {
             state.Description = description;
         }
         state.ToOut = toOut;
         JsonRpcRoot.FirePostAsync(NTKeyword.Localhost, NTKeyword.MinerClientPort, RpcRoot.GetControllerName <IMinerClientController>(), nameof(IMinerClientController.ReportWsDaemonState), null, state, timeountMilliseconds: 3000);
     }
 }
Esempio n. 5
0
        public void SaveSelfWorkLocalJsonAsync(IMinerData client, string localJson, string serverJson)
        {
            if (string.IsNullOrEmpty(localJson) || string.IsNullOrEmpty(serverJson))
            {
                return;
            }
            WorkRequest request = new WorkRequest {
                WorkId     = MineWorkData.SelfMineWorkId,
                WorkerName = client.WorkerName,
                LocalJson  = localJson.Replace(NTKeyword.MinerNameParameterName, client.WorkerName),
                ServerJson = serverJson
            };

            JsonRpcRoot.FirePostAsync(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.SaveSelfWorkLocalJson), null, request, timeountMilliseconds: 3000);
        }
Esempio n. 6
0
        private ResponseBase RunAction(MinerClientActionType actionType)
        {
            if (IsNTMinerOpened())
            {
                var request = new DataRequest <MinerClientActionType> {
                    Data = actionType
                };
                JsonRpcRoot.FirePostAsync(NTKeyword.Localhost, NTKeyword.MinerClientPort, _minerClientControllerName, nameof(IMinerClientController.RunAction), null, data: request);
            }
            else if (TryGetMinerClientLocation(out string location))
            {
                Windows.Cmd.RunClose(location, $"{NTKeyword.ActionCmdParameterName}{actionType.ToString()}");
            }
            ResponseBase response = ResponseBase.Ok(actionType.GetDescription());

            VirtualRoot.OperationResultSet.Add(response.ToOperationResult());
            return(response);
        }
Esempio n. 7
0
        public ResponseBase EnableRemoteDesktop()
        {
            ResponseBase response;

            try {
                NTMinerRegistry.SetIsRdpEnabled(true);
                Firewall.AddRdpRule();
                if (IsNTMinerOpened())
                {
                    JsonRpcRoot.FirePostAsync(NTKeyword.Localhost, NTKeyword.MinerClientPort, _minerClientControllerName, nameof(IMinerClientController.RefreshIsRemoteDesktopEnabled), null, data: null, timeountMilliseconds: 3000);
                }
                response = ResponseBase.Ok("开启Windows远程桌面");
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
                response = ResponseBase.ServerError(e.Message);
            }
            VirtualRoot.OperationResultSet.Add(response.ToOperationResult());
            return(response);
        }
Esempio n. 8
0
        public bool SetAutoBootStart(bool autoBoot, bool autoStart)
        {
            bool isSuccess = false;

            try {
                MinerProfileUtil.SetAutoStart(autoBoot, autoStart);
                if (IsNTMinerOpened())
                {
                    JsonRpcRoot.FirePostAsync(NTKeyword.Localhost, NTKeyword.MinerClientPort, _minerClientControllerName, nameof(IMinerClientController.RefreshAutoBootStart), null, data: null, timeountMilliseconds: 3000);
                }
                isSuccess = true;
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
            }
            VirtualRoot.OperationResultSet.Add(new OperationResultData {
                Timestamp    = Timestamp.GetTimestamp(),
                StateCode    = isSuccess ? 200 : 500,
                ReasonPhrase = isSuccess ? "Ok" : "Fail",
                Description  = "设置"
            });
            return(isSuccess);
        }
Esempio n. 9
0
 /// <summary>
 /// 本机网络调用
 /// </summary>
 public void StartOrStopWsAsync(bool isResetFailCount)
 {
     JsonRpcRoot.FirePostAsync(NTKeyword.Localhost, NTKeyword.NTMinerDaemonPort, _controllerName, nameof(INTMinerDaemonController.StartOrCloseWs), new Dictionary <string, string> {
         ["isResetFailCount"] = isResetFailCount.ToString()
     }, data: null, timeountMilliseconds: 3000);
 }
Esempio n. 10
0
 /// <summary>
 /// 本机网络调用
 /// </summary>
 public void CloseDaemonAsync(Action callback)
 {
     JsonRpcRoot.FirePostAsync(NTKeyword.Localhost, NTKeyword.NTMinerDaemonPort, _controllerName, nameof(INTMinerDaemonController.CloseDaemon), null, data: null, callback, timeountMilliseconds: 3000);
 }