Logging changes.

This commit is contained in:
2025-04-10 22:32:10 -04:00
parent f9365049e2
commit 98cab516fb
5 changed files with 235 additions and 90 deletions

View File

@@ -329,9 +329,7 @@ namespace MarketData.Services
ThreadPool.QueueUserWorkItem(delegate ThreadPool.QueueUserWorkItem(delegate
{ {
LoadConsumerPriceIndex(); // Load consumer price index data from Bureau of Labor Statistics
UpdateCompanyProfiles(); // financials.morningstar.com and finance.yahoo.com UpdateCompanyProfiles(); // financials.morningstar.com and finance.yahoo.com
LoadGDPPerCapita(); // api.worldbank.org
resetEvents[STAGE_2].Set(); resetEvents[STAGE_2].Set();
SMSClient.SendSMSEmail("UPDATEDAILY2 STAGE_2 complete. LoadConsumerPriceIndex,UpdateCompanyProfiles,LoadGDPPerCapita ", smsUserName, smsRecipients, smsSMTPAddress, smsUserName, smsPassword); SMSClient.SendSMSEmail("UPDATEDAILY2 STAGE_2 complete. LoadConsumerPriceIndex,UpdateCompanyProfiles,LoadGDPPerCapita ", smsUserName, smsRecipients, smsSMTPAddress, smsUserName, smsPassword);
MDTrace.WriteLine(LogLevel.DEBUG,$"STAGE_2 complete."); MDTrace.WriteLine(LogLevel.DEBUG,$"STAGE_2 complete.");
@@ -340,6 +338,8 @@ namespace MarketData.Services
ThreadPool.QueueUserWorkItem(delegate ThreadPool.QueueUserWorkItem(delegate
{ {
UpdateYieldCurve(); // www.treasury.gov UpdateYieldCurve(); // www.treasury.gov
LoadGDPPerCapita(); // api.worldbank.org
LoadConsumerPriceIndex(); // Load consumer price index data from Bureau of Labor Statistics
resetEvents[STAGE_3].Set(); resetEvents[STAGE_3].Set();
SMSClient.SendSMSEmail("UPDATEDAILY2 STAGE_3 complete. UpdateYieldCurve", smsUserName, smsRecipients, smsSMTPAddress, smsUserName, smsPassword); SMSClient.SendSMSEmail("UPDATEDAILY2 STAGE_3 complete. UpdateYieldCurve", smsUserName, smsRecipients, smsSMTPAddress, smsUserName, smsPassword);
MDTrace.WriteLine(LogLevel.DEBUG,$"STAGE_3 complete."); MDTrace.WriteLine(LogLevel.DEBUG,$"STAGE_3 complete.");
@@ -469,65 +469,81 @@ namespace MarketData.Services
public static void LoadConsumerPriceIndex() public static void LoadConsumerPriceIndex()
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine("[LoadConsumerPriceIndex] started."); MDTrace.WriteLine("Started.");
PriceIndices priceIndices=MarketDataHelper.GetConsumerPriceIndices(); PriceIndices priceIndices=MarketDataHelper.GetConsumerPriceIndices();
if(null==priceIndices) if(null==priceIndices)
{ {
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadConsumerPriceIndex] Failed, check log file for isssues."); MDTrace.WriteLine(LogLevel.DEBUG,"Failed, check log file for isssues.");
return; return;
} }
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[LoadConsumerPriceIndex] Got:{0} records from source feed.",priceIndices.Count())); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Got:{0} records from source feed.",priceIndices.Count()));
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadConsumerPriceIndex] Saving..."); MDTrace.WriteLine(LogLevel.DEBUG,"Saving...");
ConsumerPriceIndexDA.InsertUpdatePriceIndices(priceIndices); ConsumerPriceIndexDA.InsertUpdatePriceIndices(priceIndices);
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadConsumerPriceIndex] Save complete..."); MDTrace.WriteLine(LogLevel.DEBUG,"Save complete...");
} }
catch(Exception exception) catch(Exception exception)
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[LoadConsumerPriceIndex] Exception:{0}",exception.ToString())); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Exception:{0}",exception.ToString()));
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
} }
} }
public static void UpdateCompanyProfiles() public static void UpdateCompanyProfiles()
{ {
try Profiler profiler = new Profiler();
{ try
CompanyProfileMarketDataHelper companyProfileMarketDataHelper=new CompanyProfileMarketDataHelper(); {
companyProfileMarketDataHelper.UpdateCompanyProfiles(); MDTrace.WriteLine(LogLevel.DEBUG,$"Started.");
} CompanyProfileMarketDataHelper companyProfileMarketDataHelper=new CompanyProfileMarketDataHelper();
catch(Exception exception) companyProfileMarketDataHelper.UpdateCompanyProfiles();
{ }
MDTrace.WriteLine(LogLevel.DEBUG,exception); catch(Exception exception)
} {
} MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms).");
}
}
public static void LoadGDPPerCapita() public static void LoadGDPPerCapita()
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine("[LoadGSPPerCapita]"); MDTrace.WriteLine("Started.");
EconomicIndicators economicIndicators=MarketDataHelper.GetGDPPerCapita(); EconomicIndicators economicIndicators=MarketDataHelper.GetGDPPerCapita();
if(null==economicIndicators||0==economicIndicators.Count) if(null==economicIndicators||0==economicIndicators.Count)
{ {
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadGDPPerCapita] No data, see log file for potential issues."); MDTrace.WriteLine(LogLevel.DEBUG,"No data, see log file for potential issues.");
return; return;
} }
List<String> distinctCountry=(from EconomicIndicator economicIndicator in economicIndicators select economicIndicator.CountryCode).Distinct().ToList(); List<String> distinctCountry=(from EconomicIndicator economicIndicator in economicIndicators select economicIndicator.CountryCode).Distinct().ToList();
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[LoadGDPPerCapita] Downloaded {0} countries.",distinctCountry.Count)); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Downloaded {0} countries.",distinctCountry.Count));
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadGDPPerCapita] Saving..."); MDTrace.WriteLine(LogLevel.DEBUG,"Saving...");
if(EconomicIndicatorDA.InsertUpdateEconomicIndicators(economicIndicators)) if(EconomicIndicatorDA.InsertUpdateEconomicIndicators(economicIndicators))
{ {
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadGDPPerCapita] Success."); MDTrace.WriteLine(LogLevel.DEBUG,$"Save complete.");
} }
else else
{ {
MDTrace.WriteLine(LogLevel.DEBUG,"[LoadGDPPerCapita] Failed, check log file for isssues."); MDTrace.WriteLine(LogLevel.DEBUG,"Failed to save economic indicators.");
} }
} }
catch(Exception exception) catch(Exception exception)
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[LoadGDPPerCapita] Exception:{0}",exception.ToString())); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Exception:{0}",exception.ToString()));
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
} }
} }
@@ -564,7 +580,7 @@ namespace MarketData.Services
{ {
if(!CheckRunCriteria())return; if(!CheckRunCriteria())return;
DateGenerator dateGenerator = new DateGenerator(); DateGenerator dateGenerator = new DateGenerator();
MDTrace.WriteLine(LogLevel.DEBUG, "Enter"); MDTrace.WriteLine(LogLevel.DEBUG, "Started.");
AnalystRatings analystRatings = MarketDataHelper.GetLatestAnalystRatings(); AnalystRatings analystRatings = MarketDataHelper.GetLatestAnalystRatings();
List<String> symbols = PricingDA.GetSymbolsNotIn(analystRatings.Symbols); List<String> symbols = PricingDA.GetSymbolsNotIn(analystRatings.Symbols);
foreach (String symbol in symbols) foreach (String symbol in symbols)
@@ -614,6 +630,7 @@ namespace MarketData.Services
public static void UpdateMissingAnalystRatings() public static void UpdateMissingAnalystRatings()
{ {
Profiler profiler = new Profiler();
try try
{ {
DateGenerator dateGenerator = new DateGenerator(); DateGenerator dateGenerator = new DateGenerator();
@@ -648,82 +665,209 @@ namespace MarketData.Services
} }
catch (Exception exception) catch (Exception exception)
{ {
MDTrace.WriteLine(LogLevel.DEBUG, exception); MDTrace.WriteLine(LogLevel.DEBUG, $"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
} }
} }
public static void UpdateSplits() public static void UpdateSplits()
{ {
MDTrace.WriteLine("Updating splits."); Profiler profiler = new Profiler();
Splits splits=MarketDataHelper.GetSplits(); try
if(null==splits||0==splits.Count)return; {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Got {0} split records.",splits.Count)); MDTrace.WriteLine("Updating splits.");
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Writing to database.",splits.Count)); Splits splits=MarketDataHelper.GetSplits();
SplitsDA.InsertSplits(splits); if(null==splits||0==splits.Count)return;
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Done.")); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Got {0} split records.",splits.Count));
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Writing to database.",splits.Count));
SplitsDA.InsertSplits(splits);
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Done."));
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
} }
public static void ProcessAllSplits() public static void ProcessAllSplits()
{ {
MDTrace.WriteLine("Processing all splits"); Profiler profiler = new Profiler();
Splits splits=SplitsDA.GetUnappliedSplits(); try
if(null==splits||0==splits.Count)return; {
SplitHelper.ProcessSplits(splits); MDTrace.WriteLine("Processing all splits");
Splits splits=SplitsDA.GetUnappliedSplits();
if(null==splits||0==splits.Count)return;
SplitHelper.ProcessSplits(splits);
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
} }
public static void LoadInsiderTransactions() public static void LoadInsiderTransactions()
{ {
List<String> symbols = PricingDA.GetSymbols(); Profiler profiler = new Profiler();
InsiderTransactionMarketDataHelper insiderTransactionMarketDataHelper = new InsiderTransactionMarketDataHelper(); try
insiderTransactionMarketDataHelper.LoadInsiderTransactions(symbols); {
MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
List<String> symbols = PricingDA.GetSymbols();
InsiderTransactionMarketDataHelper insiderTransactionMarketDataHelper = new InsiderTransactionMarketDataHelper();
insiderTransactionMarketDataHelper.LoadInsiderTransactions(symbols);
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
} }
public static void UpdateEarningsAnnouncements(String symbol=null) public static void UpdateEarningsAnnouncements(String symbol=null)
{ {
MDTrace.WriteLine(LogLevel.DEBUG,"[UPDATEEARNINGSANNOUNCEMENTS]"); Profiler profiler = new Profiler();
EarningsAnnouncementsMarketDataHelper earningsAnnouncementsMarketDataHelper=new EarningsAnnouncementsMarketDataHelper(); try
earningsAnnouncementsMarketDataHelper.UpdateEarningsAnnouncements(symbol); {
MDTrace.WriteLine(LogLevel.DEBUG,"[UPDATEEARNINGSANNOUNCEMENTS] Done"); MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
EarningsAnnouncementsMarketDataHelper earningsAnnouncementsMarketDataHelper=new EarningsAnnouncementsMarketDataHelper();
earningsAnnouncementsMarketDataHelper.UpdateEarningsAnnouncements(symbol);
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
} }
public static void LoadZacksRank() public static void LoadZacksRank()
{ {
ZacksRankMarketDataHelper zacksRankMarketDataHelper=new ZacksRankMarketDataHelper(); Profiler profiler = new Profiler();
zacksRankMarketDataHelper.LoadZacksRank(); try
{
MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
ZacksRankMarketDataHelper zacksRankMarketDataHelper=new ZacksRankMarketDataHelper();
zacksRankMarketDataHelper.LoadZacksRank();
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
} }
public static void GetSECFilingsWatchList(String watchListName) public static void GetSECFilingsWatchList(String watchListName)
{ {
List<String> symbols = WatchListDA.GetWatchList(watchListName); Profiler profiler = new Profiler();
SECFilingMarketDataHelper secFilingMarketDataHelper=new SECFilingMarketDataHelper(); try
secFilingMarketDataHelper.UpdateSECFilings(symbols); {
} MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
List<String> symbols = WatchListDA.GetWatchList(watchListName);
SECFilingMarketDataHelper secFilingMarketDataHelper=new SECFilingMarketDataHelper();
secFilingMarketDataHelper.UpdateSECFilings(symbols);
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void UpdateAnalystPriceTarget() public static void UpdateAnalystPriceTarget()
{ {
MDTrace.WriteLine(LogLevel.DEBUG,"[UPDATEANALYSTPRICETARGET]"); Profiler profiler = new Profiler();
AnalystPriceTargetMarketDataHelper analystPriceTargetMarketDataHelper=new AnalystPriceTargetMarketDataHelper(); try
analystPriceTargetMarketDataHelper.LoadAnalystPriceTarget(); {
MDTrace.WriteLine(LogLevel.DEBUG,"[UPDATEANALYSTPRICETARGET] Done"); MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
AnalystPriceTargetMarketDataHelper analystPriceTargetMarketDataHelper=new AnalystPriceTargetMarketDataHelper();
analystPriceTargetMarketDataHelper.LoadAnalystPriceTarget();
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
} }
public static void GetETFHoldings() public static void GetETFHoldings()
{ {
ETFHoldingsMarketDataHelper etfHoldingsMarketDataHelper=new ETFHoldingsMarketDataHelper(); Profiler profiler = new Profiler();
etfHoldingsMarketDataHelper.LoadETFHoldings(); try
} {
MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
ETFHoldingsMarketDataHelper etfHoldingsMarketDataHelper=new ETFHoldingsMarketDataHelper();
etfHoldingsMarketDataHelper.LoadETFHoldings();
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void UpdateAllMissingCIK() public static void UpdateAllMissingCIK()
{ {
CIKMarketDataHelper cikMarketDataHelper=new CIKMarketDataHelper(); Profiler profiler = new Profiler();
cikMarketDataHelper.UpdateAllMissingCIK(); try
} {
MDTrace.WriteLine(LogLevel.DEBUG,"Started.");
CIKMarketDataHelper cikMarketDataHelper=new CIKMarketDataHelper();
cikMarketDataHelper.UpdateAllMissingCIK();
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
public static void UpdateDividendHistory() public static void UpdateDividendHistory()
{ {
DividendHistoryMarketDataHelper dividendHistoryMarketDataHelper=new DividendHistoryMarketDataHelper(); Profiler profiler = new Profiler();
dividendHistoryMarketDataHelper.UpdateDividendHistory(); try
} {
DividendHistoryMarketDataHelper dividendHistoryMarketDataHelper=new DividendHistoryMarketDataHelper();
dividendHistoryMarketDataHelper.UpdateDividendHistory();
}
catch(Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception: {exception.ToString()}");
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End}(ms)");
}
}
// ********************************************************************************************************************************************** // **********************************************************************************************************************************************
// ******************************************* E N D U P D A T E D A I L Y 2 M E T H O D S *************************************************** // ******************************************* E N D U P D A T E D A I L Y 2 M E T H O D S ***************************************************

View File

@@ -50,7 +50,7 @@ namespace MarketData.Helper
Index=-1; Index=-1;
ManualResetEvent[] resetEvents = new ManualResetEvent[MaxThreads]; ManualResetEvent[] resetEvents = new ManualResetEvent[MaxThreads];
for (int eventIndex = 0; eventIndex < resetEvents.Length; eventIndex++)resetEvents[eventIndex] = new ManualResetEvent(true); for (int eventIndex = 0; eventIndex < resetEvents.Length; eventIndex++)resetEvents[eventIndex] = new ManualResetEvent(true);
MDTrace.WriteLine(String.Format("[UpdateCompanyProfile] Queuing company profile fetches ...")); MDTrace.WriteLine(String.Format("Queuing company profile fetches ..."));
DateTime modified=DateTime.Now; DateTime modified=DateTime.Now;
while (true) while (true)
{ {
@@ -58,7 +58,7 @@ namespace MarketData.Helper
ManualResetEvent[] busyEvents=GetBusyEvents(resetEvents); ManualResetEvent[] busyEvents=GetBusyEvents(resetEvents);
if (null == PeekQueueItem() && 0==busyEvents.Length) if (null == PeekQueueItem() && 0==busyEvents.Length)
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[UpdateCompanyProfile] queue contains {0} items, busy events {1}, all done.",0,busyEvents.Length)); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Queue contains {0} items, busy events {1}, all done.",0,busyEvents.Length));
break; break;
} }
for (int index = 0; index < availableEvents.Length; index++) for (int index = 0; index < availableEvents.Length; index++)

View File

@@ -62,8 +62,8 @@ namespace MarketData.Helper
{ {
ManualResetEvent[] busyEvents=GetBusyEvents(events); ManualResetEvent[] busyEvents=GetBusyEvents(events);
if(busyEvents.Length!=0) if(busyEvents.Length!=0)
{ { // The following trace will skip 3 frames to show the caller of this method in the log
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Resizing event queue to {0}",busyEvents.Length)); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Resizing event queue to {0}",busyEvents.Length),3);
ManualResetEvent[] resizedEvents=new ManualResetEvent[busyEvents.Length]; ManualResetEvent[] resizedEvents=new ManualResetEvent[busyEvents.Length];
Array.Copy(busyEvents, resizedEvents, busyEvents.Length); Array.Copy(busyEvents, resizedEvents, busyEvents.Length);
return resizedEvents; return resizedEvents;
@@ -77,12 +77,12 @@ namespace MarketData.Helper
for (int index = 0; index < resetEvents.Length; index++) for (int index = 0; index < resetEvents.Length; index++)
{ {
if (!resetEvents[index].WaitOne(0)) if (!resetEvents[index].WaitOne(0))
{ { // Notice the magic number 3 at the end of the trace. The is the skip frames because we want the caller of this method to show up in the log
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Event {0} is still doing work",resetEvents[index].SafeWaitHandle.DangerousGetHandle().ToString())); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Event {0} is still doing work",resetEvents[index].SafeWaitHandle.DangerousGetHandle().ToString()),3);
availableEvents.Add(resetEvents[index]); availableEvents.Add(resetEvents[index]);
} }
} } // The following trace will skip 3 frames to show the caller of this method in the log
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("The event queue has {0} busy slots",availableEvents.Count)); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("The event queue has {0} busy slots",availableEvents.Count),3);
return availableEvents.ToArray(); return availableEvents.ToArray();
} }
@@ -92,8 +92,8 @@ namespace MarketData.Helper
for (int index = 0; index < resetEvents.Length; index++) for (int index = 0; index < resetEvents.Length; index++)
{ {
if (resetEvents[index].WaitOne(0)) if (resetEvents[index].WaitOne(0))
{ { // @ the end of this trace notice the magic number 3. This is the skip frames for the stack trace. We want the caller of this method to show up in the log
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Event {0} is available for work",resetEvents[index].SafeWaitHandle.DangerousGetHandle().ToString())); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Event {0} is available for work",resetEvents[index].SafeWaitHandle.DangerousGetHandle().ToString()),3);
availableEvents.Add(resetEvents[index]); availableEvents.Add(resetEvents[index]);
} }
} }

View File

@@ -205,7 +205,7 @@ namespace MarketData.Helper
} }
finally finally
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[UpdatePricesBigCharts]End, total took {0}(ms)",profiler.End())); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[UpdatePricesYahooSweep]End, total took {0}(ms)",profiler.End()));
} }
} }
public bool UpdatePricesAsOfSymbol(String symbol,DateTime asOf) // get prices from BigCharts public bool UpdatePricesAsOfSymbol(String symbol,DateTime asOf) // get prices from BigCharts

View File

@@ -65,10 +65,10 @@ namespace MarketData
/// <summary>WriteLine - Writes a line of text to trace log.</summary> /// <summary>WriteLine - Writes a line of text to trace log.</summary>
/// <param name="message">string content of message to write.</param> /// <param name="message">string content of message to write.</param>
/// <returns>void</returns> /// <returns>void</returns>
public static void WriteLine(LogLevel logLevel,string message) public static void WriteLine(LogLevel logLevel,string message,int skipFrames=2)
{ {
if(MDTrace.logLevel<logLevel)return; if(MDTrace.logLevel<logLevel)return;
Trace.WriteLine(GetThreadRep()+GetLogLevelRep()+"["+DateTime.Now.ToString()+"]"+" "+GetMethodInfo()+message); Trace.WriteLine(GetThreadRep()+GetLogLevelRep()+"["+DateTime.Now.ToString()+"]"+" "+GetMethodInfo(skipFrames)+message);
Console.WriteLine(message); Console.WriteLine(message);
Flush(); Flush();
} }
@@ -76,10 +76,10 @@ namespace MarketData
/// <summary>WriteLine - Writes a line of text to trace log.</summary> /// <summary>WriteLine - Writes a line of text to trace log.</summary>
/// <param name="message">string content of message to write.</param> /// <param name="message">string content of message to write.</param>
/// <returns>void</returns> /// <returns>void</returns>
public static void WriteLine(LogLevel logLevel,ConsoleColor consoleColor,string message) public static void WriteLine(LogLevel logLevel,ConsoleColor consoleColor,string message,int skipFrames=2)
{ {
if(MDTrace.logLevel<logLevel)return; if(MDTrace.logLevel<logLevel)return;
Trace.WriteLine(GetThreadRep()+GetLogLevelRep()+"["+DateTime.Now.ToString()+"]"+" "+GetMethodInfo()+message); Trace.WriteLine(GetThreadRep()+GetLogLevelRep()+"["+DateTime.Now.ToString()+"]"+" "+GetMethodInfo(skipFrames)+message);
ConsoleColor currentColor=Console.ForegroundColor; ConsoleColor currentColor=Console.ForegroundColor;
Console.ForegroundColor = consoleColor; Console.ForegroundColor = consoleColor;
Console.WriteLine(message); Console.WriteLine(message);
@@ -131,10 +131,11 @@ namespace MarketData
} }
/// <summary>GetMethodInfo - Returns information about the calling method 2 frames up.</summary> /// <summary>GetMethodInfo - Returns information about the calling method 2 frames up.</summary>
/// <returns>String</returns> /// <returns>String</returns>
private static String GetMethodInfo() private static String GetMethodInfo(int skipFrames=2)
{ {
StringBuilder sb=new StringBuilder(); StringBuilder sb=new StringBuilder();
StackFrame frame=new StackFrame(2,true); StackFrame frame=new StackFrame(skipFrames,true);
if(null==frame)return $"No Stack Frame at:{skipFrames}";
MethodBase methodBase=frame.GetMethod(); MethodBase methodBase=frame.GetMethod();
ParameterInfo[] parameters=methodBase.GetParameters(); ParameterInfo[] parameters=methodBase.GetParameters();
sb.Append("[").Append(methodBase.DeclaringType.FullName).Append("::").Append(methodBase.Name).Append("("); sb.Append("[").Append(methodBase.DeclaringType.FullName).Append("::").Append(methodBase.Name).Append("(");