erste anpassungen für neue impementierte connection der verschiedenen sql server
This commit is contained in:
parent
19b63d6c27
commit
00176a2d83
@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.12.35527.113 d17.12
|
||||
VisualStudioVersion = 17.12.35527.113
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProgrammList", "ProgrammList\ProgrammList.csproj", "{06D431CD-A938-4DFD-8D77-4C612FDAD914}"
|
||||
EndProject
|
||||
@ -15,8 +15,8 @@ Global
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|Any CPU.Build.0 = Release|Any CPU
|
||||
{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|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
|
||||
|
@ -1,17 +1,35 @@
|
||||
using System.Configuration;
|
||||
|
||||
namespace ProgrammList.ConfigManager {
|
||||
public class ConfigManager {
|
||||
public static class PrmListConfigManager {
|
||||
|
||||
public static string GetSetting(string key) {
|
||||
return ConfigurationManager.AppSettings[key];
|
||||
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);
|
||||
return config.AppSettings.Settings[key].Value;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Console.WriteLine("Error on Key " + key + ": " + e.ToString());
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
return "13";
|
||||
}
|
||||
|
||||
public static void SetSetting(string key, string value) {
|
||||
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
configuration.AppSettings.Settings[key].Value = value;
|
||||
configuration.Save(ConfigurationSaveMode.Full, true);
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using ProgrammList.ListPrograms;
|
||||
class Program {
|
||||
public static void Main(string[] args) {
|
||||
|
||||
string dbType = ConfigManager.GetSetting("DB_Type");
|
||||
string dbType = PrmListConfigManager.GetSetting("DB_Type");
|
||||
ListPrograms list = new ListPrograms(dbType);
|
||||
|
||||
Console.WriteLine("Deleting old data");
|
||||
|
63
ProgrammList/Properties/Resources.Designer.cs
generated
Normal file
63
ProgrammList/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ProgrammList.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProgrammList.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
101
ProgrammList/Properties/Resources.resx
Normal file
101
ProgrammList/Properties/Resources.resx
Normal file
@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -9,7 +9,7 @@ namespace ProgrammList.ListPrograms {
|
||||
string[] keyvaluenames = { "DisplayName", "DisplayVersion", "InstallDate" };
|
||||
private SqlBase sql = null;
|
||||
|
||||
internal ListPrograms(string sqlType) {
|
||||
internal ListPrograms(string sqlType, params string[] filename) {
|
||||
if (sqlType == null) {
|
||||
Console.WriteLine("SQL Database not defined in app.conf, allowed types:");
|
||||
Console.WriteLine("MYSQL");
|
||||
@ -25,8 +25,12 @@ namespace ProgrammList.ListPrograms {
|
||||
else if (sqlType.Equals("MSSQL", StringComparison.OrdinalIgnoreCase)) {
|
||||
sql = new Mssql();
|
||||
}
|
||||
else if (sqlType.Equals("SQLITE", StringComparison.OrdinalIgnoreCase)) {
|
||||
sql = new Sqlite(prgm_path);
|
||||
else if (sqlType.Equals("SQLITE", StringComparison.OrdinalIgnoreCase) && filename != null) {
|
||||
sql = new Sqlite(prgm_path, filename[0]);
|
||||
}
|
||||
else {
|
||||
// Default sqlite im gleichen ordner
|
||||
sql = new Sqlite(prgm_path, "sqllite.db");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,13 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace ProgrammList.sql {
|
||||
public class Mssql : SqlBaseAbstract {
|
||||
public class Mssql : SqlBase {
|
||||
|
||||
public string[] valuenames = { "PCID", "DisplayName", "DisplayVersion", "InstallDate", "update_date", "APP_Architecture" };
|
||||
public string connstring = null;
|
||||
string constring = null;
|
||||
|
||||
SqlConnection mssqlcon = null;
|
||||
|
||||
//private static Dbconnection instance;
|
||||
public Mssql() {
|
||||
@ -15,12 +21,22 @@ namespace ProgrammList.sql {
|
||||
TrustServerCertificate = true
|
||||
};
|
||||
|
||||
connstring = builder.ToString();
|
||||
constring = builder.ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Open() {
|
||||
mssqlcon.Open();
|
||||
}
|
||||
|
||||
public void Close() {
|
||||
mssqlcon.Close();
|
||||
}
|
||||
|
||||
public void GetAllData() {
|
||||
Open(DB.MSSQL);
|
||||
var command = sqlcon.CreateCommand();
|
||||
Open();
|
||||
var command = mssqlcon.CreateCommand();
|
||||
command.CommandText = @"SELECT * FROM list";
|
||||
|
||||
using (var reader = command.ExecuteReader()) {
|
||||
@ -31,8 +47,8 @@ namespace ProgrammList.sql {
|
||||
Close();
|
||||
}
|
||||
public bool GetSingleLine(string pcid, string program, string version) {
|
||||
Open(DB.MSSQL);
|
||||
var command = sqlcon.CreateCommand();
|
||||
Open();
|
||||
var command = mssqlcon.CreateCommand();
|
||||
command.CommandText = @"SELECT * FROM list where PCID like "
|
||||
+ pcid + " and DisplayName like "
|
||||
+ program + " and DisplayVersion like " + version + ";";
|
||||
@ -43,8 +59,8 @@ namespace ProgrammList.sql {
|
||||
}
|
||||
|
||||
public void CheckTableExists() {
|
||||
Open(DB.MSSQL);
|
||||
var command = sqlcon.CreateCommand();
|
||||
Open();
|
||||
var command = mssqlcon.CreateCommand();
|
||||
command.CommandText = "select case when exists (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'prgmlist' AND TABLE_NAME = 'list') then 1 else 0 end";
|
||||
var returncode = command.ExecuteScalar();
|
||||
if (returncode != null) {
|
||||
@ -71,8 +87,8 @@ namespace ProgrammList.sql {
|
||||
|
||||
|
||||
public void InsertData(Dictionary<string, string> valuesqlCommand) {
|
||||
Open(DB.MSSQL);
|
||||
var transaction = sqlcon.BeginTransaction();
|
||||
Open();
|
||||
var transaction = mssqlcon.BeginTransaction();
|
||||
|
||||
string result = "";
|
||||
for (int i = 0; i < valuenames.Length; i++) {
|
||||
@ -88,7 +104,7 @@ namespace ProgrammList.sql {
|
||||
|
||||
string sqlCommand = "INSERT INTO list(" + cols + ")" + "VALUES(" + result + ")";
|
||||
|
||||
var command = new SqlCommand(sqlCommand, sqlcon, transaction);
|
||||
var command = new SqlCommand(sqlCommand, mssqlcon, transaction);
|
||||
command.ExecuteNonQuery();
|
||||
transaction.Commit();
|
||||
Console.WriteLine(sqlCommand);
|
||||
@ -105,8 +121,8 @@ namespace ProgrammList.sql {
|
||||
}
|
||||
|
||||
public void DeleteOldData(string hostname) {
|
||||
Open(DB.MSSQL);
|
||||
var command = sqlcon.CreateCommand();
|
||||
Open();
|
||||
var command = mssqlcon.CreateCommand();
|
||||
string sqlCommand = @"delete from list where PCID = '" + hostname + "';";
|
||||
command.CommandText = sqlCommand;
|
||||
command.ExecuteReader();
|
||||
@ -114,8 +130,8 @@ namespace ProgrammList.sql {
|
||||
}
|
||||
|
||||
public void UpdateData(Dictionary<string, string> value) {
|
||||
Open(DB.MSSQL);
|
||||
var transaction = sqlcon.BeginTransaction();
|
||||
Open();
|
||||
var transaction = mssqlcon.BeginTransaction();
|
||||
string sqlCommand = @"Update list ";
|
||||
|
||||
string result = "set ";
|
||||
@ -133,7 +149,7 @@ namespace ProgrammList.sql {
|
||||
" and DisplayVersion like " + value.GetValueOrDefault("DisplayVersion");
|
||||
|
||||
|
||||
var command = new SqlCommand(sqlCommand, sqlcon, transaction);
|
||||
var command = new SqlCommand(sqlCommand, mssqlcon, transaction);
|
||||
for (int i = 0; i < valuenames.Length; i++) {
|
||||
if (valuenames[i] != "PCID") {
|
||||
command.Parameters.AddWithValue("$" + valuenames[i], value.GetValueOrDefault(valuenames[i]));
|
||||
|
@ -3,11 +3,14 @@
|
||||
namespace ProgrammList.sql {
|
||||
|
||||
|
||||
internal class Mysql : SqlBaseAbstract {
|
||||
internal class Mysql {
|
||||
public string[] valuenames = { "PCID", "DisplayName", "DisplayVersion", "InstallDate", "update_date", "APP_Architecture" };
|
||||
public string connstring = null;
|
||||
public MySqlConnection mysqlcon = null;
|
||||
|
||||
|
||||
public Boolean GetSingleLine(string pcid, string program, string version) {
|
||||
Open(DB.MYSQL);
|
||||
Open();
|
||||
var command = mysqlcon.CreateCommand();
|
||||
command.CommandText = @"SELECT * FROM list where PCID like "
|
||||
+ pcid + " and DisplayName like "
|
||||
@ -18,8 +21,17 @@ namespace ProgrammList.sql {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public void Open() {
|
||||
mysqlcon.Open();
|
||||
}
|
||||
|
||||
public void Close() {
|
||||
mysqlcon.Close();
|
||||
}
|
||||
|
||||
public void CheckTableExists() {
|
||||
Open(DB.MYSQL);
|
||||
Open();
|
||||
var command = mysqlcon.CreateCommand();
|
||||
command.CommandText = @"SHOW TABLES LIKE 'list';";
|
||||
var name = command.ExecuteScalar();
|
||||
@ -35,7 +47,7 @@ namespace ProgrammList.sql {
|
||||
|
||||
|
||||
public void InsertData(Dictionary<string, string> valuesqlCommand) {
|
||||
Open(DB.MYSQL);
|
||||
Open();
|
||||
var transaction = mysqlcon.BeginTransaction();
|
||||
|
||||
string result = "";
|
||||
@ -69,7 +81,7 @@ namespace ProgrammList.sql {
|
||||
}
|
||||
|
||||
public void UpdateData(Dictionary<string, string> value) {
|
||||
Open(DB.MYSQL);
|
||||
Open();
|
||||
var transaction = mysqlcon.BeginTransaction();
|
||||
string sqlCommand = @"Update list ";
|
||||
|
||||
@ -102,7 +114,7 @@ namespace ProgrammList.sql {
|
||||
|
||||
|
||||
public void DeleteOldData(string hostname) {
|
||||
Open(DB.MYSQL);
|
||||
Open();
|
||||
var command = mysqlcon.CreateCommand();
|
||||
string sqlCommand = @"delete from list where PCID = '" + hostname + "';";
|
||||
command.CommandText = sqlCommand;
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
interface SqlBase {
|
||||
|
||||
|
||||
internal void Open();
|
||||
internal void Close();
|
||||
internal bool GetSingleLine(string pcid, string program, string version);
|
||||
|
||||
internal void CheckTableExists();
|
||||
|
@ -1,86 +0,0 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
namespace ProgrammList.sql {
|
||||
|
||||
public abstract class SqlBaseAbstract : SqlBase {
|
||||
|
||||
|
||||
public string[] valuenames = { "PCID", "DisplayName", "DisplayVersion", "InstallDate", "update_date", "APP_Architecture" };
|
||||
public string connstring = null;
|
||||
public MySqlConnection mysqlcon = null;
|
||||
public SqlConnection sqlcon = null;
|
||||
public SqliteConnection sqlitecon = null;
|
||||
|
||||
public void Close() {
|
||||
if (mysqlcon != null) {
|
||||
mysqlcon.Close();
|
||||
}
|
||||
else if (sqlcon != null) {
|
||||
sqlcon.Close();
|
||||
}
|
||||
else if (sqlitecon != null) {
|
||||
sqlitecon.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Open(DB type) {
|
||||
switch (type) {
|
||||
case DB.MYSQL:
|
||||
case DB.MARIADB:
|
||||
mysqlcon = new MySqlConnection(connstring);
|
||||
try {
|
||||
mysqlcon.Open();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Console.Write(ex.ToString());
|
||||
}
|
||||
break;
|
||||
case DB.MSSQL:
|
||||
sqlcon = new SqlConnection(connstring);
|
||||
try {
|
||||
mysqlcon.Open();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Console.Write(ex.ToString());
|
||||
}
|
||||
break;
|
||||
case DB.SQLITE:
|
||||
sqlitecon = new SqliteConnection(connstring);
|
||||
try {
|
||||
mysqlcon.Open();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Console.Write(ex.ToString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool SqlBase.GetSingleLine(string pcid, string program, string version) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void SqlBase.CheckTableExists() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void SqlBase.InsertData(Dictionary<string, string> valuesqlCommand) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void SqlBase.InsertOrUpdateData(Dictionary<string, string> value) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void SqlBase.DeleteOldData(string hostname) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void SqlBase.UpdateData(Dictionary<string, string> value) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,43 @@
|
||||
using Microsoft.Data.Sqlite;
|
||||
using System.Configuration;
|
||||
|
||||
namespace ProgrammList.sql {
|
||||
public class Sqlite : SqlBaseAbstract {
|
||||
public class Sqlite : SqlBase {
|
||||
|
||||
string filename;
|
||||
SqliteConnection sqlitecon;
|
||||
|
||||
public string[] valuenames = { "PCID", "DisplayName", "DisplayVersion", "InstallDate", "update_date", "APP_Architecture" };
|
||||
public string connstring = null;
|
||||
|
||||
public Sqlite(string prm_path, string filename) {
|
||||
sqlitecon = new SqliteConnection("Data Source=" + prm_path + filename);
|
||||
}
|
||||
|
||||
public void Open() {
|
||||
sqlitecon.Open();
|
||||
}
|
||||
|
||||
public void Close() {
|
||||
sqlitecon.Close();
|
||||
}
|
||||
|
||||
|
||||
public void Open(DB type) {
|
||||
sqlitecon = new SqliteConnection(connstring);
|
||||
sqlitecon.Open();
|
||||
}
|
||||
|
||||
|
||||
public Sqlite(string prm_path) {
|
||||
sqlitecon = new SqliteConnection("Data Source=" + prm_path + ConfigurationManager.AppSettings["filename"]);
|
||||
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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user