Code enhancements
This commit is contained in:
@@ -5,9 +5,16 @@ namespace MarketData
|
||||
{
|
||||
public class CommandArgs : Dictionary<String,NVP>
|
||||
{
|
||||
private String[] arguments = default;
|
||||
|
||||
public String[] GetArguments()
|
||||
{
|
||||
return arguments;
|
||||
}
|
||||
// While the commands are converted to uppercase care must be taken to preserve the case of the arguments.
|
||||
public CommandArgs(String[] args)
|
||||
{
|
||||
arguments = args;
|
||||
for(int index=1;index<args.Length;index++)
|
||||
{
|
||||
String command=args[index];
|
||||
|
||||
@@ -20,7 +20,8 @@ namespace MarketData
|
||||
/// This is essentially the starting point where we bootstrap the legacy entry point
|
||||
/// </summary>
|
||||
public void Execute()
|
||||
{ _mainService.RunService(_arguments.GetArguments(), _configuration);
|
||||
{
|
||||
_mainService.RunService(_arguments.GetArguments(), _configuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace MarketData.Services
|
||||
{
|
||||
public class MainService : IMainService
|
||||
{
|
||||
private Dictionary<String, Func<CommandArgs,Task>> tasks = new Dictionary<String,Func<CommandArgs,Task>>();
|
||||
|
||||
/// <summary>
|
||||
/// This is the main entry point
|
||||
/// </summary>
|
||||
@@ -21,84 +23,49 @@ namespace MarketData.Services
|
||||
public void RunService(String[] args,IConfiguration configuration)
|
||||
{
|
||||
Profiler profiler = new Profiler();
|
||||
MDTrace.LogLevel = LogLevel.DEBUG;
|
||||
String strLogFile = "marketdata.log";
|
||||
Utility.DeleteFile(strLogFile);
|
||||
Trace.Listeners.Add(new TextWriterTraceListener(strLogFile));
|
||||
DateTime currentDate=DateTime.Now;
|
||||
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"[RunService] Started @ {Utility.DateTimeToStringYYYYHMMHDDHHMMSSTT(currentDate)}");
|
||||
Trace.Listeners.Remove("Default");
|
||||
|
||||
tasks.Add("LOADHEADLINESWATCHLIST",TaskLoadHeadlinesWatchList);
|
||||
tasks.Add("LOADPREMARKETDATA",TaskLoadPremarketData);
|
||||
tasks.Add("UPDATEDAILY2",TaskUpdateDaily2);
|
||||
tasks.Add("UPDATELATESTPRICEOPENPOSITIONS",TaskUpdateLatestPriceOpenPositions);
|
||||
tasks.Add("UPDATELATESTPRICEWATCHLIST",TaskUpdateLatestPriceWatchList);
|
||||
tasks.Add("UPDATELATESTANALYSTRATINGS",TaskUpdateLatestAnalystRatings);
|
||||
tasks.Add("UPDATEANALYSTRATINGS",TaskUpdateAnalystRatings);
|
||||
tasks.Add("ECHO",TaskEcho);
|
||||
|
||||
GlobalConfig.Instance.Configuration = configuration; // This call sets up configuration stuff so it needs to be first.
|
||||
if (args.Length < 1 || String.IsNullOrEmpty(args[0]))
|
||||
{
|
||||
DisplayUsage();
|
||||
return;
|
||||
}
|
||||
|
||||
string arg = args[0].ToUpper();
|
||||
|
||||
CreateLogging(arg); // log files are now of the form market_data+task.log. Also log files will expire daily
|
||||
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"[RunService] Started @ {Utility.DateTimeToStringYYYYHMMHDDHHMMSSTT(currentDate)}");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"[RunService] Argument {arg}");
|
||||
|
||||
DateTime maxHolidayDate =HolidayDA.GetMaxHolidayDate();
|
||||
if(currentDate>maxHolidayDate)
|
||||
{
|
||||
Console.WriteLine(String.Format("There are no holidays defined in the system. Add holidays for year {0} into marketholidays table",currentDate.Year));
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("There are no holidays defined in the system. Add holidays for year {0} into marketholidays table",currentDate.Year));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length < 1)
|
||||
if(!tasks.ContainsKey(arg))
|
||||
{
|
||||
DisplayUsage();
|
||||
DisplayUsage();
|
||||
return;
|
||||
}
|
||||
|
||||
string arg = args[0].ToUpper();
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"[RunService] Argument {arg}");
|
||||
|
||||
try
|
||||
{
|
||||
if(arg.Equals("LOADHEADLINESWATCHLIST"))
|
||||
{
|
||||
CommandArgs commandArgs=new CommandArgs(args);
|
||||
if(!commandArgs.Has("WATCHLIST")){Console.WriteLine("LOADHEADLINESWATCHLIST REQUIRES WATCHLIST");return;}
|
||||
else LoadHeadlinesWatchList(commandArgs.Coalesce<String>("WATCHLIST"));
|
||||
}
|
||||
else if(arg.Equals("LOADPREMARKETDATA"))
|
||||
{
|
||||
LoadPremarketData();
|
||||
}
|
||||
else if (arg.Equals("UPDATEDAILY2"))
|
||||
{
|
||||
CommandArgs commandArgs=new CommandArgs(args);
|
||||
if(!commandArgs.Has("DATE")){Console.WriteLine("UPDATEDAILY2 MISSING DATE");return;}
|
||||
UpdateDaily2(commandArgs.Coalesce<DateTime>("DATE"));
|
||||
}
|
||||
else if (arg.Equals("UPDATELATESTPRICEOPENPOSITIONS"))
|
||||
{
|
||||
UpdateLatestPriceOpenPositions();
|
||||
}
|
||||
else if (arg.Equals("UPDATELATESTPRICEWATCHLIST"))
|
||||
{
|
||||
CommandArgs commandArgs=new CommandArgs(args);
|
||||
if(!commandArgs.Has("WATCHLIST")){Console.WriteLine("UPDATELATESTPRICEWATCHLIST MISSING WATCHLIST");return;}
|
||||
UpdateLatestPriceWatchList(commandArgs.Coalesce<String>("WATCHLIST"));
|
||||
}
|
||||
else if (arg.Equals("UPDATELATESTANALYSTRATINGS"))
|
||||
{
|
||||
CommandArgs commandArgs = new CommandArgs(args);
|
||||
if (commandArgs.Has("UPDATESECURITYMASTER")) UpdateLatestAnalystRatings(commandArgs.Coalesce<Boolean>("UPDATESECURITYMASTER"));
|
||||
else UpdateLatestAnalystRatings();
|
||||
}
|
||||
else if (arg.Equals("UPDATEANALYSTRATINGS"))
|
||||
{
|
||||
CommandArgs commandArgs = new CommandArgs(args);
|
||||
if (commandArgs.Has("SYMBOL") && commandArgs.Has("MINDATE")) UpdateAnalystRatings(commandArgs.Coalesce<String>("SYMBOL"), commandArgs.Coalesce<DateTime>("MINDATE"));
|
||||
else if (commandArgs.Has("SYMBOL") ) UpdateAnalystRatings(commandArgs.Coalesce<String>("SYMBOL"));
|
||||
else if (commandArgs.Has("MINDATE")) UpdateAnalystRatings(null,commandArgs.Coalesce<DateTime>("MINDATE"));
|
||||
else UpdateAnalystRatings();
|
||||
}
|
||||
else if(arg.Equals("ECHO"))
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"ECHO");
|
||||
for(int index =0; index<args.Length;index++)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"ARG[{index}]:{args[index]}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayUsage();
|
||||
}
|
||||
tasks[arg](new CommandArgs(args));
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@@ -110,9 +77,85 @@ namespace MarketData.Services
|
||||
LocalPriceCache.GetInstance().Dispose();
|
||||
GBPriceCache.GetInstance().Dispose();
|
||||
}
|
||||
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"[RunService] Done, total took {profiler.End()}(ms)");
|
||||
}
|
||||
|
||||
public async Task TaskLoadHeadlinesWatchList(CommandArgs commandArgs)
|
||||
{
|
||||
if(!commandArgs.Has("WATCHLIST")){Console.WriteLine("LOADHEADLINESWATCHLIST REQUIRES WATCHLIST");return;}
|
||||
else LoadHeadlinesWatchList(commandArgs.Coalesce<String>("WATCHLIST"));
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task TaskLoadPremarketData(CommandArgs commandArgs)
|
||||
{
|
||||
LoadPremarketData();
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task TaskUpdateDaily2(CommandArgs commandArgs)
|
||||
{
|
||||
if(!commandArgs.Has("DATE")){Console.WriteLine("UPDATEDAILY2 MISSING DATE");return;}
|
||||
UpdateDaily2(commandArgs.Coalesce<DateTime>("DATE"));
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task TaskUpdateLatestPriceOpenPositions(CommandArgs commandArgs)
|
||||
{
|
||||
UpdateLatestPriceOpenPositions();
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task TaskUpdateLatestPriceWatchList(CommandArgs commandArgs)
|
||||
{
|
||||
if(!commandArgs.Has("WATCHLIST")){Console.WriteLine("UPDATELATESTPRICEWATCHLIST MISSING WATCHLIST");return;}
|
||||
UpdateLatestPriceWatchList(commandArgs.Coalesce<String>("WATCHLIST"));
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task TaskUpdateLatestAnalystRatings(CommandArgs commandArgs)
|
||||
{
|
||||
if (commandArgs.Has("UPDATESECURITYMASTER")) UpdateLatestAnalystRatings(commandArgs.Coalesce<Boolean>("UPDATESECURITYMASTER"));
|
||||
else UpdateLatestAnalystRatings();
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task TaskUpdateAnalystRatings(CommandArgs commandArgs)
|
||||
{
|
||||
if (commandArgs.Has("SYMBOL") && commandArgs.Has("MINDATE")) UpdateAnalystRatings(commandArgs.Coalesce<String>("SYMBOL"), commandArgs.Coalesce<DateTime>("MINDATE"));
|
||||
else if (commandArgs.Has("SYMBOL") ) UpdateAnalystRatings(commandArgs.Coalesce<String>("SYMBOL"));
|
||||
else if (commandArgs.Has("MINDATE")) UpdateAnalystRatings(null,commandArgs.Coalesce<DateTime>("MINDATE"));
|
||||
else UpdateAnalystRatings();
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task TaskEcho(CommandArgs commandArgs)
|
||||
{
|
||||
String[] args = commandArgs.GetArguments();
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"ECHO");
|
||||
for(int index =0; index<args.Count();index++)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"ARG[{index}]:{args[index]}");
|
||||
}
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private static void CreateLogging(String task)
|
||||
{
|
||||
if(null == task) return;
|
||||
task=task.ToLower();
|
||||
MDTrace.LogLevel = LogLevel.DEBUG;
|
||||
String logFolder = "/logs";
|
||||
DateTime currentDate=DateTime.Now;
|
||||
String strLogFile = "marketdata_" + task + ".log";
|
||||
String currentWorkingDirectory = Directory.GetCurrentDirectory();
|
||||
Console.WriteLine($"Current directory is {currentWorkingDirectory}");
|
||||
Utility.EnsureLogFolder(currentWorkingDirectory+logFolder);
|
||||
Utility.ExpireLogs(currentWorkingDirectory+logFolder,1);
|
||||
Trace.Listeners.Add(new TextWriterTraceListener(currentWorkingDirectory+logFolder+"/"+strLogFile));
|
||||
}
|
||||
|
||||
// *********************************************************************************************************************************
|
||||
// *********************************************************************************************************************************
|
||||
// *********************************************************************************************************************************
|
||||
@@ -124,9 +167,9 @@ namespace MarketData.Services
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"LOADPREMARKETDATA");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEDAILY2 /DATE: - updates prices, yields, and ratings");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATEANALYSTRATINGS");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATELATESTANALYSTRATINGS");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATELATESTPRICEWATCHLIST /WATCHLIST:");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATELATESTPRICEOPENPOSITIONS");
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,"UPDATELATESTPRICEOPENPOSITIONS");
|
||||
}
|
||||
|
||||
// **********************************************************************************************************************************************
|
||||
@@ -166,7 +209,6 @@ namespace MarketData.Services
|
||||
if(null==result||!(result.ToUpper().Equals("Y")||result.ToUpper().Equals("YES")))return;
|
||||
}
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,$"UPDATEDAILY2 DATE:{startDate.ToShortDateString()}");
|
||||
Utility.RemoveLogFilesExcept("marketdata.log"); // don't remove the current log file
|
||||
int STAGE_1=0,STAGE_2=1,STAGE_3=2,STAGE_4=3,STAGE_5=4,STAGE_6=5,STAGE_7=6,STAGE_8=7,STAGE_9=8,STAGE_10=9,STAGE_11=10,STAGE_12=11,STAGE_FINAL=12;
|
||||
DeletePriceWatchList("valuations",startDate.ToShortDateString());
|
||||
DeletePriceWatchList("Momentum",startDate.ToShortDateString());
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"sms_smtpaddress" : "smtp.gmail.com",
|
||||
"sms_smsusername" : "skessler1964@gmail.com",
|
||||
"sms_smspassword" : "xjfo isnf gmyi zovr",
|
||||
"sms_smsrecipients" : "skessler1964sms@gmail.com",
|
||||
"sms_smsrecipients" : "skessler1964@gmail.com",
|
||||
"proxy_address" : "http://localhost:8182",
|
||||
"proxy_GetLatestPriceYahoo" : "false",
|
||||
"proxy_GetLatestPriceFidelity" : "true",
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
[LOCAL][Thread=1][TRACE.DEBUG][3/26/2025 12:43:18 PM] [MarketData.Services.MainService::RunService(args,configuration)][RunService] Started @ 2025-03-26 12:43:18 PM
|
||||
[LOCAL][Thread=1][TRACE.DEBUG][3/26/2025 12:43:19 PM] [MarketData.Services.MainService::RunService(args,configuration)][RunService] Argument ECHO
|
||||
[LOCAL][Thread=1][TRACE.DEBUG][3/26/2025 12:43:19 PM] [MarketData.Services.MainService::RunService(args,configuration)]ECHO
|
||||
[LOCAL][Thread=1][TRACE.DEBUG][3/26/2025 12:43:19 PM] [MarketData.Services.MainService::RunService(args,configuration)]ARG[0]:ECHO
|
||||
[LOCAL][Thread=1][TRACE.DEBUG][3/26/2025 12:43:19 PM] [MarketData.Services.MainService::RunService(args,configuration)]ARG[1]:/DATE:03-25-2025
|
||||
[LOCAL][Thread=1][TRACE.DEBUG][3/26/2025 12:43:19 PM] [MarketData.Cache.LocalPriceCache::Dispose()][LocalPriceCache:Dispose]Thread state is 'Running'. Joining main thread...
|
||||
[LOCAL][Thread=11][TRACE.DEBUG][3/26/2025 12:43:19 PM] [MarketData.Cache.LocalPriceCache::ThreadProc()][LocalPriceCache:ThreadProc]Thread ended. Items in cache:0
|
||||
[LOCAL][Thread=1][TRACE.DEBUG][3/26/2025 12:43:19 PM] [MarketData.Cache.LocalPriceCache::Dispose()][LocalPriceCache:Dispose] End
|
||||
[LOCAL][Thread=1][TRACE.DEBUG][3/26/2025 12:43:19 PM] [MarketData.Cache.GBPriceCache::Dispose()][GBPriceCache:Dispose]Thread state is 'WaitSleepJoin'. Joining main thread...
|
||||
[LOCAL][Thread=12][TRACE.DEBUG][3/26/2025 12:43:20 PM] [MarketData.Cache.GBPriceCache::ThreadProc()][GBPriceCache:ThreadProc]Thread ended.
|
||||
[LOCAL][Thread=1][TRACE.DEBUG][3/26/2025 12:43:20 PM] [MarketData.Cache.GBPriceCache::Dispose()][GBPriceCache:Dispose] End.
|
||||
[LOCAL][Thread=1][TRACE.DEBUG][3/26/2025 12:43:20 PM] [MarketData.Services.MainService::RunService(args,configuration)][RunService] Done, total took 1961(ms)
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
//using System.Runtime.Remoting.Messaging;
|
||||
|
||||
// Filename: MarketDataTrace.cs
|
||||
// Author:Sean Kessler
|
||||
@@ -40,19 +37,16 @@ namespace MarketData
|
||||
/// <summary>WriteLine - Writes a line of text to trace log.</summary>
|
||||
/// <param name="message">string content of message to write.</param>
|
||||
/// <returns>void</returns>
|
||||
// [Conditional("TRACE")]
|
||||
public static void Write(LogLevel logLevel,string message)
|
||||
{
|
||||
if(MDTrace.logLevel<logLevel)return;
|
||||
Trace.Write(GetCallerIP()+GetThreadRep()+GetLogLevelRep()+"["+DateTime.Now.ToString()+"]"+GetMethodInfo()+message);
|
||||
Console.Write(message);
|
||||
Flush();
|
||||
}
|
||||
|
||||
/// <summary>WriteLine - Writes a line of text to trace log.</summary>
|
||||
/// <param name="message">string content of message to write.</param>
|
||||
/// <returns>void</returns>
|
||||
// [Conditional("TRACE")]
|
||||
public static void WriteLine(string message)
|
||||
{
|
||||
WriteLine(LogLevel.DEBUG,GetCallerIP()+GetThreadRep()+GetLogLevelRep()+"["+DateTime.Now.ToString()+"]"+" "+GetMethodInfo()+message);
|
||||
@@ -61,7 +55,6 @@ namespace MarketData
|
||||
/// <summary>WriteLine - Writes a line of text to trace log.</summary>
|
||||
/// <param name="message">string content of message to write.</param>
|
||||
/// <returns>void</returns>
|
||||
// [Conditional("TRACE")]
|
||||
public static void WriteLine(LogLevel logLevel,Exception exception)
|
||||
{
|
||||
if(MDTrace.logLevel<logLevel)return;
|
||||
@@ -72,7 +65,6 @@ namespace MarketData
|
||||
/// <summary>WriteLine - Writes a line of text to trace log.</summary>
|
||||
/// <param name="message">string content of message to write.</param>
|
||||
/// <returns>void</returns>
|
||||
// [Conditional("TRACE")]
|
||||
public static void WriteLine(LogLevel logLevel,string message)
|
||||
{
|
||||
if(MDTrace.logLevel<logLevel)return;
|
||||
@@ -82,21 +74,18 @@ namespace MarketData
|
||||
}
|
||||
/// <summary>Indent - set trace log indentation.</summary>
|
||||
/// <returns>void</returns>
|
||||
// [Conditional("TRACE")]
|
||||
public static void Indent()
|
||||
{
|
||||
Trace.Indent();
|
||||
}
|
||||
/// <summary>Unindent - set trace log indentation back.</summary>
|
||||
/// <returns>void</returns>
|
||||
// [Conditional("TRACE")]
|
||||
public static void Unindent()
|
||||
{
|
||||
Trace.Unindent();
|
||||
}
|
||||
/// <summary>Flush - Flush trace log buffers to disk.</summary>
|
||||
/// <returns>void</returns>
|
||||
// [Conditional("TRACE")]
|
||||
public static void Flush()
|
||||
{
|
||||
Trace.Flush();
|
||||
@@ -149,11 +138,6 @@ namespace MarketData
|
||||
private static String GetCallerIP()
|
||||
{
|
||||
return "[LOCAL]";
|
||||
// String hostName=(String)CallContext.GetData("HostName");
|
||||
// String hostAddress=(String)CallContext.GetData("HostAddress");
|
||||
// if(null!=hostName)hostName=hostName.Split('.')[0];
|
||||
// if(null==hostName && null==hostAddress)return "[LOCAL]";
|
||||
// return "["+hostAddress+"->"+hostName+"]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
using System.IO.Compression;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Win32;
|
||||
using System.Diagnostics;
|
||||
using MarketData.MarketDataModel;
|
||||
using System.Security.Principal;
|
||||
using System.Threading;
|
||||
using ThreadState=System.Threading.ThreadState;
|
||||
using System.Net;
|
||||
|
||||
namespace MarketData.Utils
|
||||
{
|
||||
@@ -78,44 +72,79 @@ namespace MarketData.Utils
|
||||
return date;
|
||||
}
|
||||
|
||||
public static void RemoveLogFiles(String strFolder=null)
|
||||
{
|
||||
if(null==strFolder)strFolder=Directory.GetCurrentDirectory();
|
||||
String[] logFiles=Directory.GetFiles(strFolder);
|
||||
if(null==logFiles || 0==logFiles.Length)return;
|
||||
logFiles=logFiles.Where(x => x.EndsWith(".log",StringComparison.InvariantCultureIgnoreCase)).ToArray<String>();
|
||||
if(null==logFiles || 0==logFiles.Length)return;
|
||||
// This is being called before any trace listeners have been added
|
||||
public static bool EnsureLogFolder(String strLogFolder)
|
||||
{
|
||||
if(Directory.Exists(strLogFolder))return true;
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(strLogFolder);
|
||||
return true;
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ExpireLogs(String pathLogFiles,int expiryDays)
|
||||
{
|
||||
DateTime currentDate = DateTime.Now;
|
||||
DateGenerator dateGenerator = new DateGenerator();
|
||||
String[] logFiles=Directory.GetFiles(pathLogFiles,"*.log");
|
||||
foreach(String logFile in logFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Removing {0}",logFile));
|
||||
File.Delete(logFile);
|
||||
DateTime creationTime = File.GetCreationTime(logFile);
|
||||
int age = dateGenerator.DaysBetweenActual(currentDate, creationTime);
|
||||
if(age>=expiryDays)
|
||||
{
|
||||
File.Delete(logFile);
|
||||
}
|
||||
}
|
||||
catch(Exception){;}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveLogFilesExcept(String exceptFile,String strFolder=null)
|
||||
{
|
||||
if(null==strFolder)strFolder=Directory.GetCurrentDirectory();
|
||||
String[] logFiles=Directory.GetFiles(strFolder,"*.log");
|
||||
if(null==logFiles || 0==logFiles.Length)return;
|
||||
logFiles=logFiles
|
||||
.Where(x => x.EndsWith(".log",StringComparison.InvariantCultureIgnoreCase) &&
|
||||
!x.EndsWith(exceptFile,StringComparison.InvariantCultureIgnoreCase)).ToArray<String>();
|
||||
// public static void RemoveLogFiles(String strFolder=null)
|
||||
// {
|
||||
// if(null==strFolder)strFolder=Directory.GetCurrentDirectory();
|
||||
// String[] logFiles=Directory.GetFiles(strFolder);
|
||||
// if(null==logFiles || 0==logFiles.Length)return;
|
||||
// logFiles=logFiles.Where(x => x.EndsWith(".log",StringComparison.InvariantCultureIgnoreCase)).ToArray<String>();
|
||||
// if(null==logFiles || 0==logFiles.Length)return;
|
||||
// foreach(String logFile in logFiles)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Removing {0}",logFile));
|
||||
// File.Delete(logFile);
|
||||
// }
|
||||
// catch(Exception){;}
|
||||
// }
|
||||
// }
|
||||
|
||||
if(null==logFiles || 0==logFiles.Length)return;
|
||||
foreach(String logFile in logFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Removing {0}",logFile));
|
||||
File.Delete(logFile);
|
||||
}
|
||||
catch(Exception){;}
|
||||
}
|
||||
}
|
||||
// public static void RemoveLogFilesExcept(String exceptFile,String strFolder=null)
|
||||
// {
|
||||
// if(null==strFolder)strFolder=Directory.GetCurrentDirectory();
|
||||
// String[] logFiles=Directory.GetFiles(strFolder,"*.log");
|
||||
// if(null==logFiles || 0==logFiles.Length)return;
|
||||
// logFiles=logFiles
|
||||
// .Where(x => x.EndsWith(".log",StringComparison.InvariantCultureIgnoreCase) &&
|
||||
// !x.EndsWith(exceptFile,StringComparison.InvariantCultureIgnoreCase)).ToArray<String>();
|
||||
|
||||
// if(null==logFiles || 0==logFiles.Length)return;
|
||||
// foreach(String logFile in logFiles)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Removing {0}",logFile));
|
||||
// File.Delete(logFile);
|
||||
// }
|
||||
// catch(Exception){;}
|
||||
// }
|
||||
// }
|
||||
|
||||
public static String Pad(string str, char filler, int length)
|
||||
{
|
||||
|
||||
34
README.md
34
README.md
@@ -2,9 +2,23 @@
|
||||
|
||||
ARM version of marketdata libraries.
|
||||
sudo truncate syslog -- size 0
|
||||
more on syslog and journal
|
||||
https://ubuntuforums.org/showthread.php?t=2495218
|
||||
https://stackoverflow.com/questions/16995425/how-does-cmd-dev-null-21-work
|
||||
|
||||
journalctl --disk-usage # See log file disk use
|
||||
sudo journalctl --vacuum-size=200M # Drop log file size to 200M, if possible.
|
||||
sudo journalctl --vacuum-time=10d # Drop logs, over 10 days old
|
||||
|
||||
DEV NULL
|
||||
ping a.b.c > /dev/null 2>&1
|
||||
|
||||
|
||||
CRON SCHEDULE
|
||||
** THE LATEST AND GREATEST IS ALWAYS AT THE BOTTOM
|
||||
|
||||
Also note that 1>/dev/null is synonymous to, but more explicit than >/dev/null
|
||||
|
||||
# sudo service cron reload , sudo service cron restart
|
||||
# cron helper app here -> https://cron.help/#*/5_9-17_*_*_1-5
|
||||
DOTNET_ROOT=/opt/dotnet
|
||||
@@ -16,3 +30,23 @@ DOTNET_ROOT=/opt/dotnet
|
||||
0 19 * * 1-5 /opt/MarketData/MarketData/mk UPDATEDAILY2 /DATE:$(date -d"-0 days" +\%m-\%d-\%Y) 2>&1 | logger -t updatedaily2
|
||||
|
||||
|
||||
*/15 6-16 * * 1-5 /opt/MarketData/MarketData/mk LOADHEADLINESWATCHLIST /WATCHLIST:Valuations > /dev/null 2>&1
|
||||
*/5 5-16 * * 1-5 /opt/MarketData/MarketData/mk LOADPREMARKETDATA > /dev/null 2>&1
|
||||
*/5 9-16 * * 1-5 /opt/MarketData/MarketData/mk UPDATELATESTPRICEOPENPOSITIONS > /dev/null 2>&1
|
||||
*/5 9-16 * * 1-5 /opt/MarketData/MarketData/mk UPDATELATESTPRICEWATCHLIST /WATCHLIST:Valuations > /dev/null 2>&1
|
||||
*/30 9-16 * * 1-5 /opt/MarketData/MarketData/mk UPDATELATESTANALYSTRATINGS 2>&1 | logger -t analystratings
|
||||
0 19 * * 1-5 /opt/MarketData/MarketData/mk UPDATEDAILY2 /DATE:$(date -d"-0 days" +\%m-\%d-\%Y) > /dev/null 2>&1
|
||||
|
||||
# m h dom mon dow command
|
||||
# sudo service cron reload , sudo service cron restart
|
||||
# cron helper app here -> https://cron.help/#*/5_9-17_*_*_1-5
|
||||
DOTNET_ROOT=/opt/dotnet
|
||||
CRON_DIR=/opt/MarketData/MarketData
|
||||
*/15 6-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk LOADHEADLINESWATCHLIST /WATCHLIST:Valuations > /dev/null 2>&1
|
||||
*/5 5-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk LOADPREMARKETDATA > /dev/null 2>&1
|
||||
*/5 9-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATELATESTPRICEOPENPOSITIONS > /dev/null 2>&1
|
||||
*/5 9-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATELATESTPRICEWATCHLIST /WATCHLIST:Valuations > /dev/null 2>&1
|
||||
*/30 9-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATELATESTANALYSTRATINGS > /dev/null 2>&1
|
||||
0 19 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATEDAILY2 /DATE:$(date -d"-0 days" +\%m-\%d-\%Y) > /dev/null 2>&1
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user