示例#1
0
        internal static string CreateErrorMessage(ErrorType error, List <DNTParam> paramList)
        {
            if (error == ErrorType.API_EC_NONE)
            {
                return(string.Empty);
            }
            Error errorObj = new Error();

            errorObj.ErrorCode = (int)error;
            errorObj.ErrorMsg  = _errorDetails[errorObj.ErrorCode].ToString();

            ArrayList list = new ArrayList();

            foreach (DNTParam param in paramList)
            {
                list.Add(new Arg(param.Name, param.Value));
            }
            if (list.Count > 0)
            {
                ArgResponse ar = new ArgResponse();
                ar.Args       = (Arg[])list.ToArray(typeof(Arg));
                ar.List       = true;
                errorObj.Args = ar;
            }
            return(DNTRequest.GetString("format").Trim().ToLower() == "json" ?
                   JavaScriptConvert.SerializeObject(errorObj) : SerializationHelper.Serialize(errorObj));
        }
示例#2
0
        /// <summary>
        /// 输出错误信息
        /// </summary>
        /// <param name="errorCode">错误代码</param>
        private void ResponseErrorInfo(int errorCode)
        {
            string format = DNTRequest.GetString("format").Trim().ToLower();
            Error  error  = new Error();

            error.ErrorCode = errorCode;
            error.ErrorMsg  = _errorDetails[errorCode].ToString();

            ArrayList list = new ArrayList();

            foreach (string key in Request.QueryString.AllKeys)
            {
                list.Add(new Arg(key, Utils.UrlDecode(Request.QueryString[key])));
            }
            foreach (string key in Request.Form.AllKeys)
            {
                list.Add(new Arg(key, Utils.UrlDecode(Request.Form[key])));
            }
            if (list.Count > 0)
            {
                ArgResponse ar = new ArgResponse();
                ar.Args = (Arg[])list.ToArray(typeof(Arg));
                ar.List = true;

                error.Args = ar;
            }
            string responseStr = string.Empty;

            if (format == "json")
            {
                Response.ContentType = "text/html";
                error.ArgArrary      = error.Args.Args;
                responseStr          = JavaScriptConvert.SerializeObject(error);
            }
            else
            {
                responseStr = SerializationHelper.Serialize(error);
            }

            Response.Write(responseStr);
            Response.End();
        }
示例#3
0
        /// <summary>
        /// 输出错误信息
        /// </summary>
        /// <param name="errorCode">错误代码</param>
        private void ResponseErrorInfo(int errorCode)
        {
            string format = DNTRequest.GetString("format").Trim().ToLower();
            Error error = new Error();
            error.ErrorCode = errorCode;
            error.ErrorMsg = _errorDetails[errorCode].ToString();

            ArrayList list = new ArrayList();
            foreach (string key in Request.QueryString.AllKeys)
            {
                list.Add(new Arg(key, Utils.UrlDecode(Request.QueryString[key])));
            }
            foreach (string key in Request.Form.AllKeys)
            {
                list.Add(new Arg(key, Utils.UrlDecode(Request.Form[key])));
            }
            if (list.Count > 0)
            {
                ArgResponse ar = new ArgResponse();
                ar.Args = (Arg[])list.ToArray(typeof(Arg));
                ar.List = true;

                error.Args = ar;
            }
            string responseStr = string.Empty;
            if (format == "json")
            {
                Response.ContentType = "text/html";
                error.ArgArrary = error.Args.Args;
                responseStr = JavaScriptConvert.SerializeObject(error);
            }
            else
            {
                responseStr = SerializationHelper.Serialize(error);
            }

            Response.Write(responseStr);
            Response.End();

        }