public static void NewLogInformation(STATIONNAME StationName, DateTime LogDate, String Message, LogType LogCategory, long?UserID) { InformationLogs NewLog = new InformationLogs(); NewLog.LogID = (long)(DateTime.UtcNow - DateTime.MinValue).TotalMilliseconds; NewLog.UserID = UserID; NewLog.LogName = "Log from " + StationName.ToString(); NewLog.LogDate = LogDate; NewLog.LogValue = null; NewLog.LogMessage = Message; NewLog.LogCategory = LogCategory; NewLog.StationName = StationName; TTCSLogInformation.Add(NewLog); TTCSTempLogInformation.Add(NewLog); if (!TTCSLog.IsSearchByAllStation) { AddLogToGrid(StationName, LogDate, Message, LogCategory, null, UserID); } else if (TTCSLog.IsSearchByAllStation && LogDate >= StartDate && LogDate <= EndDate) { AddLogToGrid(StationName, LogDate, Message, LogCategory, null, UserID); } }
public static void NewLogInformation(STATIONNAME StationName, DateTime LogDate, String LogName, Object[] Value, String Message, LogType LogCategory, long?UserID) { InformationLogs NewLog = new InformationLogs(); NewLog.LogID = (long)(DateTime.UtcNow - DateTime.MinValue).TotalMilliseconds; NewLog.UserID = UserID; NewLog.LogName = LogName; NewLog.LogDate = LogDate; NewLog.LogValue = Value != null?String.Join(", ", Value) : null; NewLog.LogMessage = Message; NewLog.LogCategory = LogCategory; NewLog.StationName = StationName; if (DateTime.UtcNow.Hour == 1) { TTCSTempLogInformation.Clear(); } TTCSLogInformation.Add(NewLog); TTCSTempLogInformation.Add(NewLog); if (!TTCSLog.IsSearchByAllStation) { AddLogToGrid(StationName, LogDate, Message, LogCategory, NewLog.LogValue, UserID); } else if (TTCSLog.IsSearchByAllStation && LogDate >= StartDate && LogDate <= EndDate) { AddLogToGrid(StationName, LogDate, Message, LogCategory, NewLog.LogValue, UserID); } }
public static void GetLogBySearchInformarion(STATIONNAME StationName, DateTime StartDate, DateTime EndDate, Boolean IsSearchByAllStation) { List <InformationLogs> TTCSLogBySearch = TTCSLogInformation; TTCSLog.StartDate = StartDate; TTCSLog.EndDate = EndDate; TTCSLog.IsSearchByAllStation = IsSearchByAllStation; if (IsSearchByAllStation) { if (StationName == STATIONNAME.NULL) { TTCSLogBySearch = TTCSLogInformation.Where(Item => Item.LogDate.Date >= StartDate.Date && Item.LogDate.Date <= EndDate.Date).ToList(); } else { TTCSLogBySearch = TTCSLogInformation.Where(Item => Item.StationName == StationName && Item.LogDate.Date >= StartDate.Date && Item.LogDate.Date <= EndDate.Date).ToList(); } } TTCSLogGrid.Rows.Clear(); if (TTCSLogBySearch != null) { for (int i = 0; i < TTCSLogBySearch.Count; i++) { AddLogToGrid(TTCSLogBySearch[i].StationName, TTCSLogBySearch[i].LogDate, TTCSLogBySearch[i].LogMessage, TTCSLogBySearch[i].LogCategory, TTCSLogBySearch[i].LogValue, TTCSLogBySearch[i].UserID); } } }