//调用委托 private async Task <AmpMessage> ProcessQueryAPaperListAsync(AmpMessage req) { QueryAPaperReq request = null; if (req.Data == null) { request = new QueryAPaperReq(); } else { request = QueryAPaperReq.Parser.ParseFrom(req.Data); } req.FriendlyServiceName = "APaperInnerService.QueryAPaperList"; var result = await QueryAPaperListAsync(request); var response = AmpMessage.CreateResponseMessage(req.ServiceId, req.MessageId); response.FriendlyServiceName = "APaperInnerService.QueryAPaperList"; response.Code = result.Code; if (result.Data != null) { response.Data = result.Data.ToByteArray(); } return(response); }
/// <summary> /// 获取答卷列表 /// </summary> /// <param name="request"></param> /// <returns></returns> public override async Task <RpcResult <APaperListRsp> > QueryAPaperListAsync(QueryAPaperReq request) { var res = new RpcResult <APaperListRsp>(); res.Data = new APaperListRsp(); var view = new PageView(request.Page, request.Rp); var plist = await this._apaperRepo.QueryAPaperList(request.Qtext, request.QpaperId, request.CheckRole?request.Identity : "", view); res.Data.Total = view.PageIndex == 0 ? plist.Total : -1; if (plist != null && plist.DataList != null && plist.DataList.Count > 0) { foreach (var apaper in plist.DataList) { res.Data.List.Add(new DTOAPaper() { ApaperId = apaper.PaperId, CreateTime = apaper.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), QpaperId = apaper.QpaperId, UserId = apaper.UserId, QpaperSubject = apaper.QpaperSubject ?? "", QpaperUserId = apaper.QpaperUserId ?? "", Remark = apaper.Remark }); } } return(res); }
//同步方法 public RpcResult <APaperListRsp> QueryAPaperList(QueryAPaperReq req) { AmpMessage message = AmpMessage.CreateRequestMessage(20002, 2); message.FriendlyServiceName = "APaperService.QueryAPaperList"; message.Data = req.ToByteArray(); var response = base.CallInvoker.BlockingCall(message); if (response == null) { throw new RpcException("error,response is null !"); } var result = new RpcResult <APaperListRsp>(); if (response.Code != 0) { result.Code = response.Code; } if (response.Data == null) { result.Data = new APaperListRsp(); } else { result.Data = APaperListRsp.Parser.ParseFrom(response.Data); } return(result); }
public async Task <RpcResult <APaperListRsp> > QueryAPaperListAsync(QueryAPaperReq req, int timeOut = 3000) { AmpMessage message = AmpMessage.CreateRequestMessage(20002, 2); message.FriendlyServiceName = "APaperService.QueryAPaperList"; message.Data = req.ToByteArray(); var response = await base.CallInvoker.AsyncCall(message, timeOut); if (response == null) { throw new RpcException("error,response is null !"); } var result = new RpcResult <APaperListRsp>(); if (response.Code != 0) { result.Code = response.Code; } if (response.Data == null) { result.Data = new APaperListRsp(); } else { result.Data = APaperListRsp.Parser.ParseFrom(response.Data); } return(result); }
public override Task <RpcResult <APaperListRsp> > QueryAPaperListAsync(QueryAPaperReq request) { var res = new RpcResult <APaperListRsp>(); res.Data = new APaperListRsp(); if (string.IsNullOrEmpty(request.Identity)) { res.Code = ErrorCodes.AUTHORIZATION_REQUIRED; res.Data.ReturnMessage = "请先登录"; return(Task.FromResult(res)); } var client = _proxy.GetClient <APaperInnerServiceClient>(); return(client.QueryAPaperListAsync(request)); }
//抽象方法 public abstract Task <RpcResult <APaperListRsp> > QueryAPaperListAsync(QueryAPaperReq req);