Console.WriteLine removed
This commit is contained in:
parent
1c61fc198d
commit
5770a58145
@ -15,8 +15,8 @@ Global
|
|||||||
Release|x64 = Release|x64
|
Release|x64 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|Any CPU.ActiveCfg = Release|x64
|
||||||
{06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|Any CPU.Build.0 = Release|x64
|
||||||
{06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|x64.ActiveCfg = Debug|x64
|
{06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|x64.Build.0 = Debug|x64
|
{06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|x64.Build.0 = Debug|x64
|
||||||
{06D431CD-A938-4DFD-8D77-4C612FDAD914}.PrgmList|Any CPU.ActiveCfg = PrgmList|Any CPU
|
{06D431CD-A938-4DFD-8D77-4C612FDAD914}.PrgmList|Any CPU.ActiveCfg = PrgmList|Any CPU
|
||||||
|
@ -6,7 +6,6 @@ namespace ProgrammList.ConfigManager {
|
|||||||
public static string GetSetting(string key) {
|
public static string GetSetting(string key) {
|
||||||
try {
|
try {
|
||||||
if (!File.Exists(Directory.GetCurrentDirectory() + "\\app.conf")) {
|
if (!File.Exists(Directory.GetCurrentDirectory() + "\\app.conf")) {
|
||||||
Console.WriteLine("app.conf does not exist, using defaults");
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
ExeConfigurationFileMap configMap = new ExeConfigurationFileMap();
|
ExeConfigurationFileMap configMap = new ExeConfigurationFileMap();
|
||||||
@ -15,7 +14,6 @@ namespace ProgrammList.ConfigManager {
|
|||||||
return config.AppSettings.Settings[key].Value;
|
return config.AppSettings.Settings[key].Value;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
Console.WriteLine("Error on Key \"" + key + "\": Key not set");
|
|
||||||
System.Environment.Exit(13);
|
System.Environment.Exit(13);
|
||||||
}
|
}
|
||||||
return "13";
|
return "13";
|
||||||
@ -24,14 +22,12 @@ namespace ProgrammList.ConfigManager {
|
|||||||
public static void SetSetting(string key, string value) {
|
public static void SetSetting(string key, string value) {
|
||||||
try {
|
try {
|
||||||
ExeConfigurationFileMap configMap = new ExeConfigurationFileMap();
|
ExeConfigurationFileMap configMap = new ExeConfigurationFileMap();
|
||||||
Console.WriteLine("Loading " + Directory.GetCurrentDirectory() + "\\app.conf");
|
|
||||||
configMap.ExeConfigFilename = Directory.GetCurrentDirectory() + "\\app.conf";
|
configMap.ExeConfigFilename = Directory.GetCurrentDirectory() + "\\app.conf";
|
||||||
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
|
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
|
||||||
config.AppSettings.Settings["key"].Value = value;
|
config.AppSettings.Settings["key"].Value = value;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
Console.WriteLine("Error on Key " + key + ": " + e.ToString());
|
// Exception
|
||||||
Console.WriteLine(e.ToString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,10 @@ class Program {
|
|||||||
string dbType = PrmListConfigManager.GetSetting("DB_Type");
|
string dbType = PrmListConfigManager.GetSetting("DB_Type");
|
||||||
ListPrograms list = new ListPrograms(dbType);
|
ListPrograms list = new ListPrograms(dbType);
|
||||||
|
|
||||||
Console.WriteLine("Deleting old data");
|
|
||||||
list.DeleteOldData();
|
list.DeleteOldData();
|
||||||
string keyname1 = "Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstal";
|
string keyname1 = "Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstal";
|
||||||
Console.WriteLine("Searching for 32 bit");
|
|
||||||
list.createList(keyname1, "x86");
|
list.createList(keyname1, "x86");
|
||||||
string keyname2 = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
|
string keyname2 = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
|
||||||
Console.WriteLine("Searching for 64 bit");
|
|
||||||
list.createList(keyname2, "x64");
|
list.createList(keyname2, "x64");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,13 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
<Configurations>Debug;Release;PrgmList</Configurations>
|
<Configurations>Debug;Release;PrgmList</Configurations>
|
||||||
|
<ApplicationIcon>icons\back-end.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="icons\back-end.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.1" />
|
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.1" />
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.2" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.2" />
|
||||||
@ -16,5 +21,11 @@
|
|||||||
<PackageReference Include="MySql.Data" Version="9.2.0" />
|
<PackageReference Include="MySql.Data" Version="9.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Data.Sqlite">
|
||||||
|
<HintPath>bin\Release\net6.0\Microsoft.Data.Sqlite.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -13,11 +13,6 @@ namespace ProgrammList.ListPrograms {
|
|||||||
|
|
||||||
internal ListPrograms(string sqlType, params string[] filename) {
|
internal ListPrograms(string sqlType, params string[] filename) {
|
||||||
if (sqlType == null) {
|
if (sqlType == null) {
|
||||||
Console.WriteLine("SQL Database not defined in app.conf, allowed types:");
|
|
||||||
Console.WriteLine("MYSQL");
|
|
||||||
Console.WriteLine("MARIADB");
|
|
||||||
Console.WriteLine("MSSQL");
|
|
||||||
Console.WriteLine("SQLITE");
|
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +23,6 @@ namespace ProgrammList.ListPrograms {
|
|||||||
string user = PrmListConfigManager.GetSetting("user");
|
string user = PrmListConfigManager.GetSetting("user");
|
||||||
string pw = PrmListConfigManager.GetSetting("pw");
|
string pw = PrmListConfigManager.GetSetting("pw");
|
||||||
sql = new Mysql(server, database, user, pw);
|
sql = new Mysql(server, database, user, pw);
|
||||||
sqlname = "MySQL/MariaDB";
|
|
||||||
}
|
}
|
||||||
else if (sqlType.Equals("MSSQL", StringComparison.OrdinalIgnoreCase)) {
|
else if (sqlType.Equals("MSSQL", StringComparison.OrdinalIgnoreCase)) {
|
||||||
string server = PrmListConfigManager.GetSetting("server");
|
string server = PrmListConfigManager.GetSetting("server");
|
||||||
@ -36,19 +30,14 @@ namespace ProgrammList.ListPrograms {
|
|||||||
string user = PrmListConfigManager.GetSetting("user");
|
string user = PrmListConfigManager.GetSetting("user");
|
||||||
string pw = PrmListConfigManager.GetSetting("pw");
|
string pw = PrmListConfigManager.GetSetting("pw");
|
||||||
sql = new Mssql(server, user, pw, database);
|
sql = new Mssql(server, user, pw, database);
|
||||||
sqlname = "MSSQL";
|
|
||||||
}
|
}
|
||||||
else if (sqlType.Equals("SQLITE", StringComparison.OrdinalIgnoreCase) && filename != null) {
|
else if (sqlType.Equals("SQLITE", StringComparison.OrdinalIgnoreCase) && filename != null) {
|
||||||
sql = new Sqlite(prgm_path, filename[0]);
|
sql = new Sqlite(prgm_path, filename[0]);
|
||||||
sqlname = "SQLITE";
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Default sqlite im gleichen ordner
|
// Default sqlite im gleichen ordner
|
||||||
sql = new Sqlite(prgm_path, "sqllite.db");
|
sql = new Sqlite(Directory.GetCurrentDirectory() + "\\sqllite.db");
|
||||||
sqlname = "fallback default SQLITE";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void DeleteOldData() {
|
internal void DeleteOldData() {
|
||||||
|
@ -31,14 +31,11 @@ namespace ProgrammList.sql {
|
|||||||
public Sqlite(string prm_path) {
|
public Sqlite(string prm_path) {
|
||||||
string setting = ConfigManager.PrmListConfigManager.GetSetting("filename");
|
string setting = ConfigManager.PrmListConfigManager.GetSetting("filename");
|
||||||
if (setting != null && setting != "") {
|
if (setting != null && setting != "") {
|
||||||
Console.WriteLine("using db filename " + setting);
|
|
||||||
sqlitecon = new SqliteConnection("Data Source=" + prm_path + setting);
|
sqlitecon = new SqliteConnection("Data Source=" + prm_path + setting);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Console.WriteLine("reverting to default db, sqlite filename sqlite.db");
|
|
||||||
sqlitecon = new SqliteConnection("Data Source=" + prm_path + "sqlite.db");
|
sqlitecon = new SqliteConnection("Data Source=" + prm_path + "sqlite.db");
|
||||||
}
|
}
|
||||||
sqlitecon.Open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GetSingleLine(string pcid, string program, string version) {
|
public bool GetSingleLine(string pcid, string program, string version) {
|
||||||
@ -89,7 +86,6 @@ namespace ProgrammList.sql {
|
|||||||
string sqlCommand = "INSERT INTO list(" + cols + ")" + "VALUES(" + result + ")";
|
string sqlCommand = "INSERT INTO list(" + cols + ")" + "VALUES(" + result + ")";
|
||||||
SqliteConnection con;
|
SqliteConnection con;
|
||||||
var command = new SqliteCommand(sqlCommand, sqlitecon, transaction);
|
var command = new SqliteCommand(sqlCommand, sqlitecon, transaction);
|
||||||
Console.WriteLine(sqlCommand);
|
|
||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
Close();
|
Close();
|
||||||
@ -97,13 +93,10 @@ namespace ProgrammList.sql {
|
|||||||
|
|
||||||
public void InsertOrUpdateData(Dictionary<string, string> value) {
|
public void InsertOrUpdateData(Dictionary<string, string> value) {
|
||||||
if (GetSingleLine(value.GetValueOrDefault("PCID"), value.GetValueOrDefault("DisplayName"), value.GetValueOrDefault("DisplayVersion"))) {
|
if (GetSingleLine(value.GetValueOrDefault("PCID"), value.GetValueOrDefault("DisplayName"), value.GetValueOrDefault("DisplayVersion"))) {
|
||||||
|
|
||||||
Console.WriteLine("Update");
|
|
||||||
UpdateData(value);
|
UpdateData(value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Console.WriteLine("Insert");
|
|
||||||
InsertData(value);
|
InsertData(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,7 +137,6 @@ namespace ProgrammList.sql {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine(command.CommandText);
|
|
||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
Close();
|
Close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user