Beispiel #1
0
        /// <summary>
        /// 发送POST 方式请求
        /// </summary>
        /// <param name="successCallBack">请求成功回调</param>
        /// <param name="errorCallBack">请求失败回调</param>
        /// <param name="urlString">请求地址</param>
        /// <param name="paramsDict">参数列表</param>
        /// <param name="parameterModel">文件参数列表</param>
        /// <returns>返回请求对象</returns>
        private HTTPRequest SendPostType(OnSuccessCallBack successCallBack, OnErrorCallBack errorCallBack,
                                         string urlString, Dictionary <string, string> paramsDict, params FileParamModel[] parameterModel)
        {
            return(SendPostType(urlString, (request, response) =>
            {
                if (request != null)
                {
                    switch (request.State)
                    {
                    case HTTPRequestStates.Error:
                        //   返回错误消息
                        errorCallBack(new MessageModel("NetWork Error!", "网络错误", "network"));
                        break;

                    case HTTPRequestStates.ConnectionTimedOut:
                        //   返回错误消息
                        errorCallBack(new MessageModel("NetWork Error!", "连接超时", "network"));
                        break;

                    case HTTPRequestStates.TimedOut:
                        //   返回错误消息
                        errorCallBack(new MessageModel("NetWork Error!", "请求超时", "network"));
                        break;

                    case HTTPRequestStates.Finished:
                        //   返回请求成功的数据
                        successCallBack(new MessageModel("success", response, "network"));
                        break;
                    }
                }
            }, paramsDict, parameterModel));
        }
Beispiel #2
0
 /// <summary>
 /// 发送POST 方式请求
 /// </summary>
 /// <param name="urlString">请求地址</param>
 /// <param name="sucessCallBack">请求成功回调</param>
 /// <param name="errorCallBack">请求失败回调</param>
 /// <param name="paramsDict">参数列表</param>
 /// <param name="parameterModel">文件参数列表</param>
 /// <returns>返回请求对象</returns>
 public HTTPRequest SendPostType(string urlString, OnSuccessCallBack sucessCallBack, OnErrorCallBack errorCallBack, Dictionary <string, string> paramsDict, params FileParamModel[] parameterModel)
 {
     return(SendPostType(sucessCallBack, errorCallBack, urlString, paramsDict, parameterModel));
 }
Beispiel #3
0
 /// <summary>
 /// 发送POST 方式的请求
 /// </summary>
 /// <param name="urlString">请求地址</param>
 /// <param name="sucessCallBack">请求成功回调</param>
 /// <param name="errorCallBack">请求错误回调</param>
 /// <param name="parameterModel">请求需要发送的文件数据</param>
 /// <returns></returns>
 public HTTPRequest SendPostType(string urlString, OnSuccessCallBack sucessCallBack, OnErrorCallBack errorCallBack,
                                 params FileParamModel[] parameterModel)
 {
     return(SendPostType(urlString, sucessCallBack, errorCallBack, null, parameterModel));
 }