Пример #1
0
        /// <summary>
        /// 调用业务服务系统接口
        /// </summary>
        /// <param name="proEventMsg"></param>
        /// <param name="pushInfo"></param>
        /// <returns></returns>
        public ResponseResultInfo RequestBusInterface(ProcessEventMessage proEventMsg, PushBusInterfaceModel pushInfo)
        {
            var serviceInfo = InitBusinessServiceInfo(proEventMsg, pushInfo);

            try
            {
                //验证单据是否发起
                var formInstanceInfo = _formInstanceSevice.GetPrcFormInstanceByFormId(proEventMsg.FormId);
                if (formInstanceInfo == null)
                {
                    serviceInfo.ResultInfo.returnMsg = string.Format("FormId:{0},未获取到表单实例数据。", proEventMsg.FormId);
                    AddBusErrorLog(serviceInfo);
                    return(serviceInfo.ResultInfo);
                }
                pushInfo.bizId = formInstanceInfo.BizId;
                serviceInfo.ProEventMsgInfo.K2ID = pushInfo.k2Id = formInstanceInfo.Folio;

                serviceInfo.InterfaceConfig = _eventInterfaceService.GetProEventInterfaceInfo(proEventMsg.EventInterfaceId);

                string param          = GetRequstParameter(serviceInfo.InterfaceConfig.DataType, formInstanceInfo.SubmitterAccount, proEventMsg, pushInfo);
                string responseString = string.Empty;
                try
                {
                    serviceInfo.BegInterfaceTime = DateTime.Now;
                    responseString = HttpHelper.HttpPostRequest(serviceInfo.InterfaceConfig.Url, param, 60);
                    serviceInfo.EndInterfaceTime = DateTime.Now;

                    var resInfo = JsonConvert.DeserializeObject <ResultModel <ResponseResultInfo> >(responseString);
                    serviceInfo.ResultInfo = resInfo.resultInfo;
                    AddBusinessInterfaceLog(serviceInfo, param, responseString);
                }
                catch (Exception ex)
                {
                    _logger.Error(ex, $"FormId:{ proEventMsg.FormId }");
                    serviceInfo.ResultInfo.returnMsg = "访问ESB服务异常;" + ex.Message.ToString();
                    AddBusErrorLog(serviceInfo, 9, param, responseString);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, $"FormId:{ proEventMsg.FormId }");
                if (serviceInfo.ResultInfo == null)
                {
                    serviceInfo.ResultInfo = new ResponseResultInfo()
                    {
                        returnStatus = 500
                    };                                                                       //返回的格式不对
                }
                serviceInfo.ResultInfo.returnMsg = "调用业务接口异常!" + ex.Message;
                AddBusErrorLog(serviceInfo, 999);
            }

            return(serviceInfo.ResultInfo);
        }