erweitertes lesen der config dateien. kleinere fixes für syntax errors
This commit is contained in:
parent
036671a6cb
commit
ef7493a09a
@ -1,7 +1,7 @@
|
||||
using System.Configuration;
|
||||
|
||||
namespace ProgrammList.ConfigManager {
|
||||
internal class ConfigManager {
|
||||
public class ConfigManager {
|
||||
public static string GetSetting(string key) {
|
||||
return ConfigurationManager.AppSettings[key];
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
using ProgrammList.ListPrograms;
|
||||
using ProgrammList.ConfigManager;
|
||||
using ProgrammList.ListPrograms;
|
||||
|
||||
class Program {
|
||||
public static void Main(string[] args) {
|
||||
|
||||
|
||||
ListPrograms list = new ListPrograms();
|
||||
string dbType = ConfigManager.GetSetting("DB_Type");
|
||||
ListPrograms list = new ListPrograms(dbType);
|
||||
|
||||
Console.WriteLine("Deleting old data");
|
||||
list.DeleteOldData();
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Microsoft.Win32;
|
||||
using Microsoft.Win32;
|
||||
using ProgrammList.sql;
|
||||
using System.Net;
|
||||
|
||||
@ -8,7 +7,7 @@ namespace ProgrammList.ListPrograms {
|
||||
|
||||
string prgm_path = Directory.GetCurrentDirectory() + "\\";
|
||||
string[] keyvaluenames = { "DisplayName", "DisplayVersion", "InstallDate" };
|
||||
private SqlBase sql;
|
||||
private SqlBase sql = null;
|
||||
|
||||
internal ListPrograms(string sqlType) {
|
||||
if (sqlType == null) {
|
||||
@ -18,7 +17,6 @@ namespace ProgrammList.ListPrograms {
|
||||
Console.WriteLine("MSSQL");
|
||||
Console.WriteLine("SQLITE");
|
||||
throw new ArgumentNullException();
|
||||
System.Environment.Exit(13);
|
||||
}
|
||||
|
||||
if (sqlType.Equals("MYSQL", StringComparison.OrdinalIgnoreCase) || sqlType.Equals("MARIADB", StringComparison.OrdinalIgnoreCase)) {
|
||||
@ -28,10 +26,7 @@ namespace ProgrammList.ListPrograms {
|
||||
sql = new Mssql();
|
||||
}
|
||||
else if (sqlType.Equals("SQLITE", StringComparison.OrdinalIgnoreCase)) {
|
||||
string filename = ConfigManager.GetSetting("Filename");
|
||||
if (!filename.IsNullOrEmpty()) {
|
||||
sql = new Sqlite(prgm_path, filename);
|
||||
}
|
||||
sql = new Sqlite(prgm_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace ProgrammList.sql {
|
||||
else if (sqlcon != null) {
|
||||
sqlcon.Close();
|
||||
}
|
||||
else if (sqlitecon != null {
|
||||
else if (sqlitecon != null) {
|
||||
sqlitecon.Close();
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,13 @@
|
||||
using Microsoft.Data.Sqlite;
|
||||
using System.Configuration;
|
||||
|
||||
namespace ProgrammList.sql {
|
||||
public class Sqlite : SqlBaseAbstract {
|
||||
|
||||
string filename;
|
||||
|
||||
public Sqlite(string prm_path, string file) {
|
||||
|
||||
string prgm_path = prm_path + filename;
|
||||
filename = file;
|
||||
|
||||
sqlitecon = new SqliteConnection("Data Source=" + prm_path + filename);
|
||||
public Sqlite(string prm_path) {
|
||||
sqlitecon = new SqliteConnection("Data Source=" + prm_path + ConfigurationManager.AppSettings["filename"]);
|
||||
sqlitecon.Open();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user