示例#1
0
        /// <summary>
        /// Gets the inner error of the specified error from the database
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="outerError">Outer error</param>
        /// <returns>Inner error of the specified error, loaded from the database</returns>
        public static Business.Error GetErrorByOuterError(SqlConnection conn, Business.Error outerError)
        {
            try
            {
                sql.SqlCommand cmd = new sql.SqlCommand("GetErrorByOuterErrorId", conn);
                cmd.Parameters.AddWithValue("OuterErrorId", DbType.Int32, outerError.Id);

                Business.Error[] errors = cmd.ExecuteMappedReader <Business.Error, Int32>();

                switch (errors.Length)
                {
                case 0:
                    return(null);

                case 1:
                    return(errors[0]);

                default:
                    throw new SpecifiedSqlDbObjectNotFoundException(String.Format("{0} rows found in the database", errors.Length));
                }
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not load error", e);
            }
        }
示例#2
0
        public ActionResult DeleteError(Int32 errorId)
        {
            DatabaseAction(conn =>
            {
                Business.Error error = new Business.Error(conn, errorId);
                error.Delete(conn);
            });

            return(Json());
        }
示例#3
0
 /// <summary>
 /// Adds a new error to the database
 /// </summary>
 /// <param name="error">Error being added</param>
 /// <returns>New unique identifier for the error, generated by the database</returns>
 public static Int16 AddError(Business.Error error)
 {
     try
     {
         return((Int16)Control.ExecuteScalar("AddError", error.GetParametersForStoredProcedure(false)));
     }
     catch (System.Exception e)
     {
         throw new Exception.AddDbObjectException("Could not add error", e);
     }
 }
示例#4
0
        /// <summary>
        /// Creates a new Business.Error object from the data in the DataTableReader
        /// </summary>
        /// <param name="dtr">DataTableReader containing the Error's data</param>
        /// <returns>Business.Error object</returns>
        private static Business.Error GetErrorFromDataTableReader(DataTableReader dtr)
        {
            Business.Error error = new Business.Error();
            error.Id           = (Int16)dtr["Id"];
            error.Name         = (String)dtr["Name"];
            error.Message      = (String)dtr["Message"];
            error.StrackTrace  = (String)dtr["StackTrace"];
            error.outerErrorId = (Int16)dtr["OuterErrorId"];
            error.innerErrorId = (Int16)dtr["InnerErrorId"];
            error.DateThrown   = (DateTime)dtr["DateThrown"];
            error.IsInDatabase = true;

            return(error);
        }