phase 1
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
using ModVersionChecker.data.model;
|
||||
using ModVersionChecker.managers.interfaces;
|
||||
using ModVersionChecker.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModVersionChecker.managers.litedb
|
||||
{
|
||||
public class AppConfigLiteDb : LiteDb, IAppsManager
|
||||
{
|
||||
private string collection = LiteDb.APPS_COLLECTION;
|
||||
public List<AppConfig> Load()
|
||||
{
|
||||
var col = _db.GetCollection<AppConfig>(collection);
|
||||
return col.FindAll().ToList();
|
||||
}
|
||||
|
||||
public void Insert(AppConfig app)
|
||||
{
|
||||
var now = TimeUtils.GetUnixTimeMillis(null);
|
||||
app.CreatedAt = now;
|
||||
app.UpdatedAt = now;
|
||||
var col = _db.GetCollection<AppConfig>(collection);
|
||||
col.Insert(app);
|
||||
}
|
||||
|
||||
public void Update(AppConfig app)
|
||||
{
|
||||
var now = TimeUtils.GetUnixTimeMillis(null);
|
||||
app.UpdatedAt = now;
|
||||
var col = _db.GetCollection<AppConfig>(collection);
|
||||
col.Update(app);
|
||||
}
|
||||
|
||||
//public void Upsert(AppConfig app)
|
||||
//{
|
||||
// var now = TimeUtils.GetUnixTimeMillis(null);
|
||||
// app.UpdatedAt = now;
|
||||
// var col = _db.GetCollection<AppConfig>(collection);
|
||||
// if (string.IsNullOrEmpty(app.Id))
|
||||
// {
|
||||
// app.CreatedAt = now;
|
||||
// col.Insert(app);
|
||||
// }
|
||||
// col.Update(app);
|
||||
//}
|
||||
|
||||
public void Delete(string id)
|
||||
{
|
||||
var col = _db.GetCollection<AppConfig>(collection);
|
||||
col.Delete(id);
|
||||
}
|
||||
|
||||
public void Save(List<AppConfig> apps)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void UpdateStatus(AppConfig app, AppStatus status)
|
||||
{
|
||||
app.LastCheckedAt = TimeUtils.GetUnixTimeMillis(null);
|
||||
app.Status = status;
|
||||
var col = _db.GetCollection<AppConfig>(collection);
|
||||
col.Update(app);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
using ModVersionChecker.data.model;
|
||||
using ModVersionChecker.managers.interfaces;
|
||||
|
||||
namespace ModVersionChecker.managers.litedb
|
||||
{
|
||||
public class ConfigLiteDb : LiteDb, IConfigManager
|
||||
{
|
||||
private string collection = LiteDb.CONFIG_COLLECTION;
|
||||
public GlobalConfig Load()
|
||||
{
|
||||
var col = _db.GetCollection<GlobalConfig>(collection);
|
||||
return col.FindAll().FirstOrDefault() ?? new GlobalConfig();
|
||||
}
|
||||
public void Save(GlobalConfig config)
|
||||
{
|
||||
var col = _db.GetCollection<GlobalConfig>(collection);
|
||||
col.Upsert(config);
|
||||
}
|
||||
public GlobalConfig GetConfig()
|
||||
{
|
||||
return Load();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,32 +0,0 @@
|
||||
using ModVersionChecker.data.model;
|
||||
using ModVersionChecker.managers.interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModVersionChecker.managers.litedb
|
||||
{
|
||||
internal class FlightSimsLiteDb : LiteDb, IFlightSimsManager
|
||||
{
|
||||
private string collection = FLIGHT_SIMS_COLLECTION;
|
||||
public List<FsModPathConfig> Load()
|
||||
{
|
||||
var col = _db.GetCollection<FsModPathConfig>(collection);
|
||||
return col.FindAll().ToList();
|
||||
}
|
||||
|
||||
public void Save(FsModPathConfig config)
|
||||
{
|
||||
var col = _db.GetCollection<FsModPathConfig>(collection);
|
||||
col.Upsert(config);
|
||||
}
|
||||
|
||||
public FsModPathConfig? GetByShortName(string id)
|
||||
{
|
||||
var col = _db.GetCollection<FsModPathConfig>(collection);
|
||||
return col.FindOne(x => x.ShortName == id);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
using LiteDB;
|
||||
|
||||
namespace ModVersionChecker.managers.litedb
|
||||
{
|
||||
public class LiteDb
|
||||
{
|
||||
public static string DB_PATH = "ModVersionChecker.db";
|
||||
public static string APPS_COLLECTION = "apps";
|
||||
public static string CHECKER_TYPES_DEF_COLLECTION = "checker_types_def";
|
||||
public static string SOURCES_DEF_COLLECTION = "sources_def";
|
||||
public static string CONFIG_COLLECTION = "config";
|
||||
public static string FLIGHT_SIMS_COLLECTION = "flight_sims";
|
||||
|
||||
protected LiteDatabase _db = LiteDbSingleton.Instance;
|
||||
}
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
using ModVersionChecker.data.model;
|
||||
using ModVersionChecker.managers.interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModVersionChecker.managers.litedb
|
||||
{
|
||||
public class SourcesLiteDb : LiteDb, ISourcesDefManager
|
||||
{
|
||||
private string collection = SOURCES_DEF_COLLECTION;
|
||||
public List<SourceDef> List()
|
||||
{
|
||||
var col = _db.GetCollection<SourceDef>(collection);
|
||||
return col.FindAll().ToList();
|
||||
}
|
||||
|
||||
public SourceDef? GetById(string id)
|
||||
{
|
||||
var col = _db.GetCollection<SourceDef>(collection);
|
||||
return col.FindOne(x => x.Id == id);
|
||||
}
|
||||
|
||||
public void AddSourceDef(SourceDef sourceDef)
|
||||
{
|
||||
var col = _db.GetCollection<SourceDef>(collection);
|
||||
col.Insert(sourceDef);
|
||||
}
|
||||
public void RemoveSourceDef(string id)
|
||||
{
|
||||
var col = _db.GetCollection<SourceDef>(collection);
|
||||
col.Delete(id);
|
||||
}
|
||||
|
||||
public void Save(SourceDef sourceDef)
|
||||
{
|
||||
var col = _db.GetCollection<SourceDef>(collection);
|
||||
col.Upsert(sourceDef);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user