예제 #1
0
        public static List<WebAccessLogModel> ReadWebAccessLog()
        {
            var webAccessLog = new List<WebAccessLogModel>();

            string[] filePaths = Directory.GetFiles(AccessLog.WebAccessLogFolderPath);

            foreach (var filePath in filePaths)
            {
                using (var file = new System.IO.StreamReader(filePath, true))
                {
                    var line = string.Empty;
                    while ((line = file.ReadLine()) != null)
                    {
                        if (!string.IsNullOrWhiteSpace(line))
                        {
                            var webAccessLogModel = new WebAccessLogModel(line);
                            if (webAccessLogModel.UserId > 0)
                                webAccessLog.Add(webAccessLogModel);
                        }
                    }
                }
            }

            return webAccessLog;
        }
예제 #2
0
        public static List<WebAccessLogModel> ReadWebAccessLog(int userId, DateTime? fromDate, DateTime? toDate)
        {
            var webAccessLog = new List<WebAccessLogModel>();

            string[] filePaths = Directory.GetFiles(AccessLog.WebAccessLogFolderPath);

            foreach (var filePath in filePaths)
            {
                using (var file = new System.IO.StreamReader(filePath, true))
                {
                    var line = string.Empty;
                    while ((line = file.ReadLine()) != null)
                    {
                        if (!string.IsNullOrWhiteSpace(line))
                        {
                            var webAccessLogModel = new WebAccessLogModel(line);

                            if (webAccessLogModel.UserId > 0)
                            {
                                if (webAccessLogModel.UserId == userId)
                                {
                                    if ((fromDate != null && fromDate != DateTime.MinValue) && (toDate != null && toDate != DateTime.MinValue))
                                    {
                                        if (webAccessLogModel.DateTime.Date >= fromDate && webAccessLogModel.DateTime.Date <= toDate)
                                        {
                                            webAccessLog.Add(webAccessLogModel);
                                        }
                                    }
                                    else
                                    {
                                        webAccessLog.Add(webAccessLogModel);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return webAccessLog.OrderByDescending(t => t.DateTime).ToList();
        }
예제 #3
0
        public static void WriteWebAccessLog(WebAccessLogModel webAccessLogModel)
        {
            if (string.Compare(webAccessLogModel.Action, "FPResource", StringComparison.CurrentCultureIgnoreCase) == 0)
            {
                return;
            }

            using (var file = new System.IO.StreamWriter(AccessLog.WebAccessLogFilePath, true))
            {
                file.WriteLine(webAccessLogModel.ToString());
            }
        }