mirror of
https://github.com/wagesj45/mdfinder.git
synced 2025-09-09 03:20:38 -05:00
Beginning Work
This is early stage development. Still getting the main components together and figureing out how the flow should work.
This commit is contained in:
parent
7e92f9ebef
commit
f5b2f9e0f6
19 changed files with 1317 additions and 29 deletions
70
mdfinder/DBHelper.cs
Normal file
70
mdfinder/DBHelper.cs
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
using LiteDB;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mdfinder
|
||||
{
|
||||
/// <summary> A database helper class. </summary>
|
||||
public class DBHelper
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary> The default database file name. </summary>
|
||||
private const string DEFAULT_DB_FILE_NAME = "mdfinder.db";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary> Gets or sets the database. </summary>
|
||||
/// <value> The database. </value>
|
||||
private LiteDatabase Database { get; set; }
|
||||
|
||||
/// <summary> Gets the file records. </summary>
|
||||
/// <value> The file records. </value>
|
||||
public LiteCollection<FileRecord> FileRecords
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Database.GetCollection<FileRecord>("FileRecords");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary> Default constructor. </summary>
|
||||
public DBHelper()
|
||||
{
|
||||
this.Database = new LiteDatabase(DEFAULT_DB_FILE_NAME);
|
||||
}
|
||||
|
||||
/// <summary> Constructor. </summary>
|
||||
/// <param name="database"> The database. </param>
|
||||
public DBHelper(string database)
|
||||
{
|
||||
this.Database = new LiteDatabase(database);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary> Inserts a file record. </summary>
|
||||
/// <param name="path"> Full pathname of the file. </param>
|
||||
/// <param name="size"> The size. </param>
|
||||
/// <param name="hash"> The hash. </param>
|
||||
/// <param name="hashProvider"> The hash provider. </param>
|
||||
public void InsertFileRecord(string path, long size, string hash, string hashProvider)
|
||||
{
|
||||
this.FileRecords.Insert(new FileRecord() { Path = path, Size = size, Hash = hash, HashProvider = hashProvider });
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue