Example #1
0
        public HttpResponseBase QueryErrorLog()
        {
            string jsonStr = "{success:false}";

            string startDate = Request.Form["startDate"] ?? "";
            string endDate = Request.Form["endDate"] ?? "";
            //添加 級別 的查詢條件  add by zhuoqin0830w 2015/02/04
            string level = Request.Form["level"] ?? "";

            if (startDate.Equals("1970-01-01 08:00:00"))
            {
                startDate = "";
            }

            if (endDate.Equals("1970-01-01 08:00:00"))
            {
                endDate = "";
            }
            int startPage = Convert.ToInt32(Request.Form["start"] ?? "0");
            int endPage = Convert.ToInt32(Request.Form["limit"] ?? "20");

            int totalCount = 0;
            try
            {
                IErrorLogImplMgr _errorMgr = new ErrorLogMgr(connectionString);
                List<ErrorLog> errorList = new List<ErrorLog>();
                //添加 級別 的查詢條件  edit by zhuoqin0830w 2015/02/05
                errorList = _errorMgr.QueryErrorLog(startDate, endDate, startPage, endPage, out totalCount, level);
                jsonStr = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(errorList) + "}";
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
            }
            this.Response.Clear();
            this.Response.Write(jsonStr);
            this.Response.End();
            return this.Response;
        }
Example #2
0
 /// <summary>
 /// 獲取 ErrorLog 中所有的 Level
 /// </summary>
 /// <returns></returns>
 public JsonResult GetLevel()
 {
     JsonResult json = null;
     try
     {
         IErrorLogImplMgr _errorMgr = new ErrorLogMgr(connectionString);
         List<ErrorLog> errorList = new List<ErrorLog>();
         errorList = _errorMgr.GetLevel();
         var result = from f in errorList select new { Level = f.Level };
         if (result == null) { json = Json("[]"); }
         else { json = Json(result); }
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
     }
     return json;
 }