public void GetWorkJsonAsync(Guid workId, Guid clientId, Action <GetWorkJsonResponse, Exception> callback) { GetWorkJsonRequest request = new GetWorkJsonRequest() { WorkId = workId, ClientId = clientId }; RpcRoot.SignPostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IUserMineWorkController.GetWorkJson), data: request, callback); }
public GetWorkJsonResponse GetWorkJson([FromBody] GetWorkJsonRequest request) { if (request == null) { return(ResponseBase.InvalidInput <GetWorkJsonResponse>("参数错误")); } try { string workerName = string.Empty; // 如果是单机作业 if (request.WorkId.IsSelfMineWorkId()) { var clientData = WebApiRoot.ClientDataSet.GetByClientId(request.ClientId); if (clientData != null) { workerName = clientData.WorkerName; } return(GetWorkJsonResponse.Ok(string.Empty, string.Empty, workerName)); } IUserMineWork mineWork = WebApiRoot.MineWorkSet.GetById(request.WorkId); if (mineWork == null) { return(ResponseBase.NotExist <GetWorkJsonResponse>()); } string localJsonFileFullName = SpecialPath.GetMineWorkLocalJsonFileFullName(request.WorkId); string localJson = string.Empty; if (File.Exists(localJsonFileFullName)) { localJson = File.ReadAllText(localJsonFileFullName); if (!string.IsNullOrEmpty(localJson)) { var clientData = WebApiRoot.ClientDataSet.GetByClientId(request.ClientId); if (clientData != null) { workerName = clientData.WorkerName; } localJson = localJson.Replace(NTKeyword.MinerNameParameterName, workerName); } } string serverJsonFileFullName = SpecialPath.GetMineWorkServerJsonFileFullName(request.WorkId); string serverJson = string.Empty; if (File.Exists(serverJsonFileFullName)) { serverJson = File.ReadAllText(serverJsonFileFullName); } return(GetWorkJsonResponse.Ok(localJson, serverJson, workerName)); } catch (Exception e) { Logger.ErrorDebugLine(e); return(ResponseBase.ServerError <GetWorkJsonResponse>(e.Message)); } }