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); }
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); }
// ReSharper disable once InconsistentNaming public void UpgradeNTMinerAsync(IMinerData client, string ntminerFileName, Action <ResponseBase, Exception> callback) { UpgradeNTMinerRequest innerRequest = new UpgradeNTMinerRequest { NTMinerFileName = ntminerFileName }; WrapperRequest <UpgradeNTMinerRequest> request = new WrapperRequest <UpgradeNTMinerRequest> { ObjectId = client.Id, ClientId = client.ClientId, InnerRequest = innerRequest, ClientIp = client.MinerIp }; PostAsync(SControllerName, nameof(IWrapperMinerClientController.UpgradeNTMiner), request.ToQuery(SingleUser.LoginName, SingleUser.PasswordSha1), request, callback); }
// ReSharper disable once InconsistentNaming public void RestartNTMinerAsync(IMinerData client, Action <ResponseBase, Exception> callback) { WorkRequest innerRequest = new WorkRequest { WorkId = client.WorkId }; WrapperRequest <WorkRequest> request = new WrapperRequest <WorkRequest> { ObjectId = client.Id, ClientId = client.ClientId, InnerRequest = innerRequest, ClientIp = client.MinerIp }; PostAsync(SControllerName, nameof(IWrapperMinerClientController.RestartNTMiner), request.ToQuery(SingleUser.LoginName, SingleUser.PasswordSha1), request, callback); }
public void StartMineAsync(IClientData client, Guid workId, Action <ResponseBase, Exception> callback) { WorkRequest innerRequest = new WorkRequest { WorkId = workId }; WrapperRequest <WorkRequest> request = new WrapperRequest <WorkRequest> { ObjectId = client.GetId(), ClientId = client.ClientId, ClientIp = client.MinerIp, InnerRequest = innerRequest }; PostAsync(SControllerName, nameof(IWrapperMinerClientController.StartMine), request.ToQuery(SingleUser.LoginName, SingleUser.PasswordSha1), request, callback); }
public void SetClientMinerProfilePropertyAsync(IMinerData client, string propertyName, object value, Action <ResponseBase, Exception> callback) { SetClientMinerProfilePropertyRequest innerRequest = new SetClientMinerProfilePropertyRequest { PropertyName = propertyName, Value = value }; WrapperRequest <SetClientMinerProfilePropertyRequest> request = new WrapperRequest <SetClientMinerProfilePropertyRequest> { ObjectId = client.Id, ClientId = client.ClientId, ClientIp = client.MinerIp, InnerRequest = innerRequest }; PostAsync(SControllerName, nameof(IWrapperMinerClientController.SetClientMinerProfileProperty), request.ToQuery(SingleUser.LoginName, SingleUser.PasswordSha1), request, callback); }
// ReSharper disable once InconsistentNaming public void RestartNTMinerAsync(IClientData client, Action <ResponseBase, Exception> callback) { WorkRequest innerRequest = new WorkRequest { WorkId = client.WorkId }; WrapperRequest <WorkRequest> request = new WrapperRequest <WorkRequest> { ObjectId = client.GetId(), ClientId = client.ClientId, LoginName = SingleUser.LoginName, InnerRequest = innerRequest, ClientIp = client.MinerIp }; request.SignIt(SingleUser.PasswordSha1); PostAsync(SControllerName, nameof(IWrapperMinerClientController.RestartNTMiner), null, request, callback); }
public void ShutdownWindowsAsync(IClientData client, Action <ResponseBase, Exception> callback) { SignatureRequest innerRequest = new SignatureRequest { LoginName = SingleUser.LoginName }; innerRequest.SignIt(SingleUser.GetRemotePassword(client.ClientId)); WrapperRequest <SignatureRequest> request = new WrapperRequest <SignatureRequest> { ObjectId = client.GetId(), ClientId = client.ClientId, LoginName = SingleUser.LoginName, InnerRequest = innerRequest, ClientIp = client.MinerIp }; request.SignIt(SingleUser.PasswordSha1); PostAsync(SControllerName, nameof(IWrapperMinerClientController.ShutdownWindows), null, request, callback); }
// ReSharper disable once InconsistentNaming public void UpgradeNTMinerAsync(IClientData client, string ntminerFileName, Action <ResponseBase, Exception> callback) { UpgradeNTMinerRequest innerRequest = new UpgradeNTMinerRequest { LoginName = SingleUser.LoginName, NTMinerFileName = ntminerFileName }; innerRequest.SignIt(SingleUser.GetRemotePassword(client.ClientId)); WrapperRequest <UpgradeNTMinerRequest> request = new WrapperRequest <UpgradeNTMinerRequest> { ObjectId = client.GetId(), ClientId = client.ClientId, LoginName = SingleUser.LoginName, InnerRequest = innerRequest, ClientIp = client.MinerIp }; request.SignIt(SingleUser.PasswordSha1); PostAsync(SControllerName, nameof(IWrapperMinerClientController.UpgradeNTMiner), null, request, callback); }
public ResponseBase UpgradeNTMiner([FromBody] WrapperRequest <UpgradeNTMinerRequest> request) { if (request == null || request.InnerRequest == null || string.IsNullOrEmpty(request.ClientIp)) { return(ResponseBase.InvalidInput("参数错误")); } try { if (!request.IsValid(HostRoot.Current.UserSet.GetUser, ClientIp, out ResponseBase response)) { return(response); } response = Client.NTMinerDaemonService.UpgradeNTMiner(request.ClientIp, request.InnerRequest); return(response); } catch (Exception e) { e = e.GetInnerException(); Logger.ErrorDebugLine(e.Message, e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase ShutdownWindows([FromBody] WrapperRequest <SignRequest> request) { if (request == null || request.InnerRequest == null || string.IsNullOrEmpty(request.ClientIp)) { return(ResponseBase.InvalidInput("参数错误")); } try { if (!request.IsValid(User, Sign, Timestamp, ClientIp, out ResponseBase response)) { return(response); } response = RpcRoot.Client.NTMinerDaemonService.ShutdownWindows(request.ClientIp, request.InnerRequest); return(response); } catch (Exception e) { string message = e.GetInnerMessage(); Logger.ErrorDebugLine(message, e); return(ResponseBase.ServerError(message)); } }
public ResponseBase SetClientMinerProfileProperty([FromBody] WrapperRequest <SetClientMinerProfilePropertyRequest> request) { if (request == null || request.InnerRequest == null || string.IsNullOrEmpty(request.ClientIp)) { return(ResponseBase.InvalidInput("参数错误")); } try { if (!request.IsValid(User, Sign, Timestamp, ClientIp, out ResponseBase response)) { return(response); } response = Client.MinerClientService.SetMinerProfileProperty(request.ClientIp, request.InnerRequest); return(response); } catch (Exception e) { string message = e.GetInnerMessage(); Logger.ErrorDebugLine(message, e); return(ResponseBase.ServerError(message)); } }
public ResponseBase StopMine([FromBody] WrapperRequest <SignatureRequest> request) { if (request == null || request.InnerRequest == null || string.IsNullOrEmpty(request.ClientIp)) { return(ResponseBase.InvalidInput("参数错误")); } try { if (!request.IsValid(HostRoot.Instance.UserSet.GetUser, ClientIp, out ResponseBase response)) { return(response); } response = Client.NTMinerDaemonService.StopMine(request.ClientIp, request.InnerRequest); return(response); } catch (Exception e) { string message = e.GetInnerMessage(); Logger.ErrorDebugLine(message, e); return(ResponseBase.ServerError(message)); } }
public void SetClientMinerProfilePropertyAsync(IClientData client, string propertyName, object value, Action <ResponseBase, Exception> callback) { SetClientMinerProfilePropertyRequest innerRequest = new SetClientMinerProfilePropertyRequest { LoginName = SingleUser.LoginName, PropertyName = propertyName, Value = value }; innerRequest.SignIt(SingleUser.GetRemotePassword(client.ClientId)); WrapperRequest <SetClientMinerProfilePropertyRequest> request = new WrapperRequest <SetClientMinerProfilePropertyRequest> { ObjectId = client.GetId(), ClientId = client.ClientId, LoginName = SingleUser.LoginName, ClientIp = client.MinerIp, InnerRequest = innerRequest }; request.SignIt(SingleUser.PasswordSha1); PostAsync(SControllerName, nameof(IWrapperMinerClientController.SetClientMinerProfileProperty), null, request, callback); }
public ResponseBase StartMine([FromBody] WrapperRequest <WorkRequest> request) { if (request == null || request.InnerRequest == null || string.IsNullOrEmpty(request.ClientIp)) { return(ResponseBase.InvalidInput("参数错误")); } try { if (!request.IsValid(HostRoot.Current.UserSet.GetUser, ClientIp, out ResponseBase response)) { return(response); } IClientData clientData = HostRoot.Current.ClientSet.GetByObjectId(request.ObjectId); if (clientData == null) { return(ResponseBase.ClientError("给定标识的矿机不存在")); } string localJson = string.Empty, serverJson = string.Empty; Guid workId = request.InnerRequest.WorkId; if (workId != Guid.Empty) { localJson = SpecialPath.ReadMineWorkLocalJsonFile(workId).Replace("{{MinerName}}", clientData.MinerName); serverJson = SpecialPath.ReadMineWorkServerJsonFile(workId); } WorkRequest innerRequest = new WorkRequest { Timestamp = request.InnerRequest.Timestamp, WorkId = workId, LocalJson = localJson, ServerJson = serverJson }; response = Client.NTMinerDaemonService.StartMine(request.ClientIp, innerRequest); return(response); } catch (Exception e) { e = e.GetInnerException(); Logger.ErrorDebugLine(e.Message, e); return(ResponseBase.ServerError(e.Message)); } }