public static QueryClientsResponse QueryClientsForWs(QueryClientsForWsRequest request) { QueryClientsResponse response; if (request == null) { response = ResponseBase.InvalidInput <QueryClientsResponse>("参数错误"); } else { request.PagingTrim(); try { var user = UserSet.GetUser(UserId.CreateLoginNameUserId(request.LoginName)); if (user == null) { response = ResponseBase.InvalidInput <QueryClientsResponse>("用户不存在"); } else { var data = ClientDataSet.QueryClients( user, request, out int total, out CoinSnapshotData[] latestSnapshots, out int totalOnlineCount, out int totalMiningCount) ?? new List <ClientData>(); response = QueryClientsResponse.Ok(data, total, latestSnapshots, totalMiningCount, totalOnlineCount); } } catch (Exception e) { Logger.ErrorDebugLine(e); response = ResponseBase.ServerError <QueryClientsResponse>(e.Message); } } return(response); }
public ResponseBase RestartNTMiner([FromBody] WorkRequest request) { if (request == null) { return(ResponseBase.InvalidInput("参数错误")); } Logger.InfoDebugLine("重启挖矿端"); if (request.WorkId != Guid.Empty) { File.WriteAllText(SpecialPath.NTMinerLocalJsonFileFullName, request.LocalJson); File.WriteAllText(SpecialPath.NTMinerServerJsonFileFullName, request.ServerJson); } Task.Factory.StartNew(() => { try { if (IsNTMinerOpened()) { CloseNTMiner(); System.Threading.Thread.Sleep(1000); } string arguments = string.Empty; if (request.WorkId != Guid.Empty) { arguments = "--work"; } string location = NTMinerRegistry.GetLocation(); if (!string.IsNullOrEmpty(location) && File.Exists(location)) { Windows.Cmd.RunClose(location, arguments); } } catch (Exception e) { Logger.ErrorDebugLine(e); } }); return(ResponseBase.Ok()); }