mirror of
https://github.com/claunia/apprepodbmgr.git
synced 2025-12-16 19:24:42 +00:00
Rename all instances of os and oses to app and apps.
This commit is contained in:
12
.idea/.idea.apprepodbmgr/.idea/contentModel.xml
generated
12
.idea/.idea.apprepodbmgr/.idea/contentModel.xml
generated
@@ -597,17 +597,7 @@
|
||||
<e p="obj" t="ExcludeRecursive" />
|
||||
<e p="packages.config" t="Include" />
|
||||
</e>
|
||||
<e p="apprepodbmgr.Eto.XamMac2" 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.Eto.XamMac2/apprepodbmgr.Eto.XamMac2.csproj" t="IncludeRecursive" />
|
||||
<e p="apprepodbmgr.sln" t="IncludeFlat" />
|
||||
<e p="packages" t="ExcludeRecursive" />
|
||||
</e>
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace apprepodbmgr.Core
|
||||
public static List<string> Files;
|
||||
public static List<string> Folders;
|
||||
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, string> SymlinksDict;
|
||||
public static string Path;
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace apprepodbmgr.Core
|
||||
public long Length { get; set; }
|
||||
}
|
||||
|
||||
public struct DbOsFile
|
||||
public struct DbAppFile
|
||||
{
|
||||
public ulong Id;
|
||||
public string Path;
|
||||
@@ -101,11 +101,11 @@ namespace apprepodbmgr.Core
|
||||
dbCore = core;
|
||||
}
|
||||
|
||||
public bool GetAllOSes(out List<DbEntry> entries)
|
||||
public bool GetAllApps(out List<DbEntry> entries)
|
||||
{
|
||||
entries = new List<DbEntry>();
|
||||
|
||||
const string SQL = "SELECT * from oses";
|
||||
const string SQL = "SELECT * from apps";
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -145,7 +145,7 @@ namespace apprepodbmgr.Core
|
||||
return true;
|
||||
}
|
||||
|
||||
IDbCommand GetOsCommand(DbEntry entry)
|
||||
IDbCommand GetAppCommand(DbEntry entry)
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
|
||||
@@ -241,14 +241,14 @@ namespace apprepodbmgr.Core
|
||||
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();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
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)";
|
||||
|
||||
dbcmd.CommandText = SQL;
|
||||
@@ -501,7 +501,7 @@ namespace apprepodbmgr.Core
|
||||
return true;
|
||||
}
|
||||
|
||||
IDbCommand GetOsFileCommand(DbOsFile person)
|
||||
IDbCommand GetAppFileCommand(DbAppFile person)
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
|
||||
@@ -548,14 +548,14 @@ namespace apprepodbmgr.Core
|
||||
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();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
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)";
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
@@ -567,7 +567,7 @@ namespace apprepodbmgr.Core
|
||||
return true;
|
||||
}
|
||||
|
||||
IDbCommand GetFolderCommand(DbFolder person)
|
||||
IDbCommand GetFolderCommand(DbFolder folder)
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
|
||||
@@ -589,11 +589,11 @@ namespace apprepodbmgr.Core
|
||||
param6.DbType = DbType.String;
|
||||
param7.DbType = DbType.Int32;
|
||||
|
||||
param1.Value = person.Path;
|
||||
param4.Value = person.CreationTimeUtc.ToString("yyyy-MM-dd HH:mm");
|
||||
param5.Value = person.LastAccessTimeUtc.ToString("yyyy-MM-dd HH:mm");
|
||||
param6.Value = person.LastWriteTimeUtc.ToString("yyyy-MM-dd HH:mm");
|
||||
param7.Value = (int)person.Attributes;
|
||||
param1.Value = folder.Path;
|
||||
param4.Value = folder.CreationTimeUtc.ToString("yyyy-MM-dd HH:mm");
|
||||
param5.Value = folder.LastAccessTimeUtc.ToString("yyyy-MM-dd HH:mm");
|
||||
param6.Value = folder.LastWriteTimeUtc.ToString("yyyy-MM-dd HH:mm");
|
||||
param7.Value = (int)folder.Attributes;
|
||||
|
||||
dbcmd.Parameters.Add(param1);
|
||||
dbcmd.Parameters.Add(param4);
|
||||
@@ -604,86 +604,32 @@ namespace apprepodbmgr.Core
|
||||
return dbcmd;
|
||||
}
|
||||
|
||||
public bool AddFolderToOs(DbFolder folder, long os)
|
||||
public bool AddFolderToApp(DbFolder folder, long app)
|
||||
{
|
||||
IDbCommand dbcmd = GetFolderCommand(folder);
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
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.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);",
|
||||
id);
|
||||
$"INSERT INTO `app_{app}_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 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;
|
||||
|
||||
@@ -695,9 +641,31 @@ namespace apprepodbmgr.Core
|
||||
trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
sql =
|
||||
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);
|
||||
sql = $"DROP TABLE IF EXISTS `app_{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 `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;
|
||||
|
||||
@@ -708,7 +676,56 @@ namespace apprepodbmgr.Core
|
||||
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();
|
||||
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||
@@ -717,7 +734,7 @@ namespace apprepodbmgr.Core
|
||||
param1.DbType = DbType.String;
|
||||
param1.Value = hash;
|
||||
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();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dataAdapter.SelectCommand = dbcmd;
|
||||
@@ -738,7 +755,7 @@ namespace apprepodbmgr.Core
|
||||
param1.DbType = DbType.String;
|
||||
param1.Value = mdid;
|
||||
dbcmd.Parameters.Add(param1);
|
||||
dbcmd.CommandText = "SELECT * FROM `oses` WHERE mdid = @mdid";
|
||||
dbcmd.CommandText = "SELECT * FROM `apps` WHERE mdid = @mdid";
|
||||
DataSet dataSet = new DataSet();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
dataAdapter.SelectCommand = dbcmd;
|
||||
@@ -750,11 +767,11 @@ namespace apprepodbmgr.Core
|
||||
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();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -766,7 +783,7 @@ namespace apprepodbmgr.Core
|
||||
|
||||
foreach(DataRow dRow in dataTable.Rows)
|
||||
{
|
||||
DbOsFile fEntry = new DbOsFile
|
||||
DbAppFile fEntry = new DbAppFile
|
||||
{
|
||||
Id = ulong.Parse(dRow["id"].ToString()),
|
||||
Path = dRow["path"].ToString(),
|
||||
@@ -788,7 +805,7 @@ namespace apprepodbmgr.Core
|
||||
{
|
||||
entries = new List<DbFolder>();
|
||||
|
||||
string sql = $"SELECT * from os_{id}_folders";
|
||||
string sql = $"SELECT * from app_{id}_folders";
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
@@ -854,11 +871,11 @@ namespace apprepodbmgr.Core
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool HasSymlinks(long osId)
|
||||
public bool HasSymlinks(long appId)
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
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();
|
||||
dbcmd.Dispose();
|
||||
|
||||
@@ -871,11 +888,13 @@ namespace apprepodbmgr.Core
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
dbcmd.Transaction = trans;
|
||||
|
||||
string sql =
|
||||
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);",
|
||||
id);
|
||||
|
||||
dbcmd.CommandText = sql;
|
||||
dbcmd.CommandText =
|
||||
$"DROP TABLE IF EXISTS `app_{id}_symlinks`;\n\n" +
|
||||
$"CREATE TABLE IF NOT EXISTS `app_{id}_symlinks` (\n" +
|
||||
" `path` VARCHAR(8192) PRIMARY KEY,\n" +
|
||||
" `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();
|
||||
trans.Commit();
|
||||
@@ -884,7 +903,7 @@ namespace apprepodbmgr.Core
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AddSymlinkToOs(string path, string target, long os)
|
||||
public bool AddSymlinkToApp(string path, string target, long app)
|
||||
{
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
|
||||
@@ -906,7 +925,7 @@ namespace apprepodbmgr.Core
|
||||
IDbTransaction trans = dbCon.BeginTransaction();
|
||||
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;
|
||||
|
||||
@@ -921,7 +940,7 @@ namespace apprepodbmgr.Core
|
||||
{
|
||||
entries = new Dictionary<string, string>();
|
||||
|
||||
string sql = $"SELECT * from os_{id}_symlinks";
|
||||
string sql = $"SELECT * from app_{id}_symlinks";
|
||||
|
||||
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||
|
||||
@@ -105,9 +105,9 @@ namespace apprepodbmgr.Core
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
#if DEBUG
|
||||
Console.WriteLine("Creating oses table");
|
||||
Console.WriteLine("Creating applications table");
|
||||
#endif
|
||||
dbCmd.CommandText = Schema.OSesTableSql;
|
||||
dbCmd.CommandText = Schema.AppsTableSql;
|
||||
dbCmd.ExecuteNonQuery();
|
||||
|
||||
#if DEBUG
|
||||
|
||||
@@ -49,11 +49,11 @@ namespace apprepodbmgr.Core
|
||||
"CREATE INDEX `files_virus_idx` ON `files` (`virus` ASC);\n\n" +
|
||||
"CREATE INDEX `files_length_idx` ON `files` (`length` ASC);";
|
||||
|
||||
public const string OSesTableSql = "-- -----------------------------------------------------\n" +
|
||||
"-- Table `oses`\n" +
|
||||
public const string AppsTableSql = "-- -----------------------------------------------------\n" +
|
||||
"-- Table `apps`\n" +
|
||||
"-- -----------------------------------------------------\n" +
|
||||
"DROP TABLE IF EXISTS `oses` ;\n\n" +
|
||||
"CREATE TABLE IF NOT EXISTS `oses` (\n" +
|
||||
"DROP TABLE IF EXISTS `apps` ;\n\n" +
|
||||
"CREATE TABLE IF NOT EXISTS `apps` (\n" +
|
||||
" `id` INTEGER PRIMARY KEY AUTOINCREMENT,\n" +
|
||||
" `mdid` CHAR(40) NOT NULL,\n" +
|
||||
" `developer` VARCHAR(45) NOT NULL,\n" +
|
||||
@@ -72,14 +72,14 @@ namespace apprepodbmgr.Core
|
||||
" `netinstall` BOOLEAN NOT NULL,\n" +
|
||||
" `xml` BLOB NULL,\n" +
|
||||
" `json` BLOB NULL);\n\n" +
|
||||
"CREATE UNIQUE INDEX `oses_id_UNIQUE` ON `oses` (`id` ASC);\n\n" +
|
||||
"CREATE UNIQUE INDEX `oses_mdid_UNIQUE` ON `oses` (`mdid` ASC);\n\n" +
|
||||
"CREATE INDEX `oses_developer_idx` ON `oses` (`developer` ASC);\n\n" +
|
||||
"CREATE INDEX `oses_product_idx` ON `oses` (`product` ASC);\n\n" +
|
||||
"CREATE INDEX `oses_version_idx` ON `oses` (`version` ASC);\n\n" +
|
||||
"CREATE INDEX `oses_architecture_idx` ON `oses` (`architecture` ASC);\n\n" +
|
||||
"CREATE INDEX `oses_format_idx` ON `oses` (`format` ASC);\n\n" +
|
||||
"CREATE INDEX `oses_machine_idx` ON `oses` (`machine` ASC);\n\n" +
|
||||
"CREATE INDEX `oses_description_idx` ON `oses` (`description` ASC);";
|
||||
"CREATE UNIQUE INDEX `apps_id_UNIQUE` ON `apps` (`id` ASC);\n\n" +
|
||||
"CREATE UNIQUE INDEX `apps_mdid_UNIQUE` ON `apps` (`mdid` ASC);\n\n" +
|
||||
"CREATE INDEX `apps_developer_idx` ON `apps` (`developer` ASC);\n\n" +
|
||||
"CREATE INDEX `apps_product_idx` ON `apps` (`product` ASC);\n\n" +
|
||||
"CREATE INDEX `apps_version_idx` ON `apps` (`version` ASC);\n\n" +
|
||||
"CREATE INDEX `apps_architecture_idx` ON `apps` (`architecture` ASC);\n\n" +
|
||||
"CREATE INDEX `apps_format_idx` ON `apps` (`format` ASC);\n\n" +
|
||||
"CREATE INDEX `apps_machine_idx` ON `apps` (`machine` ASC);\n\n" +
|
||||
"CREATE INDEX `apps_description_idx` ON `apps` (`description` ASC);";
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ namespace apprepodbmgr.Core
|
||||
? ((NSString)obj).ToString()
|
||||
: Path
|
||||
.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
|
||||
"osrepo");
|
||||
"apprepo");
|
||||
|
||||
Current.UnArchiverPath = parsedPreferences.TryGetValue("UnArchiverPath", out obj)
|
||||
? ((NSString)obj).ToString()
|
||||
@@ -166,7 +166,7 @@ namespace apprepodbmgr.Core
|
||||
return;
|
||||
}
|
||||
|
||||
RegistryKey key = parentKey.OpenSubKey("OSRepoDBMgr");
|
||||
RegistryKey key = parentKey.OpenSubKey("AppRepoDBMgr");
|
||||
if(key == null)
|
||||
{
|
||||
SetDefaultSettings();
|
||||
@@ -195,7 +195,7 @@ namespace apprepodbmgr.Core
|
||||
string configPath =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
|
||||
string settingsPath =
|
||||
Path.Combine(configPath, "OSRepoDBMgr.xml");
|
||||
Path.Combine(configPath, "AppRepoDBMgr.xml");
|
||||
|
||||
if(!Directory.Exists(configPath))
|
||||
{
|
||||
@@ -269,7 +269,7 @@ namespace apprepodbmgr.Core
|
||||
RegistryKey parentKey = Registry
|
||||
.CurrentUser.OpenSubKey("SOFTWARE", true)
|
||||
?.CreateSubKey("Canary Islands Computer Museum");
|
||||
RegistryKey key = parentKey?.CreateSubKey("OSRepoDBMgr");
|
||||
RegistryKey key = parentKey?.CreateSubKey("AppRepoDBMgr");
|
||||
|
||||
if(key != null)
|
||||
{
|
||||
@@ -294,7 +294,7 @@ namespace apprepodbmgr.Core
|
||||
string configPath =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
|
||||
string settingsPath =
|
||||
Path.Combine(configPath, "OSRepoDBMgr.xml");
|
||||
Path.Combine(configPath, "AppRepoDBMgr.xml");
|
||||
|
||||
if(!Directory.Exists(configPath)) Directory.CreateDirectory(configPath);
|
||||
|
||||
@@ -322,7 +322,7 @@ namespace apprepodbmgr.Core
|
||||
DatabasePath =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "apprepodbmgr.db"),
|
||||
RepositoryPath =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "osrepo"),
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "apprepo"),
|
||||
UnArchiverPath = null,
|
||||
CompressionAlgorithm = AlgoEnum.GZip,
|
||||
UseAntivirus = false,
|
||||
|
||||
@@ -133,17 +133,17 @@ namespace apprepodbmgr.Core
|
||||
{
|
||||
if(File.Exists(destination))
|
||||
{
|
||||
Failed?.Invoke("OS already exists.");
|
||||
Failed?.Invoke("Application already exists.");
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -174,12 +174,12 @@ namespace apprepodbmgr.Core
|
||||
}
|
||||
|
||||
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
|
||||
stopwatch.Restart();
|
||||
#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);
|
||||
|
||||
@@ -291,7 +291,7 @@ namespace apprepodbmgr.Core
|
||||
jms.Position = 0;
|
||||
}
|
||||
|
||||
FinishedWithText?.Invoke($"Correctly added operating system with MDID {mdid}");
|
||||
FinishedWithText?.Invoke($"Correctly added application with MDID {mdid}");
|
||||
}
|
||||
catch(ThreadAbortException) { }
|
||||
catch(Exception ex)
|
||||
@@ -613,7 +613,7 @@ namespace apprepodbmgr.Core
|
||||
|
||||
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);
|
||||
|
||||
@@ -645,11 +645,11 @@ namespace apprepodbmgr.Core
|
||||
#endif
|
||||
|
||||
counter = 3;
|
||||
Context.Hashes = new Dictionary<string, DbOsFile>();
|
||||
Context.Hashes = new Dictionary<string, DbAppFile>();
|
||||
#if DEBUG
|
||||
stopwatch.Restart();
|
||||
#endif
|
||||
foreach(DbOsFile file in files)
|
||||
foreach(DbAppFile file in files)
|
||||
{
|
||||
UpdateProgress?.Invoke("", $"Adding {file.Path}...", counter, 3 + files.Count);
|
||||
|
||||
@@ -688,7 +688,7 @@ namespace apprepodbmgr.Core
|
||||
|
||||
static Stream Zf_HandleOpen(string entryName)
|
||||
{
|
||||
DbOsFile file;
|
||||
DbAppFile file;
|
||||
if(!Context.Hashes.TryGetValue(entryName, out file))
|
||||
if(!Context.Hashes.TryGetValue(entryName.Replace('/', '\\'), out file))
|
||||
throw new ArgumentException("Cannot find requested zip entry in hashes dictionary");
|
||||
|
||||
@@ -36,43 +36,38 @@ namespace apprepodbmgr.Core
|
||||
{
|
||||
public static partial class Workers
|
||||
{
|
||||
public static void GetAllOSes()
|
||||
public static void GetAllApps()
|
||||
{
|
||||
try
|
||||
{
|
||||
#if DEBUG
|
||||
stopwatch.Restart();
|
||||
#endif
|
||||
dbCore.DbOps.GetAllOSes(out List<DbEntry> oses);
|
||||
dbCore.DbOps.GetAllApps(out List<DbEntry> apps);
|
||||
#if DEBUG
|
||||
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);
|
||||
#endif
|
||||
|
||||
if(AddOS != null)
|
||||
if(AddApp != null)
|
||||
{
|
||||
#if DEBUG
|
||||
stopwatch.Restart();
|
||||
#endif
|
||||
int counter = 0;
|
||||
// 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,
|
||||
oses.Count);
|
||||
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);
|
||||
UpdateProgress?.Invoke("Populating apps table", $"{app.Developer} {app.Product}", counter,
|
||||
apps.Count);
|
||||
AddApp?.Invoke(app);
|
||||
|
||||
counter++;
|
||||
}
|
||||
#if DEBUG
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
@@ -99,23 +94,23 @@ namespace apprepodbmgr.Core
|
||||
#if DEBUG
|
||||
stopwatch.Restart();
|
||||
#endif
|
||||
Dictionary<string, DbOsFile> knownFiles = new Dictionary<string, DbOsFile>();
|
||||
Dictionary<string, DbAppFile> knownFiles = new Dictionary<string, DbAppFile>();
|
||||
|
||||
bool unknownFile = false;
|
||||
|
||||
foreach(KeyValuePair<string, DbOsFile> kvp in Context.Hashes)
|
||||
foreach(KeyValuePair<string, DbAppFile> kvp in Context.Hashes)
|
||||
{
|
||||
// Empty file with size zero
|
||||
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++;
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if(dbCore.DbOps.ExistsFile(kvp.Value.Sha256))
|
||||
@@ -137,37 +132,37 @@ namespace apprepodbmgr.Core
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateProgress?.Invoke(null, "Retrieving OSes from database", counter, Context.Hashes.Count);
|
||||
dbCore.DbOps.GetAllOSes(out List<DbEntry> oses);
|
||||
UpdateProgress?.Invoke(null, "Retrieving apps from database", counter, Context.Hashes.Count);
|
||||
dbCore.DbOps.GetAllApps(out List<DbEntry> apps);
|
||||
#if DEBUG
|
||||
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);
|
||||
#endif
|
||||
|
||||
if(oses != null && oses.Count > 0)
|
||||
if(apps != null && apps.Count > 0)
|
||||
{
|
||||
DbEntry[] osesArray = new DbEntry[oses.Count];
|
||||
oses.CopyTo(osesArray);
|
||||
DbEntry[] appsArray = new DbEntry[apps.Count];
|
||||
apps.CopyTo(appsArray);
|
||||
|
||||
long osCounter = 0;
|
||||
long appCounter = 0;
|
||||
#if DEBUG
|
||||
stopwatch.Restart();
|
||||
#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;
|
||||
foreach(KeyValuePair<string, DbOsFile> kvp in knownFiles)
|
||||
foreach(KeyValuePair<string, DbAppFile> kvp in knownFiles)
|
||||
{
|
||||
UpdateProgress2?.Invoke(null, $"Checking for file {kvp.Value.Path}", counter,
|
||||
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
|
||||
break;
|
||||
@@ -176,25 +171,18 @@ namespace apprepodbmgr.Core
|
||||
counter++;
|
||||
}
|
||||
|
||||
if(oses.Count == 0) break; // No OSes left
|
||||
if(apps.Count == 0) break; // No apps left
|
||||
}
|
||||
#if DEBUG
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
|
||||
if(AddOS != null)
|
||||
foreach(DbEntry os in oses)
|
||||
{
|
||||
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);
|
||||
}
|
||||
if(AddApp != null)
|
||||
foreach(DbEntry app in apps)
|
||||
AddApp?.Invoke(app);
|
||||
|
||||
Finished?.Invoke();
|
||||
}
|
||||
@@ -218,7 +206,7 @@ namespace apprepodbmgr.Core
|
||||
#if DEBUG
|
||||
stopwatch.Restart();
|
||||
#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);
|
||||
|
||||
@@ -247,36 +235,36 @@ namespace apprepodbmgr.Core
|
||||
stopwatch.Elapsed.TotalSeconds);
|
||||
#endif
|
||||
|
||||
UpdateProgress?.Invoke(null, "Adding OS information", counter, Context.Hashes.Count);
|
||||
dbCore.DbOps.AddOs(Context.DbInfo, out Context.DbInfo.Id);
|
||||
UpdateProgress?.Invoke(null, "Creating OS table", counter, Context.Hashes.Count);
|
||||
dbCore.DbOps.CreateTableForOs(Context.DbInfo.Id);
|
||||
UpdateProgress?.Invoke(null, "Adding application information", counter, Context.Hashes.Count);
|
||||
dbCore.DbOps.AddApp(Context.DbInfo, out Context.DbInfo.Id);
|
||||
UpdateProgress?.Invoke(null, "Creating application table", counter, Context.Hashes.Count);
|
||||
dbCore.DbOps.CreateTableForApp(Context.DbInfo.Id);
|
||||
|
||||
#if DEBUG
|
||||
stopwatch.Restart();
|
||||
#endif
|
||||
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++;
|
||||
}
|
||||
#if DEBUG
|
||||
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.Restart();
|
||||
#endif
|
||||
counter = 0;
|
||||
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);
|
||||
|
||||
dbCore.DbOps.AddFolderToOs(kvp.Value, Context.DbInfo.Id);
|
||||
dbCore.DbOps.AddFolderToApp(kvp.Value, Context.DbInfo.Id);
|
||||
|
||||
counter++;
|
||||
}
|
||||
@@ -291,10 +279,10 @@ namespace apprepodbmgr.Core
|
||||
|
||||
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);
|
||||
|
||||
dbCore.DbOps.AddSymlinkToOs(kvp.Key, kvp.Value, Context.DbInfo.Id);
|
||||
dbCore.DbOps.AddSymlinkToApp(kvp.Key, kvp.Value, Context.DbInfo.Id);
|
||||
|
||||
counter++;
|
||||
}
|
||||
@@ -377,17 +365,11 @@ namespace apprepodbmgr.Core
|
||||
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;
|
||||
|
||||
string destination = Path.Combine(Settings.Current.RepositoryPath, mdid[0].ToString(), mdid[1].ToString(),
|
||||
mdid[2].ToString(), mdid[3].ToString(), mdid[4].ToString(),
|
||||
mdid) + ".zip";
|
||||
|
||||
if(File.Exists(destination)) File.Delete(destination);
|
||||
|
||||
dbCore.DbOps.RemoveOs(id);
|
||||
dbCore.DbOps.RemoveApp(id);
|
||||
}
|
||||
|
||||
public static void GetFilesFromDb()
|
||||
|
||||
@@ -34,11 +34,11 @@ namespace apprepodbmgr.Core
|
||||
{
|
||||
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 AddOSDelegate(DbEntry os);
|
||||
public delegate void AddAppDelegate(DbEntry os);
|
||||
|
||||
public delegate void FailedDelegate(string text);
|
||||
|
||||
@@ -57,8 +57,8 @@ namespace apprepodbmgr.Core
|
||||
public static event FailedDelegate Failed;
|
||||
public static event FinishedWithoutErrorDelegate Finished;
|
||||
public static event FinishedWithTextDelegate FinishedWithText;
|
||||
public static event AddFileForOSDelegate AddFileForOS;
|
||||
public static event AddOSDelegate AddOS;
|
||||
public static event AddFileForAppDelegate AddFileForApp;
|
||||
public static event AddAppDelegate AddApp;
|
||||
public static event AddFileDelegate AddFile;
|
||||
public static event AddFilesDelegate AddFiles;
|
||||
public static event ScanFinishedDelegate ScanFinished;
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace apprepodbmgr.Core
|
||||
{
|
||||
try
|
||||
{
|
||||
Context.Hashes = new Dictionary<string, DbOsFile>();
|
||||
Context.Hashes = new Dictionary<string, DbAppFile>();
|
||||
Context.FoldersDict = new Dictionary<string, DbFolder>();
|
||||
Context.SymlinksDict = new Dictionary<string, string>();
|
||||
List<string> alreadyMetadata = new List<string>();
|
||||
@@ -423,7 +423,7 @@ namespace apprepodbmgr.Core
|
||||
fileStream.Close();
|
||||
string hash = Stringify(sha256Context.Final());
|
||||
|
||||
DbOsFile dbFile = new DbOsFile
|
||||
DbAppFile dbFile = new DbAppFile
|
||||
{
|
||||
Attributes = fi.Attributes,
|
||||
CreationTimeUtc = fi.CreationTimeUtc,
|
||||
@@ -695,7 +695,7 @@ namespace apprepodbmgr.Core
|
||||
|
||||
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);
|
||||
|
||||
@@ -762,7 +762,7 @@ namespace apprepodbmgr.Core
|
||||
#endif
|
||||
|
||||
counter = 4;
|
||||
foreach(DbOsFile file in files)
|
||||
foreach(DbAppFile file in files)
|
||||
{
|
||||
UpdateProgress?.Invoke("", $"Creating {file.Path}...", counter, 4 + files.Count);
|
||||
|
||||
@@ -931,7 +931,7 @@ namespace apprepodbmgr.Core
|
||||
#if DEBUG
|
||||
stopwatch.Restart();
|
||||
#endif
|
||||
dbCore.DbOps.GetAllOSes(out List<DbEntry> oses);
|
||||
dbCore.DbOps.GetAllApps(out List<DbEntry> apps);
|
||||
#if DEBUG
|
||||
stopwatch.Stop();
|
||||
Console.WriteLine("Core.CleanFiles(): Took {0} seconds to get OSes from database",
|
||||
@@ -954,11 +954,11 @@ namespace apprepodbmgr.Core
|
||||
#if DEBUG
|
||||
stopwatch2.Restart();
|
||||
#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;
|
||||
break;
|
||||
@@ -968,7 +968,7 @@ namespace apprepodbmgr.Core
|
||||
}
|
||||
#if DEBUG
|
||||
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);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -102,8 +102,8 @@
|
||||
<TabPage Text="Files">
|
||||
<GridView ID="treeFiles" SelectionChanged="treeFilesSelectionChanged" />
|
||||
</TabPage>
|
||||
<TabPage Text="OSes" ID="tabOSes" Visible="False">
|
||||
<GridView ID="treeOSes" />
|
||||
<TabPage Text="Applications" ID="tabApps" Visible="False">
|
||||
<GridView ID="treeApps" />
|
||||
</TabPage>
|
||||
</TabControl>
|
||||
</StackLayoutItem>
|
||||
|
||||
@@ -44,11 +44,11 @@ namespace apprepodbmgr.Eto
|
||||
{
|
||||
public class dlgAdd : Dialog
|
||||
{
|
||||
public delegate void OnAddedOSDelegate(DbEntry os);
|
||||
public delegate void OnAddedAppDelegate(DbEntry app);
|
||||
|
||||
ObservableCollection<FileEntry> fileView;
|
||||
int knownFiles;
|
||||
ObservableCollection<DBEntryForEto> osView;
|
||||
ObservableCollection<DBEntryForEto> appView;
|
||||
bool stopped;
|
||||
Thread thdAddFiles;
|
||||
Thread thdCheckFiles;
|
||||
@@ -98,85 +98,85 @@ namespace apprepodbmgr.Eto
|
||||
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)},
|
||||
HeaderText = "Developer"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.product)},
|
||||
HeaderText = "Product"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.version)},
|
||||
HeaderText = "Version"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.languages)},
|
||||
HeaderText = "Languages"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.architecture)},
|
||||
HeaderText = "Architecture"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.machine)},
|
||||
HeaderText = "Machine"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.format)},
|
||||
HeaderText = "Format"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.description)},
|
||||
HeaderText = "Description"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.oem)},
|
||||
HeaderText = "OEM?"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.upgrade)},
|
||||
HeaderText = "Upgrade?"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.update)},
|
||||
HeaderText = "Update?"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.source)},
|
||||
HeaderText = "Source?"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.files)},
|
||||
HeaderText = "Files?"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.netinstall)},
|
||||
HeaderText = "NetInstall?"
|
||||
});
|
||||
|
||||
treeOSes.AllowMultipleSelection = false;
|
||||
treeApps.AllowMultipleSelection = false;
|
||||
}
|
||||
|
||||
public event OnAddedOSDelegate OnAddedOS;
|
||||
public event OnAddedAppDelegate OnAddedApp;
|
||||
|
||||
void UnarChangeStatus()
|
||||
{
|
||||
@@ -293,8 +293,8 @@ namespace apprepodbmgr.Eto
|
||||
Workers.Finished += ChkFilesFinished;
|
||||
Workers.UpdateProgress += UpdateProgress;
|
||||
Workers.UpdateProgress2 += UpdateProgress2;
|
||||
Workers.AddFileForOS += AddFile;
|
||||
Workers.AddOS += AddOs;
|
||||
Workers.AddFileForApp += AddFile;
|
||||
Workers.AddApp += AddApp;
|
||||
thdCheckFiles.Start();
|
||||
});
|
||||
}
|
||||
@@ -312,15 +312,15 @@ namespace apprepodbmgr.Eto
|
||||
Workers.Finished -= ChkFilesFinished;
|
||||
Workers.UpdateProgress -= UpdateProgress;
|
||||
Workers.UpdateProgress2 -= UpdateProgress2;
|
||||
Workers.AddFileForOS -= AddFile;
|
||||
Workers.AddOS -= AddOs;
|
||||
Workers.AddFileForApp -= AddFile;
|
||||
Workers.AddApp -= AddApp;
|
||||
thdCheckFiles?.Abort();
|
||||
thdHashFiles = null;
|
||||
fileView?.Clear();
|
||||
if(osView == null) return;
|
||||
if(appView == null) return;
|
||||
|
||||
tabOSes.Visible = false;
|
||||
osView.Clear();
|
||||
tabApps.Visible = false;
|
||||
appView.Clear();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -332,8 +332,8 @@ namespace apprepodbmgr.Eto
|
||||
Workers.Finished -= ChkFilesFinished;
|
||||
Workers.UpdateProgress -= UpdateProgress;
|
||||
Workers.UpdateProgress2 -= UpdateProgress2;
|
||||
Workers.AddFileForOS -= AddFile;
|
||||
Workers.AddOS -= AddOs;
|
||||
Workers.AddFileForApp -= AddFile;
|
||||
Workers.AddApp -= AddApp;
|
||||
|
||||
thdCheckFiles?.Abort();
|
||||
|
||||
@@ -418,12 +418,12 @@ namespace apprepodbmgr.Eto
|
||||
});
|
||||
}
|
||||
|
||||
void AddOs(DbEntry os)
|
||||
void AddApp(DbEntry app)
|
||||
{
|
||||
Application.Instance.Invoke(delegate
|
||||
{
|
||||
tabOSes.Visible = true;
|
||||
osView.Add(new DBEntryForEto(os));
|
||||
tabApps.Visible = true;
|
||||
appView.Add(new DBEntryForEto(app));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -447,10 +447,10 @@ namespace apprepodbmgr.Eto
|
||||
btnRemoveFile.Visible = false;
|
||||
btnToggleCrack.Visible = false;
|
||||
fileView?.Clear();
|
||||
if(osView != null)
|
||||
if(appView != null)
|
||||
{
|
||||
tabOSes.Visible = false;
|
||||
osView.Clear();
|
||||
tabApps.Visible = false;
|
||||
appView.Clear();
|
||||
}
|
||||
|
||||
txtFormat.ReadOnly = true;
|
||||
@@ -560,8 +560,8 @@ namespace apprepodbmgr.Eto
|
||||
{
|
||||
stopped = true;
|
||||
|
||||
Workers.AddFileForOS -= AddFile;
|
||||
Workers.AddOS -= AddOs;
|
||||
Workers.AddFileForApp -= AddFile;
|
||||
Workers.AddApp -= AddApp;
|
||||
Workers.Failed -= AddFilesToDbFailed;
|
||||
Workers.Failed -= ChkFilesFailed;
|
||||
Workers.Failed -= ExtractArchiveFailed;
|
||||
@@ -670,10 +670,10 @@ namespace apprepodbmgr.Eto
|
||||
Workers.UpdateProgress2 -= UpdateProgress2;
|
||||
btnStop.Visible = false;
|
||||
fileView?.Clear();
|
||||
if(osView == null) return;
|
||||
if(appView == null) return;
|
||||
|
||||
tabOSes.Visible = false;
|
||||
osView.Clear();
|
||||
tabApps.Visible = false;
|
||||
appView.Clear();
|
||||
}
|
||||
|
||||
void RemoveTempFilesFailed(string text)
|
||||
@@ -776,16 +776,16 @@ namespace apprepodbmgr.Eto
|
||||
|
||||
long counter = 0;
|
||||
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);
|
||||
fileView.Add(new FileEntry {Path = kvp.Key, Hash = kvp.Value.Sha256, Known = true});
|
||||
counter++;
|
||||
}
|
||||
|
||||
// TODO: Update OS table
|
||||
// TODO: Update application table
|
||||
|
||||
OnAddedOS?.Invoke(Context.DbInfo);
|
||||
OnAddedApp?.Invoke(Context.DbInfo);
|
||||
|
||||
lblProgress.Visible = false;
|
||||
prgProgress.Visible = false;
|
||||
@@ -1118,14 +1118,14 @@ namespace apprepodbmgr.Eto
|
||||
string name = ((FileEntry)treeFiles.SelectedItem).Path;
|
||||
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.Add(name, osfile);
|
||||
((FileEntry)treeFiles.SelectedItem).IsCrack = osfile.Crack;
|
||||
Context.Hashes.Add(name, appFile);
|
||||
((FileEntry)treeFiles.SelectedItem).IsCrack = appFile.Crack;
|
||||
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)
|
||||
@@ -1160,8 +1160,8 @@ namespace apprepodbmgr.Eto
|
||||
CheckBox chkSource;
|
||||
CheckBox chkNetinstall;
|
||||
GridView treeFiles;
|
||||
TabPage tabOSes;
|
||||
GridView treeOSes;
|
||||
TabPage tabApps;
|
||||
GridView treeApps;
|
||||
Label lblProgress;
|
||||
ProgressBar prgProgress;
|
||||
Label lblProgress2;
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace apprepodbmgr.Eto
|
||||
|
||||
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()
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?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">
|
||||
<TabControl>
|
||||
<TabPage Text="Operating systems" ID="tabOSes">
|
||||
<TabPage Text="Operating systems" ID="tabApps">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||
<GridView ID="treeOSes" Enabled="False" />
|
||||
<GridView ID="treeApps" Enabled="False" />
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label ID="lblOSStatus" Visible="False">lblOSStatus</Label>
|
||||
<Label ID="lblAppStatus" Visible="False">lblAppStatus</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch">
|
||||
<Label ID="lblProgress">lblProgress</Label>
|
||||
|
||||
@@ -42,14 +42,14 @@ namespace apprepodbmgr.Eto
|
||||
int infectedFiles;
|
||||
ObservableCollection<DbFile> lstFiles;
|
||||
|
||||
ObservableCollection<DBEntryForEto> lstOSes;
|
||||
ObservableCollection<DBEntryForEto> lstApps;
|
||||
DbFile outIter;
|
||||
bool populatingFiles;
|
||||
bool scanningFiles;
|
||||
Thread thdCleanFiles;
|
||||
Thread thdCompressTo;
|
||||
Thread thdPopulateFiles;
|
||||
Thread thdPopulateOSes;
|
||||
Thread thdPopulateApps;
|
||||
Thread thdSaveAs;
|
||||
Thread thdScanFile;
|
||||
|
||||
@@ -59,81 +59,81 @@ namespace apprepodbmgr.Eto
|
||||
|
||||
Workers.InitDB();
|
||||
|
||||
lstOSes = new ObservableCollection<DBEntryForEto>();
|
||||
lstApps = new ObservableCollection<DBEntryForEto>();
|
||||
|
||||
treeOSes.DataStore = lstOSes;
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.DataStore = lstApps;
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.developer)},
|
||||
HeaderText = "Developer"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.product)},
|
||||
HeaderText = "Product"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.version)},
|
||||
HeaderText = "Version"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.languages)},
|
||||
HeaderText = "Languages"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.architecture)},
|
||||
HeaderText = "Architecture"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.machine)},
|
||||
HeaderText = "Machine"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.format)},
|
||||
HeaderText = "Format"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<DBEntryForEto, string>(r => r.description)},
|
||||
HeaderText = "Description"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.oem)},
|
||||
HeaderText = "OEM?"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.upgrade)},
|
||||
HeaderText = "Upgrade?"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.update)},
|
||||
HeaderText = "Update?"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.source)},
|
||||
HeaderText = "Source?"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.files)},
|
||||
HeaderText = "Files?"
|
||||
});
|
||||
treeOSes.Columns.Add(new GridColumn
|
||||
treeApps.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new CheckBoxCell {Binding = Binding.Property<DBEntryForEto, bool?>(r => r.netinstall)},
|
||||
HeaderText = "NetInstall?"
|
||||
});
|
||||
|
||||
treeOSes.AllowMultipleSelection = false;
|
||||
treeApps.AllowMultipleSelection = false;
|
||||
|
||||
lstFiles = new ObservableCollection<DbFile>();
|
||||
|
||||
@@ -206,60 +206,60 @@ namespace apprepodbmgr.Eto
|
||||
mnuCompress.Enabled = false;
|
||||
}
|
||||
|
||||
Workers.Failed += LoadOSesFailed;
|
||||
Workers.Finished += LoadOSesFinished;
|
||||
Workers.Failed += LoadAppsFailed;
|
||||
Workers.Finished += LoadAppsFinished;
|
||||
Workers.UpdateProgress += UpdateProgress;
|
||||
Workers.AddOS += AddOs;
|
||||
Workers.AddApp += AddApp;
|
||||
Workers.AddFile += AddFile;
|
||||
Workers.AddFiles += AddFiles;
|
||||
thdPopulateOSes = new Thread(Workers.GetAllOSes);
|
||||
thdPopulateOSes.Start();
|
||||
thdPopulateApps = new Thread(Workers.GetAllApps);
|
||||
thdPopulateApps.Start();
|
||||
}
|
||||
|
||||
void LoadOSesFailed(string text)
|
||||
void LoadAppsFailed(string text)
|
||||
{
|
||||
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);
|
||||
if(thdPopulateOSes != null)
|
||||
if(thdPopulateApps != null)
|
||||
{
|
||||
thdPopulateOSes.Abort();
|
||||
thdPopulateOSes = null;
|
||||
thdPopulateApps.Abort();
|
||||
thdPopulateApps = null;
|
||||
}
|
||||
|
||||
Workers.Failed -= LoadOSesFailed;
|
||||
Workers.Finished -= LoadOSesFinished;
|
||||
Workers.Failed -= LoadAppsFailed;
|
||||
Workers.Finished -= LoadAppsFinished;
|
||||
Workers.UpdateProgress -= UpdateProgress;
|
||||
Application.Instance.Quit();
|
||||
});
|
||||
}
|
||||
|
||||
void LoadOSesFinished()
|
||||
void LoadAppsFinished()
|
||||
{
|
||||
Application.Instance.Invoke(delegate
|
||||
{
|
||||
Workers.Failed -= LoadOSesFailed;
|
||||
Workers.Finished -= LoadOSesFinished;
|
||||
Workers.Failed -= LoadAppsFailed;
|
||||
Workers.Finished -= LoadAppsFinished;
|
||||
Workers.UpdateProgress -= UpdateProgress;
|
||||
Workers.AddOS -= AddOs;
|
||||
if(thdPopulateOSes != null)
|
||||
Workers.AddApp -= AddApp;
|
||||
if(thdPopulateApps != null)
|
||||
{
|
||||
thdPopulateOSes.Abort();
|
||||
thdPopulateOSes = null;
|
||||
thdPopulateApps.Abort();
|
||||
thdPopulateApps = null;
|
||||
}
|
||||
|
||||
lblProgress.Visible = false;
|
||||
prgProgress.Visible = false;
|
||||
treeOSes.Enabled = true;
|
||||
treeApps.Enabled = true;
|
||||
btnAdd.Visible = true;
|
||||
btnRemove.Visible = true;
|
||||
btnCompress.Visible = Context.UsableDotNetZip;
|
||||
btnSave.Visible = true;
|
||||
btnHelp.Enabled = true;
|
||||
btnSettings.Enabled = true;
|
||||
lblOSStatus.Visible = true;
|
||||
lblOSStatus.Text = $"{lstOSes.Count} operating systems";
|
||||
lblAppStatus.Visible = true;
|
||||
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)
|
||||
{
|
||||
dlgAdd dlgAdd = new dlgAdd();
|
||||
dlgAdd.OnAddedOS += os => { lstOSes.Add(new DBEntryForEto(os)); };
|
||||
dlgAdd.OnAddedApp += app => { lstApps.Add(new DBEntryForEto(app)); };
|
||||
dlgAdd.ShowModal(this);
|
||||
}
|
||||
|
||||
protected void OnBtnRemoveClicked(object sender, EventArgs e)
|
||||
{
|
||||
if(treeOSes.SelectedItem == null) return;
|
||||
if(MessageBox.Show("Are you sure you want to remove the selected OS?", MessageBoxButtons.YesNo,
|
||||
if(treeApps.SelectedItem == null) return;
|
||||
if(MessageBox.Show("Are you sure you want to remove the selected application?", MessageBoxButtons.YesNo,
|
||||
MessageBoxType.Question, MessageBoxDefaultButton.No) != DialogResult.Yes) return;
|
||||
|
||||
Workers.RemoveOS(((DBEntryForEto)treeOSes.SelectedItem).id, ((DBEntryForEto)treeOSes.SelectedItem).mdid);
|
||||
lstOSes.Remove((DBEntryForEto)treeOSes.SelectedItem);
|
||||
Workers.RemoveApp(((DBEntryForEto)treeApps.SelectedItem).id, ((DBEntryForEto)treeApps.SelectedItem).mdid);
|
||||
lstApps.Remove((DBEntryForEto)treeApps.SelectedItem);
|
||||
}
|
||||
|
||||
protected void OnBtnSaveClicked(object sender, EventArgs e)
|
||||
{
|
||||
if(treeOSes.SelectedItem == null) return;
|
||||
if(treeApps.SelectedItem == null) return;
|
||||
|
||||
SelectFolderDialog dlgFolder = new SelectFolderDialog {Title = "Save to..."};
|
||||
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;
|
||||
|
||||
lblProgress.Visible = true;
|
||||
prgProgress.Visible = true;
|
||||
lblProgress2.Visible = true;
|
||||
prgProgress2.Visible = true;
|
||||
treeOSes.Enabled = false;
|
||||
treeApps.Enabled = false;
|
||||
btnAdd.Visible = false;
|
||||
btnRemove.Visible = false;
|
||||
btnCompress.Visible = false;
|
||||
@@ -382,7 +382,7 @@ namespace apprepodbmgr.Eto
|
||||
prgProgress.Visible = false;
|
||||
lblProgress2.Visible = false;
|
||||
prgProgress2.Visible = false;
|
||||
treeOSes.Enabled = true;
|
||||
treeApps.Enabled = true;
|
||||
btnAdd.Visible = true;
|
||||
btnRemove.Visible = true;
|
||||
btnCompress.Visible = Context.UsableDotNetZip;
|
||||
@@ -414,7 +414,7 @@ namespace apprepodbmgr.Eto
|
||||
prgProgress.Visible = false;
|
||||
lblProgress2.Visible = false;
|
||||
prgProgress2.Visible = false;
|
||||
treeOSes.Enabled = true;
|
||||
treeApps.Enabled = true;
|
||||
btnAdd.Visible = true;
|
||||
btnRemove.Visible = true;
|
||||
btnCompress.Visible = Context.UsableDotNetZip;
|
||||
@@ -459,26 +459,26 @@ namespace apprepodbmgr.Eto
|
||||
|
||||
protected void OnBtnStopClicked(object sender, EventArgs e)
|
||||
{
|
||||
Workers.AddOS -= AddOs;
|
||||
Workers.AddApp -= AddApp;
|
||||
Workers.Failed -= CompressToFailed;
|
||||
Workers.Failed -= LoadOSesFailed;
|
||||
Workers.Failed -= LoadAppsFailed;
|
||||
Workers.Failed -= SaveAsFailed;
|
||||
Workers.Finished -= CompressToFinished;
|
||||
Workers.Finished -= LoadOSesFinished;
|
||||
Workers.Finished -= LoadAppsFinished;
|
||||
Workers.Finished -= SaveAsFinished;
|
||||
Workers.UpdateProgress -= UpdateProgress;
|
||||
Workers.UpdateProgress2 -= UpdateProgress2;
|
||||
|
||||
if(thdPopulateOSes != null)
|
||||
if(thdPopulateApps != null)
|
||||
{
|
||||
thdPopulateOSes.Abort();
|
||||
thdPopulateOSes = null;
|
||||
thdPopulateApps.Abort();
|
||||
thdPopulateApps = null;
|
||||
}
|
||||
|
||||
if(thdCompressTo != null)
|
||||
{
|
||||
thdPopulateOSes.Abort();
|
||||
thdPopulateOSes = null;
|
||||
thdPopulateApps.Abort();
|
||||
thdPopulateApps = null;
|
||||
}
|
||||
|
||||
if(thdSaveAs == null) return;
|
||||
@@ -494,20 +494,20 @@ namespace apprepodbmgr.Eto
|
||||
|
||||
protected void OnBtnCompressClicked(object sender, EventArgs e)
|
||||
{
|
||||
if(treeOSes.SelectedItem == null) return;
|
||||
if(treeApps.SelectedItem == null) return;
|
||||
|
||||
SaveFileDialog dlgFile = new SaveFileDialog {Title = "Compress to..."};
|
||||
|
||||
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;
|
||||
|
||||
lblProgress.Visible = true;
|
||||
prgProgress.Visible = true;
|
||||
lblProgress2.Visible = true;
|
||||
prgProgress2.Visible = true;
|
||||
treeOSes.Enabled = false;
|
||||
treeApps.Enabled = false;
|
||||
btnAdd.Visible = false;
|
||||
btnRemove.Visible = false;
|
||||
btnCompress.Visible = false;
|
||||
@@ -533,7 +533,7 @@ namespace apprepodbmgr.Eto
|
||||
lblProgress2.Visible = false;
|
||||
prgProgress.Visible = false;
|
||||
prgProgress2.Visible = false;
|
||||
treeOSes.Enabled = true;
|
||||
treeApps.Enabled = true;
|
||||
btnAdd.Visible = true;
|
||||
btnRemove.Visible = true;
|
||||
btnCompress.Visible = Context.UsableDotNetZip;
|
||||
@@ -565,7 +565,7 @@ namespace apprepodbmgr.Eto
|
||||
lblProgress2.Visible = false;
|
||||
prgProgress.Visible = false;
|
||||
prgProgress2.Visible = false;
|
||||
treeOSes.Enabled = true;
|
||||
treeApps.Enabled = true;
|
||||
btnAdd.Visible = true;
|
||||
btnRemove.Visible = true;
|
||||
btnCompress.Visible = Context.UsableDotNetZip;
|
||||
@@ -794,7 +794,7 @@ namespace apprepodbmgr.Eto
|
||||
protected void OnBtnPopulateFilesClicked(object sender, EventArgs e)
|
||||
{
|
||||
lstFiles.Clear();
|
||||
tabOSes.Enabled = false;
|
||||
tabApps.Enabled = false;
|
||||
btnStopFiles.Visible = true;
|
||||
btnPopulateFiles.Visible = false;
|
||||
|
||||
@@ -908,7 +908,7 @@ namespace apprepodbmgr.Eto
|
||||
thdPopulateFiles = null;
|
||||
}
|
||||
|
||||
tabOSes.Enabled = true;
|
||||
tabApps.Enabled = true;
|
||||
lstFiles.Clear();
|
||||
btnStopFiles.Visible = false;
|
||||
btnPopulateFiles.Visible = true;
|
||||
@@ -941,7 +941,7 @@ namespace apprepodbmgr.Eto
|
||||
btnPopulateFiles.Visible = false;
|
||||
populatingFiles = false;
|
||||
treeFiles.Enabled = true;
|
||||
tabOSes.Enabled = true;
|
||||
tabApps.Enabled = true;
|
||||
btnScanAllPending.Visible = true;
|
||||
btnCleanFiles.Visible = true;
|
||||
lblFileStatus.Visible = true;
|
||||
@@ -1012,7 +1012,7 @@ namespace apprepodbmgr.Eto
|
||||
protected void OnBtnCleanFilesClicked(object sender, EventArgs e)
|
||||
{
|
||||
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);
|
||||
if(result != DialogResult.Yes) return;
|
||||
|
||||
@@ -1021,7 +1021,7 @@ namespace apprepodbmgr.Eto
|
||||
btnScanWithClamd.Visible = false;
|
||||
btnScanAllPending.Visible = false;
|
||||
btnCheckInVirusTotal.Visible = false;
|
||||
tabOSes.Enabled = false;
|
||||
tabApps.Enabled = false;
|
||||
treeFiles.Enabled = false;
|
||||
lblProgressFiles1.Visible = true;
|
||||
lblProgressFiles2.Visible = true;
|
||||
@@ -1052,7 +1052,7 @@ namespace apprepodbmgr.Eto
|
||||
btnScanWithClamd.Visible = true;
|
||||
btnScanAllPending.Visible = true;
|
||||
btnCheckInVirusTotal.Visible = true;
|
||||
tabOSes.Enabled = true;
|
||||
tabApps.Enabled = true;
|
||||
treeFiles.Enabled = true;
|
||||
Workers.Finished -= CleanFilesFinished;
|
||||
Workers.UpdateProgress -= UpdateFileProgress;
|
||||
@@ -1074,7 +1074,7 @@ namespace apprepodbmgr.Eto
|
||||
|
||||
#region XAML UI elements
|
||||
#pragma warning disable 0649
|
||||
GridView treeOSes;
|
||||
GridView treeApps;
|
||||
Label lblProgress;
|
||||
ProgressBar prgProgress;
|
||||
Label lblProgress2;
|
||||
@@ -1097,12 +1097,12 @@ namespace apprepodbmgr.Eto
|
||||
Button btnScanWithClamd;
|
||||
Button btnCheckInVirusTotal;
|
||||
Button btnPopulateFiles;
|
||||
TabPage tabOSes;
|
||||
TabPage tabApps;
|
||||
Button btnScanAllPending;
|
||||
Button btnCleanFiles;
|
||||
ButtonMenuItem btnQuit;
|
||||
ButtonMenuItem mnuFile;
|
||||
Label lblOSStatus;
|
||||
Label lblAppStatus;
|
||||
Label lblFileStatus;
|
||||
#pragma warning restore 0649
|
||||
#endregion XAML UI elements
|
||||
|
||||
Reference in New Issue
Block a user