Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
0a81086722 | |||
299e807e8a | |||
bdb9f412a1 | |||
6599e17a18 |
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.12.35527.113 d17.12
|
VisualStudioVersion = 17.12.35527.113
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProgrammList", "ProgrammList\ProgrammList.csproj", "{06D431CD-A938-4DFD-8D77-4C612FDAD914}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProgrammList", "ProgrammList\ProgrammList.csproj", "{06D431CD-A938-4DFD-8D77-4C612FDAD914}"
|
||||||
EndProject
|
EndProject
|
||||||
@ -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 = 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 = Release|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.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
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
using System.Configuration;
|
|
||||||
|
|
||||||
namespace ProgrammList.ConfigManager {
|
|
||||||
public class ConfigManager {
|
|
||||||
public static string GetSetting(string key) {
|
|
||||||
return ConfigurationManager.AppSettings[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
37
ProgrammList/ConfigManager/PrmListConfigManager.cs
Normal file
37
ProgrammList/ConfigManager/PrmListConfigManager.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace ProgrammList.ConfigManager {
|
||||||
|
public static class PrmListConfigManager {
|
||||||
|
|
||||||
|
public static string GetSetting(string 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) {
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
ProgrammList/Icons/prm_icon/back-end.ico
Normal file
BIN
ProgrammList/Icons/prm_icon/back-end.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
@ -1,12 +1,13 @@
|
|||||||
using ProgrammList.ConfigManager;
|
using ProgrammList.ConfigManager;
|
||||||
using ProgrammList.ListPrograms;
|
using ProgrammList.ListPrograms;
|
||||||
|
using System;
|
||||||
|
|
||||||
class Program {
|
class Program {
|
||||||
public static void Main(string[] args) {
|
public static void Main(string[] args) {
|
||||||
|
|
||||||
string dbType = ConfigManager.GetSetting("DB_Type");
|
string dbType = PrmListConfigManager.GetSetting("DB_Type");
|
||||||
ListPrograms list = new ListPrograms(dbType);
|
ListPrograms list = new ListPrograms();
|
||||||
|
list.init();
|
||||||
Console.WriteLine("Deleting old data");
|
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";
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<Nullable>disable</Nullable>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
<Configurations>Debug;Release;PrgmList</Configurations>
|
<Configurations>Debug;Release;PrgmList</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Icons\prm_icon\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 +19,29 @@
|
|||||||
<PackageReference Include="MySql.Data" Version="9.2.0" />
|
<PackageReference Include="MySql.Data" Version="9.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Update="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net462</TargetFramework>
|
||||||
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
|
<SelfContained>true</SelfContained>
|
||||||
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
<AssemblyName>ProgramList</AssemblyName>
|
||||||
|
<ApplicationIcon>Icons\prm_icon\back-end.ico</ApplicationIcon>
|
||||||
|
<StartupObject>Program</StartupObject>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
using ProgrammList.ConfigManager;
|
||||||
using ProgrammList.sql;
|
using ProgrammList.sql;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace ProgrammList.ListPrograms {
|
namespace ProgrammList.ListPrograms {
|
||||||
internal class ListPrograms {
|
public class ListPrograms {
|
||||||
|
|
||||||
string prgm_path = Directory.GetCurrentDirectory() + "\\";
|
string prgm_path = Directory.GetCurrentDirectory() + "\\";
|
||||||
string[] keyvaluenames = { "DisplayName", "DisplayVersion", "InstallDate" };
|
string[] keyvaluenames = { "DisplayName", "DisplayVersion", "InstallDate" };
|
||||||
private SqlBase sql = null;
|
private SqlBase sql = null;
|
||||||
|
|
||||||
internal ListPrograms(string sqlType) {
|
public void init() {
|
||||||
|
string sqlType = PrmListConfigManager.GetSetting("DB_Type");
|
||||||
if (sqlType == null) {
|
if (sqlType == null) {
|
||||||
Console.WriteLine("SQL Database not defined in app.conf, allowed types:");
|
Console.WriteLine("SQL Database not defined in app.conf, allowed types:");
|
||||||
Console.WriteLine("MYSQL");
|
Console.WriteLine("MYSQL");
|
||||||
@ -30,12 +35,12 @@ namespace ProgrammList.ListPrograms {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void DeleteOldData() {
|
public void DeleteOldData() {
|
||||||
sql.CheckTableExists();
|
sql.CheckTableExists();
|
||||||
sql.DeleteOldData(Dns.GetHostName());
|
sql.DeleteOldData(Dns.GetHostName());
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void createList(string hkey, string bit) {
|
public void createList(string hkey, string bit) {
|
||||||
RegistryKey key = Registry.LocalMachine.OpenSubKey(hkey);
|
RegistryKey key = Registry.LocalMachine.OpenSubKey(hkey);
|
||||||
try {
|
try {
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
@ -56,11 +61,11 @@ namespace ProgrammList.ListPrograms {
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = String.Join("", value.ToArray());
|
// result = String.Join("", value.ToArray());
|
||||||
|
//
|
||||||
if (result.EndsWith(",")) {
|
// if (result.EndsWith(",")) {
|
||||||
result = result.Remove(result.Length - 1);
|
// result = result.Remove(result.Length - 1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
value.Add("PCID", "'" + Dns.GetHostName() + "'");
|
value.Add("PCID", "'" + Dns.GetHostName() + "'");
|
||||||
value.Add("update_date", "'" + DateTime.Now + "'");
|
value.Add("update_date", "'" + DateTime.Now + "'");
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
using Microsoft.Data.SqlClient;
|
using Microsoft.Data.SqlClient;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace ProgrammList.sql {
|
namespace ProgrammList.sql {
|
||||||
public class Mssql : SqlBaseAbstract {
|
public class Mssql : SqlBaseAbstract {
|
||||||
@ -46,6 +48,8 @@ namespace ProgrammList.sql {
|
|||||||
Open(DB.MSSQL);
|
Open(DB.MSSQL);
|
||||||
var command = sqlcon.CreateCommand();
|
var command = sqlcon.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";
|
command.CommandText = "select case when exists (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'prgmlist' AND TABLE_NAME = 'list') then 1 else 0 end";
|
||||||
|
|
||||||
|
Console.WriteLine("Executing: " + command.CommandText);
|
||||||
var returncode = command.ExecuteScalar();
|
var returncode = command.ExecuteScalar();
|
||||||
if (returncode != null) {
|
if (returncode != null) {
|
||||||
int rc;
|
int rc;
|
||||||
@ -76,7 +80,9 @@ namespace ProgrammList.sql {
|
|||||||
|
|
||||||
string result = "";
|
string result = "";
|
||||||
for (int i = 0; i < valuenames.Length; i++) {
|
for (int i = 0; i < valuenames.Length; i++) {
|
||||||
result += valuesqlCommand.GetValueOrDefault(valuenames[i]);
|
string val = "";
|
||||||
|
valuesqlCommand.TryGetValue(valuenames[i], out val);
|
||||||
|
result += val;
|
||||||
|
|
||||||
if (i < valuenames.Length - 1) {
|
if (i < valuenames.Length - 1) {
|
||||||
result += ",";
|
result += ",";
|
||||||
@ -96,7 +102,13 @@ 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"))) {
|
string pcid = "";
|
||||||
|
value.TryGetValue("PCID", out pcid);
|
||||||
|
string displayName = "";
|
||||||
|
value.TryGetValue("DisplayName", out displayName);
|
||||||
|
string displayVersion = "";
|
||||||
|
value.TryGetValue("DisplayVersion", out displayVersion);
|
||||||
|
if (GetSingleLine(pcid, displayName, displayVersion)) {
|
||||||
UpdateData(value);
|
UpdateData(value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -120,7 +132,9 @@ namespace ProgrammList.sql {
|
|||||||
|
|
||||||
string result = "set ";
|
string result = "set ";
|
||||||
for (int i = 0; i < valuenames.Length; i++) {
|
for (int i = 0; i < valuenames.Length; i++) {
|
||||||
result += valuenames[i] + " = " + value.GetValueOrDefault(valuenames[i]);
|
string val = "";
|
||||||
|
value.TryGetValue(valuenames[i], out val);
|
||||||
|
result += valuenames[i] + " = " + val;
|
||||||
|
|
||||||
if (i < valuenames.Length - 1) {
|
if (i < valuenames.Length - 1) {
|
||||||
result += " ,";
|
result += " ,";
|
||||||
@ -128,15 +142,23 @@ namespace ProgrammList.sql {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sqlCommand = sqlCommand + result;
|
sqlCommand = sqlCommand + result;
|
||||||
sqlCommand = sqlCommand + " WHERE PCID = " + value.GetValueOrDefault("PCID") +
|
string pcid = "";
|
||||||
" and DisplayName like " + value.GetValueOrDefault("DisplayName") +
|
value.TryGetValue("PCID", out pcid);
|
||||||
" and DisplayVersion like " + value.GetValueOrDefault("DisplayVersion");
|
string displayName = "";
|
||||||
|
value.TryGetValue("DisplayName", out displayName);
|
||||||
|
string displayVersion = "";
|
||||||
|
value.TryGetValue("DisplayVersion", out displayVersion);
|
||||||
|
sqlCommand = sqlCommand + " WHERE PCID = " + pcid +
|
||||||
|
" and DisplayName like " + displayName +
|
||||||
|
" and DisplayVersion like " + displayVersion;
|
||||||
|
|
||||||
|
|
||||||
var command = new SqlCommand(sqlCommand, sqlcon, transaction);
|
var command = new SqlCommand(sqlCommand, sqlcon, transaction);
|
||||||
for (int i = 0; i < valuenames.Length; i++) {
|
for (int i = 0; i < valuenames.Length; i++) {
|
||||||
if (valuenames[i] != "PCID") {
|
if (valuenames[i] != "PCID") {
|
||||||
command.Parameters.AddWithValue("$" + valuenames[i], value.GetValueOrDefault(valuenames[i]));
|
string itemValue = "";
|
||||||
|
value.TryGetValue(valuenames[i], out itemValue);
|
||||||
|
command.Parameters.AddWithValue("$" + valuenames[i], itemValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Console.WriteLine(sqlCommand);
|
Console.WriteLine(sqlCommand);
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace ProgrammList.sql {
|
namespace ProgrammList.sql {
|
||||||
|
|
||||||
|
|
||||||
internal class Mysql : SqlBaseAbstract {
|
public class Mysql : SqlBaseAbstract {
|
||||||
|
|
||||||
|
|
||||||
public Boolean GetSingleLine(string pcid, string program, string version) {
|
public Boolean GetSingleLine(string pcid, string program, string version) {
|
||||||
@ -40,7 +42,9 @@ namespace ProgrammList.sql {
|
|||||||
|
|
||||||
string result = "";
|
string result = "";
|
||||||
for (int i = 0; i < valuenames.Length; i++) {
|
for (int i = 0; i < valuenames.Length; i++) {
|
||||||
result += valuesqlCommand.GetValueOrDefault(valuenames[i]);
|
string val = "";
|
||||||
|
valuesqlCommand.TryGetValue(valuenames[i], out val);
|
||||||
|
result += val;
|
||||||
|
|
||||||
if (i < valuenames.Length - 1) {
|
if (i < valuenames.Length - 1) {
|
||||||
result += ",";
|
result += ",";
|
||||||
@ -48,7 +52,7 @@ namespace ProgrammList.sql {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var cols = String.Join(",", valuenames);
|
var cols = string.Join(",", valuenames);
|
||||||
|
|
||||||
string sqlCommand = "INSERT INTO list(" + cols + ")" + "VALUES(" + result + ")";
|
string sqlCommand = "INSERT INTO list(" + cols + ")" + "VALUES(" + result + ")";
|
||||||
|
|
||||||
@ -60,7 +64,13 @@ 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"))) {
|
string pcid = "";
|
||||||
|
value.TryGetValue("PCID", out pcid);
|
||||||
|
string displayName = "";
|
||||||
|
value.TryGetValue("DisplayName", out displayName);
|
||||||
|
string displayVersion = "";
|
||||||
|
value.TryGetValue("DisplayVersion", out displayVersion);
|
||||||
|
if (GetSingleLine(pcid, displayName, displayVersion)) {
|
||||||
UpdateData(value);
|
UpdateData(value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -75,7 +85,9 @@ namespace ProgrammList.sql {
|
|||||||
|
|
||||||
string result = "set ";
|
string result = "set ";
|
||||||
for (int i = 0; i < valuenames.Length; i++) {
|
for (int i = 0; i < valuenames.Length; i++) {
|
||||||
result += valuenames[i] + " = " + value.GetValueOrDefault(valuenames[i]);
|
string val = "";
|
||||||
|
value.TryGetValue(valuenames[i], out val);
|
||||||
|
result += valuenames[i] + " = " + val;
|
||||||
|
|
||||||
if (i < valuenames.Length - 1) {
|
if (i < valuenames.Length - 1) {
|
||||||
result += " ,";
|
result += " ,";
|
||||||
@ -83,15 +95,23 @@ namespace ProgrammList.sql {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sqlCommand = sqlCommand + result;
|
sqlCommand = sqlCommand + result;
|
||||||
sqlCommand = sqlCommand + " WHERE PCID = " + value.GetValueOrDefault("PCID") +
|
string pcid = "";
|
||||||
" and DisplayName like " + value.GetValueOrDefault("DisplayName") +
|
value.TryGetValue("PCID", out pcid);
|
||||||
" and DisplayVersion like " + value.GetValueOrDefault("DisplayVersion");
|
string displayName = "";
|
||||||
|
value.TryGetValue("DisplayName", out displayName);
|
||||||
|
string displayVersion = "";
|
||||||
|
value.TryGetValue("DisplayVersion", out displayVersion);
|
||||||
|
sqlCommand = sqlCommand + " WHERE PCID = " + pcid +
|
||||||
|
" and DisplayName like " + displayName +
|
||||||
|
" and DisplayVersion like " + displayVersion;
|
||||||
|
|
||||||
|
|
||||||
var command = new MySqlCommand(sqlCommand, mysqlcon, transaction);
|
var command = new MySqlCommand(sqlCommand, mysqlcon, transaction);
|
||||||
for (int i = 0; i < valuenames.Length; i++) {
|
for (int i = 0; i < valuenames.Length; i++) {
|
||||||
if (valuenames[i] != "PCID") {
|
if (valuenames[i] != "PCID") {
|
||||||
command.Parameters.AddWithValue("$" + valuenames[i], value.GetValueOrDefault(valuenames[i]));
|
string itemValue = "";
|
||||||
|
value.TryGetValue(valuenames[i], out itemValue);
|
||||||
|
command.Parameters.AddWithValue("$" + valuenames[i], itemValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Console.WriteLine(sqlCommand);
|
Console.WriteLine(sqlCommand);
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
namespace ProgrammList.sql {
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace ProgrammList.sql {
|
||||||
|
|
||||||
interface SqlBase {
|
interface SqlBase {
|
||||||
|
|
||||||
|
|
||||||
internal bool GetSingleLine(string pcid, string program, string version);
|
bool GetSingleLine(string pcid, string program, string version);
|
||||||
|
|
||||||
internal void CheckTableExists();
|
void CheckTableExists();
|
||||||
|
|
||||||
internal void InsertData(Dictionary<string, string> valuesqlCommand);
|
|
||||||
|
|
||||||
internal void InsertOrUpdateData(Dictionary<string, string> value);
|
|
||||||
|
|
||||||
internal void DeleteOldData(string hostname);
|
void InsertData(Dictionary<string, string> valuesqlCommand);
|
||||||
|
|
||||||
internal void UpdateData(Dictionary<string, string> value);
|
|
||||||
|
void InsertOrUpdateData(Dictionary<string, string> value);
|
||||||
|
|
||||||
|
void DeleteOldData(string hostname);
|
||||||
|
void UpdateData(Dictionary<string, string> value);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
using Microsoft.Data.SqlClient;
|
using Microsoft.Data.SqlClient;
|
||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace ProgrammList.sql {
|
namespace ProgrammList.sql {
|
||||||
|
|
||||||
@ -59,11 +61,15 @@ namespace ProgrammList.sql {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SqlBase.GetSingleLine(string pcid, string program, string version) {
|
void SqlBase.CheckTableExists() {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SqlBase.CheckTableExists() {
|
void SqlBase.DeleteOldData(string hostname) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SqlBase.GetSingleLine(string pcid, string program, string version) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,10 +81,6 @@ namespace ProgrammList.sql {
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SqlBase.DeleteOldData(string hostname) {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SqlBase.UpdateData(Dictionary<string, string> value) {
|
void SqlBase.UpdateData(Dictionary<string, string> value) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
|
|
||||||
namespace ProgrammList.sql {
|
namespace ProgrammList.sql {
|
||||||
@ -42,7 +44,8 @@ namespace ProgrammList.sql {
|
|||||||
|
|
||||||
string result = "";
|
string result = "";
|
||||||
for (int i = 0; i < valuenames.Length; i++) {
|
for (int i = 0; i < valuenames.Length; i++) {
|
||||||
result += valuesqlCommand.GetValueOrDefault(valuenames[i]);
|
string value = "";
|
||||||
|
result += valuesqlCommand.TryGetValue(valuenames[i], out value);
|
||||||
|
|
||||||
if (i < valuenames.Length - 1) {
|
if (i < valuenames.Length - 1) {
|
||||||
result += ",";
|
result += ",";
|
||||||
@ -61,7 +64,13 @@ 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"))) {
|
string pcid = "";
|
||||||
|
string displayName = "";
|
||||||
|
string displayVersion = "";
|
||||||
|
value.TryGetValue("PCID", out pcid);
|
||||||
|
value.TryGetValue("DisplayName", out displayName);
|
||||||
|
value.TryGetValue("DisplayVersion", out displayVersion);
|
||||||
|
if (GetSingleLine(pcid, displayName, displayVersion)) {
|
||||||
|
|
||||||
Console.WriteLine("Update");
|
Console.WriteLine("Update");
|
||||||
UpdateData(value);
|
UpdateData(value);
|
||||||
@ -86,7 +95,9 @@ namespace ProgrammList.sql {
|
|||||||
|
|
||||||
string result = "set ";
|
string result = "set ";
|
||||||
for (int i = 0; i < valuenames.Length; i++) {
|
for (int i = 0; i < valuenames.Length; i++) {
|
||||||
result += valuenames[i] + " = " + value.GetValueOrDefault(valuenames[i]);
|
string res = "";
|
||||||
|
value.TryGetValue(valuenames[i], out res);
|
||||||
|
result += valuenames[i] + " = " + res;
|
||||||
|
|
||||||
if (i < valuenames.Length - 1) {
|
if (i < valuenames.Length - 1) {
|
||||||
result += " ,";
|
result += " ,";
|
||||||
@ -94,15 +105,23 @@ namespace ProgrammList.sql {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sqlCommand = sqlCommand + result;
|
sqlCommand = sqlCommand + result;
|
||||||
sqlCommand = sqlCommand + " WHERE PCID = " + value.GetValueOrDefault("PCID") +
|
string pcid = "";
|
||||||
" and DisplayName like " + value.GetValueOrDefault("DisplayName") +
|
value.TryGetValue("PCID", out pcid);
|
||||||
" and DisplayVersion like " + value.GetValueOrDefault("DisplayVersion");
|
string displayName = "";
|
||||||
|
value.TryGetValue("DisplayName", out displayName);
|
||||||
|
string displayVersion = "";
|
||||||
|
value.TryGetValue("DisplayVersion", out displayVersion);
|
||||||
|
sqlCommand = sqlCommand + " WHERE PCID = " + pcid +
|
||||||
|
" and DisplayName like " + displayName +
|
||||||
|
" and DisplayVersion like " + displayVersion;
|
||||||
|
|
||||||
|
|
||||||
var command = new SqliteCommand(sqlCommand, sqlitecon, transaction);
|
var command = new SqliteCommand(sqlCommand, sqlitecon, transaction);
|
||||||
for (int i = 0; i < valuenames.Length; i++) {
|
for (int i = 0; i < valuenames.Length; i++) {
|
||||||
if (valuenames[i] != "PCID") {
|
if (valuenames[i] != "PCID") {
|
||||||
command.Parameters.AddWithValue("$" + valuenames[i], value.GetValueOrDefault(valuenames[i]));
|
string itemValue = "";
|
||||||
|
value.TryGetValue(valuenames[i], out itemValue);
|
||||||
|
command.Parameters.AddWithValue("$" + valuenames[i], itemValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
README.md
33
README.md
@ -1 +1,32 @@
|
|||||||
# ProgrammList
|
|
||||||
|
# ProgrammList (EN)
|
||||||
|
|
||||||
|
A Program to create a list of programs installled on a system. You may add this program on a networkfolder to get more information from single clients that execute a script to invoke it and save the data to a centralized database.
|
||||||
|
|
||||||
|
Supported databases are MSSQL, Sqlite and MySql.
|
||||||
|
|
||||||
|
For Sqlite a database file will be created as long as the parameter for it is in the coresponding app.conf file. The app.conf file has to be in the same folder as the .exe file.
|
||||||
|
For MSSQL and MySql standard parameters are used currently such as IP (localhost) and Port.
|
||||||
|
|
||||||
|
In later versions this should be made configurable through the app.conf file.
|
||||||
|
|
||||||
|
Plan for the future:
|
||||||
|
- UI To configure the program through parameter, default will be cli auto run. there may be branches for winform vs wpf
|
||||||
|
- Additional Database support and eventuall csv support. (
|
||||||
|
- Depending on .net version (see branches) a portable version or installer.
|
||||||
|
|
||||||
|
# ProgrammList (GER)
|
||||||
|
|
||||||
|
Ein Programm zum erstellen einer Liste installierter Programme auf einem Rechner. Man kann das Programmm in einen Netzwerkordner legen um von mehreren Systemen die Information zu bekommen und diese Zentral zu Speichern.
|
||||||
|
|
||||||
|
Untersützt werden bisher Speichermethoden in MSSQL, Sqlite und MySql.
|
||||||
|
|
||||||
|
Für Sqlite wird eine Dantenbankdatei über eine app.conf date erstellt. Die app.conf Datei muss sich dazu im gleichen Ordner wie die exe befinden.
|
||||||
|
Für MSSQL und MySql werden bisher Standard Parameter für IP (Localhost) und Port verwendet.
|
||||||
|
|
||||||
|
In Späteren Versionen sollte dies auch über das Config file editierbar sein.
|
||||||
|
|
||||||
|
Zukunftsplan:
|
||||||
|
- Oberfläche zur Einrichtung der Konfigurationsdatei. Eventuell in eigenen Branches (WinForm vs WPF)
|
||||||
|
- Zusätzliche Datenbanken und eventuell auch ein CSV report.
|
||||||
|
- Je nach .net version, Portable single exe oder ein installer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user