|
@@ -12,18 +12,18 @@ namespace Rac.Tools
|
|
|
{
|
|
|
internal class DataAccess
|
|
|
{
|
|
|
- private readonly string _filename;
|
|
|
+ private readonly string _dbFilePath;
|
|
|
|
|
|
- public DataAccess(string filename)
|
|
|
+ public DataAccess(string dbFilePath)
|
|
|
{
|
|
|
- _filename = filename;
|
|
|
+ _dbFilePath = dbFilePath;
|
|
|
|
|
|
CreateDatabaseIfNotExist();
|
|
|
}
|
|
|
|
|
|
private void CreateDatabaseIfNotExist()
|
|
|
{
|
|
|
- if (File.Exists(_filename)) return;
|
|
|
+ if (File.Exists(_dbFilePath)) return;
|
|
|
|
|
|
using (var conn = GetConnection())
|
|
|
{
|
|
@@ -82,7 +82,7 @@ namespace Rac.Tools
|
|
|
|
|
|
private DbConnection GetConnection()
|
|
|
{
|
|
|
- var conn = new SqliteConnection("Data Source=" + _filename);
|
|
|
+ var conn = new SqliteConnection("Data Source=" + _dbFilePath);
|
|
|
conn.Open();
|
|
|
return conn;
|
|
|
}
|
|
@@ -200,5 +200,16 @@ namespace Rac.Tools
|
|
|
return conn.Query<ArchiveEntry>($"SELECT * FROM Archives WHERE {nameof(ArchiveEntry.Url)}=@url", new { url }).FirstOrDefault();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public string[] GetAllUrl()
|
|
|
+ {
|
|
|
+ using (var conn = GetConnection())
|
|
|
+ {
|
|
|
+ return conn.Query<string>($"SELECT {nameof(ArchiveEntry.Url)} FROM Archives").ToArray();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|