Advertisement
Advertisement
| 02.15.2008 at 06:40PM PST, ID: 23167881 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 02.18.2008 at 12:08PM PST, ID: 20923006 |
| 02.19.2008 at 05:44PM PST, ID: 20934341 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: |
public class DBLogger
{
LogWriter writer = null;
FormattedDatabaseTraceListener logFileListener = null;
LogSource mainLogSource = null;
LogSource emptyTraceSource = null;
TextFormatter formatter = null;
string sCategory = "";
Database db = null;
public DBLogger(string sDBServerName, string sDBName, string sUser, string sPasswd, Level level,
string sMessage, string sMiscellaneous)
{
try
{
formatter = new TextFormatter("Timestamp: {timestamp}{newline}" +
"Message: {message}{newline}" + "Category: {category}{newline}");
emptyTraceSource = new LogSource("none");
// example: data source=arc-tms-db2005;initial catalog=northwind;Integrated Security=SSPI
string sConnectionString = "data source=" + sDBServerName + "; initial catalog=" +
sDBName + ";Integrated Security=SSPI";
db = new SqlDatabase(sConnectionString);
logFileListener = new FormattedDatabaseTraceListener(db,
"WriteLog", "AddCategory", formatter);
// adding collection of TraceListeners.
// LogSource provides tracing services through a set of TraceListeners.
switch (level)
{
case (Level.DEBUG):
mainLogSource = new LogSource("MainLogSource", SourceLevels.All);
sCategory = "Debug";
break;
case (Level.ERROR):
mainLogSource = new LogSource("MainLogSource", SourceLevels.Error);
sCategory = "Error";
break;
case (Level.MESSAGE):
mainLogSource = new LogSource("MainLogSource", SourceLevels.Information);
sCategory = "Message";
break;
default:
mainLogSource = new LogSource("MainLogSource", SourceLevels.Information);
sCategory = "Message";
break;
}
mainLogSource.Listeners.Add(logFileListener);
IDictionary<string, LogSource> traceSources = new Dictionary<string, LogSource>();
// Add to Category "Error" our EventLog Listener with the corresponding category in it.
traceSources.Add(mainLogSource.Name, mainLogSource);
writer = new LogWriter(new ILogFilter[0], // ICollection<ILogFilter> filters
traceSources, // IDictionary<string, LogSource> traceSources
emptyTraceSource, // LogSource allEventsTraceSource
emptyTraceSource, // LogSource notProcessedTraceSource
mainLogSource, // LogSource mainLogSource
"Error", // string defaultCategory
false, // bool tracingEnabled
true); // bool logWarningsWhenNoCategoriesMatch
}
catch (Exception ex)
{
}
}
/// <summary>
/// Writes an Error to the log.
/// </summary>
/// <param name="message">Error Message</param>
public void Write(string message)
{
try
{
Write(message, sCategory);
}
catch (Exception ex)
{
}
}
/// <summary>
/// Writes a message to the log using the specified
/// category.
/// </summary>
/// <param name="message"></param>
/// <param name="category"></param>
public void Write(string message, string category)
{
try
{
LogEntry ent = new LogEntry();
ent.Categories.Add(category);
ent.Message = message;
ent.Severity = System.Diagnostics.TraceEventType.Information;
writer.Write(ent);
}
catch (Exception ex)
{
}
}
public void CloseWriter()
{
writer.Dispose();
}
}
|
| 02.24.2008 at 09:24AM PST, ID: 20970565 |
| 02.24.2008 at 10:33AM PST, ID: 20970757 |
| 02.24.2008 at 11:35AM PST, ID: 20970992 |
| 02.24.2008 at 01:23PM PST, ID: 20971456 |
| 02.25.2008 at 12:33PM PST, ID: 20978924 |
| 02.25.2008 at 01:06PM PST, ID: 20979244 |
| 02.26.2008 at 12:32AM PST, ID: 20982494 |
| 02.26.2008 at 03:30AM PST, ID: 20983262 |
| 02.27.2008 at 01:06AM PST, ID: 20992444 |
| 02.27.2008 at 02:00AM PST, ID: 20992668 |
| 02.28.2008 at 01:01PM PST, ID: 21008009 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: |
public DBLogger(string sDBServerName, string sDBName, string sUser, string sPasswd, Level level,
string sMessage, string sMiscellaneous)
{
emptyTraceSource = new LogSource("none");
// example: data source=arc-tms-db2005;initial catalog=northwind;Integrated Security=SSPI
string sConnectionString = "data source=" + sDBServerName + "; initial catalog=" +
sDBName + ";Integrated Security=SSPI";
db = new SqlDatabase(sConnectionString);
logFileListener = new FormattedDatabaseTraceListener(db,
"WriteLog", "AddCategory", null);
// adding collection of TraceListeners.
// LogSource provides tracing services through a set of TraceListeners.
switch (level)
{
case (Level.DEBUG):
mainLogSource = new LogSource("MainLogSource", SourceLevels.All);
sCategory = "Debug";
break;
case (Level.ERROR):
mainLogSource = new LogSource("MainLogSource", SourceLevels.Error);
sCategory = "Error";
break;
case (Level.MESSAGE):
mainLogSource = new LogSource("MainLogSource", SourceLevels.Information);
sCategory = "Message";
break;
default:
mainLogSource = new LogSource("MainLogSource", SourceLevels.Information);
sCategory = "Message";
break;
}
mainLogSource.Listeners.Add(logFileListener);
IDictionary<string, LogSource> traceSources = new Dictionary<string, LogSource>();
// Add to Category "Error" our EventLog Listener with the corresponding category in it.
traceSources.Add(sCategory, mainLogSource);
writer = new LogWriter(new ILogFilter[0], // ICollection<ILogFilter> filters
traceSources, // IDictionary<string, LogSource> traceSources
emptyTraceSource, // LogSource allEventsTraceSource
emptyTraceSource, // LogSource notProcessedTraceSource
mainLogSource, // LogSource mainLogSource
"Error", // string defaultCategory
false, // bool tracingEnabled
true); // bool logWarningsWhenNoCategoriesMatch
Debug.Write(writer.IsLoggingEnabled());
}
|