public override void HandleRequest(string jsonString, AjaxBase ajax)
        {
            if (!User.IsAdminLoggedIn(ajax))
            {
                ajax.Unauthorized();
                return;
            }

            AdminErrorLogsGetRequest request = Utility.ParseJson<AdminErrorLogsGetRequest>(jsonString);
            AdminErrorLogsGetResponse response = new AdminErrorLogsGetResponse();
            response.numberOfLogs = Convert.ToInt32(Database.Select("errorlog", null, null, null, "COUNT(*)")[0]["COUNT(*)"]);
            List<ErrorLogJson> logs = new List<ErrorLogJson>();
            foreach (Dictionary<string, object> data in Database.Select("errorlog", null, "`time` DESC", (request.page * request.elementsPerPage) + "," + request.elementsPerPage))
            {
                ErrorLogJson log = new ErrorLogJson();
                log.id = Convert.ToInt32(data["id"]);
                log.time = Convert.ToInt32(data["time"]);
                log.type = Convert.ToString(data["type"]);
                log.source = Convert.ToString(data["source"]);
                log.message = Convert.ToString(data["message"]);
                log.stackTrace = Convert.ToString(data["stacktrace"]);
                logs.Add(log);
            }

            response.logs = logs.ToArray();
            ajax.ReturnJson(response);
        }
Пример #2
0
        private void GetRequestSuccess(AdminErrorLogsGetResponse response)
        {
            numberOfLogs = response.numberOfLogs;
            pagination.Refresh();

            jQuery.Select("#admin-errorlogs-tbody").Children().Remove();
            if (response.logs.Length == 0)
            {
                Template.Get("admin", "noitem-trow", true).AppendTo(jQuery.Select("#admin-errorlogs-tbody"));
            }

            for (int i = 0; i < response.logs.Length; i++)
            {
                jQueryObject row = Template.Get("admin", "admin-errorlogs-trow", true).AppendTo(jQuery.Select("#admin-errorlogs-tbody"));
                jQuery.Select(".admin-errorlogs-time", row).Text(String.Format(Strings.Get("TimeFormat"), new Date(response.logs[i].time * 1000)));
                jQuery.Select(".admin-errorlogs-stacktrace", row).Attribute("data-stacktrace", response.logs[i].stackTrace).Click(ShowButtonClicked);
                jQuery.Select(".admin-errorlogs-type", row).Text(response.logs[i].type);
                jQuery.Select(".admin-errorlogs-source", row).Text(response.logs[i].source);
                jQuery.Select(".admin-errorlogs-message", row).Text(response.logs[i].message);
            }
        }