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