Skip to content

Commit

Permalink
1.1.1 Argument fix
Browse files Browse the repository at this point in the history
Fix openLog argument
Add arguments to log
  • Loading branch information
MonsterPoney committed Mar 13, 2022
1 parent 708e814 commit 1d6abf0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
31 changes: 16 additions & 15 deletions Spot Wallets Report Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ namespace Spot_Wallets_Report_Generator {
internal class Program {
public static Logger log;

public static bool initialInsert = false, error=false;
public static bool initialInsert = false, error = false;
public static readonly ConfigFile ini = new ConfigFile($"{Environment.CurrentDirectory}/config.ini");
private static string reportFolder, reportPrefix, sortBy, reportExtension;
private static float ignoreUnder;
public static string dbPath;
private static bool useDB, useBTCEvol, useUSDTEvol, openLog=false, openReport=false, autoTimeSync;
private static bool useDB, useBTCEvol, useUSDTEvol, openLog = false, openReport = false, autoTimeSync;
private static List<Balance> dailyDatas;

[DllImport("user32.dll")]
Expand All @@ -38,10 +38,10 @@ internal class Program {

private const int SW_HIDE = 0;
static void Main(string[] args) {
try {
try {
log = new Logger("./", "", true);
SetConsoleCtrlHandler(new HandlerRoutine(ConsoleCtrlCheck), true);

// Get arguments
try {
string Arguments = ini.ReadKey("Options", "Arguments").ToLower();
Expand All @@ -56,6 +56,7 @@ static void Main(string[] args) {
}
// Apply arguments
for (int i = 0; i < args.Length; i++) {
WriteLog($"Argument {args[i]}");
if (args[i] == "-nc" || args[i] == "--noconsole") {
var hwnd = GetConsoleWindow();
ShowWindow(hwnd, SW_HIDE);
Expand Down Expand Up @@ -91,7 +92,7 @@ static void Main(string[] args) {
Console.ReadKey();
}
Environment.Exit(1);
}
}
}

// Exception if null for booleans
Expand All @@ -116,7 +117,7 @@ static void Main(string[] args) {
dailyDatas = new List<Balance>();
if (bool.TryParse(ini.ReadKey("API", "UseBinance").ToLower(), out bool useBinance) == true) {
if (useBinance) {

WriteLog("Get Binance spot wallet.");
dailyDatas.AddRange(BinanceCalls.GetWallet());
/*
Expand Down Expand Up @@ -333,12 +334,12 @@ private static void GenerateReport() {
sheet.Cells["A" + (i + 1)].Value = "Total";
sheet.Cells["H" + (i + 1)].Formula = $"SUM(H2:H{i})";
sheet.Cells["I" + (i + 1)].Formula = $"SUM(I2:I{i})";
sheet.Cells["A1:K" + (i+1)].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
sheet.Cells["A1:K" + (i+1)].AutoFitColumns();
sheet.Cells["A1:K" + (i + 1)].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
sheet.Cells["A1:K" + (i + 1)].AutoFitColumns();
sheet.Calculate();
sheet.ClearFormulas();

var table = sheet.Tables.Add(sheet.Cells["A1:K" + (i+1)], $"DayTable_{DateTime.Now:yyyyMMdd}");
var table = sheet.Tables.Add(sheet.Cells["A1:K" + (i + 1)], $"DayTable_{DateTime.Now:yyyyMMdd}");
table.TableStyle = OfficeOpenXml.Table.TableStyles.Light1;

try {
Expand Down Expand Up @@ -369,7 +370,7 @@ private static void GenerateReport() {
sheet.Cells["R" + (x + 1)].Value = float.Parse(previousTotal[x].Value.Split('|')[0]);
}
// Date format
sheet.Cells["Q" + (previousTotal.Count + 1)].Value = DateTime.ParseExact(sheet.Name,"yyyyMMdd",null).ToString("yyyy/MM/dd");
sheet.Cells["Q" + (previousTotal.Count + 1)].Value = DateTime.ParseExact(sheet.Name, "yyyyMMdd", null).ToString("yyyy/MM/dd");
sheet.Cells["Q1:Q" + (previousTotal.Count + 1)].Style.Numberformat.Format = "0";
sheet.Cells["R" + (previousTotal.Count + 1)].Value = sheet.Cells["H" + (i + 1)].Value;
sheet.Cells["R1:R" + (previousTotal.Count + 1)].Style.Numberformat.Format = "#,##0.000000";
Expand Down Expand Up @@ -502,12 +503,12 @@ public enum CtrlTypes {
}

public static bool ConsoleCtrlCheck(CtrlTypes ctrlType) {
if (openLog&&log.HasException) {// && log.HasException || error
if (openLog && (log.HasException || error)) {
try {
Process.Start(new FileInfo(log.LogName).FullName);
}
catch(Exception e) {
WriteLog($"Exception when trying to open log.",e.Message+e.StackTrace);
catch (Exception e) {
WriteLog($"Exception when trying to open log.", e.Message + e.StackTrace);
}
}
if (openReport) {
Expand All @@ -516,9 +517,9 @@ public static bool ConsoleCtrlCheck(CtrlTypes ctrlType) {
}
catch (Exception e) {
WriteLog($"Exception when trying to open report.", e.Message + e.StackTrace);
}
}
}
return true;
}
}
}
}
4 changes: 2 additions & 2 deletions Spot Wallets Report Generator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]

0 comments on commit 1d6abf0

Please sign in to comment.