Esempio n. 1
0
 public ResponseBase StopMine([FromBody] SignRequest 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));
     }
 }
Esempio n. 2
0
 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(string clientIp, SignRequest request)
 {
     using (HttpClient client = new HttpClient()) {
         Task <HttpResponseMessage> message = client.PostAsJsonAsync($"http://{clientIp}:{Consts.NTMinerDaemonPort}/api/{s_controllerName}/{nameof(INTMinerDaemonController.EnableWindowsRemoteDesktop)}", request);
         ResponseBase response = message.Result.Content.ReadAsAsync <ResponseBase>().Result;
         return(response);
     }
 }
Esempio n. 4
0
 public ResponseBase StopMine(string clientIp, SignRequest request)
 {
     using (HttpClient client = new HttpClient()) {
         Task <HttpResponseMessage> getHttpResponse = client.PostAsJsonAsync($"http://{clientIp}:{NTKeyword.MinerClientPort}/api/{s_controllerName}/{nameof(IMinerClientController.StopMine)}", request);
         ResponseBase response = getHttpResponse.Result.Content.ReadAsAsync <ResponseBase>().Result;
         return(response);
     }
 }
Esempio n. 5
0
 public ResponseBase StopMine([FromBody] SignRequest request)
 {
     if (request == null)
     {
         return(ResponseBase.InvalidInput("参数错误"));
     }
     return(VirtualRoot.DaemonOperation.StopMine());
 }
            public void LoginAsync(string loginName, string password, Action <ResponseBase, Exception> callback)
            {
                SignRequest request = new SignRequest()
                {
                };

                PostAsync(SControllerName, nameof(IControlCenterController.LoginControlCenter), request.ToQuery(loginName, password), request, callback);
            }
Esempio n. 7
0
 public ResponseBase RestartWindows([FromBody] SignRequest request)
 {
     if (request == null)
     {
         return(ResponseBase.InvalidInput("参数错误"));
     }
     return(VirtualRoot.DaemonOperation.RestartWindows());
 }
 public ResponseBase ShutdownWindows(string clientIp, SignRequest request)
 {
     using (HttpClient client = new HttpClient()) {
         Task <HttpResponseMessage> getHttpResponse = client.PostAsJsonAsync($"http://{clientIp}:{NTKeyword.NTMinerDaemonPort.ToString()}/api/{s_controllerName}/{nameof(INTMinerDaemonController.ShutdownWindows)}", request);
         ResponseBase response = getHttpResponse.Result.Content.ReadAsAsync <ResponseBase>().Result;
         return(response);
     }
 }
Esempio n. 9
0
 public ResponseBase EnableWindowsRemoteDesktop(string clientIp, SignRequest request)
 {
     using (HttpClient client = RpcRoot.Create()) {
         Task <HttpResponseMessage> getHttpResponse = client.PostAsJsonAsync($"http://{clientIp}:{NTKeyword.NTMinerDaemonPort.ToString()}/api/{s_controllerName}/{nameof(INTMinerDaemonController.EnableWindowsRemoteDesktop)}", request);
         ResponseBase response = getHttpResponse.Result.Content.ReadAsAsync <ResponseBase>().Result;
         return(response);
     }
 }
 public ResponseBase StopMine(string clientIp, SignRequest request)
 {
     using (HttpClient client = new HttpClient()) {
         Task <HttpResponseMessage> message = client.PostAsJsonAsync($"http://{clientIp}:{VirtualRoot.NTMinerDaemonPort}/api/{s_controllerName}/{nameof(INTMinerDaemonController.StopMine)}", request);
         ResponseBase response = message.Result.Content.ReadAsAsync <ResponseBase>().Result;
         return(response);
     }
 }
Esempio n. 11
0
 public void StopMineAsync(string clientIp, SignRequest request, Action <ResponseBase, Exception> callback)
 {
     Task.Factory.StartNew(() => {
         try {
             ResponseBase response = StopMine(clientIp, request);
             callback?.Invoke(response, null);
         }
         catch (Exception e) {
             callback?.Invoke(null, e);
         }
     });
 }
Esempio n. 12
0
            public void StopMineAsync(IMinerData client, Action <ResponseBase, Exception> callback)
            {
                SignRequest innerRequest             = new SignRequest {
                };
                WrapperRequest <SignRequest> request = new WrapperRequest <SignRequest> {
                    ObjectId     = client.Id,
                    ClientId     = client.ClientId,
                    ClientIp     = client.MinerIp,
                    InnerRequest = innerRequest
                };

                PostAsync(SControllerName, nameof(IWrapperMinerClientController.StopMine), request.ToQuery(SingleUser.LoginName, SingleUser.PasswordSha1), request, callback);
            }
Esempio n. 13
0
 // TODO:异步化
 /// <summary>
 /// 同步方法
 /// </summary>
 /// <returns></returns>
 public DataResponse <List <WalletData> > GetWallets()
 {
     try {
         SignRequest request = new SignRequest {
         };
         DataResponse <List <WalletData> > response = Post <DataResponse <List <WalletData> > >(SControllerName, nameof(IWalletController.Wallets), request.ToQuery(SingleUser.LoginName, SingleUser.PasswordSha1), request, timeout: 2000);
         return(response);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(null);
     }
 }
Esempio n. 14
0
            public void RestartWindowsAsync(IClientData client, Action <ResponseBase, Exception> callback)
            {
                SignRequest innerRequest             = new SignRequest {
                };
                WrapperRequest <SignRequest> request = new WrapperRequest <SignRequest> {
                    ObjectId     = client.GetId(),
                    ClientId     = client.ClientId,
                    InnerRequest = innerRequest,
                    ClientIp     = client.MinerIp
                };

                PostAsync(SControllerName, nameof(IWrapperMinerClientController.RestartWindows), request.ToQuery(SingleUser.LoginName, SingleUser.PasswordSha1), request, callback);
            }
Esempio n. 15
0
 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));
     }
 }
Esempio n. 16
0
 public ResponseBase StopMine([FromBody] SignRequest 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));
     }
 }
Esempio n. 17
0
 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));
     }
 }
Esempio n. 18
0
 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));
     }
 }
Esempio n. 19
0
 public ResponseBase CloseMinerStudio([FromBody] SignRequest 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));
     }
 }
Esempio n. 20
0
 public ResponseBase CloseNTMiner([FromBody] SignRequest 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));
     }
 }
Esempio n. 21
0
 public ResponseBase ShutdownWindows([FromBody] SignRequest 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));
     }
 }
 // TODO:异步化
 /// <summary>
 /// 同步方法
 /// </summary>
 /// <returns></returns>
 public List <MineWorkData> GetMineWorks()
 {
     try {
         SignRequest request = new SignRequest {
         };
         DataResponse <List <MineWorkData> > response = Post <DataResponse <List <MineWorkData> > >(SControllerName, nameof(IMineWorkController.MineWorks), request.ToQuery(SingleUser.LoginName, SingleUser.PasswordSha1), request, timeout: 2000);
         if (response != null && response.Data != null)
         {
             return(response.Data);
         }
         return(new List <MineWorkData>());
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(new List <MineWorkData>());
     }
 }
Esempio n. 23
0
 public ResponseBase CloseMinerStudio([FromBody] SignRequest request)
 {
     if (request == null)
     {
         return(ResponseBase.InvalidInput("参数错误"));
     }
     try {
         VirtualRoot.ThisLocalInfo(nameof(MinerStudioController), $"退出群控端");
         TimeSpan.FromMilliseconds(100).Delay().ContinueWith(t => {
             VirtualRoot.Execute(new CloseNTMinerCommand());
         });
         return(ResponseBase.Ok());
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(ResponseBase.ServerError(e.Message));
     }
 }