/// <summary> /// Method LogGNGFindEventForMe logs when a user calls the 'find events for me' /// function on GreetNGroup. If the log was failed to be made, /// it will increment the errorCounter. /// </summary> /// <param name="usersID">Hahsed user ID</param> /// <param name="ip">IP Address</param> /// <returns>Returns true or false if the log was successfully made</returns> public bool LogGNGFindEventForMe(string usersID, string ip) { _gngLoggerService.CreateNewLog(logFileName, configurations.GetLogDirectory()); var logMade = false; var log = new GNGLog { LogID = "FindEventForMe", UserID = usersID, IpAddress = ip, DateTime = DateTime.UtcNow.ToString(), Description = "Used Find Events For Me" }; logList = _gngLoggerService.FillCurrentLogsList(); logList.Add(log); logMade = _gngLoggerService.WriteGNGLogToFile(logList); return(logMade); }
/// <summary> /// Method LogClicksMade logs a user navigating around GreetNGroup based on the /// url they started at and the url they ended at inside GreetNGroup. If the log /// failed to be made, it will increment the errorCounter. /// </summary> /// <param name="startPoint">Starting URL</param> /// <param name="endPoint">Ending URL</param> /// <param name="usersID">user ID (empty if user does not exist)</param> /// <param name="ip">IP address of the user/guest</param> /// <returns>Return true or false if the log was made successfully</returns> public bool LogClicksMade(string startPoint, string endPoint, string usersID, string ip) { var fileName = DateTime.UtcNow.ToString(configurations.GetDateTimeFormat()) + configurations.GetLogExtention(); _gngLoggerService.CreateNewLog(fileName, configurations.GetLogDirectory()); var logMade = false; var log = new GNGLog { LogID = "ClickEvent", UserID = usersID, IpAddress = ip, DateTime = DateTime.UtcNow.ToString(), Description = startPoint + " to " + endPoint }; var logList = _gngLoggerService.FillCurrentLogsList(); logList.Add(log); logMade = _gngLoggerService.WriteGNGLogToFile(logList); return(logMade); }
/// <summary> /// Method LogAccountDeletion logs when a user deletes their GreetNGroup account. /// </summary> /// <param name="usersID">user ID</param> /// <param name="ip">IP address</param> /// <returns>Returns true or false if log was successfully made</returns> public bool LogAccountDeletion(string usersID, string ip) { var fileName = DateTime.UtcNow.ToString(configurations.GetDateTimeFormat()) + configurations.GetLogExtention(); _gngLoggerService.CreateNewLog(fileName, configurations.GetLogDirectory()); var logMade = false; var log = new GNGLog { LogID = "AccountDeletion", UserID = usersID, IpAddress = ip, DateTime = DateTime.UtcNow.ToString(), Description = "User " + usersID + " deleted account" }; var logList = _gngLoggerService.FillCurrentLogsList(); logList.Add(log); logMade = _gngLoggerService.WriteGNGLogToFile(logList); return(logMade); }
/// <summary> /// Method LogErrorsEncountered logs any errors a user encountered inside GreetNGroup. /// The error code and url of the error encountered will be tracked inside the log. If the /// log was failed to be made, it will increment the errorCounter. /// </summary> /// <param name="usersID">user ID (empty if user does not exist)</param> /// <param name="errorCode">Error code encountered</param> /// <param name="urlOfErr">URL of error encountered</param> /// <param name="ip">IP address of the user/guest</param> /// <returns>Return true or false if the log was made successfully</returns> public bool LogErrorsEncountered(string usersID, string errorCode, string urlOfErr, string errDesc, string ip) { var fileName = DateTime.UtcNow.ToString(configurations.GetDateTimeFormat()) + configurations.GetLogExtention(); CreateNewLog(fileName, configurations.GetLogDirectory()); var logMade = false; var log = new GNGLog { LogID = "ErrorEncountered", UserID = usersID, IpAddress = ip, DateTime = DateTime.UtcNow.ToString(), Description = errorCode + " encountered at " + urlOfErr + "\n" + errDesc }; var logList = FillCurrentLogsList(); logList.Add(log); logMade = WriteGNGLogToFile(logList); return(logMade); }
/// <summary> /// Method LogFailed Login logs falied apptempts to login from SSO /// </summary> /// <param name="usersID">user ID</param> /// <returns>Returns true or false if the log was successfully made</returns> public bool LogFailedLogin(string userID) { var fileName = DateTime.UtcNow.ToString(configurations.GetDateTimeFormat()) + configurations.GetLogExtention(); CreateNewLog(fileName, configurations.GetLogDirectory()); var logMade = false; var log = new GNGLog { LogID = "FailedLogin", UserID = "", IpAddress = "", DateTime = DateTime.UtcNow.ToString(), Description = userID + " Failed to Login" }; var logList = FillCurrentLogsList(); logList.Add(log); logMade = WriteGNGLogToFile(logList); return(logMade); }
/// <summary> /// Method LogGNGSearchAction logs when a user searches for another user or event. The log /// tracks the search entry the user made. If the log was failed to be made, /// it will increment the errorCounter. /// </summary> /// <param name="usersID">user ID</param> /// <param name="searchedItem">Search entry</param> /// <param name="ip">IP Address</param> /// <returns>Returns true or false if the log was successfully made</returns> public bool LogGNGSearchAction(string usersID, string searchedItem, string ip) { var fileName = DateTime.UtcNow.ToString(configurations.GetDateTimeFormat()) + configurations.GetLogExtention(); CreateNewLog(fileName, configurations.GetLogDirectory()); var logMade = false; var log = new GNGLog { LogID = "SearchAction", UserID = usersID, IpAddress = ip, DateTime = DateTime.UtcNow.ToString(), Description = "User searched for " + searchedItem }; var logList = FillCurrentLogsList(); logList.Add(log); logMade = WriteGNGLogToFile(logList); return(logMade); }
/// <summary> /// Method LogMaliciousAttack logs any attempted malicious attacks /// made by a registered or nonregistered user /// </summary> /// <param name="url">Url where the malicious attack occurred</param> /// <param name="ip">IP address of the attacker</param> /// <param name="usersID">User ID of attacker (empty string if not a registered user)</param> /// <returns>Returns bool based on if log was successfully made</returns> public bool LogMaliciousAttack(string url, string ip, string usersID) { var fileName = DateTime.UtcNow.ToString(configurations.GetDateTimeFormat()) + configurations.GetLogExtention(); CreateNewLog(fileName, configurations.GetLogDirectory()); var logMade = false; var log = new GNGLog { LogID = "MaliciousAttacks", UserID = usersID, IpAddress = ip, DateTime = DateTime.UtcNow.ToString(), Description = "Malicious attack attempted at " + url }; var logList = FillCurrentLogsList(); logList.Add(log); logMade = WriteGNGLogToFile(logList); return(logMade); }
/// <summary> /// Method LogBadRequest logs when a user gets a bad request code from the controller /// </summary> /// <param name="usersID">UserID who received the bad request (Blank if user is not registered)</param> /// <param name="ip">IP of the user</param> /// <param name="url">Url of where the bad request occurred</param> /// <param name="exception">Exception message</param> /// <returns></returns> public bool LogBadRequest(string usersID, string ip, string url, string exception) { var fileName = DateTime.UtcNow.ToString(configurations.GetDateTimeFormat()) + configurations.GetLogExtention(); CreateNewLog(fileName, configurations.GetLogDirectory()); var logMade = false; var log = new GNGLog { LogID = "BadRequest", UserID = usersID, IpAddress = ip, DateTime = DateTime.UtcNow.ToString(), Description = "Bad request at " + url + ": " + exception }; var logList = FillCurrentLogsList(); logList.Add(log); logMade = WriteGNGLogToFile(logList); return(logMade); }
/// <summary> /// Method LogGNGEventExpiration logs when an event has passed and can no longer /// be joined /// </summary> /// <param name="hostId">User ID of the host who created the event</param> /// <param name="eventId">Event ID of the event that expired</param> /// <returns>Returns a bool based on if it was logged successfully or not</returns> public bool LogGNGEventExpiration(string hostId, int eventId) { var fileName = DateTime.UtcNow.ToString(configurations.GetDateTimeFormat()) + configurations.GetLogExtention(); _gngLoggerService.CreateNewLog(fileName, configurations.GetLogDirectory()); var logMade = false; var log = new GNGLog { LogID = "EventExpired", UserID = hostId, IpAddress = "N/A", DateTime = DateTime.UtcNow.ToString(), Description = "Event " + eventId + " expired" }; var logList = _gngLoggerService.FillCurrentLogsList(); logList.Add(log); logMade = _gngLoggerService.WriteGNGLogToFile(logList); return(logMade); }
/// <summary> /// Author: Jonalyn /// Method LogGNGInternalErrors logs errors that occur on the backend of GNG. Any errors /// in logging will increment the error counter in the error handler. Should this continue to /// cause errors, the system admin will be contacted with the error message. /// </summary> /// <param name="exception">The exception that was caught in string form</param> /// <returns>Returns true or false if the log was successfully made or not</returns> public bool LogGNGInternalErrors(string exception) { var fileName = configurations.GetDateTimeFormat() + configurations.GetLogExtention(); CreateNewLog(fileName, configurations.GetLogDirectory()); var logMade = false; var log = new GNGLog { //Don't care about user id or ip address for internal error log LogID = "InternalErrors", UserID = "N/A", IpAddress = "N/A", DateTime = DateTime.UtcNow.ToString(), Description = "Internal errors occurred: " + exception }; var logList = FillCurrentLogsList(); logList.Add(log); logMade = WriteGNGLogToFile(logList); return(logMade); }