85 lines
3.1 KiB
C#
85 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web.Http;
|
|
using NLog;
|
|
using System.Web.Mvc;
|
|
using System.Text;
|
|
|
|
namespace API.Controllers
|
|
{
|
|
public abstract class BaseController : ApiController
|
|
{
|
|
|
|
public const short MAX_INNER_EXCEPTION_LOG_LEVEL = 5;
|
|
// protected static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
//public void LogError(ExceptionContext exceptionContext)
|
|
//{
|
|
// Logger.Fatal(exceptionContext.Exception);
|
|
//}
|
|
//public void LogError(string message)
|
|
//{
|
|
// Logger.Fatal(message);
|
|
//}
|
|
//public void LogException(Exception ex)
|
|
//{
|
|
// var sb = new StringBuilder();
|
|
// sb.AppendLine(string.Format("{0}: {1}", ex.GetType(), ex.Message));
|
|
// sb.AppendLine(ex.StackTrace);
|
|
|
|
// var innerCount = 0;
|
|
// var innerEx = ex;
|
|
// while (innerEx.InnerException != null && innerCount++ < MAX_INNER_EXCEPTION_LOG_LEVEL)
|
|
// {
|
|
// if (innerEx.Message != innerEx.InnerException.Message)
|
|
// sb.AppendLine("Inner Exception Message: " + innerEx.InnerException.Message);
|
|
// innerEx = innerEx.InnerException;
|
|
// }
|
|
// if (System.Web.HttpContext.Current != null)
|
|
// {
|
|
// sb.AppendLine();
|
|
// sb.AppendLine(string.Format("URL: {0}", System.Web.HttpContext.Current.Request.Url));
|
|
// sb.AppendLine(string.Format("Referrer: {0}", System.Web.HttpContext.Current.Request.UrlReferrer));
|
|
// sb.AppendLine(string.Format("QueryString: {0}", System.Web.HttpContext.Current.Request.QueryString));
|
|
// sb.AppendLine(string.Format("UserHostAddress: {0}", System.Web.HttpContext.Current.Request.UserHostAddress));
|
|
// sb.AppendLine(string.Format("UserAgent: {0}", System.Web.HttpContext.Current.Request.UserAgent));
|
|
// if (System.Web.HttpContext.Current.Request.Form.Count > 0)
|
|
// {
|
|
// sb.AppendLine();
|
|
// sb.AppendLine("Form:");
|
|
// foreach (string key in System.Web.HttpContext.Current.Request.Form.Keys)
|
|
// {
|
|
// sb.AppendLine(string.Format("{0}: {1}", key, System.Web.HttpContext.Current.Request.Form[key]));
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// // log error using NLog
|
|
// Logger.Fatal(sb.ToString());
|
|
//}
|
|
|
|
//protected override void Dispose(bool disposing)
|
|
//{
|
|
|
|
//}
|
|
//protected JsonResult BigJson(object data)
|
|
//{
|
|
// return BigJson(data, JsonRequestBehavior.DenyGet);
|
|
//}
|
|
|
|
//protected JsonResult BigJson(object data, JsonRequestBehavior behavior)
|
|
//{
|
|
// return new JsonResult()
|
|
// {
|
|
// Data = data,
|
|
// MaxJsonLength = int.MaxValue,
|
|
// JsonRequestBehavior = behavior
|
|
// };
|
|
//}
|
|
}
|
|
}
|