Beispiel #1
0
        public SystemLogSearchResult SystemLogs([FromBody] SearchParameters searchData)
        {
            SystemLogSearchResult objSystemLogSearchResult = new SystemLogSearchResult();

            // Must be a Super Administrator to call this Method
            if (!UtilitySecurity.IsSuperUser(this.User.Identity.Name, GetConnectionString()))
            {
                objSystemLogSearchResult.errorMessage = "Must be a Super Administrator to call this Method";
                return(objSystemLogSearchResult);
            }

            return(SystemLogsMethod(searchData, this.User.Identity.Name, GetConnectionString()));
        }
Beispiel #2
0
        // Methods

        #region public static SystemLogSearchResult SystemLogsMethod(SearchParameters searchData, string CurrentUser, string ConnectionString)
        public static SystemLogSearchResult SystemLogsMethod(SearchParameters searchData, string CurrentUser, string ConnectionString)
        {
            SystemLogSearchResult objSystemLogSearchResult = new SystemLogSearchResult();

            objSystemLogSearchResult.SystemLogList = new List <DTOSystemLog>();

            var optionsBuilder = new DbContextOptionsBuilder <ADefHelpDeskContext>();

            optionsBuilder.UseSqlServer(ConnectionString);

            using (var context = new ADefHelpDeskContext(optionsBuilder.Options))
            {
                var QueryResult = (from systemLog in context.AdefHelpDeskSystemLog
                                   select systemLog).OrderByDescending(l => l.LogId)
                                  .Skip(searchData.rowsPerPage * (searchData.pageNumber - 1))
                                  .Take(searchData.rowsPerPage).ToList();

                List <DTOSystemLog> colDTOSystemLog = new List <DTOSystemLog>();

                foreach (var item in QueryResult)
                {
                    DTOSystemLog objDTOSystemLog = new DTOSystemLog();

                    objDTOSystemLog.LogID       = item.LogId;
                    objDTOSystemLog.LogType     = item.LogType;
                    objDTOSystemLog.LogMessage  = item.LogMessage;
                    objDTOSystemLog.UserName    = item.UserName ?? "";
                    objDTOSystemLog.CreatedDate = item.CreatedDate.ToShortDateString() + ' ' + item.CreatedDate.ToShortTimeString();

                    colDTOSystemLog.Add(objDTOSystemLog);
                }

                objSystemLogSearchResult.SystemLogList = colDTOSystemLog;
                objSystemLogSearchResult.totalRows     = context.AdefHelpDeskSystemLog.Count();
                objSystemLogSearchResult.errorMessage  = string.Empty;
            }

            return(objSystemLogSearchResult);
        }