public void InsertLog(String ViewName, String user) { Logging logging = new Logging(); logging.ViewName = ViewName; logging.LastUpdated = DateTime.Now; logging.UserID = user; projectrepository.InsertLog(logging); projectrepository.Save(); }
/// <summary> Executes the Standard Error Log with exception object only</summary> /// <param name="id">Accepts an exception object</param> /// <returns>Updates AMP.System.ErrorLog</returns> public void LogError(Exception ex, string user) { //Create an new instance of the model ErrorLog ErrorLog errorlog = new ErrorLog(); //Populate error log with the correct information //Handle nulls if (ex.Message == null) { errorlog.ErrorMessage = ""; } else { errorlog.ErrorMessage = ex.Message.ToString(); } //Handle nulls (Inner Exception is not always populated) if (ex.InnerException == null) { errorlog.InnerException = ""; } else { errorlog.InnerException = ex.InnerException.ToString(); } //Add the line number to the exception. //Handle nulls if (ex.StackTrace == null) { errorlog.StackTrace = ""; } else { errorlog.StackTrace = ex.StackTrace.ToString(); errorlog.InnerException = errorlog.InnerException + " - Line Number " + GetLineNumber(ex).ToString(); } errorlog.LastUpdated = DateTime.Now; errorlog.UserID = user; //Execute Insert Log error method projectrepository.InsertError(errorlog); //Save projectrepository.Save(); }