Add Exception handling, set min pool size to zero
This commit is contained in:
@@ -5,6 +5,7 @@ using MarketData.Generator;
|
||||
using MarketData;
|
||||
using LogLevel = MarketData.LogLevel;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MarketData.Utils;
|
||||
|
||||
namespace MarketDataServer.Controllers
|
||||
{
|
||||
@@ -19,37 +20,69 @@ namespace MarketDataServer.Controllers
|
||||
[HttpGet(Name = "GetPrices")]
|
||||
public IEnumerable<Price> GetPrices(String token, String symbol, int days)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetPrices]", DateTime.Now));
|
||||
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
|
||||
return PricingDA.GetPrices(symbol, days);
|
||||
try
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetPrices]", DateTime.Now));
|
||||
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
|
||||
return PricingDA.GetPrices(symbol, days);
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetBollingerBands")]
|
||||
public BollingerBands GetBollingerBands(String token,String symbol,int dayCount)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetBollingerBands]", DateTime.Now));
|
||||
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
|
||||
Prices prices=PricingDA.GetPrices(symbol,dayCount);
|
||||
BollingerBands bollingerBands=BollingerBandGenerator.GenerateBollingerBands(prices);
|
||||
return bollingerBands;
|
||||
try
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetBollingerBands]", DateTime.Now));
|
||||
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
|
||||
Prices prices=PricingDA.GetPrices(symbol,dayCount);
|
||||
BollingerBands bollingerBands=BollingerBandGenerator.GenerateBollingerBands(prices);
|
||||
return bollingerBands;
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetLatestPricingDate")]
|
||||
public DateTime GetLatestPricingDate(String token)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetLatestPricingDate]", DateTime.Now));
|
||||
if (!Authorizations.GetInstance().IsAuthorized(token)) return DateTime.MinValue;
|
||||
DateTime latestPricingDate=PricingDA.GetLatestDate();
|
||||
return latestPricingDate;
|
||||
try
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetLatestPricingDate]", DateTime.Now));
|
||||
if (!Authorizations.GetInstance().IsAuthorized(token)) return DateTime.MinValue;
|
||||
DateTime latestPricingDate=PricingDA.GetLatestDate();
|
||||
return latestPricingDate;
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
|
||||
return Utility.Epoch;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetCompanyNameForSymbol")]
|
||||
public String GetCompanyNameForSymbol(String token, String symbol)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PortfolioController::GetCompanyNameForSymbol]", DateTime.Now));
|
||||
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
|
||||
String companyName=PricingDA.GetNameForSymbol(symbol);
|
||||
return companyName;
|
||||
try
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PortfolioController::GetCompanyNameForSymbol]", DateTime.Now));
|
||||
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
|
||||
String companyName=PricingDA.GetNameForSymbol(symbol);
|
||||
return companyName;
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user