示例#1
0
        public void sendApiRequestAsync(
            Dictionary <object, object> context, RequestInputModel paramBean, ResponseCallBack callback)
        {
            string validate = paramBean != null?paramBean.validateParam() : "";

            Config Config         = (Config)context[Constant.CONFIG_CONTEXT_KEY];
            string configValidate = Config.validateParam();

            if (!StringUtil.isEmpty(validate) || !StringUtil.isEmpty(configValidate))
            {
                if (StringUtil.isEmpty(validate))
                {
                    validate = configValidate;
                }
                OutputModel Out = ParamInvokeUtil.getOutputModel(callback);
                HttpRequestClient.fillResponseCallbackModel(Constant.REQUEST_ERROR_CODE, validate, Out);
                callback.onAPIResponse(Out);
            }
            else
            {
                HttpWebRequest request = buildRequest(context, paramBean);
                HttpRequestClient.getInstance()
                .requestActionAsync(request, Config.isSafeOkHttp(), callback);
            }
        }
示例#2
0
        public OutputModel sendApiRequest(Dictionary <object, object> context, RequestInputModel paramBean, Type outputClass)
        {
            string validate = paramBean != null?paramBean.validateParam() : "";

            Config Config         = (Config)context[Constant.CONFIG_CONTEXT_KEY];
            string configValidate = Config.validateParam();

            if (!StringUtil.isEmpty(validate) || !StringUtil.isEmpty(configValidate))
            {
                if (StringUtil.isEmpty(validate))
                {
                    validate = configValidate;
                }
                try
                {
                    OutputModel model = (OutputModel)Activator.CreateInstance(outputClass);
                    HttpRequestClient.fillResponseCallbackModel(Constant.REQUEST_ERROR_CODE, validate, model);
                    return(model);
                }
                catch (Exception e)
                {
                    logger.Fatal(e.Message);
                    throw new QCException(e.Message);
                }
            }
            else
            {
                HttpWebRequest request = buildRequest(context, paramBean);
                return(HttpRequestClient.getInstance().requestAction(request, Config.isSafeOkHttp(), outputClass));
            }
        }