예제 #1
0
        public override void AddEntry(LogEntry entry)
        {
            SqlConnection          connection   = new SqlConnection(this.ConnectionString);
            LogEntriesTableAdapter tableAdapter = new LogEntriesTableAdapter();

            tableAdapter.Connection = connection;

            tableAdapter.Insert(entry.Id, entry.Message, (byte)entry.Level, entry.TimeStamp);
        }
        public override void LoadSettings()
        {
            try
            {
                string enabledAsString = ConfigurationManager.Logger.ProviderSettings[Properties.Settings.Default.KeyAlphaSqlLogProviderIsEnabled].Value;
                Enabled = bool.Parse(enabledAsString);
            }
            catch (Exception)
            {
                LoggerEventLog.WriteEntry("Configuration error for the provider " + Name + ". The provider will be disabled.", EventLogEntryType.Error);
                Enabled = false;
                return;
            }

            if (Enabled)
            {
                ConnectionString        = ConfigurationManager.ConnectionStrings[Properties.Settings.Default.AlphaSqlLogProviderConnectionStringName].ConnectionString;
                sqlConnection           = new SqlConnection(ConnectionString);
                tableAdapter            = new LogEntriesTableAdapter();
                tableAdapter.Connection = sqlConnection;
            }
        }