public ResponseBase RemoveClients([FromBody] MinerIdsRequest request) { if (request == null || request.ObjectIds == null) { return(ResponseBase.InvalidInput("参数错误")); } try { if (!IsValidUser(request, out ResponseBase response, out UserData user)) { return(response); } foreach (var objectId in request.ObjectIds) { var minerData = WebApiRoot.ClientDataSet.GetByObjectId(objectId); if (minerData != null && minerData.IsOwnerBy(user)) { WebApiRoot.ClientDataSet.RemoveByObjectId(objectId); } } return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public void RemoveClientsAsync(List <string> objectIds, Action <ResponseBase, Exception> callback) { var request = new MinerIdsRequest { ObjectIds = objectIds }; RpcRoot.JsonRpc.SignPostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IClientDataController.RemoveClients), data: request, callback); }
public void RefreshClientsAsync(List <string> objectIds, Action <DataResponse <List <ClientData> >, Exception> callback) { MinerIdsRequest request = new MinerIdsRequest() { ObjectIds = objectIds }; PostAsync(SControllerName, nameof(IControlCenterController.RefreshClients), request.ToQuery(SingleUser.LoginName, SingleUser.PasswordSha1), request, callback); }
public void RefreshClientsAsync(List <string> objectIds, Action <DataResponse <List <ClientData> >, Exception> callback) { MinerIdsRequest request = new MinerIdsRequest() { ObjectIds = objectIds }; RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IClientController.RefreshClients), request, request, callback); }
public void RemoveClientsAsync(List <string> objectIds, Action <ResponseBase, Exception> callback) { MinerIdsRequest request = new MinerIdsRequest() { ObjectIds = objectIds }; PostAsync(SControllerName, nameof(IClientController.RemoveClients), request.ToQuery(SingleUser.LoginName, SingleUser.PasswordSha1), request, callback); }
public void RemoveClientsAsync(List <string> objectIds, Action <ResponseBase, Exception> callback) { MinerIdsRequest request = new MinerIdsRequest() { LoginName = SingleUser.LoginName, ObjectIds = objectIds }; request.SignIt(SingleUser.PasswordSha1); PostAsync(SControllerName, nameof(IControlCenterController.RemoveClients), null, request, callback); }
public ResponseBase RemoveClients([FromBody] MinerIdsRequest request) { if (request == null || request.ObjectIds == null) { return(ResponseBase.InvalidInput("参数错误")); } try { foreach (var objectId in request.ObjectIds) { var minerData = AppRoot.ClientDataSet.GetByObjectId(objectId); if (minerData != null && (User.IsAdmin() || minerData.IsOwnerBy(User))) { AppRoot.ClientDataSet.RemoveByObjectId(objectId); } } return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public ResponseBase RemoveClients([FromBody] MinerIdsRequest request) { if (request == null || request.ObjectIds == null) { return(ResponseBase.InvalidInput("参数错误")); } try { if (!request.IsValid(User, Sign, Timestamp, base.ClientIp, out ResponseBase response)) { return(response); } foreach (var objectId in request.ObjectIds) { HostRoot.Instance.ClientSet.Remove(objectId); } return(ResponseBase.Ok()); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError(e.Message)); } }
public DataResponse <List <ClientData> > RefreshClients([FromBody] MinerIdsRequest request) { if (request == null || request.ObjectIds == null) { return(ResponseBase.InvalidInput <DataResponse <List <ClientData> > >("参数错误")); } if (!HostRoot.Instance.HostConfig.IsPull) { return(ResponseBase.InvalidInput <DataResponse <List <ClientData> > >("服务端配置为不支持刷新")); } try { if (!request.IsValid(User, Sign, Timestamp, base.ClientIp, out DataResponse <List <ClientData> > response)) { return(response); } var data = HostRoot.Instance.ClientSet.RefreshClients(request.ObjectIds); return(DataResponse <List <ClientData> > .Ok(data)); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError <DataResponse <List <ClientData> > >(e.Message)); } }