Beispiel #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);
            }
        }
        public void sendApiRequestAsync(
            Dictionary <object, object> context, RequestInputModel paramBean, ResponseCallBack callback)
        {
            string validate = paramBean != null?paramBean.validateParam() : "";

            EvnContext evnContext  = (EvnContext)context[QSConstant.EVN_CONTEXT_KEY];
            string     evnValidate = evnContext.validateParam();

            if (!QSStringUtil.isEmpty(validate) || !QSStringUtil.isEmpty(evnValidate))
            {
                if (QSStringUtil.isEmpty(validate))
                {
                    validate = evnValidate;
                }
                OutputModel Out = QSParamInvokeUtil.getOutputModel(callback);
                QSHttpRequestClient.fillResponseCallbackModel(QSConstant.REQUEST_ERROR_CODE, validate, Out);
                callback.onAPIResponse(Out);
            }
            else
            {
                HttpWebRequest request = buildRequest(context, paramBean);
                QSHttpRequestClient.getInstance()
                .requestActionAsync(request, evnContext.isSafeOkHttp(), callback);
            }
        }
Beispiel #3
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));
            }
        }
        public OutputModel sendApiRequest(Dictionary <object, object> context, RequestInputModel paramBean, Type outputClass)
        {
            string validate = paramBean != null?paramBean.validateParam() : "";

            EvnContext evnContext  = (EvnContext)context[QSConstant.EVN_CONTEXT_KEY];
            string     evnValidate = evnContext.validateParam();

            if (!QSStringUtil.isEmpty(validate) || !QSStringUtil.isEmpty(evnValidate))
            {
                if (QSStringUtil.isEmpty(validate))
                {
                    validate = evnValidate;
                }
                try
                {
                    OutputModel model = (OutputModel)Activator.CreateInstance(outputClass);
                    QSHttpRequestClient.fillResponseCallbackModel(QSConstant.REQUEST_ERROR_CODE, validate, model);
                    return(model);
                }
                catch (Exception e)
                {
                    logger.Fatal(e.Message);
                    throw new QSException(e.Message);
                }
            }
            else
            {
                HttpWebRequest request = buildRequest(context, paramBean);
                return(QSHttpRequestClient.getInstance().requestAction(request, evnContext.isSafeOkHttp(), outputClass));
            }
        }