SafeDispatch/SafeMobileLIB_DLL/DBmanagers/DBupdateManager.cs

75 lines
2.1 KiB
C#
Raw Normal View History

2024-02-22 16:43:59 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Npgsql;
using System.IO;
namespace SafeMobileLib
{
public class DBupdateManager : DBmanager
{
public DBupdateManager(string p_server, string p_dbname, string p_user, string p_password, string p_port)
: base(p_server, p_dbname, p_user, p_password, p_port)
{
}
public sqlResponse Insert_New_DBUpdate(String Version)
{
sqlResponse resp = sqlResponse.SQLerror;
long TimeNow = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
try
{
using (NpgsqlConnection connection = new NpgsqlConnection())
{
connection.ConnectionString = getConnectionString();
connection.Open();
string query = "INSERT INTO updatelist (version,timeGMT) VALUES('" + Version + "'," + TimeNow + ")";
using (NpgsqlCommand cmd = new NpgsqlCommand(query, connection))
{
cmd.ExecuteNonQuery();
}
resp = sqlResponse.done;
}
}
catch (Exception o)
{
Console.WriteLine("File: SMdb_access.cs Meth: INSERT NEW UPDATE in Database " + o.Message.ToString());
resp = sqlResponse.SQLerror;
}
return resp;
}
public sqlResponse Update_database_for_SD6()
{
sqlResponse resp = sqlResponse.SQLerror;
NpgsqlCommand cmd;
try
{
InitConnection();
resp = sqlResponse.done;
}
catch (Exception o)
{
Console.WriteLine("File: SMdb_access.cs Meth: INSERT NEW UPDATE in Database " + o.Message.ToString());
resp = sqlResponse.SQLerror;
}
finally
{
CloseConnection();
}
return resp;
}
}
}