Rename all instances of os and oses to app and apps.

This commit is contained in:
2018-02-23 03:33:22 +00:00
parent 0a873967d2
commit 46e86ef1b2
15 changed files with 353 additions and 362 deletions

View File

@@ -597,17 +597,7 @@
<e p="obj" t="ExcludeRecursive" /> <e p="obj" t="ExcludeRecursive" />
<e p="packages.config" t="Include" /> <e p="packages.config" t="Include" />
</e> </e>
<e p="apprepodbmgr.Eto.XamMac2" t="IncludeRecursive"> <e p="apprepodbmgr.Eto.XamMac2/apprepodbmgr.Eto.XamMac2.csproj" t="IncludeRecursive" />
<e p="Info.plist" t="Include" />
<e p="Program.cs" t="Include" />
<e p="Properties" t="Include">
<e p="AssemblyInfo.cs" t="Include" />
</e>
<e p="Resources" t="Include" />
<e p="apprepodbmgr.Eto.XamMac2.csproj" t="IncludeRecursive" />
<e p="bin" t="ExcludeRecursive" />
<e p="packages.config" t="Include" />
</e>
<e p="apprepodbmgr.sln" t="IncludeFlat" /> <e p="apprepodbmgr.sln" t="IncludeFlat" />
<e p="packages" t="ExcludeRecursive" /> <e p="packages" t="ExcludeRecursive" />
</e> </e>

View File

@@ -40,7 +40,7 @@ namespace apprepodbmgr.Core
public static List<string> Files; public static List<string> Files;
public static List<string> Folders; public static List<string> Folders;
public static List<string> Symlinks; public static List<string> Symlinks;
public static Dictionary<string, DbOsFile> Hashes; public static Dictionary<string, DbAppFile> Hashes;
public static Dictionary<string, DbFolder> FoldersDict; public static Dictionary<string, DbFolder> FoldersDict;
public static Dictionary<string, string> SymlinksDict; public static Dictionary<string, string> SymlinksDict;
public static string Path; public static string Path;

View File

@@ -67,7 +67,7 @@ namespace apprepodbmgr.Core
public long Length { get; set; } public long Length { get; set; }
} }
public struct DbOsFile public struct DbAppFile
{ {
public ulong Id; public ulong Id;
public string Path; public string Path;
@@ -101,11 +101,11 @@ namespace apprepodbmgr.Core
dbCore = core; dbCore = core;
} }
public bool GetAllOSes(out List<DbEntry> entries) public bool GetAllApps(out List<DbEntry> entries)
{ {
entries = new List<DbEntry>(); entries = new List<DbEntry>();
const string SQL = "SELECT * from oses"; const string SQL = "SELECT * from apps";
IDbCommand dbcmd = dbCon.CreateCommand(); IDbCommand dbcmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -145,7 +145,7 @@ namespace apprepodbmgr.Core
return true; return true;
} }
IDbCommand GetOsCommand(DbEntry entry) IDbCommand GetAppCommand(DbEntry entry)
{ {
IDbCommand dbcmd = dbCon.CreateCommand(); IDbCommand dbcmd = dbCon.CreateCommand();
@@ -241,14 +241,14 @@ namespace apprepodbmgr.Core
return dbcmd; return dbcmd;
} }
public bool AddOs(DbEntry entry, out long id) public bool AddApp(DbEntry entry, out long id)
{ {
IDbCommand dbcmd = GetOsCommand(entry); IDbCommand dbcmd = GetAppCommand(entry);
IDbTransaction trans = dbCon.BeginTransaction(); IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans; dbcmd.Transaction = trans;
const string SQL = const string SQL =
"INSERT INTO oses (developer, product, version, languages, architecture, machine, format, description, oem, upgrade, `update`, source, files, netinstall, xml, json, mdid)" + "INSERT INTO apps (developer, product, version, languages, architecture, machine, format, description, oem, upgrade, `update`, source, files, netinstall, xml, json, mdid)" +
" VALUES (@developer, @product, @version, @languages, @architecture, @machine, @format, @description, @oem, @upgrade, @update, @source, @files, @netinstall, @xml, @json, @mdid)"; " VALUES (@developer, @product, @version, @languages, @architecture, @machine, @format, @description, @oem, @upgrade, @update, @source, @files, @netinstall, @xml, @json, @mdid)";
dbcmd.CommandText = SQL; dbcmd.CommandText = SQL;
@@ -501,7 +501,7 @@ namespace apprepodbmgr.Core
return true; return true;
} }
IDbCommand GetOsFileCommand(DbOsFile person) IDbCommand GetAppFileCommand(DbAppFile person)
{ {
IDbCommand dbcmd = dbCon.CreateCommand(); IDbCommand dbcmd = dbCon.CreateCommand();
@@ -548,14 +548,14 @@ namespace apprepodbmgr.Core
return dbcmd; return dbcmd;
} }
public bool AddFileToOs(DbOsFile file, long os) public bool AddFileToApp(DbAppFile file, long app)
{ {
IDbCommand dbcmd = GetOsFileCommand(file); IDbCommand dbcmd = GetAppFileCommand(file);
IDbTransaction trans = dbCon.BeginTransaction(); IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans; dbcmd.Transaction = trans;
string sql = string sql =
$"INSERT INTO `os_{os}` (`path`, `sha256`, `length`, `creation`, `access`, `modification`, `attributes`)" + $"INSERT INTO `app_{app}` (`path`, `sha256`, `length`, `creation`, `access`, `modification`, `attributes`)" +
" VALUES (@path, @sha256, @length, @creation, @access, @modification, @attributes)"; " VALUES (@path, @sha256, @length, @creation, @access, @modification, @attributes)";
dbcmd.CommandText = sql; dbcmd.CommandText = sql;
@@ -567,7 +567,7 @@ namespace apprepodbmgr.Core
return true; return true;
} }
IDbCommand GetFolderCommand(DbFolder person) IDbCommand GetFolderCommand(DbFolder folder)
{ {
IDbCommand dbcmd = dbCon.CreateCommand(); IDbCommand dbcmd = dbCon.CreateCommand();
@@ -589,11 +589,11 @@ namespace apprepodbmgr.Core
param6.DbType = DbType.String; param6.DbType = DbType.String;
param7.DbType = DbType.Int32; param7.DbType = DbType.Int32;
param1.Value = person.Path; param1.Value = folder.Path;
param4.Value = person.CreationTimeUtc.ToString("yyyy-MM-dd HH:mm"); param4.Value = folder.CreationTimeUtc.ToString("yyyy-MM-dd HH:mm");
param5.Value = person.LastAccessTimeUtc.ToString("yyyy-MM-dd HH:mm"); param5.Value = folder.LastAccessTimeUtc.ToString("yyyy-MM-dd HH:mm");
param6.Value = person.LastWriteTimeUtc.ToString("yyyy-MM-dd HH:mm"); param6.Value = folder.LastWriteTimeUtc.ToString("yyyy-MM-dd HH:mm");
param7.Value = (int)person.Attributes; param7.Value = (int)folder.Attributes;
dbcmd.Parameters.Add(param1); dbcmd.Parameters.Add(param1);
dbcmd.Parameters.Add(param4); dbcmd.Parameters.Add(param4);
@@ -604,86 +604,32 @@ namespace apprepodbmgr.Core
return dbcmd; return dbcmd;
} }
public bool AddFolderToOs(DbFolder folder, long os) public bool AddFolderToApp(DbFolder folder, long app)
{ {
IDbCommand dbcmd = GetFolderCommand(folder); IDbCommand dbcmd = GetFolderCommand(folder);
IDbTransaction trans = dbCon.BeginTransaction(); IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans; dbcmd.Transaction = trans;
string sql = $"INSERT INTO `os_{os}_folders` (`path`, `creation`, `access`, `modification`, `attributes`)" +
" VALUES (@path, @creation, @access, @modification, @attributes)";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
trans.Commit();
dbcmd.Dispose();
return true;
}
public bool RemoveOs(long id)
{
IDbCommand dbcmd = dbCon.CreateCommand();
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
string sql = $"DROP TABLE IF EXISTS `os_{id}`;";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
trans.Commit();
dbcmd.Dispose();
dbcmd = dbCon.CreateCommand();
trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
sql = $"DROP TABLE IF EXISTS `os_{id}_folders`;";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
trans.Commit();
dbcmd.Dispose();
dbcmd = dbCon.CreateCommand();
trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
sql = $"DROP TABLE IF EXISTS `os_{id}_symlinks`;";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
trans.Commit();
dbcmd.Dispose();
dbcmd = dbCon.CreateCommand();
trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
sql = $"DELETE FROM oses WHERE id = '{id}';";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
trans.Commit();
dbcmd.Dispose();
return true;
}
public bool CreateTableForOs(long id)
{
IDbCommand dbcmd = dbCon.CreateCommand();
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
string sql = string sql =
string.Format("DROP TABLE IF EXISTS `os_{0}`;\n\n" + "CREATE TABLE IF NOT EXISTS `os_{0}` (\n" + " `id` INTEGER PRIMARY KEY AUTOINCREMENT,\n" + " `path` VARCHAR(8192) NOT NULL,\n" + " `sha256` VARCHAR(64) NOT NULL,\n\n" + " `length` BIGINT NOT NULL,\n" + " `creation` DATETIME NULL,\n" + " `access` DATETIME NULL,\n" + " `modification` DATETIME NULL,\n" + " `attributes` INTEGER NULL);\n\n" + "CREATE UNIQUE INDEX `os_{0}_id_UNIQUE` ON `os_{0}` (`id` ASC);\n\n" + "CREATE INDEX `os_{0}_path_idx` ON `os_{0}` (`path` ASC);", $"INSERT INTO `app_{app}_folders` (`path`, `creation`, `access`, `modification`, `attributes`)" +
id); " VALUES (@path, @creation, @access, @modification, @attributes)";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
trans.Commit();
dbcmd.Dispose();
return true;
}
public bool RemoveApp(long id)
{
IDbCommand dbcmd = dbCon.CreateCommand();
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
string sql = $"DROP TABLE IF EXISTS `app_{id}`;";
dbcmd.CommandText = sql; dbcmd.CommandText = sql;
@@ -695,9 +641,31 @@ namespace apprepodbmgr.Core
trans = dbCon.BeginTransaction(); trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans; dbcmd.Transaction = trans;
sql = sql = $"DROP TABLE IF EXISTS `app_{id}_folders`;";
string.Format("DROP TABLE IF EXISTS `os_{0}_folders`;\n\n" + "CREATE TABLE IF NOT EXISTS `os_{0}_folders` (\n" + " `id` INTEGER PRIMARY KEY AUTOINCREMENT,\n" + " `path` VARCHAR(8192) NOT NULL,\n" + " `creation` DATETIME NULL,\n" + " `access` DATETIME NULL,\n" + " `modification` DATETIME NULL,\n" + " `attributes` INTEGER NULL);\n\n" + "CREATE UNIQUE INDEX `os_{0}_folders_id_UNIQUE` ON `os_{0}_folders` (`id` ASC);\n\n" + "CREATE INDEX `os_{0}_folders_path_idx` ON `os_{0}_folders` (`path` ASC);",
id); dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
trans.Commit();
dbcmd.Dispose();
dbcmd = dbCon.CreateCommand();
trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
sql = $"DROP TABLE IF EXISTS `app_{id}_symlinks`;";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
trans.Commit();
dbcmd.Dispose();
dbcmd = dbCon.CreateCommand();
trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
sql = $"DELETE FROM apps WHERE id = '{id}';";
dbcmd.CommandText = sql; dbcmd.CommandText = sql;
@@ -708,7 +676,56 @@ namespace apprepodbmgr.Core
return true; return true;
} }
public bool ExistsFileInOs(string hash, long osId) public bool CreateTableForApp(long id)
{
IDbCommand dbcmd = dbCon.CreateCommand();
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
string sql = $"DROP TABLE IF EXISTS `app_{id}`;\n\n" +
$"CREATE TABLE IF NOT EXISTS `app_{id}` (\n" +
" `id` INTEGER PRIMARY KEY AUTOINCREMENT,\n" +
" `path` VARCHAR(8192) NOT NULL,\n" +
" `sha256` VARCHAR(64) NOT NULL,\n\n" +
" `length` BIGINT NOT NULL,\n" +
" `creation` DATETIME NULL,\n" +
" `access` DATETIME NULL,\n" +
" `modification` DATETIME NULL,\n" +
" `attributes` INTEGER NULL);\n\n" +
$"CREATE UNIQUE INDEX `app_{id}_id_UNIQUE` ON `app_{id}` (`id` ASC);\n\n" +
$"CREATE INDEX `app_{id}_path_idx` ON `app_{id}` (`path` ASC);";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
trans.Commit();
dbcmd.Dispose();
dbcmd = dbCon.CreateCommand();
trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
sql = $"DROP TABLE IF EXISTS `os_{id}_folders`;\n\n" +
$"CREATE TABLE IF NOT EXISTS `os_{id}_folders` (\n" +
" `id` INTEGER PRIMARY KEY AUTOINCREMENT,\n" +
" `path` VARCHAR(8192) NOT NULL,\n" +
" `creation` DATETIME NULL,\n" +
" `access` DATETIME NULL,\n" +
" `modification` DATETIME NULL,\n" +
" `attributes` INTEGER NULL);\n\n" +
$"CREATE UNIQUE INDEX `os_{id}_folders_id_UNIQUE` ON `os_{id}_folders` (`id` ASC);\n\n" +
$"CREATE INDEX `os_{id}_folders_path_idx` ON `os_{id}_folders` (`path` ASC);";
dbcmd.CommandText = sql;
dbcmd.ExecuteNonQuery();
trans.Commit();
dbcmd.Dispose();
return true;
}
public bool ExistsFileInApp(string hash, long appId)
{ {
IDbCommand dbcmd = dbCon.CreateCommand(); IDbCommand dbcmd = dbCon.CreateCommand();
IDbDataParameter param1 = dbcmd.CreateParameter(); IDbDataParameter param1 = dbcmd.CreateParameter();
@@ -717,7 +734,7 @@ namespace apprepodbmgr.Core
param1.DbType = DbType.String; param1.DbType = DbType.String;
param1.Value = hash; param1.Value = hash;
dbcmd.Parameters.Add(param1); dbcmd.Parameters.Add(param1);
dbcmd.CommandText = $"SELECT * FROM `os_{osId}` WHERE sha256 = @hash"; dbcmd.CommandText = $"SELECT * FROM `app_{appId}` WHERE sha256 = @hash";
DataSet dataSet = new DataSet(); DataSet dataSet = new DataSet();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
dataAdapter.SelectCommand = dbcmd; dataAdapter.SelectCommand = dbcmd;
@@ -738,7 +755,7 @@ namespace apprepodbmgr.Core
param1.DbType = DbType.String; param1.DbType = DbType.String;
param1.Value = mdid; param1.Value = mdid;
dbcmd.Parameters.Add(param1); dbcmd.Parameters.Add(param1);
dbcmd.CommandText = "SELECT * FROM `oses` WHERE mdid = @mdid"; dbcmd.CommandText = "SELECT * FROM `apps` WHERE mdid = @mdid";
DataSet dataSet = new DataSet(); DataSet dataSet = new DataSet();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
dataAdapter.SelectCommand = dbcmd; dataAdapter.SelectCommand = dbcmd;
@@ -750,11 +767,11 @@ namespace apprepodbmgr.Core
return false; return false;
} }
public bool GetAllFilesInOs(out List<DbOsFile> entries, long id) public bool GetAllFilesInApp(out List<DbAppFile> entries, long id)
{ {
entries = new List<DbOsFile>(); entries = new List<DbAppFile>();
string sql = $"SELECT * from os_{id}"; string sql = $"SELECT * from app_{id}";
IDbCommand dbcmd = dbCon.CreateCommand(); IDbCommand dbcmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -766,7 +783,7 @@ namespace apprepodbmgr.Core
foreach(DataRow dRow in dataTable.Rows) foreach(DataRow dRow in dataTable.Rows)
{ {
DbOsFile fEntry = new DbOsFile DbAppFile fEntry = new DbAppFile
{ {
Id = ulong.Parse(dRow["id"].ToString()), Id = ulong.Parse(dRow["id"].ToString()),
Path = dRow["path"].ToString(), Path = dRow["path"].ToString(),
@@ -788,7 +805,7 @@ namespace apprepodbmgr.Core
{ {
entries = new List<DbFolder>(); entries = new List<DbFolder>();
string sql = $"SELECT * from os_{id}_folders"; string sql = $"SELECT * from app_{id}_folders";
IDbCommand dbcmd = dbCon.CreateCommand(); IDbCommand dbcmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -854,11 +871,11 @@ namespace apprepodbmgr.Core
return true; return true;
} }
public bool HasSymlinks(long osId) public bool HasSymlinks(long appId)
{ {
IDbCommand dbcmd = dbCon.CreateCommand(); IDbCommand dbcmd = dbCon.CreateCommand();
dbcmd.CommandText = dbcmd.CommandText =
$"SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND name = 'os_{osId}_symlinks'"; $"SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND name = 'app_{appId}_symlinks'";
object count = dbcmd.ExecuteScalar(); object count = dbcmd.ExecuteScalar();
dbcmd.Dispose(); dbcmd.Dispose();
@@ -871,11 +888,13 @@ namespace apprepodbmgr.Core
IDbTransaction trans = dbCon.BeginTransaction(); IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans; dbcmd.Transaction = trans;
string sql = dbcmd.CommandText =
string.Format("DROP TABLE IF EXISTS `os_{0}_symlinks`;\n\n" + "CREATE TABLE IF NOT EXISTS `os_{0}_symlinks` (\n" + " `path` VARCHAR(8192) PRIMARY KEY,\n" + " `target` VARCHAR(8192) NOT NULL);\n\n" + "CREATE UNIQUE INDEX `os_{0}_symlinks_path_UNIQUE` ON `os_{0}_symlinks` (`path` ASC);\n\n" + "CREATE INDEX `os_{0}_symlinks_target_idx` ON `os_{0}_symlinks` (`target` ASC);", $"DROP TABLE IF EXISTS `app_{id}_symlinks`;\n\n" +
id); $"CREATE TABLE IF NOT EXISTS `app_{id}_symlinks` (\n" +
" `path` VARCHAR(8192) PRIMARY KEY,\n" +
dbcmd.CommandText = sql; " `target` VARCHAR(8192) NOT NULL);\n\n" +
$"CREATE UNIQUE INDEX `app_{id}_symlinks_path_UNIQUE` ON `app_{id}_symlinks` (`path` ASC);\n\n" +
$"CREATE INDEX `app_{id}_symlinks_target_idx` ON `app_{id}_symlinks` (`target` ASC);";
dbcmd.ExecuteNonQuery(); dbcmd.ExecuteNonQuery();
trans.Commit(); trans.Commit();
@@ -884,7 +903,7 @@ namespace apprepodbmgr.Core
return true; return true;
} }
public bool AddSymlinkToOs(string path, string target, long os) public bool AddSymlinkToApp(string path, string target, long app)
{ {
IDbCommand dbcmd = dbCon.CreateCommand(); IDbCommand dbcmd = dbCon.CreateCommand();
@@ -906,7 +925,7 @@ namespace apprepodbmgr.Core
IDbTransaction trans = dbCon.BeginTransaction(); IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans; dbcmd.Transaction = trans;
string sql = $"INSERT INTO `os_{os}_symlinks` (`path`, `target`)" + " VALUES (@path, @target)"; string sql = $"INSERT INTO `app_{app}_symlinks` (`path`, `target`)" + " VALUES (@path, @target)";
dbcmd.CommandText = sql; dbcmd.CommandText = sql;
@@ -921,7 +940,7 @@ namespace apprepodbmgr.Core
{ {
entries = new Dictionary<string, string>(); entries = new Dictionary<string, string>();
string sql = $"SELECT * from os_{id}_symlinks"; string sql = $"SELECT * from app_{id}_symlinks";
IDbCommand dbcmd = dbCon.CreateCommand(); IDbCommand dbcmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();

View File

@@ -105,9 +105,9 @@ namespace apprepodbmgr.Core
dbCmd.ExecuteNonQuery(); dbCmd.ExecuteNonQuery();
#if DEBUG #if DEBUG
Console.WriteLine("Creating oses table"); Console.WriteLine("Creating applications table");
#endif #endif
dbCmd.CommandText = Schema.OSesTableSql; dbCmd.CommandText = Schema.AppsTableSql;
dbCmd.ExecuteNonQuery(); dbCmd.ExecuteNonQuery();
#if DEBUG #if DEBUG

View File

@@ -49,11 +49,11 @@ namespace apprepodbmgr.Core
"CREATE INDEX `files_virus_idx` ON `files` (`virus` ASC);\n\n" + "CREATE INDEX `files_virus_idx` ON `files` (`virus` ASC);\n\n" +
"CREATE INDEX `files_length_idx` ON `files` (`length` ASC);"; "CREATE INDEX `files_length_idx` ON `files` (`length` ASC);";
public const string OSesTableSql = "-- -----------------------------------------------------\n" + public const string AppsTableSql = "-- -----------------------------------------------------\n" +
"-- Table `oses`\n" + "-- Table `apps`\n" +
"-- -----------------------------------------------------\n" + "-- -----------------------------------------------------\n" +
"DROP TABLE IF EXISTS `oses` ;\n\n" + "DROP TABLE IF EXISTS `apps` ;\n\n" +
"CREATE TABLE IF NOT EXISTS `oses` (\n" + "CREATE TABLE IF NOT EXISTS `apps` (\n" +
" `id` INTEGER PRIMARY KEY AUTOINCREMENT,\n" + " `id` INTEGER PRIMARY KEY AUTOINCREMENT,\n" +
" `mdid` CHAR(40) NOT NULL,\n" + " `mdid` CHAR(40) NOT NULL,\n" +
" `developer` VARCHAR(45) NOT NULL,\n" + " `developer` VARCHAR(45) NOT NULL,\n" +
@@ -72,14 +72,14 @@ namespace apprepodbmgr.Core
" `netinstall` BOOLEAN NOT NULL,\n" + " `netinstall` BOOLEAN NOT NULL,\n" +
" `xml` BLOB NULL,\n" + " `xml` BLOB NULL,\n" +
" `json` BLOB NULL);\n\n" + " `json` BLOB NULL);\n\n" +
"CREATE UNIQUE INDEX `oses_id_UNIQUE` ON `oses` (`id` ASC);\n\n" + "CREATE UNIQUE INDEX `apps_id_UNIQUE` ON `apps` (`id` ASC);\n\n" +
"CREATE UNIQUE INDEX `oses_mdid_UNIQUE` ON `oses` (`mdid` ASC);\n\n" + "CREATE UNIQUE INDEX `apps_mdid_UNIQUE` ON `apps` (`mdid` ASC);\n\n" +
"CREATE INDEX `oses_developer_idx` ON `oses` (`developer` ASC);\n\n" + "CREATE INDEX `apps_developer_idx` ON `apps` (`developer` ASC);\n\n" +
"CREATE INDEX `oses_product_idx` ON `oses` (`product` ASC);\n\n" + "CREATE INDEX `apps_product_idx` ON `apps` (`product` ASC);\n\n" +
"CREATE INDEX `oses_version_idx` ON `oses` (`version` ASC);\n\n" + "CREATE INDEX `apps_version_idx` ON `apps` (`version` ASC);\n\n" +
"CREATE INDEX `oses_architecture_idx` ON `oses` (`architecture` ASC);\n\n" + "CREATE INDEX `apps_architecture_idx` ON `apps` (`architecture` ASC);\n\n" +
"CREATE INDEX `oses_format_idx` ON `oses` (`format` ASC);\n\n" + "CREATE INDEX `apps_format_idx` ON `apps` (`format` ASC);\n\n" +
"CREATE INDEX `oses_machine_idx` ON `oses` (`machine` ASC);\n\n" + "CREATE INDEX `apps_machine_idx` ON `apps` (`machine` ASC);\n\n" +
"CREATE INDEX `oses_description_idx` ON `oses` (`description` ASC);"; "CREATE INDEX `apps_description_idx` ON `apps` (`description` ASC);";
} }
} }

View File

@@ -102,7 +102,7 @@ namespace apprepodbmgr.Core
? ((NSString)obj).ToString() ? ((NSString)obj).ToString()
: Path : Path
.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), .Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
"osrepo"); "apprepo");
Current.UnArchiverPath = parsedPreferences.TryGetValue("UnArchiverPath", out obj) Current.UnArchiverPath = parsedPreferences.TryGetValue("UnArchiverPath", out obj)
? ((NSString)obj).ToString() ? ((NSString)obj).ToString()
@@ -166,7 +166,7 @@ namespace apprepodbmgr.Core
return; return;
} }
RegistryKey key = parentKey.OpenSubKey("OSRepoDBMgr"); RegistryKey key = parentKey.OpenSubKey("AppRepoDBMgr");
if(key == null) if(key == null)
{ {
SetDefaultSettings(); SetDefaultSettings();
@@ -195,7 +195,7 @@ namespace apprepodbmgr.Core
string configPath = string configPath =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config"); Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
string settingsPath = string settingsPath =
Path.Combine(configPath, "OSRepoDBMgr.xml"); Path.Combine(configPath, "AppRepoDBMgr.xml");
if(!Directory.Exists(configPath)) if(!Directory.Exists(configPath))
{ {
@@ -269,7 +269,7 @@ namespace apprepodbmgr.Core
RegistryKey parentKey = Registry RegistryKey parentKey = Registry
.CurrentUser.OpenSubKey("SOFTWARE", true) .CurrentUser.OpenSubKey("SOFTWARE", true)
?.CreateSubKey("Canary Islands Computer Museum"); ?.CreateSubKey("Canary Islands Computer Museum");
RegistryKey key = parentKey?.CreateSubKey("OSRepoDBMgr"); RegistryKey key = parentKey?.CreateSubKey("AppRepoDBMgr");
if(key != null) if(key != null)
{ {
@@ -294,7 +294,7 @@ namespace apprepodbmgr.Core
string configPath = string configPath =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config"); Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
string settingsPath = string settingsPath =
Path.Combine(configPath, "OSRepoDBMgr.xml"); Path.Combine(configPath, "AppRepoDBMgr.xml");
if(!Directory.Exists(configPath)) Directory.CreateDirectory(configPath); if(!Directory.Exists(configPath)) Directory.CreateDirectory(configPath);
@@ -322,7 +322,7 @@ namespace apprepodbmgr.Core
DatabasePath = DatabasePath =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "apprepodbmgr.db"), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "apprepodbmgr.db"),
RepositoryPath = RepositoryPath =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "osrepo"), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "apprepo"),
UnArchiverPath = null, UnArchiverPath = null,
CompressionAlgorithm = AlgoEnum.GZip, CompressionAlgorithm = AlgoEnum.GZip,
UseAntivirus = false, UseAntivirus = false,

View File

@@ -133,17 +133,17 @@ namespace apprepodbmgr.Core
{ {
if(File.Exists(destination)) if(File.Exists(destination))
{ {
Failed?.Invoke("OS already exists."); Failed?.Invoke("Application already exists.");
return; return;
} }
Failed?.Invoke("OS already exists in the database but not in the repository, check for inconsistencies."); Failed?.Invoke("Application already exists in the database but not in the repository, check for inconsistencies.");
return; return;
} }
if(File.Exists(destination)) if(File.Exists(destination))
{ {
Failed?.Invoke("OS already exists in the repository but not in the database, check for inconsistencies."); Failed?.Invoke("Application already exists in the repository but not in the database, check for inconsistencies.");
return; return;
} }
@@ -174,12 +174,12 @@ namespace apprepodbmgr.Core
} }
long totalSize = 0, currentSize = 0; long totalSize = 0, currentSize = 0;
foreach(KeyValuePair<string, DbOsFile> file in Context.Hashes) totalSize += file.Value.Length; foreach(KeyValuePair<string, DbAppFile> file in Context.Hashes) totalSize += file.Value.Length;
#if DEBUG #if DEBUG
stopwatch.Restart(); stopwatch.Restart();
#endif #endif
foreach(KeyValuePair<string, DbOsFile> file in Context.Hashes) foreach(KeyValuePair<string, DbAppFile> file in Context.Hashes)
{ {
UpdateProgress?.Invoke("Compressing...", file.Value.Path, currentSize, totalSize); UpdateProgress?.Invoke("Compressing...", file.Value.Path, currentSize, totalSize);
@@ -291,7 +291,7 @@ namespace apprepodbmgr.Core
jms.Position = 0; jms.Position = 0;
} }
FinishedWithText?.Invoke($"Correctly added operating system with MDID {mdid}"); FinishedWithText?.Invoke($"Correctly added application with MDID {mdid}");
} }
catch(ThreadAbortException) { } catch(ThreadAbortException) { }
catch(Exception ex) catch(Exception ex)
@@ -613,7 +613,7 @@ namespace apprepodbmgr.Core
UpdateProgress?.Invoke("", "Asking DB for files...", 1, 100); UpdateProgress?.Invoke("", "Asking DB for files...", 1, 100);
dbCore.DbOps.GetAllFilesInOs(out List<DbOsFile> files, Context.DbInfo.Id); dbCore.DbOps.GetAllFilesInApp(out List<DbAppFile> files, Context.DbInfo.Id);
UpdateProgress?.Invoke("", "Asking DB for folders...", 2, 100); UpdateProgress?.Invoke("", "Asking DB for folders...", 2, 100);
@@ -645,11 +645,11 @@ namespace apprepodbmgr.Core
#endif #endif
counter = 3; counter = 3;
Context.Hashes = new Dictionary<string, DbOsFile>(); Context.Hashes = new Dictionary<string, DbAppFile>();
#if DEBUG #if DEBUG
stopwatch.Restart(); stopwatch.Restart();
#endif #endif
foreach(DbOsFile file in files) foreach(DbAppFile file in files)
{ {
UpdateProgress?.Invoke("", $"Adding {file.Path}...", counter, 3 + files.Count); UpdateProgress?.Invoke("", $"Adding {file.Path}...", counter, 3 + files.Count);
@@ -688,7 +688,7 @@ namespace apprepodbmgr.Core
static Stream Zf_HandleOpen(string entryName) static Stream Zf_HandleOpen(string entryName)
{ {
DbOsFile file; DbAppFile file;
if(!Context.Hashes.TryGetValue(entryName, out file)) if(!Context.Hashes.TryGetValue(entryName, out file))
if(!Context.Hashes.TryGetValue(entryName.Replace('/', '\\'), out file)) if(!Context.Hashes.TryGetValue(entryName.Replace('/', '\\'), out file))
throw new ArgumentException("Cannot find requested zip entry in hashes dictionary"); throw new ArgumentException("Cannot find requested zip entry in hashes dictionary");

View File

@@ -36,43 +36,38 @@ namespace apprepodbmgr.Core
{ {
public static partial class Workers public static partial class Workers
{ {
public static void GetAllOSes() public static void GetAllApps()
{ {
try try
{ {
#if DEBUG #if DEBUG
stopwatch.Restart(); stopwatch.Restart();
#endif #endif
dbCore.DbOps.GetAllOSes(out List<DbEntry> oses); dbCore.DbOps.GetAllApps(out List<DbEntry> apps);
#if DEBUG #if DEBUG
stopwatch.Stop(); stopwatch.Stop();
Console.WriteLine("Core.GetAllOSes(): Took {0} seconds to get OSes from database", Console.WriteLine("Core.GetAllApps(): Took {0} seconds to get apps from database",
stopwatch.Elapsed.TotalSeconds); stopwatch.Elapsed.TotalSeconds);
#endif #endif
if(AddOS != null) if(AddApp != null)
{ {
#if DEBUG #if DEBUG
stopwatch.Restart(); stopwatch.Restart();
#endif #endif
int counter = 0; int counter = 0;
// TODO: Check file name and existence // TODO: Check file name and existence
foreach(DbEntry os in oses) foreach(DbEntry app in apps)
{ {
UpdateProgress?.Invoke("Populating OSes table", $"{os.Developer} {os.Product}", counter, UpdateProgress?.Invoke("Populating apps table", $"{app.Developer} {app.Product}", counter,
oses.Count); apps.Count);
string destination = Path.Combine(Settings.Current.RepositoryPath, os.Mdid[0].ToString(), AddApp?.Invoke(app);
os.Mdid[1].ToString(), os.Mdid[2].ToString(),
os.Mdid[3].ToString(), os.Mdid[4].ToString(), os.Mdid) +
".zip";
AddOS?.Invoke(os);
counter++; counter++;
} }
#if DEBUG #if DEBUG
stopwatch.Stop(); stopwatch.Stop();
Console.WriteLine("Core.GetAllOSes(): Took {0} seconds to add OSes to the GUI", Console.WriteLine("Core.GetAllApps(): Took {0} seconds to add apps to the GUI",
stopwatch.Elapsed.TotalSeconds); stopwatch.Elapsed.TotalSeconds);
#endif #endif
} }
@@ -99,23 +94,23 @@ namespace apprepodbmgr.Core
#if DEBUG #if DEBUG
stopwatch.Restart(); stopwatch.Restart();
#endif #endif
Dictionary<string, DbOsFile> knownFiles = new Dictionary<string, DbOsFile>(); Dictionary<string, DbAppFile> knownFiles = new Dictionary<string, DbAppFile>();
bool unknownFile = false; bool unknownFile = false;
foreach(KeyValuePair<string, DbOsFile> kvp in Context.Hashes) foreach(KeyValuePair<string, DbAppFile> kvp in Context.Hashes)
{ {
// Empty file with size zero // Empty file with size zero
if(kvp.Value.Sha256 == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") if(kvp.Value.Sha256 == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
{ {
AddFileForOS(kvp.Key, kvp.Value.Sha256, true, kvp.Value.Crack); AddFileForApp(kvp.Key, kvp.Value.Sha256, true, kvp.Value.Crack);
counter++; counter++;
continue; continue;
} }
UpdateProgress?.Invoke(null, "Checking files in database", counter, Context.Hashes.Count); UpdateProgress?.Invoke(null, "Checking files in database", counter, Context.Hashes.Count);
AddFileForOS?.Invoke(kvp.Key, kvp.Value.Sha256, dbCore.DbOps.ExistsFile(kvp.Value.Sha256), AddFileForApp?.Invoke(kvp.Key, kvp.Value.Sha256, dbCore.DbOps.ExistsFile(kvp.Value.Sha256),
kvp.Value.Crack); kvp.Value.Crack);
if(dbCore.DbOps.ExistsFile(kvp.Value.Sha256)) if(dbCore.DbOps.ExistsFile(kvp.Value.Sha256))
@@ -137,37 +132,37 @@ namespace apprepodbmgr.Core
return; return;
} }
UpdateProgress?.Invoke(null, "Retrieving OSes from database", counter, Context.Hashes.Count); UpdateProgress?.Invoke(null, "Retrieving apps from database", counter, Context.Hashes.Count);
dbCore.DbOps.GetAllOSes(out List<DbEntry> oses); dbCore.DbOps.GetAllApps(out List<DbEntry> apps);
#if DEBUG #if DEBUG
stopwatch.Stop(); stopwatch.Stop();
Console.WriteLine("Core.CheckDbForFiles(): Took {0} seconds get all OSes from DB", Console.WriteLine("Core.CheckDbForFiles(): Took {0} seconds get all apps from DB",
stopwatch.Elapsed.TotalSeconds); stopwatch.Elapsed.TotalSeconds);
#endif #endif
if(oses != null && oses.Count > 0) if(apps != null && apps.Count > 0)
{ {
DbEntry[] osesArray = new DbEntry[oses.Count]; DbEntry[] appsArray = new DbEntry[apps.Count];
oses.CopyTo(osesArray); apps.CopyTo(appsArray);
long osCounter = 0; long appCounter = 0;
#if DEBUG #if DEBUG
stopwatch.Restart(); stopwatch.Restart();
#endif #endif
foreach(DbEntry os in osesArray) foreach(DbEntry app in appsArray)
{ {
UpdateProgress?.Invoke(null, $"Check OS id {os.Id}", osCounter, osesArray.Length); UpdateProgress?.Invoke(null, $"Check application id {app.Id}", appCounter, appsArray.Length);
counter = 0; counter = 0;
foreach(KeyValuePair<string, DbOsFile> kvp in knownFiles) foreach(KeyValuePair<string, DbAppFile> kvp in knownFiles)
{ {
UpdateProgress2?.Invoke(null, $"Checking for file {kvp.Value.Path}", counter, UpdateProgress2?.Invoke(null, $"Checking for file {kvp.Value.Path}", counter,
knownFiles.Count); knownFiles.Count);
if(!dbCore.DbOps.ExistsFileInOs(kvp.Value.Sha256, os.Id)) if(!dbCore.DbOps.ExistsFileInApp(kvp.Value.Sha256, app.Id))
{ {
if(oses.Contains(os)) oses.Remove(os); if(apps.Contains(app)) apps.Remove(app);
// If one file is missing, the rest don't matter // If one file is missing, the rest don't matter
break; break;
@@ -176,25 +171,18 @@ namespace apprepodbmgr.Core
counter++; counter++;
} }
if(oses.Count == 0) break; // No OSes left if(apps.Count == 0) break; // No apps left
} }
#if DEBUG #if DEBUG
stopwatch.Stop(); stopwatch.Stop();
Console.WriteLine("Core.CheckDbForFiles(): Took {0} seconds correlate all files with all known OSes", Console.WriteLine("Core.CheckDbForFiles(): Took {0} seconds correlate all files with all known applications",
stopwatch.Elapsed.TotalSeconds); stopwatch.Elapsed.TotalSeconds);
#endif #endif
} }
if(AddOS != null) if(AddApp != null)
foreach(DbEntry os in oses) foreach(DbEntry app in apps)
{ AddApp?.Invoke(app);
string destination = Path.Combine(Settings.Current.RepositoryPath, os.Mdid[0].ToString(),
os.Mdid[1].ToString(), os.Mdid[2].ToString(),
os.Mdid[3].ToString(), os.Mdid[4].ToString(), os.Mdid) +
".zip";
AddOS?.Invoke(os);
}
Finished?.Invoke(); Finished?.Invoke();
} }
@@ -218,7 +206,7 @@ namespace apprepodbmgr.Core
#if DEBUG #if DEBUG
stopwatch.Restart(); stopwatch.Restart();
#endif #endif
foreach(KeyValuePair<string, DbOsFile> kvp in Context.Hashes) foreach(KeyValuePair<string, DbAppFile> kvp in Context.Hashes)
{ {
UpdateProgress?.Invoke(null, "Adding files to database", counter, Context.Hashes.Count); UpdateProgress?.Invoke(null, "Adding files to database", counter, Context.Hashes.Count);
@@ -247,36 +235,36 @@ namespace apprepodbmgr.Core
stopwatch.Elapsed.TotalSeconds); stopwatch.Elapsed.TotalSeconds);
#endif #endif
UpdateProgress?.Invoke(null, "Adding OS information", counter, Context.Hashes.Count); UpdateProgress?.Invoke(null, "Adding application information", counter, Context.Hashes.Count);
dbCore.DbOps.AddOs(Context.DbInfo, out Context.DbInfo.Id); dbCore.DbOps.AddApp(Context.DbInfo, out Context.DbInfo.Id);
UpdateProgress?.Invoke(null, "Creating OS table", counter, Context.Hashes.Count); UpdateProgress?.Invoke(null, "Creating application table", counter, Context.Hashes.Count);
dbCore.DbOps.CreateTableForOs(Context.DbInfo.Id); dbCore.DbOps.CreateTableForApp(Context.DbInfo.Id);
#if DEBUG #if DEBUG
stopwatch.Restart(); stopwatch.Restart();
#endif #endif
counter = 0; counter = 0;
foreach(KeyValuePair<string, DbOsFile> kvp in Context.Hashes) foreach(KeyValuePair<string, DbAppFile> kvp in Context.Hashes)
{ {
UpdateProgress?.Invoke(null, "Adding files to OS in database", counter, Context.Hashes.Count); UpdateProgress?.Invoke(null, "Adding files to application in database", counter, Context.Hashes.Count);
dbCore.DbOps.AddFileToOs(kvp.Value, Context.DbInfo.Id); dbCore.DbOps.AddFileToApp(kvp.Value, Context.DbInfo.Id);
counter++; counter++;
} }
#if DEBUG #if DEBUG
stopwatch.Stop(); stopwatch.Stop();
Console.WriteLine("Core.AddFilesToDb(): Took {0} seconds to add all files to the OS in the database", Console.WriteLine("Core.AddFilesToDb(): Took {0} seconds to add all files to the application in the database",
stopwatch.Elapsed.TotalSeconds); stopwatch.Elapsed.TotalSeconds);
stopwatch.Restart(); stopwatch.Restart();
#endif #endif
counter = 0; counter = 0;
foreach(KeyValuePair<string, DbFolder> kvp in Context.FoldersDict) foreach(KeyValuePair<string, DbFolder> kvp in Context.FoldersDict)
{ {
UpdateProgress?.Invoke(null, "Adding folders to OS in database", counter, UpdateProgress?.Invoke(null, "Adding folders to application in database", counter,
Context.FoldersDict.Count); Context.FoldersDict.Count);
dbCore.DbOps.AddFolderToOs(kvp.Value, Context.DbInfo.Id); dbCore.DbOps.AddFolderToApp(kvp.Value, Context.DbInfo.Id);
counter++; counter++;
} }
@@ -291,10 +279,10 @@ namespace apprepodbmgr.Core
foreach(KeyValuePair<string, string> kvp in Context.SymlinksDict) foreach(KeyValuePair<string, string> kvp in Context.SymlinksDict)
{ {
UpdateProgress?.Invoke(null, "Adding symbolic links to OS in database", counter, UpdateProgress?.Invoke(null, "Adding symbolic links to application in database", counter,
Context.SymlinksDict.Count); Context.SymlinksDict.Count);
dbCore.DbOps.AddSymlinkToOs(kvp.Key, kvp.Value, Context.DbInfo.Id); dbCore.DbOps.AddSymlinkToApp(kvp.Key, kvp.Value, Context.DbInfo.Id);
counter++; counter++;
} }
@@ -377,17 +365,11 @@ namespace apprepodbmgr.Core
dbCore?.CloseDb(); dbCore?.CloseDb();
} }
public static void RemoveOS(long id, string mdid) public static void RemoveApp(long id, string mdid)
{ {
if(id == 0 || string.IsNullOrWhiteSpace(mdid)) return; if(id == 0 || string.IsNullOrWhiteSpace(mdid)) return;
string destination = Path.Combine(Settings.Current.RepositoryPath, mdid[0].ToString(), mdid[1].ToString(), dbCore.DbOps.RemoveApp(id);
mdid[2].ToString(), mdid[3].ToString(), mdid[4].ToString(),
mdid) + ".zip";
if(File.Exists(destination)) File.Delete(destination);
dbCore.DbOps.RemoveOs(id);
} }
public static void GetFilesFromDb() public static void GetFilesFromDb()

View File

@@ -34,11 +34,11 @@ namespace apprepodbmgr.Core
{ {
public delegate void AddFileDelegate(DbFile file); public delegate void AddFileDelegate(DbFile file);
public delegate void AddFileForOSDelegate(string filename, string hash, bool known, bool isCrack); public delegate void AddFileForAppDelegate(string filename, string hash, bool known, bool isCrack);
public delegate void AddFilesDelegate(List<DbFile> file); public delegate void AddFilesDelegate(List<DbFile> file);
public delegate void AddOSDelegate(DbEntry os); public delegate void AddAppDelegate(DbEntry os);
public delegate void FailedDelegate(string text); public delegate void FailedDelegate(string text);
@@ -57,8 +57,8 @@ namespace apprepodbmgr.Core
public static event FailedDelegate Failed; public static event FailedDelegate Failed;
public static event FinishedWithoutErrorDelegate Finished; public static event FinishedWithoutErrorDelegate Finished;
public static event FinishedWithTextDelegate FinishedWithText; public static event FinishedWithTextDelegate FinishedWithText;
public static event AddFileForOSDelegate AddFileForOS; public static event AddFileForAppDelegate AddFileForApp;
public static event AddOSDelegate AddOS; public static event AddAppDelegate AddApp;
public static event AddFileDelegate AddFile; public static event AddFileDelegate AddFile;
public static event AddFilesDelegate AddFiles; public static event AddFilesDelegate AddFiles;
public static event ScanFinishedDelegate ScanFinished; public static event ScanFinishedDelegate ScanFinished;

View File

@@ -106,7 +106,7 @@ namespace apprepodbmgr.Core
{ {
try try
{ {
Context.Hashes = new Dictionary<string, DbOsFile>(); Context.Hashes = new Dictionary<string, DbAppFile>();
Context.FoldersDict = new Dictionary<string, DbFolder>(); Context.FoldersDict = new Dictionary<string, DbFolder>();
Context.SymlinksDict = new Dictionary<string, string>(); Context.SymlinksDict = new Dictionary<string, string>();
List<string> alreadyMetadata = new List<string>(); List<string> alreadyMetadata = new List<string>();
@@ -423,7 +423,7 @@ namespace apprepodbmgr.Core
fileStream.Close(); fileStream.Close();
string hash = Stringify(sha256Context.Final()); string hash = Stringify(sha256Context.Final());
DbOsFile dbFile = new DbOsFile DbAppFile dbFile = new DbAppFile
{ {
Attributes = fi.Attributes, Attributes = fi.Attributes,
CreationTimeUtc = fi.CreationTimeUtc, CreationTimeUtc = fi.CreationTimeUtc,
@@ -695,7 +695,7 @@ namespace apprepodbmgr.Core
UpdateProgress?.Invoke("", "Asking DB for files...", 1, 100); UpdateProgress?.Invoke("", "Asking DB for files...", 1, 100);
dbCore.DbOps.GetAllFilesInOs(out List<DbOsFile> files, Context.DbInfo.Id); dbCore.DbOps.GetAllFilesInApp(out List<DbAppFile> files, Context.DbInfo.Id);
UpdateProgress?.Invoke("", "Asking DB for folders...", 2, 100); UpdateProgress?.Invoke("", "Asking DB for folders...", 2, 100);
@@ -762,7 +762,7 @@ namespace apprepodbmgr.Core
#endif #endif
counter = 4; counter = 4;
foreach(DbOsFile file in files) foreach(DbAppFile file in files)
{ {
UpdateProgress?.Invoke("", $"Creating {file.Path}...", counter, 4 + files.Count); UpdateProgress?.Invoke("", $"Creating {file.Path}...", counter, 4 + files.Count);
@@ -931,7 +931,7 @@ namespace apprepodbmgr.Core
#if DEBUG #if DEBUG
stopwatch.Restart(); stopwatch.Restart();
#endif #endif
dbCore.DbOps.GetAllOSes(out List<DbEntry> oses); dbCore.DbOps.GetAllApps(out List<DbEntry> apps);
#if DEBUG #if DEBUG
stopwatch.Stop(); stopwatch.Stop();
Console.WriteLine("Core.CleanFiles(): Took {0} seconds to get OSes from database", Console.WriteLine("Core.CleanFiles(): Took {0} seconds to get OSes from database",
@@ -954,11 +954,11 @@ namespace apprepodbmgr.Core
#if DEBUG #if DEBUG
stopwatch2.Restart(); stopwatch2.Restart();
#endif #endif
foreach(DbEntry os in oses) foreach(DbEntry app in apps)
{ {
UpdateProgress2?.Invoke(null, $"Checking OS {counterO} of {oses.Count}", counterO, oses.Count); UpdateProgress2?.Invoke(null, $"Checking OS {counterO} of {apps.Count}", counterO, apps.Count);
if(dbCore.DbOps.ExistsFileInOs(file.Sha256, os.Id)) if(dbCore.DbOps.ExistsFileInApp(file.Sha256, app.Id))
{ {
fileExists = true; fileExists = true;
break; break;
@@ -968,7 +968,7 @@ namespace apprepodbmgr.Core
} }
#if DEBUG #if DEBUG
stopwatch2.Stop(); stopwatch2.Stop();
Console.WriteLine("Core.CleanFiles(): Took {0} seconds to check file in all OSes", Console.WriteLine("Core.CleanFiles(): Took {0} seconds to check file in all applications",
stopwatch2.Elapsed.TotalSeconds); stopwatch2.Elapsed.TotalSeconds);
#endif #endif

View File

@@ -102,8 +102,8 @@
<TabPage Text="Files"> <TabPage Text="Files">
<GridView ID="treeFiles" SelectionChanged="treeFilesSelectionChanged" /> <GridView ID="treeFiles" SelectionChanged="treeFilesSelectionChanged" />
</TabPage> </TabPage>
<TabPage Text="OSes" ID="tabOSes" Visible="False"> <TabPage Text="Applications" ID="tabApps" Visible="False">
<GridView ID="treeOSes" /> <GridView ID="treeApps" />
</TabPage> </TabPage>
</TabControl> </TabControl>
</StackLayoutItem> </StackLayoutItem>

View File

@@ -44,11 +44,11 @@ namespace apprepodbmgr.Eto
{ {
public class dlgAdd : Dialog public class dlgAdd : Dialog
{ {
public delegate void OnAddedOSDelegate(DbEntry os); public delegate void OnAddedAppDelegate(DbEntry app);
ObservableCollection<FileEntry> fileView; ObservableCollection<FileEntry> fileView;
int knownFiles; int knownFiles;
ObservableCollection<DBEntryForEto> osView; ObservableCollection<DBEntryForEto> appView;
bool stopped; bool stopped;
Thread thdAddFiles; Thread thdAddFiles;
Thread thdCheckFiles; Thread thdCheckFiles;
@@ -98,85 +98,85 @@ namespace apprepodbmgr.Eto
e.BackgroundColor = ((FileEntry)e.Item).Known ? Colors.Green : Colors.Red; e.BackgroundColor = ((FileEntry)e.Item).Known ? Colors.Green : Colors.Red;
}; };
osView = new ObservableCollection<DBEntryForEto>(); appView = new ObservableCollection<DBEntryForEto>();
treeOSes.DataStore = osView; treeApps.DataStore = appView;
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.developer)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.developer)},
HeaderText = "Developer" HeaderText = "Developer"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.product)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.product)},
HeaderText = "Product" HeaderText = "Product"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.version)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.version)},
HeaderText = "Version" HeaderText = "Version"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.languages)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.languages)},
HeaderText = "Languages" HeaderText = "Languages"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.architecture)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.architecture)},
HeaderText = "Architecture" HeaderText = "Architecture"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.machine)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.machine)},
HeaderText = "Machine" HeaderText = "Machine"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.format)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.format)},
HeaderText = "Format" HeaderText = "Format"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.description)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.description)},
HeaderText = "Description" HeaderText = "Description"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.oem)}, DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.oem)},
HeaderText = "OEM?" HeaderText = "OEM?"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.upgrade)}, DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.upgrade)},
HeaderText = "Upgrade?" HeaderText = "Upgrade?"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.update)}, DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.update)},
HeaderText = "Update?" HeaderText = "Update?"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.source)}, DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.source)},
HeaderText = "Source?" HeaderText = "Source?"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.files)}, DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.files)},
HeaderText = "Files?" HeaderText = "Files?"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.netinstall)}, DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.netinstall)},
HeaderText = "NetInstall?" HeaderText = "NetInstall?"
}); });
treeOSes.AllowMultipleSelection = false; treeApps.AllowMultipleSelection = false;
} }
public event OnAddedOSDelegate OnAddedOS; public event OnAddedAppDelegate OnAddedApp;
void UnarChangeStatus() void UnarChangeStatus()
{ {
@@ -293,8 +293,8 @@ namespace apprepodbmgr.Eto
Workers.Finished += ChkFilesFinished; Workers.Finished += ChkFilesFinished;
Workers.UpdateProgress += UpdateProgress; Workers.UpdateProgress += UpdateProgress;
Workers.UpdateProgress2 += UpdateProgress2; Workers.UpdateProgress2 += UpdateProgress2;
Workers.AddFileForOS += AddFile; Workers.AddFileForApp += AddFile;
Workers.AddOS += AddOs; Workers.AddApp += AddApp;
thdCheckFiles.Start(); thdCheckFiles.Start();
}); });
} }
@@ -312,15 +312,15 @@ namespace apprepodbmgr.Eto
Workers.Finished -= ChkFilesFinished; Workers.Finished -= ChkFilesFinished;
Workers.UpdateProgress -= UpdateProgress; Workers.UpdateProgress -= UpdateProgress;
Workers.UpdateProgress2 -= UpdateProgress2; Workers.UpdateProgress2 -= UpdateProgress2;
Workers.AddFileForOS -= AddFile; Workers.AddFileForApp -= AddFile;
Workers.AddOS -= AddOs; Workers.AddApp -= AddApp;
thdCheckFiles?.Abort(); thdCheckFiles?.Abort();
thdHashFiles = null; thdHashFiles = null;
fileView?.Clear(); fileView?.Clear();
if(osView == null) return; if(appView == null) return;
tabOSes.Visible = false; tabApps.Visible = false;
osView.Clear(); appView.Clear();
}); });
} }
@@ -332,8 +332,8 @@ namespace apprepodbmgr.Eto
Workers.Finished -= ChkFilesFinished; Workers.Finished -= ChkFilesFinished;
Workers.UpdateProgress -= UpdateProgress; Workers.UpdateProgress -= UpdateProgress;
Workers.UpdateProgress2 -= UpdateProgress2; Workers.UpdateProgress2 -= UpdateProgress2;
Workers.AddFileForOS -= AddFile; Workers.AddFileForApp -= AddFile;
Workers.AddOS -= AddOs; Workers.AddApp -= AddApp;
thdCheckFiles?.Abort(); thdCheckFiles?.Abort();
@@ -418,12 +418,12 @@ namespace apprepodbmgr.Eto
}); });
} }
void AddOs(DbEntry os) void AddApp(DbEntry app)
{ {
Application.Instance.Invoke(delegate Application.Instance.Invoke(delegate
{ {
tabOSes.Visible = true; tabApps.Visible = true;
osView.Add(new DBEntryForEto(os)); appView.Add(new DBEntryForEto(app));
}); });
} }
@@ -447,10 +447,10 @@ namespace apprepodbmgr.Eto
btnRemoveFile.Visible = false; btnRemoveFile.Visible = false;
btnToggleCrack.Visible = false; btnToggleCrack.Visible = false;
fileView?.Clear(); fileView?.Clear();
if(osView != null) if(appView != null)
{ {
tabOSes.Visible = false; tabApps.Visible = false;
osView.Clear(); appView.Clear();
} }
txtFormat.ReadOnly = true; txtFormat.ReadOnly = true;
@@ -560,8 +560,8 @@ namespace apprepodbmgr.Eto
{ {
stopped = true; stopped = true;
Workers.AddFileForOS -= AddFile; Workers.AddFileForApp -= AddFile;
Workers.AddOS -= AddOs; Workers.AddApp -= AddApp;
Workers.Failed -= AddFilesToDbFailed; Workers.Failed -= AddFilesToDbFailed;
Workers.Failed -= ChkFilesFailed; Workers.Failed -= ChkFilesFailed;
Workers.Failed -= ExtractArchiveFailed; Workers.Failed -= ExtractArchiveFailed;
@@ -670,10 +670,10 @@ namespace apprepodbmgr.Eto
Workers.UpdateProgress2 -= UpdateProgress2; Workers.UpdateProgress2 -= UpdateProgress2;
btnStop.Visible = false; btnStop.Visible = false;
fileView?.Clear(); fileView?.Clear();
if(osView == null) return; if(appView == null) return;
tabOSes.Visible = false; tabApps.Visible = false;
osView.Clear(); appView.Clear();
} }
void RemoveTempFilesFailed(string text) void RemoveTempFilesFailed(string text)
@@ -776,16 +776,16 @@ namespace apprepodbmgr.Eto
long counter = 0; long counter = 0;
fileView.Clear(); fileView.Clear();
foreach(KeyValuePair<string, DbOsFile> kvp in Context.Hashes) foreach(KeyValuePair<string, DbAppFile> kvp in Context.Hashes)
{ {
UpdateProgress(null, "Updating table", counter, Context.Hashes.Count); UpdateProgress(null, "Updating table", counter, Context.Hashes.Count);
fileView.Add(new FileEntry {Path = kvp.Key, Hash = kvp.Value.Sha256, Known = true}); fileView.Add(new FileEntry {Path = kvp.Key, Hash = kvp.Value.Sha256, Known = true});
counter++; counter++;
} }
// TODO: Update OS table // TODO: Update application table
OnAddedOS?.Invoke(Context.DbInfo); OnAddedApp?.Invoke(Context.DbInfo);
lblProgress.Visible = false; lblProgress.Visible = false;
prgProgress.Visible = false; prgProgress.Visible = false;
@@ -1118,14 +1118,14 @@ namespace apprepodbmgr.Eto
string name = ((FileEntry)treeFiles.SelectedItem).Path; string name = ((FileEntry)treeFiles.SelectedItem).Path;
bool known = ((FileEntry)treeFiles.SelectedItem).Known; bool known = ((FileEntry)treeFiles.SelectedItem).Known;
if(!Context.Hashes.TryGetValue(name, out DbOsFile osfile)) return; if(!Context.Hashes.TryGetValue(name, out DbAppFile appFile)) return;
osfile.Crack = !osfile.Crack; appFile.Crack = !appFile.Crack;
Context.Hashes.Remove(name); Context.Hashes.Remove(name);
Context.Hashes.Add(name, osfile); Context.Hashes.Add(name, appFile);
((FileEntry)treeFiles.SelectedItem).IsCrack = osfile.Crack; ((FileEntry)treeFiles.SelectedItem).IsCrack = appFile.Crack;
fileView.Remove((FileEntry)treeFiles.SelectedItem); fileView.Remove((FileEntry)treeFiles.SelectedItem);
fileView.Add(new FileEntry {Path = name, Hash = osfile.Sha256, Known = known, IsCrack = osfile.Crack}); fileView.Add(new FileEntry {Path = name, Hash = appFile.Sha256, Known = known, IsCrack = appFile.Crack});
} }
void treeFilesSelectionChanged(object sender, EventArgs e) void treeFilesSelectionChanged(object sender, EventArgs e)
@@ -1160,8 +1160,8 @@ namespace apprepodbmgr.Eto
CheckBox chkSource; CheckBox chkSource;
CheckBox chkNetinstall; CheckBox chkNetinstall;
GridView treeFiles; GridView treeFiles;
TabPage tabOSes; TabPage tabApps;
GridView treeOSes; GridView treeApps;
Label lblProgress; Label lblProgress;
ProgressBar prgProgress; ProgressBar prgProgress;
Label lblProgress2; Label lblProgress2;

View File

@@ -208,7 +208,7 @@ namespace apprepodbmgr.Eto
void FillFilesCombos() void FillFilesCombos()
{ {
foreach(KeyValuePair<string, DbOsFile> files in Context.Hashes) lstFilesForMedia.Add(files.Key); foreach(KeyValuePair<string, DbAppFile> files in Context.Hashes) lstFilesForMedia.Add(files.Key);
} }
public void FillFields() public void FillFields()

View File

@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Form xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="365" Width="612" Title="App Repository DB Manager"> <Form xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="365" Width="612" Title="App Repository DB Manager">
<TabControl> <TabControl>
<TabPage Text="Operating systems" ID="tabOSes"> <TabPage Text="Operating systems" ID="tabApps">
<StackLayout Orientation="Vertical"> <StackLayout Orientation="Vertical">
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch"> <StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
<GridView ID="treeOSes" Enabled="False" /> <GridView ID="treeApps" Enabled="False" />
</StackLayoutItem> </StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Center"> <StackLayoutItem HorizontalAlignment="Center">
<Label ID="lblOSStatus" Visible="False">lblOSStatus</Label> <Label ID="lblAppStatus" Visible="False">lblAppStatus</Label>
</StackLayoutItem> </StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch"> <StackLayoutItem HorizontalAlignment="Stretch">
<Label ID="lblProgress">lblProgress</Label> <Label ID="lblProgress">lblProgress</Label>

View File

@@ -42,14 +42,14 @@ namespace apprepodbmgr.Eto
int infectedFiles; int infectedFiles;
ObservableCollection<DbFile> lstFiles; ObservableCollection<DbFile> lstFiles;
ObservableCollection<DBEntryForEto> lstOSes; ObservableCollection<DBEntryForEto> lstApps;
DbFile outIter; DbFile outIter;
bool populatingFiles; bool populatingFiles;
bool scanningFiles; bool scanningFiles;
Thread thdCleanFiles; Thread thdCleanFiles;
Thread thdCompressTo; Thread thdCompressTo;
Thread thdPopulateFiles; Thread thdPopulateFiles;
Thread thdPopulateOSes; Thread thdPopulateApps;
Thread thdSaveAs; Thread thdSaveAs;
Thread thdScanFile; Thread thdScanFile;
@@ -59,81 +59,81 @@ namespace apprepodbmgr.Eto
Workers.InitDB(); Workers.InitDB();
lstOSes = new ObservableCollection<DBEntryForEto>(); lstApps = new ObservableCollection<DBEntryForEto>();
treeOSes.DataStore = lstOSes; treeApps.DataStore = lstApps;
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.developer)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.developer)},
HeaderText = "Developer" HeaderText = "Developer"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.product)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.product)},
HeaderText = "Product" HeaderText = "Product"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.version)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.version)},
HeaderText = "Version" HeaderText = "Version"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.languages)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.languages)},
HeaderText = "Languages" HeaderText = "Languages"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.architecture)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.architecture)},
HeaderText = "Architecture" HeaderText = "Architecture"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.machine)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.machine)},
HeaderText = "Machine" HeaderText = "Machine"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.format)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.format)},
HeaderText = "Format" HeaderText = "Format"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.description)}, DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.description)},
HeaderText = "Description" HeaderText = "Description"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.oem)}, DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.oem)},
HeaderText = "OEM?" HeaderText = "OEM?"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.upgrade)}, DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.upgrade)},
HeaderText = "Upgrade?" HeaderText = "Upgrade?"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.update)}, DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.update)},
HeaderText = "Update?" HeaderText = "Update?"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.source)}, DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.source)},
HeaderText = "Source?" HeaderText = "Source?"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.files)}, DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.files)},
HeaderText = "Files?" HeaderText = "Files?"
}); });
treeOSes.Columns.Add(new GridColumn treeApps.Columns.Add(new GridColumn
{ {
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.netinstall)}, DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.netinstall)},
HeaderText = "NetInstall?" HeaderText = "NetInstall?"
}); });
treeOSes.AllowMultipleSelection = false; treeApps.AllowMultipleSelection = false;
lstFiles = new ObservableCollection<DbFile>(); lstFiles = new ObservableCollection<DbFile>();
@@ -206,60 +206,60 @@ namespace apprepodbmgr.Eto
mnuCompress.Enabled = false; mnuCompress.Enabled = false;
} }
Workers.Failed += LoadOSesFailed; Workers.Failed += LoadAppsFailed;
Workers.Finished += LoadOSesFinished; Workers.Finished += LoadAppsFinished;
Workers.UpdateProgress += UpdateProgress; Workers.UpdateProgress += UpdateProgress;
Workers.AddOS += AddOs; Workers.AddApp += AddApp;
Workers.AddFile += AddFile; Workers.AddFile += AddFile;
Workers.AddFiles += AddFiles; Workers.AddFiles += AddFiles;
thdPopulateOSes = new Thread(Workers.GetAllOSes); thdPopulateApps = new Thread(Workers.GetAllApps);
thdPopulateOSes.Start(); thdPopulateApps.Start();
} }
void LoadOSesFailed(string text) void LoadAppsFailed(string text)
{ {
Application.Instance.Invoke(delegate Application.Instance.Invoke(delegate
{ {
MessageBox.Show($"Error {text} when populating OSes file, exiting...", MessageBoxButtons.OK, MessageBox.Show($"Error {text} when populating applications, exiting...", MessageBoxButtons.OK,
MessageBoxType.Error, MessageBoxDefaultButton.OK); MessageBoxType.Error, MessageBoxDefaultButton.OK);
if(thdPopulateOSes != null) if(thdPopulateApps != null)
{ {
thdPopulateOSes.Abort(); thdPopulateApps.Abort();
thdPopulateOSes = null; thdPopulateApps = null;
} }
Workers.Failed -= LoadOSesFailed; Workers.Failed -= LoadAppsFailed;
Workers.Finished -= LoadOSesFinished; Workers.Finished -= LoadAppsFinished;
Workers.UpdateProgress -= UpdateProgress; Workers.UpdateProgress -= UpdateProgress;
Application.Instance.Quit(); Application.Instance.Quit();
}); });
} }
void LoadOSesFinished() void LoadAppsFinished()
{ {
Application.Instance.Invoke(delegate Application.Instance.Invoke(delegate
{ {
Workers.Failed -= LoadOSesFailed; Workers.Failed -= LoadAppsFailed;
Workers.Finished -= LoadOSesFinished; Workers.Finished -= LoadAppsFinished;
Workers.UpdateProgress -= UpdateProgress; Workers.UpdateProgress -= UpdateProgress;
Workers.AddOS -= AddOs; Workers.AddApp -= AddApp;
if(thdPopulateOSes != null) if(thdPopulateApps != null)
{ {
thdPopulateOSes.Abort(); thdPopulateApps.Abort();
thdPopulateOSes = null; thdPopulateApps = null;
} }
lblProgress.Visible = false; lblProgress.Visible = false;
prgProgress.Visible = false; prgProgress.Visible = false;
treeOSes.Enabled = true; treeApps.Enabled = true;
btnAdd.Visible = true; btnAdd.Visible = true;
btnRemove.Visible = true; btnRemove.Visible = true;
btnCompress.Visible = Context.UsableDotNetZip; btnCompress.Visible = Context.UsableDotNetZip;
btnSave.Visible = true; btnSave.Visible = true;
btnHelp.Enabled = true; btnHelp.Enabled = true;
btnSettings.Enabled = true; btnSettings.Enabled = true;
lblOSStatus.Visible = true; lblAppStatus.Visible = true;
lblOSStatus.Text = $"{lstOSes.Count} operating systems"; lblAppStatus.Text = $"{lstApps.Count} applications";
}); });
} }
@@ -319,43 +319,43 @@ namespace apprepodbmgr.Eto
}); });
} }
void AddOs(DbEntry os) void AddApp(DbEntry app)
{ {
Application.Instance.Invoke(delegate { lstOSes.Add(new DBEntryForEto(os)); }); Application.Instance.Invoke(delegate { lstApps.Add(new DBEntryForEto(app)); });
} }
protected void OnBtnAddClicked(object sender, EventArgs e) protected void OnBtnAddClicked(object sender, EventArgs e)
{ {
dlgAdd dlgAdd = new dlgAdd(); dlgAdd dlgAdd = new dlgAdd();
dlgAdd.OnAddedOS += os => { lstOSes.Add(new DBEntryForEto(os)); }; dlgAdd.OnAddedApp += app => { lstApps.Add(new DBEntryForEto(app)); };
dlgAdd.ShowModal(this); dlgAdd.ShowModal(this);
} }
protected void OnBtnRemoveClicked(object sender, EventArgs e) protected void OnBtnRemoveClicked(object sender, EventArgs e)
{ {
if(treeOSes.SelectedItem == null) return; if(treeApps.SelectedItem == null) return;
if(MessageBox.Show("Are you sure you want to remove the selected OS?", MessageBoxButtons.YesNo, if(MessageBox.Show("Are you sure you want to remove the selected application?", MessageBoxButtons.YesNo,
MessageBoxType.Question, MessageBoxDefaultButton.No) != DialogResult.Yes) return; MessageBoxType.Question, MessageBoxDefaultButton.No) != DialogResult.Yes) return;
Workers.RemoveOS(((DBEntryForEto)treeOSes.SelectedItem).id, ((DBEntryForEto)treeOSes.SelectedItem).mdid); Workers.RemoveApp(((DBEntryForEto)treeApps.SelectedItem).id, ((DBEntryForEto)treeApps.SelectedItem).mdid);
lstOSes.Remove((DBEntryForEto)treeOSes.SelectedItem); lstApps.Remove((DBEntryForEto)treeApps.SelectedItem);
} }
protected void OnBtnSaveClicked(object sender, EventArgs e) protected void OnBtnSaveClicked(object sender, EventArgs e)
{ {
if(treeOSes.SelectedItem == null) return; if(treeApps.SelectedItem == null) return;
SelectFolderDialog dlgFolder = new SelectFolderDialog {Title = "Save to..."}; SelectFolderDialog dlgFolder = new SelectFolderDialog {Title = "Save to..."};
if(dlgFolder.ShowDialog(this) != DialogResult.Ok) return; if(dlgFolder.ShowDialog(this) != DialogResult.Ok) return;
Context.DbInfo.Id = ((DBEntryForEto)treeOSes.SelectedItem).id; Context.DbInfo.Id = ((DBEntryForEto)treeApps.SelectedItem).id;
Context.Path = dlgFolder.Directory; Context.Path = dlgFolder.Directory;
lblProgress.Visible = true; lblProgress.Visible = true;
prgProgress.Visible = true; prgProgress.Visible = true;
lblProgress2.Visible = true; lblProgress2.Visible = true;
prgProgress2.Visible = true; prgProgress2.Visible = true;
treeOSes.Enabled = false; treeApps.Enabled = false;
btnAdd.Visible = false; btnAdd.Visible = false;
btnRemove.Visible = false; btnRemove.Visible = false;
btnCompress.Visible = false; btnCompress.Visible = false;
@@ -382,7 +382,7 @@ namespace apprepodbmgr.Eto
prgProgress.Visible = false; prgProgress.Visible = false;
lblProgress2.Visible = false; lblProgress2.Visible = false;
prgProgress2.Visible = false; prgProgress2.Visible = false;
treeOSes.Enabled = true; treeApps.Enabled = true;
btnAdd.Visible = true; btnAdd.Visible = true;
btnRemove.Visible = true; btnRemove.Visible = true;
btnCompress.Visible = Context.UsableDotNetZip; btnCompress.Visible = Context.UsableDotNetZip;
@@ -414,7 +414,7 @@ namespace apprepodbmgr.Eto
prgProgress.Visible = false; prgProgress.Visible = false;
lblProgress2.Visible = false; lblProgress2.Visible = false;
prgProgress2.Visible = false; prgProgress2.Visible = false;
treeOSes.Enabled = true; treeApps.Enabled = true;
btnAdd.Visible = true; btnAdd.Visible = true;
btnRemove.Visible = true; btnRemove.Visible = true;
btnCompress.Visible = Context.UsableDotNetZip; btnCompress.Visible = Context.UsableDotNetZip;
@@ -459,26 +459,26 @@ namespace apprepodbmgr.Eto
protected void OnBtnStopClicked(object sender, EventArgs e) protected void OnBtnStopClicked(object sender, EventArgs e)
{ {
Workers.AddOS -= AddOs; Workers.AddApp -= AddApp;
Workers.Failed -= CompressToFailed; Workers.Failed -= CompressToFailed;
Workers.Failed -= LoadOSesFailed; Workers.Failed -= LoadAppsFailed;
Workers.Failed -= SaveAsFailed; Workers.Failed -= SaveAsFailed;
Workers.Finished -= CompressToFinished; Workers.Finished -= CompressToFinished;
Workers.Finished -= LoadOSesFinished; Workers.Finished -= LoadAppsFinished;
Workers.Finished -= SaveAsFinished; Workers.Finished -= SaveAsFinished;
Workers.UpdateProgress -= UpdateProgress; Workers.UpdateProgress -= UpdateProgress;
Workers.UpdateProgress2 -= UpdateProgress2; Workers.UpdateProgress2 -= UpdateProgress2;
if(thdPopulateOSes != null) if(thdPopulateApps != null)
{ {
thdPopulateOSes.Abort(); thdPopulateApps.Abort();
thdPopulateOSes = null; thdPopulateApps = null;
} }
if(thdCompressTo != null) if(thdCompressTo != null)
{ {
thdPopulateOSes.Abort(); thdPopulateApps.Abort();
thdPopulateOSes = null; thdPopulateApps = null;
} }
if(thdSaveAs == null) return; if(thdSaveAs == null) return;
@@ -494,20 +494,20 @@ namespace apprepodbmgr.Eto
protected void OnBtnCompressClicked(object sender, EventArgs e) protected void OnBtnCompressClicked(object sender, EventArgs e)
{ {
if(treeOSes.SelectedItem == null) return; if(treeApps.SelectedItem == null) return;
SaveFileDialog dlgFile = new SaveFileDialog {Title = "Compress to..."}; SaveFileDialog dlgFile = new SaveFileDialog {Title = "Compress to..."};
if(dlgFile.ShowDialog(this) != DialogResult.Ok) return; if(dlgFile.ShowDialog(this) != DialogResult.Ok) return;
Context.DbInfo.Id = ((DBEntryForEto)treeOSes.SelectedItem).id; Context.DbInfo.Id = ((DBEntryForEto)treeApps.SelectedItem).id;
Context.Path = dlgFile.FileName; Context.Path = dlgFile.FileName;
lblProgress.Visible = true; lblProgress.Visible = true;
prgProgress.Visible = true; prgProgress.Visible = true;
lblProgress2.Visible = true; lblProgress2.Visible = true;
prgProgress2.Visible = true; prgProgress2.Visible = true;
treeOSes.Enabled = false; treeApps.Enabled = false;
btnAdd.Visible = false; btnAdd.Visible = false;
btnRemove.Visible = false; btnRemove.Visible = false;
btnCompress.Visible = false; btnCompress.Visible = false;
@@ -533,7 +533,7 @@ namespace apprepodbmgr.Eto
lblProgress2.Visible = false; lblProgress2.Visible = false;
prgProgress.Visible = false; prgProgress.Visible = false;
prgProgress2.Visible = false; prgProgress2.Visible = false;
treeOSes.Enabled = true; treeApps.Enabled = true;
btnAdd.Visible = true; btnAdd.Visible = true;
btnRemove.Visible = true; btnRemove.Visible = true;
btnCompress.Visible = Context.UsableDotNetZip; btnCompress.Visible = Context.UsableDotNetZip;
@@ -565,7 +565,7 @@ namespace apprepodbmgr.Eto
lblProgress2.Visible = false; lblProgress2.Visible = false;
prgProgress.Visible = false; prgProgress.Visible = false;
prgProgress2.Visible = false; prgProgress2.Visible = false;
treeOSes.Enabled = true; treeApps.Enabled = true;
btnAdd.Visible = true; btnAdd.Visible = true;
btnRemove.Visible = true; btnRemove.Visible = true;
btnCompress.Visible = Context.UsableDotNetZip; btnCompress.Visible = Context.UsableDotNetZip;
@@ -794,7 +794,7 @@ namespace apprepodbmgr.Eto
protected void OnBtnPopulateFilesClicked(object sender, EventArgs e) protected void OnBtnPopulateFilesClicked(object sender, EventArgs e)
{ {
lstFiles.Clear(); lstFiles.Clear();
tabOSes.Enabled = false; tabApps.Enabled = false;
btnStopFiles.Visible = true; btnStopFiles.Visible = true;
btnPopulateFiles.Visible = false; btnPopulateFiles.Visible = false;
@@ -908,7 +908,7 @@ namespace apprepodbmgr.Eto
thdPopulateFiles = null; thdPopulateFiles = null;
} }
tabOSes.Enabled = true; tabApps.Enabled = true;
lstFiles.Clear(); lstFiles.Clear();
btnStopFiles.Visible = false; btnStopFiles.Visible = false;
btnPopulateFiles.Visible = true; btnPopulateFiles.Visible = true;
@@ -941,7 +941,7 @@ namespace apprepodbmgr.Eto
btnPopulateFiles.Visible = false; btnPopulateFiles.Visible = false;
populatingFiles = false; populatingFiles = false;
treeFiles.Enabled = true; treeFiles.Enabled = true;
tabOSes.Enabled = true; tabApps.Enabled = true;
btnScanAllPending.Visible = true; btnScanAllPending.Visible = true;
btnCleanFiles.Visible = true; btnCleanFiles.Visible = true;
lblFileStatus.Visible = true; lblFileStatus.Visible = true;
@@ -1012,7 +1012,7 @@ namespace apprepodbmgr.Eto
protected void OnBtnCleanFilesClicked(object sender, EventArgs e) protected void OnBtnCleanFilesClicked(object sender, EventArgs e)
{ {
DialogResult result = DialogResult result =
MessageBox.Show("This option will search the database for any known file that doesn't\n" + "belong to any OS and remove it from the database.\n\n" + "It will then search the repository for any file not on the database and remove it.\n\n" + "THIS OPERATION MAY VERY LONG, CANNOT BE CANCELED AND REMOVES DATA ON DISK.\n\n" + "Are you sure to continue?", MessageBox.Show("This option will search the database for any known file that doesn't\n" + "belong to any application and remove it from the database.\n\n" + "It will then search the repository for any file not on the database and remove it.\n\n" + "THIS OPERATION MAY VERY LONG, CANNOT BE CANCELED AND REMOVES DATA ON DISK.\n\n" + "Are you sure to continue?",
MessageBoxButtons.YesNo, MessageBoxType.Question); MessageBoxButtons.YesNo, MessageBoxType.Question);
if(result != DialogResult.Yes) return; if(result != DialogResult.Yes) return;
@@ -1021,7 +1021,7 @@ namespace apprepodbmgr.Eto
btnScanWithClamd.Visible = false; btnScanWithClamd.Visible = false;
btnScanAllPending.Visible = false; btnScanAllPending.Visible = false;
btnCheckInVirusTotal.Visible = false; btnCheckInVirusTotal.Visible = false;
tabOSes.Enabled = false; tabApps.Enabled = false;
treeFiles.Enabled = false; treeFiles.Enabled = false;
lblProgressFiles1.Visible = true; lblProgressFiles1.Visible = true;
lblProgressFiles2.Visible = true; lblProgressFiles2.Visible = true;
@@ -1052,7 +1052,7 @@ namespace apprepodbmgr.Eto
btnScanWithClamd.Visible = true; btnScanWithClamd.Visible = true;
btnScanAllPending.Visible = true; btnScanAllPending.Visible = true;
btnCheckInVirusTotal.Visible = true; btnCheckInVirusTotal.Visible = true;
tabOSes.Enabled = true; tabApps.Enabled = true;
treeFiles.Enabled = true; treeFiles.Enabled = true;
Workers.Finished -= CleanFilesFinished; Workers.Finished -= CleanFilesFinished;
Workers.UpdateProgress -= UpdateFileProgress; Workers.UpdateProgress -= UpdateFileProgress;
@@ -1074,7 +1074,7 @@ namespace apprepodbmgr.Eto
#region XAML UI elements #region XAML UI elements
#pragma warning disable 0649 #pragma warning disable 0649
GridView treeOSes; GridView treeApps;
Label lblProgress; Label lblProgress;
ProgressBar prgProgress; ProgressBar prgProgress;
Label lblProgress2; Label lblProgress2;
@@ -1097,12 +1097,12 @@ namespace apprepodbmgr.Eto
Button btnScanWithClamd; Button btnScanWithClamd;
Button btnCheckInVirusTotal; Button btnCheckInVirusTotal;
Button btnPopulateFiles; Button btnPopulateFiles;
TabPage tabOSes; TabPage tabApps;
Button btnScanAllPending; Button btnScanAllPending;
Button btnCleanFiles; Button btnCleanFiles;
ButtonMenuItem btnQuit; ButtonMenuItem btnQuit;
ButtonMenuItem mnuFile; ButtonMenuItem mnuFile;
Label lblOSStatus; Label lblAppStatus;
Label lblFileStatus; Label lblFileStatus;
#pragma warning restore 0649 #pragma warning restore 0649
#endregion XAML UI elements #endregion XAML UI elements