WebServer controller changes along with JSON settings

This commit is contained in:
2025-04-07 15:41:19 -04:00
parent f39d50af89
commit a7627e3f22
8 changed files with 40 additions and 96 deletions

82
.gitignore vendored
View File

@@ -17,82 +17,6 @@ eNavigator/eNavigatorUI/bin/**
eNavigator/eNavigatorUI/obj/**
eNavigator/MarketDataLib/bin/**
eNavigator/MarketDataLib/obj/**
MarketDataServer/bin/Debug/net8.0/appsettings.json
MarketDataServer/bin/Debug/net8.0/Axiom.Core.dll
MarketDataServer/bin/Debug/net8.0/Axiom.Core.pdb
MarketDataServer/bin/Debug/net8.0/BouncyCastle.Cryptography.dll
MarketDataServer/bin/Debug/net8.0/Google.Protobuf.dll
MarketDataServer/bin/Debug/net8.0/HtmlAgilityPack.dll
MarketDataServer/bin/Debug/net8.0/K4os.Compression.LZ4.dll
MarketDataServer/bin/Debug/net8.0/K4os.Compression.LZ4.Streams.dll
MarketDataServer/bin/Debug/net8.0/K4os.Hash.xxHash.dll
MarketDataServer/bin/Debug/net8.0/log4net.dll
MarketDataServer/bin/Debug/net8.0/log4net.xml
MarketDataServer/bin/Debug/net8.0/MarketDataLib.dll
MarketDataServer/bin/Debug/net8.0/MarketDataLib.pdb
MarketDataServer/bin/Debug/net8.0/Microsoft.Extensions.Configuration.Abstractions.dll
MarketDataServer/bin/Debug/net8.0/Microsoft.Extensions.Configuration.dll
MarketDataServer/bin/Debug/net8.0/Microsoft.Extensions.Configuration.FileExtensions.dll
MarketDataServer/bin/Debug/net8.0/Microsoft.Extensions.Configuration.Json.dll
MarketDataServer/bin/Debug/net8.0/Microsoft.Extensions.FileProviders.Abstractions.dll
MarketDataServer/bin/Debug/net8.0/Microsoft.Extensions.FileProviders.Physical.dll
MarketDataServer/bin/Debug/net8.0/Microsoft.Extensions.FileSystemGlobbing.dll
MarketDataServer/bin/Debug/net8.0/Microsoft.Extensions.Primitives.dll
MarketDataServer/bin/Debug/net8.0/Microsoft.OpenApi.dll
MarketDataServer/bin/Debug/net8.0/Microsoft.Win32.SystemEvents.dll
MarketDataServer/bin/Debug/net8.0/mks
MarketDataServer/bin/Debug/net8.0/mks.deps.json
MarketDataServer/bin/Debug/net8.0/mks.dll
MarketDataServer/bin/Debug/net8.0/mks.pdb
MarketDataServer/bin/Debug/net8.0/mks.runtimeconfig.json
MarketDataServer/bin/Debug/net8.0/MySql.Data.dll
MarketDataServer/bin/Debug/net8.0/Newtonsoft.Json.dll
MarketDataServer/bin/Debug/net8.0/Swashbuckle.AspNetCore.Swagger.dll
MarketDataServer/bin/Debug/net8.0/Swashbuckle.AspNetCore.SwaggerGen.dll
MarketDataServer/bin/Debug/net8.0/Swashbuckle.AspNetCore.SwaggerUI.dll
MarketDataServer/bin/Debug/net8.0/System.Configuration.ConfigurationManager.dll
MarketDataServer/bin/Debug/net8.0/System.Drawing.Common.dll
MarketDataServer/bin/Debug/net8.0/System.IO.Pipelines.dll
MarketDataServer/bin/Debug/net8.0/System.Private.Windows.Core.dll
MarketDataServer/bin/Debug/net8.0/System.Security.Cryptography.ProtectedData.dll
MarketDataServer/bin/Debug/net8.0/System.Security.Permissions.dll
MarketDataServer/bin/Debug/net8.0/System.Text.Encodings.Web.dll
MarketDataServer/bin/Debug/net8.0/System.Text.Json.dll
MarketDataServer/bin/Debug/net8.0/System.Windows.Extensions.dll
MarketDataServer/bin/Debug/net8.0/ZstdSharp.dll
MarketDataServer/bin/Debug/net8.0/logs/marketdata_marketdataserver.log
MarketDataServer/bin/Debug/net8.0/runtimes/browser/lib/net8.0/System.Text.Encodings.Web.dll
MarketDataServer/bin/Debug/net8.0/runtimes/win/lib/net8.0/Microsoft.Win32.SystemEvents.dll
MarketDataServer/bin/Debug/net8.0/runtimes/win/lib/net8.0/System.Windows.Extensions.dll
MarketDataServer/bin/Debug/net8.0/runtimes/win-x64/native/comerr64.dll
MarketDataServer/bin/Debug/net8.0/runtimes/win-x64/native/gssapi64.dll
MarketDataServer/bin/Debug/net8.0/runtimes/win-x64/native/k5sprt64.dll
MarketDataServer/bin/Debug/net8.0/runtimes/win-x64/native/krb5_64.dll
MarketDataServer/bin/Debug/net8.0/runtimes/win-x64/native/krbcc64.dll
MarketDataServer/obj/MarketDataServer.csproj.nuget.dgspec.json
MarketDataServer/obj/MarketDataServer.csproj.nuget.g.props
MarketDataServer/obj/MarketDataServer.csproj.nuget.g.targets
MarketDataServer/obj/project.assets.json
MarketDataServer/obj/project.nuget.cache
MarketDataServer/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs
MarketDataServer/obj/Debug/net8.0/apphost
MarketDataServer/obj/Debug/net8.0/MarketDa.2D592492.Up2Date
MarketDataServer/obj/Debug/net8.0/MarketDataServer.AssemblyInfo.cs
MarketDataServer/obj/Debug/net8.0/MarketDataServer.AssemblyInfoInputs.cache
MarketDataServer/obj/Debug/net8.0/MarketDataServer.assets.cache
MarketDataServer/obj/Debug/net8.0/MarketDataServer.csproj.AssemblyReference.cache
MarketDataServer/obj/Debug/net8.0/MarketDataServer.csproj.CoreCompileInputs.cache
MarketDataServer/obj/Debug/net8.0/MarketDataServer.csproj.FileListAbsolute.txt
MarketDataServer/obj/Debug/net8.0/MarketDataServer.GeneratedMSBuildEditorConfig.editorconfig
MarketDataServer/obj/Debug/net8.0/MarketDataServer.genruntimeconfig.cache
MarketDataServer/obj/Debug/net8.0/MarketDataServer.GlobalUsings.g.cs
MarketDataServer/obj/Debug/net8.0/mks.dll
MarketDataServer/obj/Debug/net8.0/mks.MvcApplicationPartsAssemblyInfo.cache
MarketDataServer/obj/Debug/net8.0/mks.MvcApplicationPartsAssemblyInfo.cs
MarketDataServer/obj/Debug/net8.0/mks.pdb
MarketDataServer/obj/Debug/net8.0/staticwebassets.build.json
MarketDataServer/obj/Debug/net8.0/ref/mks.dll
MarketDataServer/obj/Debug/net8.0/refint/mks.dll
MarketDataServer/obj/Debug/net8.0/staticwebassets/msbuild.build.mks.props
MarketDataServer/obj/Debug/net8.0/staticwebassets/msbuild.buildMultiTargeting.mks.props
MarketDataServer/obj/Debug/net8.0/staticwebassets/msbuild.buildTransitive.mks.props
MarketDataServer/bin/**
MarketDataServer/obj/**
MarketDataServer/logs/**

12
.vscode/launch.json vendored
View File

@@ -5,7 +5,7 @@
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"name": ".NET Core Launch (mk)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
@@ -16,9 +16,15 @@
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"name": ".NET Core Launch (mks)",
"type": "coreclr",
"request": "attach"
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/MarketDataServer/bin/Debug/net8.0/mks.dll",
"args": [],
"cwd": "${workspaceFolder}/MarketDataServer",
"console": "internalConsole",
"stopAtEntry": false
}
]
}

View File

@@ -69,7 +69,7 @@ namespace MarketData.Cache
DateTime maxDate=symbolPrices.MaxDate; // get the latest date in the cache
if(maxDbDates.ContainsKey(symbol) && !maxDbDates[symbol].Date.Equals(maxDate.Date)) // if the cache date and the database date are not equal then reload the cache
{
MDTrace.WriteLine(LogLevel.DEBUG,$"[LocalPriceCache] Cache date and Database date for {symbol} are not equal, reloading cache. Cache Date:{maxDate.ToShortDateString()} Database Date:{maxDbDates[symbol].Date.ToShortDateString()}");
// MDTrace.WriteLine(LogLevel.DEBUG,$"[LocalPriceCache] Cache date and Database date for {symbol} are not equal, reloading cache. Cache Date:{maxDate.ToShortDateString()} Database Date:{maxDbDates[symbol].Date.ToShortDateString()}");
Prices prices=PricingDA.GetPrices(symbol,symbolPrices.MinDate); // reload the prices for this symbol using the current minDate in the cache as a lower boundary
if(null==prices)continue; // if we can't load any prices for symbol then just continue
priceCache.Remove(symbol); // remove the pricing entries in the price cache for the symbol
@@ -77,7 +77,7 @@ namespace MarketData.Cache
}
else
{
MDTrace.WriteLine(LogLevel.DEBUG,$"[LocalPriceCache] Fetching latest price from database for {symbol} on {maxDate.ToShortDateString()}");
// MDTrace.WriteLine(LogLevel.DEBUG,$"[LocalPriceCache] Fetching latest price from database for {symbol} on {maxDate.ToShortDateString()}");
Price price=PricingDA.GetPrice(symbol,maxDate); // the max date from the cache equals the max date from the database so just reload the latest price from the database
if(null==price)continue; // if no latest price then just continue
symbolPrices.Remove(maxDate); // remove the current price associated with the max date

View File

@@ -146,6 +146,7 @@ namespace MarketData.DataAccess
try
{
if(null == symbols || 0==symbols.Count)return hasStopLimit;
StringBuilder sb=new StringBuilder();
if(null==symbols) return null;
sqlConnection=SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("portfolio_data"));

View File

@@ -296,6 +296,7 @@ namespace MarketData.DataAccess
try
{
if(null ==symbols || 0==symbols.Count)return latestDates;
StringBuilder sb = new StringBuilder();
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("market_data"));
sb.Append(" select symbol, max(date) as date ");

View File

@@ -18,8 +18,8 @@ namespace MarketDataServer.Controllers
{
private ActiveGainLossGenerator gainLossGenerator=new ActiveGainLossGenerator();
[HttpGet(Name = "GetGainLoss")]
public IEnumerable<GainLossSummaryItem> GetGainLoss(String token, DateTime selectedDate)
[HttpGet]
public IEnumerable<GainLossSummaryItem> GetGainLossByDate(String token,DateTime selectedDate)
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][GainLossController::GetGainLoss](String token, DateTime selectedDate)", DateTime.Now));
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
@@ -53,8 +53,8 @@ namespace MarketDataServer.Controllers
return gainLossSummaryItems;
}
[HttpGet(Name = "GetGainLoss")]
public IEnumerable<GainLossSummaryItem> GetGainLoss(String token, DateTime selectedDate,String account)
[HttpGet]
public IEnumerable<GainLossSummaryItem> GetGainLossByDateAndAccount(String token,DateTime selectedDate,String account)
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][GainLossController::GetGainLoss](String token, DateTime selectedDate,String account)", DateTime.Now));
LocalPriceCache.GetInstance().Refresh();
@@ -89,8 +89,8 @@ namespace MarketDataServer.Controllers
return gainLossSummaryItems;
}
[HttpGet(Name = "GetGainLossWithDetail")]
public IEnumerable<GainLossSummaryItemDetail> GetGainLossWithDetail(String token, DateTime selectedDate)
[HttpGet]
public IEnumerable<GainLossSummaryItemDetail> GetGainLossWithDetailByDate(String token,DateTime selectedDate)
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][GainLossController::GetGainLossWithDetail](String token, DateTime selectedDate)", DateTime.Now));
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
@@ -175,8 +175,8 @@ namespace MarketDataServer.Controllers
return gainLossSummaryItemDetailCollection;
}
[HttpGet(Name = "GetGainLossWithDetail")]
public IEnumerable<GainLossSummaryItemDetail> GetGainLossWithDetail(String token, DateTime selectedDate, String account)
[HttpGet]
public IEnumerable<GainLossSummaryItemDetail> GetGainLossWithDetailByDateAndAccount(String token, DateTime selectedDate, String account)
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][GainLossController::GetGainLossWithDetail](String token, DateTime selectedDate,String account)", DateTime.Now));
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;

View File

@@ -1,7 +1,10 @@
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Serialization;
using MarketData;
using MarketData.Configuration;
using MarketData.Utils;
using Microsoft.AspNetCore.Mvc;
using MarketDataServer.Authorization;
namespace MarketDataServer
@@ -21,7 +24,16 @@ namespace MarketDataServer
MDTrace.WriteLine(MarketData.LogLevel.DEBUG,$"Server Address:{baseAddress}");
builder.Services.AddControllers();
builder.Services.AddControllers().AddJsonOptions(options =>
{
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.WriteAsString;
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase));
});
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen( config =>
{

View File

@@ -2,7 +2,7 @@
"market_data" : "Database=market_data;Datasource=euporie;Username=guest;Password=guest",
"portfolio_data" : "Database=portfolio_data;Datasource=euporie;Username=guest;Password=guest",
"user_data" : "Database=user_data;Datasource=euporie;Username=guest;Password=guest",
"server_address" : "http://localhost:8000/",
"server_address" : "http://0.0.0.0:8000/",
"sms_smtpaddress" : "smtp.gmail.com",
"sms_smsusername" : "skessler1964@gmail.com",
"sms_smspassword" : "xjfo isnf gmyi zovr",