Initial commit: Predictalytics solution
Clean Architecture .NET 8 solution (Domain/Application/Infrastructure/Api/Worker/WinFormsHost) for analyzing Polymarket traders for copytrading/strategy-replication candidates. Includes EF Core InitialBaseline migration and DB secrets removed from source/config in preparation for version control.
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Predictalytics.WinFormsHost;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
private const string FileName = "settings.json";
|
||||
|
||||
[Category("Webserver")]
|
||||
[DisplayName("Port")]
|
||||
[Description("Der Port, über den die WebUI und API erreichbar sind.")]
|
||||
[DefaultValue(5000)]
|
||||
public int WebserverPort { get; set; } = 5000;
|
||||
|
||||
[Category("Webserver")]
|
||||
[DisplayName("Database Debug")]
|
||||
[Description("Wenn aktiv, werden detaillierte Verbindungsinformationen im Terminal angezeigt.")]
|
||||
[DefaultValue(false)]
|
||||
public bool DbConnectionDebug { get; set; } = false;
|
||||
|
||||
private string _dbServer = "localhost";
|
||||
private string _dbName = "";
|
||||
private string _dbUser = "";
|
||||
private string _dbPassword = "";
|
||||
|
||||
[Category("Database")]
|
||||
[DisplayName("Server")]
|
||||
public string DbServer { get => _dbServer; set => _dbServer = string.IsNullOrWhiteSpace(value) ? _dbServer : value.Trim(); }
|
||||
|
||||
[Category("Database")]
|
||||
[DisplayName("Database")]
|
||||
public string DbName { get => _dbName; set => _dbName = string.IsNullOrWhiteSpace(value) ? _dbName : value.Trim(); }
|
||||
|
||||
[Category("Database")]
|
||||
[DisplayName("User")]
|
||||
public string DbUser { get => _dbUser; set => _dbUser = string.IsNullOrWhiteSpace(value) ? _dbUser : value.Trim(); }
|
||||
|
||||
[Category("Database")]
|
||||
[DisplayName("Password")]
|
||||
[PasswordPropertyText(true)]
|
||||
public string DbPassword { get => _dbPassword; set => _dbPassword = string.IsNullOrWhiteSpace(value) ? _dbPassword : value.Trim(); }
|
||||
|
||||
[Browsable(false)]
|
||||
public string ConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
var builder = new MySqlConnector.MySqlConnectionStringBuilder
|
||||
{
|
||||
Server = DbServer?.Trim(),
|
||||
Database = DbName?.Trim(),
|
||||
UserID = DbUser?.Trim(),
|
||||
Password = DbPassword?.Trim(),
|
||||
AllowPublicKeyRetrieval = true,
|
||||
SslMode = MySqlConnector.MySqlSslMode.None,
|
||||
Pooling = true,
|
||||
MinimumPoolSize = 0,
|
||||
MaximumPoolSize = 100
|
||||
};
|
||||
return builder.ConnectionString;
|
||||
}
|
||||
}
|
||||
|
||||
public static AppSettings Load()
|
||||
{
|
||||
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FileName);
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
var settings = new AppSettings();
|
||||
settings.Save();
|
||||
return settings;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var json = File.ReadAllText(filePath);
|
||||
return JsonSerializer.Deserialize<AppSettings>(json) ?? new AppSettings();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new AppSettings();
|
||||
}
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FileName);
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
var json = JsonSerializer.Serialize(this, options);
|
||||
File.WriteAllText(filePath, json);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user