Phase 6 (Stufe 6): MongoDB vollstaendig entfernt

- Legacy-Form stillgelegt: frm_main(.Designer/.resx) + frm_analytics(.Designer/.resx)
  geloescht, 'Open Legacy'-Menue aus LauncherForm entfernt.
- Program.cs: IMongoDatabase-Registrierung + closed_trades-Cleanup weg;
  Trade-Nummerierung liest jetzt hoechste TradeId aus ICopyTradeLogRepository.
- StartupHydrationService: Mongo-/Bson-Fallback entfernt (Settings kommen aus
  dem Repo; fehlende Accounts erhalten Default-Settings).
- Alle Mongo*Repository (Core 4 + Modul 4) geloescht; DI-Zweige auf EF/MySQL
  reduziert (AddCorePersistence, CopyTradingModule).
- ConfigMigrator: Mongo-Pfad (Run/MigrateSettings) entfernt; nur noch
  RunFromJson + VerifyMySql (kein Mongo-Treiber mehr).
- Modelle: [BsonId] entfernt (EF-Keys via HasKey); ObjectId-Defaults -> Guid.
- LiteDB-Shim (MongoDbLiteDBShim) geloescht; MongoDB.Driver- + LiteDB-Pakete
  aus App/Core entfernt; stale usings + user-sichtbare Strings bereinigt.
- DatabaseOptions/appsettings.json: Mongo-Provider/Connection-Felder entfernt.
- Build gruen; --verify-mysql bestaetigt 3 Accounts/3 Settings/32 Trader/2344 Markets.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Richard
2026-07-05 18:34:17 +02:00
co-authored by Claude Opus 4.8
parent d227d24ca8
commit b951b912f4
38 changed files with 48 additions and 5681 deletions
@@ -1,39 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MongoDB.Driver;
using PolyTraderSharp.Models;
namespace PolyTrader.Modules.CopyTrading.Persistence.Mongo
{
public class MongoMasterTraderHistoryRepository : IMasterTraderHistoryRepository
{
private readonly IMongoCollection<MasterTraderHistoryRecord> _col;
public MongoMasterTraderHistoryRepository(IMongoDatabase db)
{
_col = db.GetCollection<MasterTraderHistoryRecord>("mt_history");
}
public void EnsureIndexes()
{
try
{
_col.Indexes.CreateOne(new CreateIndexModel<MasterTraderHistoryRecord>(
Builders<MasterTraderHistoryRecord>.IndexKeys.Ascending(x => x.TraderId)));
_col.Indexes.CreateOne(new CreateIndexModel<MasterTraderHistoryRecord>(
Builders<MasterTraderHistoryRecord>.IndexKeys.Ascending(x => x.ClosedAt)));
}
catch { }
}
public bool Exists(int traderId, string tokenId, DateTime windowStart, DateTime windowEnd) =>
_col.Find(x => x.TraderId == traderId && x.TokenId == tokenId
&& x.ClosedAt >= windowStart && x.ClosedAt <= windowEnd).Any();
public void Insert(MasterTraderHistoryRecord record) => _col.InsertOne(record);
public List<MasterTraderHistoryRecord> GetByTraderSince(int traderId, DateTime since) =>
_col.Find(x => x.TraderId == traderId && x.ClosedAt >= since).ToList();
}
}
@@ -1,26 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using MongoDB.Driver;
using PolyTraderSharp.Models;
namespace PolyTrader.Modules.CopyTrading.Persistence.Mongo
{
public class MongoTrackedTraderRepository : ITrackedTraderRepository
{
private readonly IMongoCollection<TrackedTrader> _col;
public MongoTrackedTraderRepository(IMongoDatabase db)
{
_col = db.GetCollection<TrackedTrader>("trackers");
}
public List<TrackedTrader> GetAll() => _col.Find(_ => true).ToList();
public void Upsert(TrackedTrader trader) =>
_col.ReplaceOne(x => x.Id == trader.Id, trader, new ReplaceOptions { IsUpsert = true });
public void Update(TrackedTrader trader) => _col.ReplaceOne(x => x.Id == trader.Id, trader);
public void Delete(int id) => _col.DeleteOne(x => x.Id == id);
}
}
@@ -1,45 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using MongoDB.Driver;
using PolyTraderSharp.Models;
namespace PolyTrader.Modules.CopyTrading.Persistence
{
public class MongoCopyTradeLogRepository : ICopyTradeLogRepository
{
private readonly IMongoCollection<ClosedTrade> _col;
public MongoCopyTradeLogRepository(IMongoDatabase db)
{
_col = db.GetCollection<ClosedTrade>("closed_trades");
}
public void EnsureIndexes()
{
CreateIndex(x => x.TradeId);
CreateIndex(x => x.AccountId);
CreateIndex(x => x.TokenId);
CreateIndex(x => x.SourceTraderId);
}
private void CreateIndex(Expression<Func<ClosedTrade, object>> field)
{
try
{
var keys = Builders<ClosedTrade>.IndexKeys.Ascending(field);
_col.Indexes.CreateOne(new CreateIndexModel<ClosedTrade>(keys));
}
catch { }
}
public bool Exists(int accountId, string tokenId) =>
_col.Find(x => x.AccountId == accountId && x.TokenId == tokenId).Any();
public void Insert(ClosedTrade trade) => _col.InsertOne(trade);
public List<ClosedTrade> Find(Expression<Func<ClosedTrade, bool>> predicate) =>
_col.Find(predicate).ToList();
}
}
@@ -1,27 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using MongoDB.Driver;
using PolyTraderSharp.Models;
namespace PolyTrader.Modules.CopyTrading.Persistence
{
public class MongoCopyTradingAccountSettingsRepository : ICopyTradingAccountSettingsRepository
{
private readonly IMongoCollection<CopyTradingAccountSettings> _col;
public MongoCopyTradingAccountSettingsRepository(IMongoDatabase db)
{
_col = db.GetCollection<CopyTradingAccountSettings>("ct_account_settings");
}
public List<CopyTradingAccountSettings> GetAll() => _col.Find(_ => true).ToList();
public CopyTradingAccountSettings? Get(int accountId) =>
_col.Find(x => x.AccountId == accountId).FirstOrDefault();
public void Upsert(CopyTradingAccountSettings settings) =>
_col.ReplaceOne(x => x.AccountId == settings.AccountId, settings, new ReplaceOptions { IsUpsert = true });
public void Delete(int accountId) => _col.DeleteOne(x => x.AccountId == accountId);
}
}