Remove Profiling in some DAs

This commit is contained in:
2025-04-15 01:22:27 -04:00
parent eb9d45f4bd
commit 79e6fab88e
5 changed files with 12 additions and 70 deletions

View File

@@ -15,7 +15,6 @@ namespace MarketData.DataAccess
// ***********************************************************************************************************
public static bool UpdateCompanyProfile(CompanyProfile companyProfile)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlTransaction sqlTransaction = null;
MySqlCommand sqlCommand=null;
@@ -67,13 +66,11 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlTransaction) sqlTransaction.Dispose();
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static CompanyProfiles GetCompanyProfiles()
{
Profiler profiler = new Profiler();
CompanyProfiles companyProfiles=new CompanyProfiles();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
@@ -115,13 +112,11 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static CompanyProfile GetCompanyProfile(String symbol)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -160,14 +155,12 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
// This handles the actual company profile table where we store additional company related informtion
private static bool CompanyProfileDetailsExists(CompanyProfile companyProfile,MySqlConnection sqlConnection,MySqlTransaction sqlTransaction)
{
Profiler profiler = new Profiler();
MySqlDataReader sqlDataReader=null;
MySqlCommand sqlCommand=null;
String strQuery = null;
@@ -193,13 +186,11 @@ namespace MarketData.DataAccess
{
if(null!=sqlCommand)sqlCommand.Dispose();
if(null!=sqlDataReader){sqlDataReader.Close();sqlDataReader.Dispose();}
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
private static bool InsertCompanyProfileDescription(CompanyProfile companyProfile,MySqlConnection sqlConnection,MySqlTransaction sqlTransaction)
{
Profiler profiler = new Profiler();
MySqlCommand sqlCommand=null;
String strQuery = null;
@@ -225,13 +216,11 @@ namespace MarketData.DataAccess
finally
{
if(null!=sqlCommand)sqlCommand.Dispose();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
private static bool UpdateCompanyProfileDescription(CompanyProfile companyProfile,MySqlConnection sqlConnection,MySqlTransaction sqlTransaction)
{
Profiler profiler = new Profiler();
MySqlCommand sqlCommand=null;
String strQuery = null;
@@ -255,7 +244,6 @@ namespace MarketData.DataAccess
finally
{
if(null!=sqlCommand)sqlCommand.Dispose();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
}

View File

@@ -12,7 +12,6 @@ namespace MarketData.DataAccess
}
public static bool CheckFundamentalModifiedOn(String symbol,DateTime modified)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand =null;
@@ -44,12 +43,10 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static DateTime GetLatestDate(String symbol)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -82,12 +79,10 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if(null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static TimeSeriesCollection GetTotalCashMils(String symbol)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand =null;
@@ -127,12 +122,10 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static TimeSeriesCollection GetPERatio(String symbol)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand =null;
@@ -172,12 +165,10 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static TimeSeriesCollection GetEPS(String symbol,DateTime? maxDate=null)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand = null;
@@ -218,12 +209,10 @@ namespace MarketData.DataAccess
if (null != sqlCommand) sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static Fundamental GetFundamental(String symbol)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand =null;
@@ -286,12 +275,10 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static Fundamental GetFundamental(String symbol, DateTime asof)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -357,13 +344,11 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
// get the maximum date on record on or before asof
public static DateTime? GetMaxDateFromFundamental(String symbol,DateTime asof)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -397,12 +382,10 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static Fundamental GetFundamentalMaxDate(String symbol, DateTime asof)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -472,13 +455,11 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static Fundamentals GetFundamentalMaxDateTop(String symbol, DateTime asof, int top)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -554,13 +535,11 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static bool InsertFundamentals(Fundamentals fundamentals)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlTransaction sqlTransaction = null;
String strQuery = null;
@@ -651,13 +630,11 @@ namespace MarketData.DataAccess
{
if(null!=sqlTransaction)sqlTransaction.Dispose();
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static bool InsertFundamental(Fundamental fundamental)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlTransaction sqlTransaction = null;
String strQuery = null;
@@ -744,7 +721,6 @@ namespace MarketData.DataAccess
{
if(null!=sqlTransaction)sqlTransaction.Dispose();
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
private static bool DeleteFundamentals(Fundamentals fundamentals, MySqlConnection sqlConnection, MySqlTransaction sqlTransaction)
@@ -757,7 +733,6 @@ namespace MarketData.DataAccess
}
private static bool DeleteFundamental(Fundamental fundamental, MySqlConnection sqlConnection, MySqlTransaction sqlTransaction)
{
Profiler profiler = new Profiler();
StringBuilder sb = new StringBuilder();
String strQuery = null;
@@ -783,7 +758,6 @@ namespace MarketData.DataAccess
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
}

View File

@@ -10,7 +10,6 @@ namespace MarketData.DataAccess
// ********************************************* I N C O M E S T A T E M E N T **************************************
public static bool CheckIncomeStatementModifiedOn(String symbol, DateTime modified,IncomeStatement.PeriodType periodType)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -43,12 +42,10 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static List<DateTime> GetIncomeStatementDates(String symbol,IncomeStatement.PeriodType periodType)
{
Profiler profiler = new Profiler();
List<DateTime> incomeStatementDates = new List<DateTime>();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
@@ -83,12 +80,10 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static DateTime? GetLatestIncomeStatementDate(String symbol,IncomeStatement.PeriodType periodType)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -123,12 +118,10 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static IncomeStatement GetIncomeStatement(String symbol,IncomeStatement.PeriodType periodType)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -177,7 +170,6 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static TimeSeriesCollection GetRevenue(String symbol,IncomeStatement.PeriodType period)
@@ -221,13 +213,11 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
// Profit Margin is calculated as a percentage.
public static TimeSeriesCollection GetProfitMargin(String symbol,IncomeStatement.PeriodType period=IncomeStatement.PeriodType.Annual)
{
Profiler profiler = new Profiler();
TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
@@ -271,13 +261,11 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
// Profit Margin is calculated as a percentage.
public static TimeSeriesCollection GetProfitMarginMaxAsOf(String symbol,DateTime maxDate, IncomeStatement.PeriodType period = IncomeStatement.PeriodType.Annual)
{
Profiler profiler = new Profiler();
TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
@@ -322,12 +310,10 @@ namespace MarketData.DataAccess
if (null != sqlCommand) sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static IncomeStatement GetIncomeStatement(String symbol,DateTime asof,IncomeStatement.PeriodType periodType)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -374,12 +360,10 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static IncomeStatement GetIncomeStatementMaxAsOf(String symbol,DateTime asof,IncomeStatement.PeriodType periodType)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlDataReader sqlDataReader = null;
MySqlCommand sqlCommand=null;
@@ -427,12 +411,10 @@ namespace MarketData.DataAccess
if(null!=sqlCommand)sqlCommand.Dispose();
if (null != sqlDataReader) {sqlDataReader.Close();sqlDataReader.Dispose();}
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
public static bool InsertIncomeStatements(List<IncomeStatement> incomeStatements)
{
Profiler profiler = new Profiler();
MySqlConnection sqlConnection = null;
MySqlTransaction sqlTransaction = null;
String strQuery = null;
@@ -495,7 +477,6 @@ namespace MarketData.DataAccess
{
if (null != sqlTransaction) sqlTransaction.Dispose();
if (null != sqlConnection) sqlConnection.Close();
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()}(ms)");
}
}
private static bool DeleteIncomeStatements(List<IncomeStatement> incomeStatements, MySqlConnection sqlConnection, MySqlTransaction sqlTransaction)