Пример #1
0
        /// <summary>
        /// 获取错误的返回
        /// </summary>
        protected JsonResult ErrorJsonResult(ErrCodeEnum code, string title = null, Exception ex = null)
        {
            if (!string.IsNullOrEmpty(title) || ex != null)
            {
                LogHelper.ErrorAsync(title, code.ToDescription(), ex);
            }

            return(new JsonResult(new ResponseContext <object>(false, code, null)));
        }
Пример #2
0
        /// <summary>
        /// 获取错误的返回
        /// </summary>
        protected JsonResult ErrorJsonResult(ErrCodeEnum code, RequestHead head = null, string title = null, Exception ex = null)
        {
            if (!string.IsNullOrEmpty(title) || ex != null)
            {
                log.ErrorAsync(title, ex, head);
            }

            return(new JsonResult(new ResponseContext <object>(code, null)));
        }
Пример #3
0
 public Response(ErrCodeEnum err, string msg = null)
 {
     ResultCode    = err;
     ResultMessage = err.ToDescription();
     if (!msg.IsNullOrEmpty())
     {
         ResultMessage = msg;
     }
 }
Пример #4
0
        /// <summary>
        /// 获取错误的返回
        /// </summary>
        protected JsonResult ErrorJsonResult(ErrCodeEnum code)
        {
            var errResponse = new ResponseContext <object>(null)
            {
                Head = new ResponseHead(-1, code, code.ToDescription())
            };

            return(new JsonResult(errResponse));
        }
Пример #5
0
 public ResponseContext(ErrCodeEnum codeEnum, T data, string msg = null)
 {
     ResultCode    = codeEnum;
     ResultMessage = codeEnum.ToDescription();
     Data          = data;
     if (!msg.IsNullOrEmpty())
     {
         ResultMessage = msg;
     }
 }
Пример #6
0
 public ResponseContext(bool success, ErrCodeEnum err, T data, string msg = null)
 {
     Success       = success;
     Code          = err;
     ResultMessage = err.ToDescription();
     Content       = data;
     if (!msg.IsNullOrEmpty())
     {
         ResultMessage = msg;
     }
 }
Пример #7
0
 /// <summary>
 /// 写入服务接口调用日志到数据库,用作接口性能检测
 /// </summary>
 protected void WriteServiceLog(string module, string method, RequestHead reqHead, ErrCodeEnum code, string msg, object request, object response)
 {
     if (reqHead == null || request == null)
     {
         return;
     }
     LogHelper.WriteServiceLog(new ServiceLogEntity()
     {
         Module        = module,
         Method        = method,
         Request       = request.SerializeToString(),
         Response      = response.SerializeToString(),
         UId           = reqHead.UId,
         Code          = (int)code,
         Msg           = msg,
         Platform      = reqHead.Platform.ToString(),
         TransactionId = reqHead.TransactionId,
         CreateTime    = DateTime.Now
     });
 }
Пример #8
0
 public ResponseContext(ErrCodeEnum codeEnum)
 {
     ResultCode    = codeEnum;
     ResultMessage = codeEnum.ToDescription();
     Data          = default;
 }
Пример #9
0
 public ResponseHead(int ret, ErrCodeEnum code, string msg)
 {
     Ret  = ret;
     Code = code;
     Msg  = msg;
 }