示例#1
0
        public async Task <RpcResult <QPaperStaRsp> > GetAPaperStaAsync(GetQPaperStaReq req, int timeOut = 3000)
        {
            AmpMessage message = AmpMessage.CreateRequestMessage(10002, 1);

            message.FriendlyServiceName = "APaperFacadeService.GetAPaperSta";
            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 <QPaperStaRsp>();

            if (response.Code != 0)
            {
                result.Code = response.Code;
            }

            if (response.Data == null)
            {
                result.Data = new QPaperStaRsp();
            }
            else
            {
                result.Data = QPaperStaRsp.Parser.ParseFrom(response.Data);
            }

            return(result);
        }
        //同步方法
        public RpcResult <QPaperStaRsp> GetAPaperSta(GetQPaperStaReq req)
        {
            AmpMessage message = AmpMessage.CreateRequestMessage(10000, 24);

            message.FriendlyServiceName = "SurveyGateService.GetAPaperSta";


            message.Data = req.ToByteArray();
            var response = base.CallInvoker.BlockingCall(message);

            if (response == null)
            {
                throw new RpcException("error,response is null !");
            }
            var result = new RpcResult <QPaperStaRsp>();

            if (response.Code != 0)
            {
                result.Code = response.Code;
            }
            else if (response.Data == null)
            {
                result.Code = ErrorCodes.CODE_INTERNAL_ERROR;
            }
            else
            {
                result.Data = QPaperStaRsp.Parser.ParseFrom(response.Data);
            }
            return(result);
        }