From 46502f398d70ab59a0ad3620aa1341a2f082bd99 Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 7 Nov 2025 05:52:30 -0500 Subject: [PATCH] Refactor some logging. --- .../Helper/DividendHistoryMarketDataHelper.cs | 1 - .../InsiderTransactionMarketDataHelper.cs | 52 ++++++++++++------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/MarketData/MarketDataLib/Helper/DividendHistoryMarketDataHelper.cs b/MarketData/MarketDataLib/Helper/DividendHistoryMarketDataHelper.cs index 8a4b9ef..db7963f 100755 --- a/MarketData/MarketDataLib/Helper/DividendHistoryMarketDataHelper.cs +++ b/MarketData/MarketDataLib/Helper/DividendHistoryMarketDataHelper.cs @@ -159,7 +159,6 @@ namespace MarketData.Helper return false; } MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Got {0} dividend history records for {1}", dividendHistory.Count, symbol)); - MDTrace.WriteLine(LogLevel.DEBUG,"Adding..."); if (DividendHistoryDA.InsertOrUpdate(dividendHistory)) MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Added {0} dividend history records for {1}", dividendHistory.Count, symbol)); else MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Failed to update dividend history for {0}", symbol)); return true; diff --git a/MarketData/MarketDataLib/Helper/InsiderTransactionMarketDataHelper.cs b/MarketData/MarketDataLib/Helper/InsiderTransactionMarketDataHelper.cs index 7e6c63e..928a5da 100755 --- a/MarketData/MarketDataLib/Helper/InsiderTransactionMarketDataHelper.cs +++ b/MarketData/MarketDataLib/Helper/InsiderTransactionMarketDataHelper.cs @@ -151,17 +151,24 @@ namespace MarketData.Helper private static void LoadInsiderTransactionsSymbolEx(String symbol) { - symbol = symbol.ToUpper(); - MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Load insider transactions for {0}", symbol)); - InsiderTransactions insiderTransactions = MarketDataHelper.GetInsiderTransactions(symbol); - if (null == insiderTransactions || 0 == insiderTransactions.Count) + Profiler profiler = new Profiler(); + try { - MDTrace.WriteLine(LogLevel.DEBUG,String.Format("No insider transactions for {0}", symbol)); - return; + symbol = symbol.ToUpper(); + MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Load insider transactions for {0}", symbol)); + InsiderTransactions insiderTransactions = MarketDataHelper.GetInsiderTransactions(symbol); + if (null == insiderTransactions || 0 == insiderTransactions.Count) + { + MDTrace.WriteLine(LogLevel.DEBUG,String.Format("No insider transactions for {0}", symbol)); + return; + } + MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Insider Transactions, Saving {0} records for {1}", insiderTransactions.Count, symbol)); + InsiderTransactionDA.InsertInsiderTransactions(insiderTransactions); + } + finally + { + MDTrace.WriteLine(LogLevel.DEBUG,$"{symbol} Done, took {profiler.End()}(ms)"); } - MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Insider Transactions, Saving {0} records for {1}", insiderTransactions.Count, symbol)); - InsiderTransactionDA.InsertInsiderTransactions(insiderTransactions); - MDTrace.WriteLine(LogLevel.DEBUG,"Insider Transactions - Done."); } private void ThreadPoolCallbackYearGreaterEqual(Object threadHelperContext) @@ -176,18 +183,25 @@ namespace MarketData.Helper private static void LoadInsiderTransactionsYearGreaterEqualEx(String symbol, int yearGreaterEqual) { - symbol = symbol.ToUpper(); - MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Load insider transactions for {0} years>={1}", symbol,yearGreaterEqual)); - InsiderTransactions insiderTransactions = MarketDataHelper.GetInsiderTransactionsYear(symbol, yearGreaterEqual); - if (null == insiderTransactions || 0 == insiderTransactions.Count) + Profiler profiler = new Profiler(); + try { - MDTrace.WriteLine(LogLevel.DEBUG,String.Format("No insider transactions for {0} years>={1}", symbol,yearGreaterEqual)); - return; + symbol = symbol.ToUpper(); + MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Load insider transactions for {0} years>={1}", symbol,yearGreaterEqual)); + InsiderTransactions insiderTransactions = MarketDataHelper.GetInsiderTransactionsYear(symbol, yearGreaterEqual); + if (null == insiderTransactions || 0 == insiderTransactions.Count) + { + MDTrace.WriteLine(LogLevel.DEBUG,String.Format("No insider transactions for {0} years>={1}", symbol,yearGreaterEqual)); + return; + } + MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Insider Transactions, Saving {0} records for {1} years>={2}", insiderTransactions.Count, symbol, yearGreaterEqual)); + InsiderTransactionDA.DeleteInsiderTransactionsYearsGreaterEqual(symbol, yearGreaterEqual); + InsiderTransactionDA.InsertInsiderTransactions(insiderTransactions); + } + finally + { + MDTrace.WriteLine(LogLevel.DEBUG,$"{symbol} Done, took {profiler.End()}(ms)"); } - MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Insider Transactions, Saving {0} records for {1} years>={2}", insiderTransactions.Count, symbol, yearGreaterEqual)); - InsiderTransactionDA.DeleteInsiderTransactionsYearsGreaterEqual(symbol, yearGreaterEqual); - InsiderTransactionDA.InsertInsiderTransactions(insiderTransactions); - MDTrace.WriteLine(LogLevel.DEBUG,"Insider Transactions - Done."); } } }