- Using custom logger class to log errors and events slows down the process
- public class Logger
- {
- public static void Log(string message)
- {
- mySqlClassInDAL.ExecuteNonQuery(string.Format("Insert into LogTable (msg) values ({0})",message));
- }
- }
- try
- {
- PlayGame("Angry Pigs");
- }
- catch
- {
- Logger.Log("Can't Play Game");
- }
- public int ExecuteNonQuery(string NonQuery)
- {
- using (SqlConnection sc = new SqlConnection(AppConnectionString))
- {
- SqlCommand sqlCommand = new SqlCommand(NonQuery, sc);
- sqlCommand.Connection.Open();
- return sqlCommand.ExecuteNonQuery();
- }
- }
- Audit Login -- network protocol: TCP/IP
- RPC:Completed exec sp_executesql N'INSERT INTO ...
- Audit Logout
- RPC:Completed exec sp_reset_connection
- Audit Login -- network protocol: TCP/IP
- RPC:Completed exec sp_executesql N'INSERT INTO ...
- Audit Logout
- RPC:Completed exec sp_reset_connection
- Console.WriteLine(DateTime.Now);
- for (int i = 0; i < 1000; i++)
- {
- ExecuteNonQuery(string.Format("INSERT INTO LogTable ... ", (i+baseNo).ToString()));
- ExecuteNonQuery("UPDATE Customers... Where ID = " + (i+baseNo).ToString());
- }
- Console.WriteLine(DateTime.Now);
- .
- .
- .
- for (int i = 0; i < 1000; i++)
- {
- List<object> parameterValues = new List<object> { "abc", 1, (i+baseNo).ToString() };
- ExecuteSP("INSERTINTOLOG", parameterValues);
- ExecuteSP("UPDATECustomers", new List<object> { i+baseNo });
- }
- Console.WriteLine(DateTime.Now);
- .
- .
- .
- var blockingCollection = new BlockingCollection<LogWriter>();
- CREATE PROC sp_AddtoLog @in_values nText AS
- DECLARE @hDoc int
- --Prepare input values as an XML documnet
- exec sp_xml_preparedocument @hDoc OUTPUT, @in_values
- --Select data from the table based on values in XML
- Insert into Log values (LogiD,Message)
- SELECT * FROM Orders WHERE CustomerID IN (
- SELECT LogID,Message FROM OPENXML (@hdoc, '/NewDataSet/Logs', 1)
- WITH (LogID NCHAR(5),Message varchar(200)))
- EXEC sp_xml_removedocument @hDoc
- string logs =dsLog.GetXml();