Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
        public void sendApiRequestAsync(String requestUrl, Dictionary <object, object> context, ResponseCallBack callback)
        {
            EvnContext     evnContext = (EvnContext)context[QSConstant.EVN_CONTEXT_KEY];
            HttpWebRequest request    = QSHttpRequestClient.getInstance().buildUrlRequest(requestUrl);

            QSHttpRequestClient.getInstance().requestActionAsync(request, evnContext.isSafeOkHttp(), callback);
        }
Ejemplo n.º 4
0
        public OutputModel sendApiRequest(
            string requestUrl, Dictionary <object, object> context, Type outputClass)
        {
            EvnContext     evnContext = (EvnContext)context[QSConstant.EVN_CONTEXT_KEY];
            HttpWebRequest request    = QSHttpRequestClient.getInstance().buildUrlRequest(requestUrl);

            return(QSHttpRequestClient.getInstance()
                   .requestAction(request, evnContext.isSafeOkHttp(), outputClass));
        }