Example #1
0
        public HKDBLogsModel GetDbLogs(string search = "", int itemsPerPage = 10, int pageNumber = 1)
        {
            try
            {
                var request = new HKDBLogsModel()
                {
                    Search       = search,
                    ItemsPerPage = itemsPerPage,
                    CurrentPage  = pageNumber,
                };

                var paged = logService.GetDBLog(request);

                DbLogsModel.CurrentPage  = int.Parse(paged.CurrentPage.ToString());
                DbLogsModel.ItemsPerPage = int.Parse(paged.ItemsPerPage.ToString());
                DbLogsModel.ListDBLogs   = paged.Items;
                DbLogsModel.TotalItems   = int.Parse(paged.TotalItems.ToString());
                DbLogsModel.TotalPages   = int.Parse(paged.TotalPages.ToString());

                return(DbLogsModel);
            }
            catch (Exception ex)
            {
                LogHelper.Error <Exception>(ex.Message, ex);
                return(null);
            }
        }
        /// <summary>
        /// Get DB Logs
        /// </summary>
        /// <returns>IEnumerable of TraceLogFileModel</returns>
        public Page <DBLogModel> GetDBLog(HKDBLogsModel request)
        {
            var sqlLog = "SELECT umbracoLog.id AS Id, umbracoLog.userId AS UserId, umbracoUser.userName AS UserName, umbracoUser.userLogin AS UserLogin, umbracoLog.NodeId AS NodeId, umbracoNode.text AS NodeName, umbracoLog.DateStamp AS Date, umbracoLog.logHeader AS Header, umbracoLog.logComment AS Comment ";

            sqlLog += "FROM umbracoLog INNER JOIN umbracoUser ON umbracoLog.userId = umbracoUser.id LEFT OUTER JOIN umbracoNode ON umbracoLog.NodeId = umbracoNode.id ";

            if (!String.IsNullOrEmpty(request.Search))
            {
                sqlLog += "WHERE (umbracoLog.logHeader LIKE '%" + request.Search.ToLower() + "%') OR ";
                sqlLog += "(umbracoUser.userName LIKE '%" + request.Search.ToLower() + "%') OR ";
                sqlLog += "(umbracoNode.text LIKE '%" + request.Search.ToLower() + "%') OR ";
                sqlLog += "(umbracoLog.logComment LIKE '%" + request.Search.ToLower() + "%') ";
            }

            sqlLog += "ORDER BY umbracoLog.DateStamp DESC";

            return(db.Page <DBLogModel>(request.CurrentPage, request.ItemsPerPage, sqlLog));
        }