示例#1
0
文件: Form1.cs 项目: ryanmcg1/Logger
        private void button1_Click(object sender, EventArgs e)
        {
            LogEntry le = new LogEntry();
            le.LogEntrySeverity = 7;
            le.LogEntrymessage = "test";
            le.LogEntryDateCreated = DateTime.Now;
            le.LogEntryError = "a";
            le.LogEntrySource = "source";

            Logger CL = new Logger(LogDatabaseTypes.SqlServer);
            CL.Write(le);

            this.logFileTableAdapter.Fill(this.customLoggerDataSet.LogFile);
        }
示例#2
0
 public override void Write(LogEntry logEvent)
 {
     try
     {
         using (SqlConnection sqlConn = new SqlConnection(sqlConnString))
             using (SqlCommand sqlCommand = new SqlCommand("INSERT INTO " + tableName + " values (@LogEntrymessage,@LogEntrySeverity,@LogEntryError,@LogEntrySource,@LogEntryDateCreated)", sqlConn))
             {
                 sqlCommand.Parameters.Add(new SqlParameter("@LogEntrymessage", logEvent.LogEntrymessage));
                 sqlCommand.Parameters.Add(new SqlParameter("@LogEntrySeverity", logEvent.LogEntrySeverity));
                 sqlCommand.Parameters.Add(new SqlParameter("@LogEntryError", logEvent.LogEntryError));
                 sqlCommand.Parameters.Add(new SqlParameter("@LogEntrySource", logEvent.LogEntrySource));
                 sqlCommand.Parameters.Add(new SqlParameter("@LogEntryDateCreated", logEvent.LogEntryDateCreated));
                 sqlConn.Open();
                 sqlCommand.ExecuteNonQuery();
                 sqlConn.Close();
             }
     }
     catch (SqlException ex )
     {
         throw ex ;
     }
 }
示例#3
0
 public void Write(LogEntry le)
 {
     _dal.Write(le);
 }
示例#4
0
 public abstract void Write(LogEntry log);
示例#5
0
 public override void Write(LogEntry log)
 {
     throw new NotImplementedException();
 }