diff --git a/BlobStorages/skyscraper5.Data.Minio/MinioObjectStorage.cs b/BlobStorages/skyscraper5.Data.Minio/MinioObjectStorage.cs index fb6bc0c..fd80c26 100644 --- a/BlobStorages/skyscraper5.Data.Minio/MinioObjectStorage.cs +++ b/BlobStorages/skyscraper5.Data.Minio/MinioObjectStorage.cs @@ -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; } } } diff --git a/DataTableStorages/skyscraper5.Data.PostgreSql/Dvbi.cs b/DataTableStorages/skyscraper5.Data.PostgreSql/Dvbi.cs new file mode 100644 index 0000000..9d0181f --- /dev/null +++ b/DataTableStorages/skyscraper5.Data.PostgreSql/Dvbi.cs @@ -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(); + } + } +} diff --git a/DataTableStorages/skyscraper5.Data.PostgreSql/PostgresqlDataStore.cs b/DataTableStorages/skyscraper5.Data.PostgreSql/PostgresqlDataStore.cs index de0e731..59a5d5e 100644 --- a/DataTableStorages/skyscraper5.Data.PostgreSql/PostgresqlDataStore.cs +++ b/DataTableStorages/skyscraper5.Data.PostgreSql/PostgresqlDataStore.cs @@ -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 }; } + + } } diff --git a/DataTableStorages/skyscraper5.Data.PostgreSql/Rds.cs b/DataTableStorages/skyscraper5.Data.PostgreSql/Rds.cs new file mode 100644 index 0000000..0d659ab --- /dev/null +++ b/DataTableStorages/skyscraper5.Data.PostgreSql/Rds.cs @@ -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(); + } + + } +} diff --git a/DataTableStorages/skyscraper5.Data.PostgreSql/Sgt.cs b/DataTableStorages/skyscraper5.Data.PostgreSql/Sgt.cs new file mode 100644 index 0000000..63235c7 --- /dev/null +++ b/DataTableStorages/skyscraper5.Data.PostgreSql/Sgt.cs @@ -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(); + } + } +} diff --git a/FactoryStorages/skyscraper5.Storage.PostgresqlMinio/PostgresqlMinioStorageFactory.cs b/FactoryStorages/skyscraper5.Storage.PostgresqlMinio/PostgresqlMinioStorageFactory.cs index e3462d2..5f48d0b 100644 --- a/FactoryStorages/skyscraper5.Storage.PostgresqlMinio/PostgresqlMinioStorageFactory.cs +++ b/FactoryStorages/skyscraper5.Storage.PostgresqlMinio/PostgresqlMinioStorageFactory.cs @@ -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(); } diff --git a/skyscraper8/Program.cs b/skyscraper8/Program.cs index 5967bf3..f8d0efd 100644 --- a/skyscraper8/Program.cs +++ b/skyscraper8/Program.cs @@ -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; } diff --git a/skyscraper8/Properties/launchSettings.json b/skyscraper8/Properties/launchSettings.json index 0549299..9e3ea99 100644 --- a/skyscraper8/Properties/launchSettings.json +++ b/skyscraper8/Properties/launchSettings.json @@ -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)": { diff --git a/skyscraper8/Skyscraper/Plugins/ISkyscraperMpePlugin.cs b/skyscraper8/Skyscraper/Plugins/ISkyscraperMpePlugin.cs index 084a5a9..6e1c3e3 100644 --- a/skyscraper8/Skyscraper/Plugins/ISkyscraperMpePlugin.cs +++ b/skyscraper8/Skyscraper/Plugins/ISkyscraperMpePlugin.cs @@ -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); diff --git a/skyscraper8/Skyscraper/Plugins/PluginLogLevel.cs b/skyscraper8/Skyscraper/Plugins/PluginLogLevel.cs new file mode 100644 index 0000000..cd99610 --- /dev/null +++ b/skyscraper8/Skyscraper/Plugins/PluginLogLevel.cs @@ -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 + } +} diff --git a/skyscraper8/Skyscraper/Plugins/PluginLogManager.cs b/skyscraper8/Skyscraper/Plugins/PluginLogManager.cs new file mode 100644 index 0000000..11fc5a6 --- /dev/null +++ b/skyscraper8/Skyscraper/Plugins/PluginLogManager.cs @@ -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 knownLoggers; + + public static PluginLogger GetLogger(Type type) + { + if (knownLoggers == null) + { + knownLoggers = new Dictionary(); + } + + if (knownLoggers.ContainsKey(type)) + { + return knownLoggers[type]; + } + else + { + PluginLogger child = new PluginLogger(type); + knownLoggers.Add(type, child); + return child; + } + } + } +} diff --git a/skyscraper8/Skyscraper/Plugins/PluginLogMessage.cs b/skyscraper8/Skyscraper/Plugins/PluginLogMessage.cs deleted file mode 100644 index 526770e..0000000 --- a/skyscraper8/Skyscraper/Plugins/PluginLogMessage.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace skyscraper5.Skyscraper.Plugins -{ - public delegate void PluginLogMessage(string message); -} diff --git a/skyscraper8/Skyscraper/Plugins/PluginLogger.cs b/skyscraper8/Skyscraper/Plugins/PluginLogger.cs new file mode 100644 index 0000000..f96eacf --- /dev/null +++ b/skyscraper8/Skyscraper/Plugins/PluginLogger.cs @@ -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()); + } + } + } +} diff --git a/skyscraper8/Skyscraper/Plugins/PluginManager.cs b/skyscraper8/Skyscraper/Plugins/PluginManager.cs index 7ae0022..27356e9 100644 --- a/skyscraper8/Skyscraper/Plugins/PluginManager.cs +++ b/skyscraper8/Skyscraper/Plugins/PluginManager.cs @@ -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(); diff --git a/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs b/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs index d0e385a..a1cb352 100644 --- a/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs +++ b/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs @@ -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) {