Zbiór zmian 553 dla branches/ErrorLog/BazaReklam/Classes/Logger.cs
- Data:
- 2009-04-08 09:21:32 (17 years ago)
- Pliki:
-
- 1 zmodyfikowane
-
branches/ErrorLog/BazaReklam/Classes/Logger.cs (zmodyfikowane) (2 diffs)
Legenda:
- Bez zmian
- Dodane
- Usunięte
-
branches/ErrorLog/BazaReklam/Classes/Logger.cs
r549 r553 1 1 using System; 2 using System. Collections.Generic;2 using System.Data; 3 3 using System.Data.SqlClient; 4 using System.Text;5 4 6 5 namespace Baza_Reklam.Classes … … 8 7 public class Logger 9 8 { 10 public static void LogException(Exception ex , string userName, DateTime dateTime)9 public static void LogException(Exception exception, string userName, DateTime dateTime) 11 10 { 12 SqlConnection conn = new SqlConnection(ConnString.getConnString().Value); 11 SqlConnection conn = null; 12 SqlCommand cmd = null; 13 13 14 try 15 { 16 conn = new SqlConnection(ConnString.getConnString().Value); 17 conn.Open(); 18 cmd = new SqlCommand("dbo.sp_LogException", conn); 19 cmd.CommandType = CommandType.StoredProcedure; 20 cmd.Parameters.AddWithValue("@errorMessage", exception.Message); 21 cmd.Parameters.AddWithValue("@userName", userName); 22 cmd.Parameters.AddWithValue("@dateTime", dateTime); 23 cmd.Parameters.AddWithValue("@errorDetails", exception.ToString()); 24 cmd.ExecuteNonQuery(); 25 } 26 catch (Exception ex) 27 { 28 EmailSender.SendNotification(ex, exception, userName, dateTime); 29 } 30 finally 31 { 32 if (cmd != null) 33 cmd.Dispose(); 34 35 if (conn != null && conn.State == ConnectionState.Open) 36 { 37 conn.Close(); 38 conn.Dispose(); 39 } 40 } 14 41 } 15 42 }
