Added new method stubs to the Postgresql driver.

This commit is contained in:
feyris-tan 2025-06-05 12:15:16 +02:00
parent 1909331d2d
commit 60cf0b4ffe
15 changed files with 291 additions and 71 deletions

View File

@ -128,14 +128,13 @@ namespace skyscraper5.Data
catch (AggregateException e)
{
MinioException minioException = e.InnerExceptions[0] as MinioException;
switch (minioException.Response.Code)
if (minioException.Message.Contains("Minio.Exceptions.ObjectNotFoundException"))
{
case "NoSuchKey":
return false;
case "Forbidden":
return true;
default:
throw new NotImplementedException(minioException.Response.Code);
return false;
}
else
{
throw minioException;
}
}
}

View File

@ -0,0 +1,84 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.DvbI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper5.Data.PostgreSql
{
public partial class PostgresqlDataStore : DataStorage
{
public void InsertDvbiServiceListEntryPoint(long sourceHash)
{
throw new NotImplementedException();
}
public bool TestForServiceListEntryPoints(long sourceHash)
{
throw new NotImplementedException();
}
public void InsertDvbiServiceList(DvbiServiceList serviceList)
{
throw new NotImplementedException();
}
public bool TestForDvbiService(string id)
{
throw new NotImplementedException();
}
public bool TestForDvbiServiceListEntryPoints(long sourceHash)
{
throw new NotImplementedException();
}
public void UpdateDvbiServiceListLastCheckedDate(string id, DateTime currentTime)
{
throw new NotImplementedException();
}
public DateTime GetLastDvbiServiceListEntryPointUpdateDate(long sourceHash)
{
throw new NotImplementedException();
}
public DateTime GetDvbiServiceListLastUpdateDate(string id)
{
throw new NotImplementedException();
}
public void AddDvbiServiceListToServiceListEntryPoint(DvbiServiceList serviceList, long sourceHash)
{
throw new NotImplementedException();
}
public void AddDvbiServiceToServiceList(string id, string serviceListId)
{
throw new NotImplementedException();
}
public int GetDvbiServiceVersion(string id)
{
throw new NotImplementedException();
}
public void UpdateDvbiService(DvbIService service)
{
throw new NotImplementedException();
}
public void UpdateDvbiServiceListEntryPointUpdateDate(long hash, DateTime currentTime)
{
throw new NotImplementedException();
}
public void InsertDvbiService(DvbIService service)
{
throw new NotImplementedException();
}
}
}

View File

@ -1,23 +1,14 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Net;
using System.Net.NetworkInformation;
using Npgsql;
using NpgsqlTypes;
using skyscraper5.Docsis.MacManagement;
using skyscraper5.Dvb.Psi.Model;
using skyscraper5.Dvb.SystemSoftwareUpdate.Model;
using skyscraper5.Dvb.TvAnytime;
using skyscraper5.Rds.Messages;
using skyscraper5.Skyscraper.Gps;
using skyscraper5.Skyscraper.Headless;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper5.src.InteractionChannel.Model;
using skyscraper5.src.InteractionChannel.Model.Descriptors;
using skyscraper5.src.Skyscraper.FrequencyListGenerator;
using skyscraper5.src.Skyscraper.Scraper.Dns;
using skyscraper8.DvbI;
using skyscraper8.Ses;
namespace skyscraper5.Data.PostgreSql
{
@ -30,39 +21,6 @@ namespace skyscraper5.Data.PostgreSql
private NpgsqlConnectionStringBuilder connectionStringBuilder;
public bool TestForKnownRdsData(int currentNetworkId, int currentTransportStreamId, int programNumber)
{
throw new NotImplementedException();
}
public void EnableRdsCollection(int currentNetworkId, int currentTransportStreamId, int programNumber)
{
throw new NotImplementedException();
}
public bool UpdateRdsProgrammeServiceName(int currentNetworkId, int currentTransportStreamId, int programNumber,
string programmeService2)
{
throw new NotImplementedException();
}
public bool UpdateRdsRadioText(int currentNetworkId, int currentTransportStreamId, int programNumber,
string text)
{
throw new NotImplementedException();
}
public bool UpdateRdsPty(int currentNetworkId, int currentTransportStreamId, int programNumber,
PTY.ProgrammeTypeCodes pty)
{
throw new NotImplementedException();
}
public bool MarkAsRdsTrafficInformationProgramme(int currentNetworkId, int currentTransportStreamId,
int programNumber)
{
throw new NotImplementedException();
}
public bool TestForRelatedContent(EitEvent lEvent, RctLinkInfo rctLinkInfo)
{
@ -74,12 +32,6 @@ namespace skyscraper5.Data.PostgreSql
throw new NotImplementedException();
}
private static void SetNulls(NpgsqlCommand command)
{
foreach (NpgsqlParameter param in command.Parameters)
@ -91,9 +43,6 @@ namespace skyscraper5.Data.PostgreSql
}
}
private int? detectedLocation;
public int? GetCurrentLocationId()
{
@ -168,8 +117,6 @@ namespace skyscraper5.Data.PostgreSql
throw new NotImplementedException();
}
public HeadlessJob GetQueuedJob()
{
using (NpgsqlConnection connection = new NpgsqlConnection(connectionStringBuilder.ToString()))
@ -216,6 +163,8 @@ namespace skyscraper5.Data.PostgreSql
{
return new object[] { connectionStringBuilder };
}
}
}

View File

@ -0,0 +1,48 @@
using skyscraper5.Rds.Messages;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper5.Data.PostgreSql
{
public partial class PostgresqlDataStore : DataStorage
{
public bool TestForKnownRdsData(int currentNetworkId, int currentTransportStreamId, int programNumber)
{
throw new NotImplementedException();
}
public void EnableRdsCollection(int currentNetworkId, int currentTransportStreamId, int programNumber)
{
throw new NotImplementedException();
}
public bool UpdateRdsProgrammeServiceName(int currentNetworkId, int currentTransportStreamId, int programNumber,
string programmeService2)
{
throw new NotImplementedException();
}
public bool UpdateRdsRadioText(int currentNetworkId, int currentTransportStreamId, int programNumber,
string text)
{
throw new NotImplementedException();
}
public bool UpdateRdsPty(int currentNetworkId, int currentTransportStreamId, int programNumber,
PTY.ProgrammeTypeCodes pty)
{
throw new NotImplementedException();
}
public bool MarkAsRdsTrafficInformationProgramme(int currentNetworkId, int currentTransportStreamId,
int programNumber)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,34 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.Ses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper5.Data.PostgreSql
{
public partial class PostgresqlDataStore : DataStorage
{
public bool TestForSgtList(SgtList list)
{
throw new NotImplementedException();
}
public void InsertSgtList(SgtList list)
{
throw new NotImplementedException();
}
public bool TestForSgtService(SgtService child)
{
throw new NotImplementedException();
}
public void InsertSgtService(SgtService child)
{
throw new NotImplementedException();
}
}
}

View File

@ -7,6 +7,7 @@ using skyscraper5.Data.PostgreSql;
using skyscraper5.Skyscraper.Plugins;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.Skyscraper.Plugins;
namespace skyscraper5.Storage.PostgresqlMinio
{
@ -14,8 +15,11 @@ namespace skyscraper5.Storage.PostgresqlMinio
[ScrapeStorageFactoryId(3,"PostgreSQL & MinIO",false)]
public class PostgresqlMinioStorageFactory : IScraperStorageFactory
{
private static PluginLogger logger = PluginLogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public IScraperStroage CreateScraperStroage()
{
logger.Log(PluginLogLevel.Info, "Connecting to PostgreSQL & MinIO");
NpgsqlConnectionStringBuilder ncsb = new NpgsqlConnectionStringBuilder();
ncsb.Database = PostgreSqlDatabase;
ncsb.ApplicationName = "skyscraper5";
@ -36,6 +40,7 @@ namespace skyscraper5.Storage.PostgresqlMinio
bool bucketExists = mc.BucketExistsAsync(bucketExistsArgs).Result;
if (!bucketExists)
{
logger.Log(PluginLogLevel.Info, "Creating MinIO Bucket: {0}", MinioBucket);
MakeBucketArgs makeBucketArgs = new MakeBucketArgs().WithBucket(MinioBucket);
mc.MakeBucketAsync(makeBucketArgs).Wait();
}

View File

@ -362,7 +362,7 @@ namespace skyscraper5
FileInfo fi = new FileInfo(filename);
if (!fi.Exists)
{
Console.WriteLine("{0} not found.", fi.FullName);
logger.FatalFormat("{0} not found.", fi.FullName);
return;
}

View File

@ -2,7 +2,7 @@
"profiles": {
"skyscraper8": {
"commandName": "Project",
"commandLineArgs": "\"C:\\Temp\\Astra1_12604_v_SGT-000000.ts\"",
"commandLineArgs": "file-live \"C:\\Temp\\Astra1_12604_v_SGT-000000.ts\"",
"remoteDebugEnabled": false
},
"Container (Dockerfile)": {

View File

@ -5,7 +5,7 @@ namespace skyscraper5.Skyscraper.Plugins
{
public interface ISkyscraperMpePlugin
{
void ConnectToStorage(object[] connector, PluginLogMessage logger);
void ConnectToStorage(object[] connector);
void SetContext(DateTime? currentTime);
bool CanHandlePacket(InternetHeader internetHeader, byte[] ipv4Packet);
void HandlePacket(InternetHeader internetHeader, byte[] ipv4Packet);

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper8.Skyscraper.Plugins
{
public enum PluginLogLevel
{
All = 1,
Debug = 2,
Info = 4,
Warn = 8,
Error = 16,
Fatal = 32,
Off = 64
}
}

View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper8.Skyscraper.Plugins
{
public class PluginLogManager
{
private PluginLogManager() { }
private static Dictionary<Type, PluginLogger> knownLoggers;
public static PluginLogger GetLogger(Type type)
{
if (knownLoggers == null)
{
knownLoggers = new Dictionary<Type, PluginLogger>();
}
if (knownLoggers.ContainsKey(type))
{
return knownLoggers[type];
}
else
{
PluginLogger child = new PluginLogger(type);
knownLoggers.Add(type, child);
return child;
}
}
}
}

View File

@ -1,4 +0,0 @@
namespace skyscraper5.Skyscraper.Plugins
{
public delegate void PluginLogMessage(string message);
}

View File

@ -0,0 +1,51 @@
using log4net;
using log4net.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper8.Skyscraper.Plugins
{
public class PluginLogger
{
private static readonly ILog superLogger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);
internal PluginLogger(Type type)
{
Type = type;
Logger = LogManager.GetLogger(type.Name);
superLogger.DebugFormat("Logging for {0} enabled.",type.Name);
}
internal Type Type { get; }
private ILog Logger { get; set; }
public void Log(PluginLogLevel level, string message, params object[] a)
{
switch(level)
{
case PluginLogLevel.Off:
break;
case PluginLogLevel.Error:
Logger.ErrorFormat(message, a);
break;
case PluginLogLevel.Warn:
Logger.WarnFormat(message, a);
break;
case PluginLogLevel.Info:
Logger.InfoFormat(message, a);
break;
case PluginLogLevel.Debug:
Logger.DebugFormat(message, a);
break;
case PluginLogLevel.All:
Console.WriteLine(message, a);
break;
default:
throw new NotImplementedException(level.ToString());
}
}
}
}

View File

@ -174,6 +174,8 @@ namespace skyscraper5.Skyscraper.Plugins
private void ScanAssembly(Assembly assembly)
{
AssemblyName assemblyName = assembly.GetName();
logger.DebugFormat("Scan assembly: {0}", assemblyName.Name);
foreach (Type type in assembly.GetTypes())
{
bool isSkyscraperPlugin = type.GetCustomAttributes(typeof(SkyscraperPluginAttribute)).Any();

View File

@ -1731,12 +1731,11 @@ namespace skyscraper5.Skyscraper.Scraper
{
mpePlugins = PluginManager.GetInstance().GetMpePlugins();
object[] connector = ScraperStorage.GetPluginConnector();
PluginLogMessage messager = message => LogEvent(SkyscraperContextEvent.PluginMessage, message);
foreach (ISkyscraperMpePlugin plugin in mpePlugins)
{
try
{
plugin.ConnectToStorage(connector, messager);
plugin.ConnectToStorage(connector);
}
catch (Exception e)
{