예제 #1
0
        public static KingResponse GetResponse(KingRequest request, object data)
        {
            KingResponse response = new KingResponse();

            response.Success  = true;
            response.ErrorMsg = "";
            if (request != null)
            {
                response.RequestID = request.ID;
            }
            else
            {
                response.RequestID = "";
            }
            response.Data = data;
            return(response);
        }
예제 #2
0
        /// <summary>
        /// 按错误数据创建输出对象
        /// </summary>
        /// <param name="errorMsg"></param>
        /// <returns></returns>
        public static KingResponse GetErrorResponse(string errorMsg, KingRequest request = null)
        {
            KingResponse response = new KingResponse();

            response.Success  = false;
            response.ErrorMsg = errorMsg;
            if (request != null)
            {
                response.RequestID = request.ID;
            }
            else
            {
                response.RequestID = "";
            }
            response.Data = null;
            return(response);
        }
예제 #3
0
 /// <summary>
 /// 按错误数据获取错误输出字符串
 /// </summary>
 /// <param name="errorMsg"></param>
 /// <returns></returns>
 public static string GetErrorResponseString(string errorMsg, KingRequest request = null)
 {
     return(JsonHelper.EncodeJson(GetErrorResponse(errorMsg, request)));
 }