Esempio n. 1
0
        public int Add(ErrorInfo errorInfo)
        {
            var errorLogCount = errorLog.Count;
            errorInfo.LogId = errorLogCount + 1;
            errorLog.Add(errorInfo);

            return errorInfo.LogId;
        }
        public void AddLogEntry_GivenErrorInfoObjectAddsItToRepositoryAndReturnsId()
        {
            var errorInfo = new ErrorInfo();
            errorInfo.ErrorDescription = "Test Error Info added to the repository.";
            service.AddLogEntry(errorInfo);

            Assert.IsTrue(repository.GetAll().Any());
            Assert.IsTrue(errorInfo.LogId == 1);
        }
Esempio n. 3
0
        public int Add(ErrorInfo errorInfo)
        {
            var db = new SqlDb(_connection);
            var com = StoredProcedureFactory.Create(_errorLoggingProcedure,
                                                    new SqlParameter("@OffendingURL", errorInfo.OffendingUrl),
                                                    new SqlParameter("@OccuredDate", errorInfo.ErrorDate),
                                                    new SqlParameter("@ErrorTitle", errorInfo.ErrorTitle),
                                                    new SqlParameter("@ErrorDescription", errorInfo.ErrorDescription),
                                                    new SqlParameter("@CurrentLogin", errorInfo.UserId),
                                                    new SqlParameter("@ApplicationName", errorInfo.ApplicationName));

            return db.ExecuteAndReturnScalar(com, "There was a problem logging the error to the database.").ToInt();
        }
Esempio n. 4
0
        public virtual ErrorInfo GetErrorInfoFromException(Exception ex, string url, string userId, string appName)
        {
            var message = ex.Message;
            if (ex is HttpException)
            {
                if (ex.InnerException != null)
                {
                    var iex = ex.InnerException;
                    message = iex.Message;
                }
            }

            var errorInfo = new ErrorInfo();
            errorInfo.ApplicationName = appName;
            errorInfo.ErrorDate = DateTime.Now;
            errorInfo.ErrorDescription = ex.ToString();
            errorInfo.ErrorTitle = message;
            errorInfo.OffendingUrl = url;
            errorInfo.UserId = userId;

            return errorInfo;
        }
Esempio n. 5
0
 public void AddLogEntry(ErrorInfo errorInfo)
 {
     errorInfo.LogId = _pageErrorRepository.Add(errorInfo);
 }