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