/// <summary> /// Adds a new error log to storage, after creating the timestamp. /// </summary> /// <param name="error_message">The error message for the error log to be added</param> /// <returns>The newly added error_log object</returns> public ERROR_LOG Log(string error_message) { if (error_message == null) { throw new ResourceCreationException() { ExceptionMessage = "The error message was blank." }; } DateTime time = DateTime.Now; ERROR_LOG error_log = new ERROR_LOG { LOG_TIME = time, LOG_MESSAGE = error_message, }; // The Add() method returns the added error_log. var payload = _unitOfWork.ErrorLogRepository.Add(error_log); if (payload == null) { throw new ResourceCreationException() { ExceptionMessage = "There was an error creating the error_log. Perhaps the error is a duplicate." }; } _unitOfWork.Save(); return(payload); }
public void addErrorLog(ERROR_LOG errorLog) { logger.Info("addErrorLog: " + errorLog.ID + " start!!!"); using (BRContext db = new BRContext()) { addErrorLog(errorLog, db); saveChanges(db); } logger.Info("addBank: " + errorLog.ID + " end!!!"); }
public static void logError(Exception exception, string error) { ErrorLogService ers = new ErrorLogService(); ERROR_LOG erl = new ERROR_LOG(); erl.ID = Guid.NewGuid(); erl.Timestamp = DateTime.Now; erl.ErrorMessage = exception.Message + "Error:" + error; erl.StackTrace = exception.StackTrace; erl.InnerException = exception.InnerException == null ? "" : exception.InnerException.ToString(); ers.addErrorLog(erl); }
/// <summary> /// Adds a new error log to storage. /// </summary> /// <param name="error_log">The error log to be added</param> /// <returns>The newly added error_log object</returns> public ERROR_LOG Add(ERROR_LOG error_log) { // The Add() method returns the added error_log. var payload = _unitOfWork.ErrorLogRepository.Add(error_log); if (payload == null) { throw new ResourceCreationException() { ExceptionMessage = "There was an error creating the error_log. Perhaps the error is a duplicate." }; } _unitOfWork.Save(); return(payload); }
public IHttpActionResult Post([FromBody] ERROR_LOG error_log) { if (!ModelState.IsValid || error_log == null) { string errors = ""; foreach (var modelstate in ModelState.Values) { foreach (var error in modelstate.Errors) { errors += "|" + error.ErrorMessage + "|" + error.Exception; } } throw new BadInputException() { ExceptionMessage = errors }; } var result = _errorLogService.Add(error_log); return(Created("error log", result)); }
public void delete(ERROR_LOG errorLog) { db.Entry(errorLog).State = EntityState.Deleted; }
public void update(ERROR_LOG errorLog) { db.Entry(errorLog).State = EntityState.Modified; }
public void insert(ERROR_LOG errorLog) { db.ERROR_LOG.Add(errorLog); }
public void addErrorLog(ERROR_LOG errorLog, BRContext db) { ErrorLogRepository ur = new ErrorLogRepository(db); ur.insert(errorLog); }