示例#1
0
        public static List <Error_Type> ReturnErrors(bool corrected, int UserID)
        {
            List <Error_Type> errors = new List <Error_Type>();
            //our first instinct is to record an error to the database
            string sSQL = "SELECT * FROM dbo.ErrorTable ORDER BY ErrorID DESC";

            using (Data DC = new Data("conn", "Errors", "ReturnErrors"))
            {
                try
                {
                    //make an independent connection to the error database
                    DC.AddCommand(CommandType.Text, sSQL);

                    DataTable dt = DC.ExecuteCommandForDT();

                    if (dt != null)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            errors.Add(new Error_Type
                            {
                                UserID        = UserID,
                                Err_Message   = dr["Err_Message"].StringSafe(),
                                Err_Subject   = dr["Err_Subject"].StringSafe(),
                                ErrorID       = (int)Utils.ParseNumControlledReturn(dr["ErrorID"]),
                                LiteralDesc   = dr["LiteralDesc"].StringSafe(),
                                Page          = dr["Page"].StringSafe(),
                                Process       = dr["Process"].StringSafe(),
                                SQL           = dr["SQL"].StringSafe(),
                                Time_Of_Error = Utils.ParseDateControlledReturn(dr["Time_Of_Error"])
                            });
                        }
                    }
                }
                catch (Exception ex)
                {
                    DC.MakeError(ex, "ReturnErrors", sSQL);
                }
                finally
                {
                    if (DC != null)
                    {
                        DC.Dispose();
                    }
                }
            }
            return(errors);
        }