Started work on the 'Folder Roots'. Added the skeleton of this feature to the ProfileManager form.
This commit is contained in:
@@ -7,6 +7,7 @@ using System.IO;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using System.Configuration;
|
||||
|
||||
namespace DataOrganizer
|
||||
{
|
||||
@@ -48,6 +49,7 @@ namespace DataOrganizer
|
||||
public List<Profile> GetProfiles()
|
||||
{
|
||||
var query = "SELECT * FROM profile";
|
||||
|
||||
var profiles = new List<Profile>();
|
||||
|
||||
using (var connection = new SqliteConnection(ConnectionString))
|
||||
@@ -68,6 +70,29 @@ namespace DataOrganizer
|
||||
RowId = Convert.ToInt32(reader["profile_id"])
|
||||
});
|
||||
}
|
||||
|
||||
reader.Close();
|
||||
|
||||
command.CommandText = "SELECT root_id, name FROM folder_root WHERE profile_id = @ID";
|
||||
|
||||
foreach(var profile in profiles)
|
||||
{
|
||||
command.Parameters.Clear();
|
||||
command.Parameters.AddWithValue("ID", profile.RowId);
|
||||
|
||||
reader = command.ExecuteReader();
|
||||
|
||||
while(reader.Read())
|
||||
{
|
||||
profile.FolderGroups.Add(new FolderGroup
|
||||
{
|
||||
Name = reader["name"].ToString(),
|
||||
rowId = Convert.ToInt32(reader["root_id"])
|
||||
});
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +102,7 @@ namespace DataOrganizer
|
||||
public bool UpdateProfile(Profile profile)
|
||||
{
|
||||
var query = @"UPDATE main.profile SET machine_name = @MachineName, default_new_content_folder_name = @DefaultPath, profile_name = @Name WHERE profile_id = @ID";
|
||||
|
||||
using (var connection = new SqliteConnection(ConnectionString))
|
||||
{
|
||||
using (var command = new SqliteCommand(query, connection))
|
||||
@@ -98,6 +124,7 @@ namespace DataOrganizer
|
||||
public bool InsertNewProfile(Profile profile)
|
||||
{
|
||||
var query = @"INSERT INTO main.profile (machine_name, default_new_content_folder_name, profile_name) VALUES (@MachineName, @DefaultPath, @Name)";
|
||||
|
||||
using (var connection = new SqliteConnection(ConnectionString))
|
||||
{
|
||||
using (var command = new SqliteCommand(query, connection))
|
||||
@@ -115,12 +142,39 @@ namespace DataOrganizer
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool InsertNewFolderGroup(Profile profile, string name)
|
||||
{
|
||||
var query = @"INSERT INTO main.folder_root (name, profile_id) VALUES (@Name, @ProfileID)";
|
||||
|
||||
using (var connection = new SqliteConnection(ConnectionString))
|
||||
{
|
||||
using (var command = new SqliteCommand(query, connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("ProfileID", profile.RowId);
|
||||
command.Parameters.AddWithValue("Name", name);
|
||||
|
||||
connection.Open();
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public struct Profile
|
||||
{
|
||||
public string Name;
|
||||
public string DefaultNewContentFolder;
|
||||
public string MachineName;
|
||||
public int RowId;
|
||||
public List<FolderGroup> FolderGroups;
|
||||
}
|
||||
|
||||
public struct FolderGroup
|
||||
{
|
||||
public int rowId;
|
||||
public string Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user