Removed IScraperStorage.cs, instead made DataStorage.cs and ObjectStorage.cs. This breaks the ImgUi - for now.

This commit is contained in:
feyris-tan 2025-06-29 20:08:52 +02:00
parent 645b10959e
commit 32c358c257
70 changed files with 774 additions and 2101 deletions

View File

@ -8,9 +8,9 @@ using Minio.DataModel;
using Minio.DataModel.Args;
using Minio.Exceptions;
using skyscraper5.Dvb.DataBroadcasting.SkyscraperVfs;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.DvbNip;
using skyscraper8.Ietf.FLUTE;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data
{
@ -136,7 +136,8 @@ namespace skyscraper5.Data
catch (AggregateException e)
{
MinioException minioException = e.InnerExceptions[0] as MinioException;
if (minioException.Message.Contains("Minio.Exceptions.ObjectNotFoundException"))
ObjectNotFoundException objectNotFoundException = minioException as ObjectNotFoundException;
if (objectNotFoundException != null)
{
definetlyMissingFiles.Add(combine);
return false;

View File

@ -0,0 +1,55 @@
using Minio;
using Minio.DataModel.Args;
using skyscraper5.Skyscraper.Plugins;
using skyscraper8.Skyscraper.Plugins;
using skyscraper8.Skyscraper.Scraper.Storage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper5.Data.Minio
{
[SkyscraperPlugin]
[StorageId(1)]
[StorageName("MinIO")]
public class MinioObjectStorageFactory : ObjectStorageFactory
{
private static PluginLogger logger = PluginLogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public string Bucket { get; set; }
public bool Secure { get; set; }
public string SecretKey { get; set; }
public string AccessKey { get; set; }
public string Endpoint { get; set; }
public ObjectStorage CreateObjectStorage()
{
IMinioClient mc = new MinioClient()
.WithEndpoint(Endpoint)
.WithCredentials(AccessKey, SecretKey)
.WithSSL(Secure).Build();
BucketExistsArgs bucketExistsArgs = new BucketExistsArgs().WithBucket(Bucket);
bool bucketExists = mc.BucketExistsAsync(bucketExistsArgs).Result;
if (!bucketExists)
{
logger.Log(PluginLogLevel.Info, "Creating MinIO Bucket: {0}", Bucket);
MakeBucketArgs makeBucketArgs = new MakeBucketArgs().WithBucket(Bucket);
mc.MakeBucketAsync(makeBucketArgs).Wait();
}
MinioObjectStorage minioOs = new MinioObjectStorage(mc, Bucket);
return minioOs;
}
public bool IsEquivalent(DataStorageFactory dataStorageFactory)
{
return false;
}
}
}

View File

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Minio" Version="6.0.4" />
<PackageReference Include="Minio" Version="6.0.5" />
</ItemGroup>
<ItemGroup>

View File

@ -1,6 +1,5 @@

using MySqlConnector;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper5.Mhp.Si;
using skyscraper5.Mhp.Si.Model;
using System.Collections.Generic;
@ -9,6 +8,7 @@ using skyscraper5.Mhp.Descriptors;
using skyscraper5.Mhp.Descriptors.InteractionTransportSelectors;
using System;
using skyscraper5.Teletext;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,5 +1,4 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -23,6 +22,7 @@ using skyscraper5.src.InteractionChannel.Model.Descriptors;
using System.Net.NetworkInformation;
using System.Net;
using skyscraper5.src.Skyscraper.Scraper.Dns;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,6 +1,6 @@
using MySqlConnector;
using skyscraper5.Mpeg2.Descriptors;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.Skyscraper.Scraper.Storage;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -1,5 +1,5 @@
using MySqlConnector;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.Skyscraper.Scraper.Storage;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -1,5 +1,5 @@
using MySqlConnector;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.Skyscraper.Scraper.Storage;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -1,11 +1,11 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySqlConnector;
using skyscraper5.DsmCc.Descriptors;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,5 +1,4 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -8,6 +7,7 @@ using System.Threading.Tasks;
using MySqlConnector;
using skyscraper5.Dvb.Descriptors;
using skyscraper5.Dvb.Psi.Model;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,5 +1,5 @@
using skyscraper5.Dvb.DataBroadcasting.IntModel;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.Skyscraper.Scraper.Storage;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -15,13 +15,13 @@ using skyscraper5.Skyscraper.Equipment;
using skyscraper5.Skyscraper.Gps;
using skyscraper5.Skyscraper.Headless;
using skyscraper5.Skyscraper.IO.CrazycatStreamReader;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper5.Skyscraper.Scraper.Storage.Utilities;
using skyscraper5.src.InteractionChannel.Model.Descriptors;
using skyscraper5.src.InteractionChannel.Model;
using skyscraper5.src.Skyscraper.FrequencyListGenerator;
using skyscraper5.src.Skyscraper.Scraper.Dns;
using skyscraper5.Teletext;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -9,7 +9,7 @@ using MySqlConnector;
using skyscraper5.Dvb.Descriptors;
using skyscraper5.Dvb.Descriptors.Extension;
using skyscraper5.Dvb.Psi.Model;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,10 +1,10 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySqlConnector;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,5 +1,4 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -11,6 +10,7 @@ using skyscraper5.Mpeg2.Descriptors;
using skyscraper5.Mpeg2.Psi.Model;
using System.IO;
using static skyscraper5.Dvb.Descriptors.ApplicationSignallingDescriptor;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,5 +1,4 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -7,6 +6,7 @@ using System.Threading.Tasks;
using MySqlConnector;
using skyscraper5.Scte35;
using skyscraper5.Scte35.Descriptors;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,5 +1,4 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using System;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
@ -9,6 +8,7 @@ using MySqlConnector;
using skyscraper5.Dvb.Descriptors;
using skyscraper5.Dvb.Psi.Model;
using static skyscraper5.Dvb.Descriptors.ServiceListDescriptor;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,7 +1,7 @@
using MySqlConnector;
using skyscraper5.Skyscraper;
using skyscraper5.Skyscraper.Headless;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.Skyscraper.Scraper.Storage;
using System;
using System.Collections.Generic;
using System.Diagnostics;

View File

@ -1,5 +1,4 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -12,6 +11,7 @@ using skyscraper5.Mpeg2.Descriptors;
using skyscraper5.Mpeg2.Psi.Model;
using static skyscraper5.Dvb.Descriptors.ContentIdentifierDescriptor;
using System.Diagnostics.Metrics;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,10 +1,10 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySqlConnector;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,6 +1,6 @@
using MySqlConnector;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper5.Teletext;
using skyscraper8.Skyscraper.Scraper.Storage;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -1,5 +1,4 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Versioning;
@ -7,6 +6,7 @@ using System.Text;
using System.Threading.Tasks;
using MySqlConnector;
using skyscraper5.Dvb.Descriptors;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,5 +1,5 @@
using MySqlConnector;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.Skyscraper.Scraper.Storage;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -1,11 +1,11 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySqlConnector;
using skyscraper5.Dvb.SystemSoftwareUpdate.Model;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,5 +1,4 @@
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using System;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.IO;
@ -7,6 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySqlConnector;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.MySql
{

View File

@ -1,6 +1,5 @@
using Npgsql;
using NpgsqlTypes;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.DvbI;
using System;
using System.Collections.Generic;
@ -9,6 +8,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper8.DvbNip;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.PostgreSql
{

View File

@ -10,7 +10,6 @@ using NpgsqlTypes;
using skyscraper5.Dvb.Descriptors;
using skyscraper5.Dvb.Psi.Model;
using skyscraper5.Mpeg2.Psi.Model;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper5.Skyscraper.Scraper.Storage.Utilities;
namespace skyscraper5.Data.PostgreSql

View File

@ -6,8 +6,8 @@ using NpgsqlTypes;
using skyscraper5.Dvb.Psi.Model;
using skyscraper5.Dvb.TvAnytime;
using skyscraper5.Skyscraper.Headless;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.DvbNip;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Data.PostgreSql
{

View File

@ -0,0 +1,49 @@
using Npgsql;
using skyscraper5.Skyscraper.Plugins;
using skyscraper8.Skyscraper.Plugins;
using skyscraper8.Skyscraper.Scraper.Storage;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper5.Data.PostgreSql
{
[SkyscraperPlugin]
[StorageId(3)]
[StorageName("PostgreSQL")]
public class PostgresqlDataStoreFactory : DataStorageFactory
{
private static PluginLogger logger = PluginLogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public string Username { get; set; }
public ushort Port { get; set; }
public string Password { get; set; }
public string Host { get; set; }
public string Database { get; set; }
public DataStorage CreateDataStorage()
{
logger.Log(PluginLogLevel.Info, "Connecting to PostgreSQL & MinIO");
NpgsqlConnectionStringBuilder ncsb = new NpgsqlConnectionStringBuilder();
ncsb.Database = Database;
ncsb.ApplicationName = "skyscraper5";
ncsb.Host = Host;
ncsb.Password = Password;
ncsb.Pooling = true;
ncsb.Port = Port;
ncsb.Username = Username;
if (Debugger.IsAttached)
ncsb.Timeout = 1024;
return new PostgresqlDataStore(ncsb);
}
}
}

View File

@ -1,5 +1,5 @@
using skyscraper5.Rds.Messages;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.Skyscraper.Scraper.Storage;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -1,8 +1,8 @@
using Newtonsoft.Json;
using Npgsql;
using NpgsqlTypes;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper8.Ses;
using skyscraper8.Skyscraper.Scraper.Storage;
using skyscraper8.Skyscraper.Scraper.Storage.Utilities;
using System;
using System.Collections.Generic;

View File

@ -124,7 +124,7 @@
* HLS Stream
* benötigt vorher einen PCR delayten Stream
* benötigt vorher einen Rate-Limited Stream
* ScraperStorage ablösen, und stattdessen DataStorage und FileStorage einzeln setzen.
* [DONE] ScraperStorage ablösen, und stattdessen DataStorage und FileStorage einzeln setzen.
* .tar/.tar.gz File mit FilesystemStorage Inhalt importieren
* WGS84 zu Lat/Lon konvertieren - für RCS-Map.
* Beispielcode in C# hier: https://stackoverflow.com/a/16660841

View File

@ -0,0 +1,14 @@
# Data Storages
These contain tabular data, like EIT Events, Scan results, etc.
|ID|Type |
|--|----------|
| 1|In-Memory |
| 2|Filesystem|
| 3|PostgreSQL|
# Object Storages
These contain blob-like data, like Screenshots, DSM-CC Carousels, etc.
|ID|Type |
|--|----------|
| 1|MinIO |
| 2|Filesystem|

View File

@ -1,56 +0,0 @@
using Minio;
using Minio.DataModel.Args;
using MySqlConnector;
using skyscraper5.Data;
using skyscraper5.Data.MySql;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
namespace skyscraper5.Storage.MariaDbMinio
{
[ScrapeStorageFactoryId(2,"MariaDB & MinIO",false)]
public class MariaDbMinioStorageFactory : IScraperStorageFactory
{
public IScraperStroage CreateScraperStroage()
{
MySqlConnectionStringBuilder mcsb = new MySqlConnectionStringBuilder();
mcsb.Database = MariaDbDatabase;
mcsb.Password = MariaDbPassword;
mcsb.Port = MariaDbPort;
mcsb.Server = MariaDbHost;
mcsb.UserID = MariaDbUsername;
mcsb.ApplicationName = "skyscraper5";
mcsb.Pooling = true;
IMinioClient mc = new MinioClient()
.WithEndpoint(MinioEndpoint)
.WithCredentials(MinioAccessKey, MinioSecretKey)
.WithSSL(MinioSecure).Build();
BucketExistsArgs bucketExistsArgs = new BucketExistsArgs().WithBucket(MinioBucket);
bool bucketExists = mc.BucketExistsAsync(bucketExistsArgs).Result;
if (!bucketExists)
{
MakeBucketArgs makeBucketArgs = new MakeBucketArgs().WithBucket(MinioBucket);
mc.MakeBucketAsync(makeBucketArgs).Wait();
}
MySqlDataStorage myds = new MySqlDataStorage(mcsb);
MinioObjectStorage mos = new MinioObjectStorage(mc, MinioBucket);
return new SplitScraperStorage(myds, mos);
}
public string MariaDbHost { get; set; }
public ushort MariaDbPort { get; set; }
public string MariaDbUsername { get; set; }
public string MariaDbPassword { get; set; }
public string MariaDbDatabase { get; set; }
public string MinioEndpoint { get; set; }
public string MinioAccessKey { get; set; }
public string MinioSecretKey { get; set; }
public bool MinioSecure { get; set; }
public string MinioBucket { get; set; }
}
}

View File

@ -1,12 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\BlobStorages\skyscraper5.Data.Minio\skyscraper5.Data.Minio.csproj" />
<ProjectReference Include="..\..\DataTableStorages\skyscraper5.Data.MySql\skyscraper8.Data.MySql.csproj" />
</ItemGroup>
</Project>

View File

@ -1,75 +0,0 @@
using System.Diagnostics;
using Minio;
using Minio.DataModel.Args;
using Npgsql;
using skyscraper5.Data;
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
{
[SkyscraperPlugin]
[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";
ncsb.Host = PostgreSqlHost;
ncsb.Password = PostgreSqlPassword;
ncsb.Pooling = true;
ncsb.Port = PostgreSqlPort;
ncsb.Username = PostgreSqlUsername;
if (Debugger.IsAttached)
ncsb.Timeout = 1024;
IMinioClient mc = new MinioClient()
.WithEndpoint(MinioEndpoint)
.WithCredentials(MinioAccessKey, MinioSecretKey)
.WithSSL(MinioSecure).Build();
BucketExistsArgs bucketExistsArgs = new BucketExistsArgs().WithBucket(MinioBucket);
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();
}
PostgresqlDataStore postgresDs = new PostgresqlDataStore(ncsb);
MinioObjectStorage minioOs = new MinioObjectStorage(mc, MinioBucket);
return new SplitScraperStorage(postgresDs, minioOs);
}
public string MinioBucket { get; set; }
public bool MinioSecure { get; set; }
public string MinioSecretKey { get; set; }
public string MinioAccessKey { get; set; }
public string MinioEndpoint { get; set; }
public string PostgreSqlUsername { get; set; }
public ushort PostgreSqlPort { get; set; }
public string PostgreSqlPassword { get; set; }
public string PostgreSqlHost { get; set; }
public string PostgreSqlDatabase { get; set; }
}
}

View File

@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\BlobStorages\skyscraper5.Data.Minio\skyscraper5.Data.Minio.csproj" />
<ProjectReference Include="..\..\DataTableStorages\skyscraper5.Data.PostgreSql\skyscraper5.Data.PostgreSql.csproj" />
</ItemGroup>
</Project>

View File

@ -47,12 +47,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "skyscraper5.Data.PostgreSql
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "skyscraper5.RSR.IQTester", "Gimmicks\skyscraper5.RSR.IQTester\skyscraper5.RSR.IQTester.csproj", "{0E4C7079-228A-B94C-379A-8A14B08BAB34}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "StorageFactories", "StorageFactories", "{21CE40E6-0C04-4994-9353-F8A4208B6DA2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "skyscraper5.Storage.MariaDbMinio", "FactoryStorages\skyscraper5.Storage.MariaDbMinio\skyscraper5.Storage.MariaDbMinio.csproj", "{11572C79-1D7F-5609-C7D6-8E32130E3901}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "skyscraper5.Storage.PostgresqlMinio", "FactoryStorages\skyscraper5.Storage.PostgresqlMinio\skyscraper5.Storage.PostgresqlMinio.csproj", "{B3930CC1-4877-FC74-8CD3-CFED82DB7474}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "skyscraper5.DNS", "MpePlugins\skyscraper5.DNS\skyscraper5.DNS.csproj", "{3B52C24E-58E2-F982-F9B7-B9E7465B82A2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "skyscraper5.Gimmicks.IptvCollector", "Gimmicks\skyscraper5.Gimmicks.IptvCollector\skyscraper5.Gimmicks.IptvCollector.csproj", "{8F17668C-623C-F9B3-EAD4-2922E5414B75}"
@ -131,14 +125,6 @@ Global
{0E4C7079-228A-B94C-379A-8A14B08BAB34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E4C7079-228A-B94C-379A-8A14B08BAB34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E4C7079-228A-B94C-379A-8A14B08BAB34}.Release|Any CPU.Build.0 = Release|Any CPU
{11572C79-1D7F-5609-C7D6-8E32130E3901}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11572C79-1D7F-5609-C7D6-8E32130E3901}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11572C79-1D7F-5609-C7D6-8E32130E3901}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11572C79-1D7F-5609-C7D6-8E32130E3901}.Release|Any CPU.Build.0 = Release|Any CPU
{B3930CC1-4877-FC74-8CD3-CFED82DB7474}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3930CC1-4877-FC74-8CD3-CFED82DB7474}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3930CC1-4877-FC74-8CD3-CFED82DB7474}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3930CC1-4877-FC74-8CD3-CFED82DB7474}.Release|Any CPU.Build.0 = Release|Any CPU
{3B52C24E-58E2-F982-F9B7-B9E7465B82A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B52C24E-58E2-F982-F9B7-B9E7465B82A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B52C24E-58E2-F982-F9B7-B9E7465B82A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -178,8 +164,6 @@ Global
{17C2E095-B952-8919-2C68-F2EAA7A601C3} = {CDAECB5B-E4A5-4287-85CA-6D65085A091E}
{07214423-32B2-DDE8-8D38-511D55ADC206} = {CDAECB5B-E4A5-4287-85CA-6D65085A091E}
{0E4C7079-228A-B94C-379A-8A14B08BAB34} = {E00647B6-4509-4A1C-A7CB-D0C72325D23E}
{11572C79-1D7F-5609-C7D6-8E32130E3901} = {21CE40E6-0C04-4994-9353-F8A4208B6DA2}
{B3930CC1-4877-FC74-8CD3-CFED82DB7474} = {21CE40E6-0C04-4994-9353-F8A4208B6DA2}
{3B52C24E-58E2-F982-F9B7-B9E7465B82A2} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{8F17668C-623C-F9B3-EAD4-2922E5414B75} = {E00647B6-4509-4A1C-A7CB-D0C72325D23E}
{46CACA1C-F9B2-2FE0-2068-716F381325E9} = {E23457C5-3A34-48EE-8107-C91E2C174B2D}

View File

@ -37,6 +37,8 @@ namespace skyscraper8.DvbNip
if (string.IsNullOrEmpty(Path.GetExtension(newFilename)))
newFilename += ".dat";
newFilename = newFilename.Replace("%3D", "-3D-");
return newFilename;
}

View File

@ -10,6 +10,7 @@ using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using log4net;
using skyscraper5.Dvb.Psi.Model;
using skyscraper5.Mpeg2;
using skyscraper5.Skyscraper;
@ -20,17 +21,20 @@ using skyscraper5.Skyscraper.IO.TunerInterface;
using skyscraper5.Skyscraper.Plugins;
using skyscraper5.Skyscraper.Scraper;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5
{
public class Passing
{
public IScraperStroage ScraperStorage { get; set; }
public DataStorage DataStorage { get; private set; }
public ObjectStorage ObjectStorage { get; private set; }
private IStreamReader streamReader;
private List<TunerMetadata> tuners;
private List<SatellitePosition> satellitePositions;
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);
public Passing()
public Passing()
{
}
@ -39,47 +43,42 @@ namespace skyscraper5
{
Ini ini = PluginManager.GetInstance().Ini;
int requiredFactoryId = ini.ReadValue("startup", "storage", -1);
if (requiredFactoryId == -1)
{
Console.WriteLine("Could not determine storage factory from ini file. Configure it using the UI!");
return false;
}
ScraperStorageFactoryConnectionManager connectionManager = ScraperStorageFactoryConnectionManager.GetInstance();
DirectoryInfo di = new DirectoryInfo(".");
FileInfo[] fileInfos = di.GetFiles("skyscraper5.Storage.*.dll");
foreach (KeyValuePair<ScrapeStorageFactoryIdAttribute, IScraperStorageFactory> keyValuePair in connectionManager.GetKnownFactories())
StorageConnectionManager connectionManager = StorageConnectionManager.GetInstance();
IEnumerable<Tuple<int, bool, string>> allKnownFactoryNames = connectionManager.GetAllKnownFactoryNames();
foreach (Tuple<int, bool, string> knownFactoryName in allKnownFactoryNames)
{
Console.WriteLine("Found Storage Factory #{0}, {1}", keyValuePair.Key.Id, keyValuePair.Key.DisplayName);
logger.InfoFormat("Found {0} Storage Factory #{1}, {2}",knownFactoryName.Item2 ? "Data" : "Object",knownFactoryName.Item1,knownFactoryName.Item3);
}
string iniCategoryName = String.Format("storage{0}", requiredFactoryId);
if (!ini.ContainsKey(iniCategoryName))
logger.Debug("Acquiring Default Data Storage...");
DataStorageFactory dataStorageFactory = connectionManager.GetDefaultDataStorageFactory();
logger.Debug("Acquiring Default Object Storage...");
ObjectStorageFactory objectStorageFactory = connectionManager.GetDefaultObjectStorageFactory();
logger.Debug("Acquiring Data Storage...");
DataStorage = dataStorageFactory.CreateDataStorage();
if (DataStorage == null)
{
Console.WriteLine("Could not find configuration for the storage factory. Configure it using the UI!");
return false;
logger.FatalFormat("The data storage factory didn't create a data storage.");
return false;
}
KeyValuePair<ScrapeStorageFactoryIdAttribute, IScraperStorageFactory> valuePair = connectionManager.GetKnownFactories().First(x => x.Key.Id == requiredFactoryId);
if (valuePair.Key == null)
bool isEquivalent = objectStorageFactory.IsEquivalent(dataStorageFactory);
if (isEquivalent)
{
Console.WriteLine("Storage Factory {0} was not loaded. Reconfigure with the UI!", requiredFactoryId);
return false;
logger.Debug("Using the Data Storage as Object Storage.");
ObjectStorage = (ObjectStorage)DataStorage;
}
string factoryCname = String.Format("storage{0}", valuePair.Key.Id);
PluginManager.GetInstance().AutoconfigureObject(factoryCname, valuePair.Value);
Console.WriteLine("Booting {0}...", valuePair.Key.DisplayName);
ScraperStorage = valuePair.Value.CreateScraperStroage();
if (ScraperStorage == null)
else
{
Console.WriteLine("The storage factory didn't create a storage.");
return false;
logger.Debug("Acquiring Object Storage...");
ObjectStorage = objectStorageFactory.CreateObjectStorage();
if (ObjectStorage == null)
{
logger.FatalFormat("The object storage factory didn't create an object storage.");
return false;
}
}
TunerFactoryConnectionManager tunerFactoryConnectionManager = TunerFactoryConnectionManager.GetInstance();
@ -152,9 +151,9 @@ namespace skyscraper5
continue;
}
;
if (ScraperStorage.UiTunerTestFor(foundTuner))
if (DataStorage.UiTunerTestFor(foundTuner))
{
ScraperStorage.UiTunerGetConfiguration(foundTuner);
DataStorage.UiTunerGetConfiguration(foundTuner);
}
if (tuners == null)
@ -162,14 +161,14 @@ namespace skyscraper5
tuners.Add(foundTuner);
}
satellitePositions = ScraperStorage.UiSatellitesListAll();
satellitePositions = DataStorage.UiSatellitesListAll();
return true;
}
private HeadlessJob GetNextJob()
{
HeadlessJob headlessJob = ScraperStorage.GetQueuedJob();
HeadlessJob headlessJob = DataStorage.GetQueuedJob();
if (headlessJob != null)
{
return headlessJob;
@ -186,7 +185,7 @@ namespace skyscraper5
Run(headlessJob);
if (!headlessJob.isSynthetic)
{
ScraperStorage.SetQueuedJobComplete(headlessJob);
DataStorage.SetQueuedJobComplete(headlessJob);
}
}
}
@ -225,7 +224,7 @@ namespace skyscraper5
private void ReimportTag(int tag1)
{
IReadOnlyList<string> queue = ScraperStorage.ListImportFileByTag1(tag1);
IReadOnlyList<string> queue = DataStorage.ListImportFileByTag1(tag1);
foreach(string filename in queue)
{
FileInfo fi = new FileInfo(filename);
@ -253,7 +252,7 @@ namespace skyscraper5
if (!fi.Extension.ToLowerInvariant().Equals(".ts"))
continue;
if (ScraperStorage.ImportFileKnown(fi))
if (DataStorage.ImportFileKnown(fi))
continue;
FileStream fileStream = fi.OpenRead();
@ -262,8 +261,8 @@ namespace skyscraper5
ScrapeStream(fileStream,true, out tstype);
stopwatch.Stop();
Console.WriteLine("Importing {0} took {1}",fi.Name, stopwatch.Elapsed);
ScraperStorage.WaitForCompletion();
ScraperStorage.ImportMarkFileAsKnown(fi, stopwatch.Elapsed, tstype);
DataStorage.WaitForCompletion();
DataStorage.ImportMarkFileAsKnown(fi, stopwatch.Elapsed, tstype);
fileStream.Close();
}
else
@ -283,7 +282,7 @@ namespace skyscraper5
private void ScrapeStream(Stream inStream, bool disk, out int tstype)
{
SkyscraperContext skyscraperContext = new SkyscraperContext(new TsContext(), ScraperStorage);
SkyscraperContext skyscraperContext = new SkyscraperContext(new TsContext(), DataStorage,ObjectStorage);
skyscraperContext.SourceIsDisk = disk;
skyscraperContext.InitalizeFilterChain();
skyscraperContext.IngestFromStream(inStream);

View File

@ -28,6 +28,7 @@ using skyscraper5.T2MI;
using skyscraper5.src.Mpeg2.PacketFilter;
using skyscraper8.Skyscraper.IO;
using log4net;
using skyscraper8.Skyscraper.Scraper.Storage;
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config")]
namespace skyscraper5
@ -149,8 +150,9 @@ namespace skyscraper5
if (args[0].ToLowerInvariant().Equals("importtest"))
{
DirectoryInfo doThisDir = new DirectoryInfo(args[1]);
IScraperStroage imss = new InMemoryScraperStorage();
TsFileCollectionImporter importer = new TsFileCollectionImporter(imss, doThisDir);
InMemoryScraperStorage imss = new InMemoryScraperStorage();
FilesystemStorage fs = new FilesystemStorage(new DirectoryInfo("."));
TsFileCollectionImporter importer = new TsFileCollectionImporter(imss, fs, doThisDir);
importer.Run();
return;
}
@ -161,8 +163,8 @@ namespace skyscraper5
{
DirectoryInfo srcDir = new DirectoryInfo(args[1]);
DirectoryInfo tgtDir = new DirectoryInfo(args[2]);
IScraperStroage fss = new FilesystemScraperStorage(tgtDir);
TsFileCollectionImporter importer = new TsFileCollectionImporter(fss, srcDir);
FilesystemStorage fss = new FilesystemStorage(tgtDir);
TsFileCollectionImporter importer = new TsFileCollectionImporter(fss, fss, srcDir);
importer.Run();
return;
}
@ -203,13 +205,7 @@ namespace skyscraper5
dummyTsGenerator.Run();
return;
}
if (args[0].ToLowerInvariant().Equals("merge-bl-jobs"))
{
MergeDbBlindscanJobs.RunAsMain();
return;
}
if (args[0].ToLowerInvariant().Equals("file-live"))
{
Program.HandleFileToLiveSystem(args[1]);
@ -248,7 +244,8 @@ namespace skyscraper5
private static void ProcessDirectory(DirectoryInfo di)
{
IScraperStroage scraperStroage = new InMemoryScraperStorage();
DataStorage dataStorage = new InMemoryScraperStorage();
FilesystemStorage filesystemStorage = new FilesystemStorage(new DirectoryInfo("."));
//DirectoryInfo di = new DirectoryInfo(@"E:\Skyscraper\Astra 19.2");
FileInfo[] fileInfos = di.GetFiles("*.ts");
@ -256,7 +253,7 @@ namespace skyscraper5
{
Console.WriteLine(new string('_', Console.WindowWidth - 1));
Console.WriteLine("Processing: {0}", fileInfo.Name);
SkyscraperContext skyscraper = new SkyscraperContext(new TsContext(), scraperStroage);
SkyscraperContext skyscraper = new SkyscraperContext(new TsContext(), dataStorage,filesystemStorage);
//StreamTypeAutodetectionTest streamTypeAutodetectionTest = new StreamTypeAutodetectionTest();
FileStream fileStream = fileInfo.OpenRead();
@ -293,18 +290,26 @@ namespace skyscraper5
private static void HandleUdpTesting()
{
HandleUdpInput(new InMemoryScraperStorage());
DataStorage data = new InMemoryScraperStorage();
ObjectStorage objects = new FilesystemStorage(new DirectoryInfo("."));
HandleUdpInput(data,objects);
}
private static void HandleUdpLive()
{
ScraperStorageFactoryConnectionManager connectionManager = ScraperStorageFactoryConnectionManager.GetInstance();
IScraperStorageFactory factory = connectionManager.AutoGetDefaultFactory();
IScraperStroage scraperStorage = factory.CreateScraperStroage();
HandleUdpInput(scraperStorage);
StorageConnectionManager connectionManager = StorageConnectionManager.GetInstance();
DataStorageFactory dataFactory = connectionManager.GetDefaultDataStorageFactory();
ObjectStorageFactory objectFactory = connectionManager.GetDefaultObjectStorageFactory();
DataStorage dataStorage = dataFactory.CreateDataStorage();
ObjectStorage objectStorage;
if (objectFactory.IsEquivalent(dataFactory))
objectStorage = (ObjectStorage)dataStorage;
else
objectStorage = objectFactory.CreateObjectStorage();
HandleUdpInput(dataStorage,objectStorage);
}
private static void HandleUdpInput(IScraperStroage scraperStorage)
private static void HandleUdpInput(DataStorage dataStorage,ObjectStorage objectStorage)
{
NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface networkInterface in networkInterfaces)
@ -333,7 +338,7 @@ namespace skyscraper5
if (!remote.Equals(oldRemote))
{
oldRemote = remote;
skyscraper = new SkyscraperContext(new TsContext(), scraperStorage);
skyscraper = new SkyscraperContext(new TsContext(), dataStorage,objectStorage);
skyscraper.InitalizeFilterChain();
skyscraper.EnableTimeout = true;
logger.InfoFormat("Got zapped by {0}", remote);
@ -351,23 +356,31 @@ namespace skyscraper5
private static void HandleCrazyScanToTestingSystem(string url)
{
IScraperStroage scraperStorage = new InMemoryScraperStorage();
HandleCrazyScan(url, scraperStorage, true);
}
DataStorage dataStorage = new InMemoryScraperStorage();
ObjectStorage objectStorage = new FilesystemStorage(new DirectoryInfo("."));
HandleCrazyScan(url, dataStorage, objectStorage, true);
}
private static void HandleFileToLiveSystem(string filename)
{
ScraperStorageFactoryConnectionManager connectionManager = ScraperStorageFactoryConnectionManager.GetInstance();
IScraperStorageFactory factory = connectionManager.AutoGetDefaultFactory();
IScraperStroage scraperStorage = factory.CreateScraperStroage();
FileInfo fi = new FileInfo(filename);
StorageConnectionManager connectionManager = StorageConnectionManager.GetInstance();
DataStorageFactory dataStorageFactory = connectionManager.GetDefaultDataStorageFactory();
ObjectStorageFactory objectStorageFactory = connectionManager.GetDefaultObjectStorageFactory();
DataStorage dataStorage = dataStorageFactory.CreateDataStorage();
ObjectStorage objectStorage;
if (objectStorageFactory.IsEquivalent(dataStorageFactory))
objectStorage = (ObjectStorage)dataStorage;
else
objectStorage = objectStorageFactory.CreateObjectStorage();
FileInfo fi = new FileInfo(filename);
if (!fi.Exists)
{
logger.FatalFormat("{0} not found.", fi.FullName);
return;
}
SkyscraperContext skyscraper = new SkyscraperContext(new TsContext(), scraperStorage);
SkyscraperContext skyscraper = new SkyscraperContext(new TsContext(), dataStorage,objectStorage);
skyscraper.InitalizeFilterChain();
skyscraper.EnableTimeout = false;
skyscraper.TcpProxyEnabled = false;
@ -382,14 +395,21 @@ namespace skyscraper5
private static void HandleCrazyScanToLiveSystem(string url, bool withTimeout = true)
{
ScraperStorageFactoryConnectionManager connectionManager = ScraperStorageFactoryConnectionManager.GetInstance();
IScraperStorageFactory factory = connectionManager.AutoGetDefaultFactory();
IScraperStroage storage = factory.CreateScraperStroage();
storage.Ping();
HandleCrazyScan(url, storage, withTimeout);
StorageConnectionManager connectionManager = StorageConnectionManager.GetInstance();
DataStorageFactory dataStorageFactory = connectionManager.GetDefaultDataStorageFactory();
ObjectStorageFactory objectStorageFactory = connectionManager.GetDefaultObjectStorageFactory();
DataStorage dataStorage = dataStorageFactory.CreateDataStorage();
ObjectStorage objectStorage;
if (objectStorageFactory.IsEquivalent(dataStorageFactory))
objectStorage = (ObjectStorage)dataStorage;
else
objectStorage = objectStorageFactory.CreateObjectStorage();
objectStorage.Ping();
HandleCrazyScan(url, dataStorage,objectStorage, withTimeout);
}
private static void HandleCrazyScan(string url, IScraperStroage scraperStorage, bool timeout)
private static void HandleCrazyScan(string url, DataStorage dataStorage, ObjectStorage objectStorage, bool timeout)
{
if (!url.StartsWith("tcp://"))
{
@ -410,7 +430,7 @@ namespace skyscraper5
TcpClient tcpClient = new TcpClient(hostname, port);
SkyscraperContext skyscraper = new SkyscraperContext(new TsContext(), scraperStorage);
SkyscraperContext skyscraper = new SkyscraperContext(new TsContext(), dataStorage,objectStorage);
skyscraper.InitalizeFilterChain(new SkipFilter(1024));
//skyscraper.EnableTimeout = timeout;
//skyscraper.TimeoutSeconds = 10;
@ -422,8 +442,9 @@ namespace skyscraper5
{
//Environment.CurrentDirectory = fi.Directory.FullName;
TsContext tsContext = new TsContext();
IScraperStroage scraperStorage = new InMemoryScraperStorage();
SkyscraperContext skyscraper = new SkyscraperContext(tsContext, scraperStorage);
DataStorage dataStorage = new InMemoryScraperStorage();
ObjectStorage objectStorage = new FilesystemStorage(new DirectoryInfo("."));
SkyscraperContext skyscraper = new SkyscraperContext(tsContext, dataStorage,objectStorage);
skyscraper.InitalizeFilterChain();
FileStream fileStream = fi.OpenRead();
skyscraper.IngestFromStream(fileStream);
@ -441,7 +462,7 @@ namespace skyscraper5
{
Console.WriteLine("No PCR detected.");
}
Console.WriteLine("DNS Records found: {0}", scraperStorage.DnsCountA());
Console.WriteLine("DNS Records found: {0}", dataStorage.DnsCountA());
Console.WriteLine("");
Console.WriteLine(new string('-', Console.WindowWidth));

View File

@ -71,7 +71,7 @@ namespace skyscraper5.Scorcher
outputStream = fi.OpenRead();
TsContext tsContext = new TsContext();
SkyscraperContext sc = new SkyscraperContext(tsContext, null, 0);
SkyscraperContext sc = new SkyscraperContext(tsContext, null, null,0);
sc.IngestFromStream(outputStream);
outputStream.Close();

View File

@ -12,6 +12,7 @@ using skyscraper5.Skyscraper.Plugins;
using skyscraper5.Skyscraper.Scraper;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper5.Skyscraper.Scraper.Storage.InMemory;
using skyscraper8.Skyscraper.Scraper.Storage;
using Console = System.Console;
namespace skyscraper5.Skyscraper
@ -103,13 +104,13 @@ namespace skyscraper5.Skyscraper
streamWriter.WriteLine(outLine);
StreamReaderScraperController scraper = new StreamReaderScraperController(streamReader);
scraper.ScraperStroage = new InMemoryScraperStorage();
scraper.DataStorage = new InMemoryScraperStorage();
scraper.Recording = false;
Console.Write("Running PSI acquisition...");
scraper.Run();
Console.WriteLine(".DONE");
IScraperStroage data = scraper.ScraperStroage;
DataStorage data = scraper.DataStorage;
IEnumerable<Tuple<int, int, ProgramMapping>> pmtEntries = data.SelectAllPmt().ToList();
List<Tuple<int, int, SdtService>> tuples = data.SelectAllSdt().ToList();
foreach (var (tsId, networkId, programMapping) in pmtEntries)

View File

@ -1,12 +1,13 @@
using System;
using System.Collections.Generic;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Skyscraper.Equipment
{
public static class EquipmentUtilities
{
public static void InsertDefaultLnbTypes(IScraperStroage storage)
public static void InsertDefaultLnbTypes(DataStorage storage)
{
List<LnbType> knownLnbTypes = storage.UiLnbTypesListAll();
foreach (LnbType defaultLnbType in GetDefaultLnbTypes())
@ -28,7 +29,7 @@ namespace skyscraper5.Skyscraper.Equipment
yield return lnbType;
}
public static void InsertDefaultDishTypes(IScraperStroage storage)
public static void InsertDefaultDishTypes(DataStorage storage)
{
List<DishType> knownDishTypes = storage.UiDishTypesListAll();
foreach (DishType defaultDishType in GetDefaultDishTypes())

View File

@ -1,133 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Skyscraper.Scraper.Storage;
namespace skyscraper5.src.Skyscraper.FrequencyListGenerator
{
internal class MergeDbBlindscanJobs
{
public static void RunAsMain()
{
ScraperStorageFactoryConnectionManager storageFactoryConnectionManager = ScraperStorageFactoryConnectionManager.GetInstance();
IScraperStorageFactory storageFactory = storageFactoryConnectionManager.AutoGetDefaultFactory();
IScraperStroage storage = storageFactory.CreateScraperStroage();
List<DbBlindscanJob> jobs = GetMergeableBlindscanJobs(storage);
if (jobs.Count <= 1)
{
Console.WriteLine("Nothing to merge!");
return;
}
MergeBlindscanJobs(jobs, storage);
}
public static void MergeBlindscanJobs(List<DbBlindscanJob> jobs, IDbBlindscanJobStorage storage)
{
//Zuerst schauen ob im Ziel irgendwas gesäubert werden muss.
DbBlindscanJob mergeTarget = jobs[0];
DbBlindscanJobPolarizationStatus[] targetCleaningModes = new DbBlindscanJobPolarizationStatus[]
{
mergeTarget.HorizontalLowState, mergeTarget.HorizontalHighState, mergeTarget.VerticalLowState, mergeTarget.VerticalHighState
};
for (int i = 0; i < targetCleaningModes.Length; i++)
{
switch(targetCleaningModes[i])
{
case DbBlindscanJobPolarizationStatus.SELECTED_DONE:
continue;
case DbBlindscanJobPolarizationStatus.SELECTED_SCRAPING:
storage.DeleteBlindscanResults(mergeTarget.JobGuid, i);
continue;
case DbBlindscanJobPolarizationStatus.SELECTED_WAITING:
continue;
default:
throw new NotImplementedException(targetCleaningModes[i].ToString());
}
}
for (int i = 1; i < jobs.Count; i++)
{
DbBlindscanJob mergeSource = jobs[i];
DbBlindscanJobPolarizationStatus[] modes = new DbBlindscanJobPolarizationStatus[]
{
mergeSource.HorizontalLowState, mergeSource.HorizontalHighState, mergeSource.VerticalLowState, mergeSource.VerticalHighState
};
for (int j = 0; j < modes.Length; j++)
{
bool deleted = false;
switch(modes[j])
{
case DbBlindscanJobPolarizationStatus.NOT_SELECTED:
continue;
case DbBlindscanJobPolarizationStatus.SELECTED_SCRAPING:
storage.DeleteBlindscanJob(mergeSource.JobGuid);
deleted = true;
break;
case DbBlindscanJobPolarizationStatus.SELECTED_WAITING:
continue;
case DbBlindscanJobPolarizationStatus.SELECTED_DONE:
storage.MoveBlScanResultsToAnotherJob(mergeSource.JobGuid, mergeTarget.JobGuid, j);
continue;
default:
throw new NotImplementedException(modes[j].ToString());
}
if (!deleted)
storage.DeleteBlindscanJob(mergeTarget.JobGuid);
}
}
}
public static List<DbBlindscanJob> GetMergeableBlindscanJobs(IScraperStroage storage)
{
List<DbBlindscanJob> mergableJobs = new List<DbBlindscanJob>();
DbBlindscanJob firstJob = null;
bool hl = false, hh = false, vl = false, vh = false;
long offset = 0;
while (true)
{
DbBlindscanJob blindscanJob = storage.GetPastBlindscanJob(offset++);
if (blindscanJob == null)
break;
if (blindscanJob.HorizontalLowState == DbBlindscanJobPolarizationStatus.SELECTED_DONE)
hl = true;
if (blindscanJob.HorizontalHighState == DbBlindscanJobPolarizationStatus.SELECTED_DONE)
hh = true;
if (blindscanJob.VerticalLowState == DbBlindscanJobPolarizationStatus.SELECTED_DONE)
vl = true;
if (blindscanJob.VerticalHighState == DbBlindscanJobPolarizationStatus.SELECTED_DONE)
vh = true;
if (firstJob == null)
{
firstJob = blindscanJob;
mergableJobs.Add(firstJob);
continue;
}
if (blindscanJob.DiseqCIndex != firstJob.DiseqCIndex)
break;
if (!blindscanJob.SatPosition.Equals(firstJob.SatPosition))
break;
if (!blindscanJob.TunerMAC.Equals(firstJob.TunerMAC))
break;
if (blindscanJob.TunerStandard != firstJob.TunerStandard)
break;
mergableJobs.Add(blindscanJob);
if (hl && hh && vl && vh)
break;
}
mergableJobs.Reverse();
return mergableJobs;
}
}
}

View File

@ -4,6 +4,7 @@ using System.Threading;
using skyscraper5.Skyscraper.Drawing;
using skyscraper5.Skyscraper.Plugins;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Skyscraper.Gps
{
@ -12,10 +13,10 @@ namespace skyscraper5.Skyscraper.Gps
public static void StandaloneProgram()
{
PluginManager pluginManager = PluginManager.GetInstance();
IScraperStorageFactory storageFactory = ScraperStorageFactoryConnectionManager.GetInstance().AutoGetDefaultFactory();
IScraperStroage scraperStroage = storageFactory.CreateScraperStroage();
DataStorageFactory dataStorageFactory = StorageConnectionManager.GetInstance().GetDefaultDataStorageFactory();
DataStorage dataStorage = dataStorageFactory.CreateDataStorage();
WhatCanIReceive instance = new WhatCanIReceive(scraperStroage);
WhatCanIReceive instance = new WhatCanIReceive(dataStorage);
int configuredGpsId = GpsManager.GetConfiguredGpsId();
IGpsReceiverFactory receiverFactory = GpsManager.GetGpsReceiverFactoryById(configuredGpsId);
@ -35,9 +36,9 @@ namespace skyscraper5.Skyscraper.Gps
gpsReceiver.Stop();
}
public IScraperStroage Storage { get; }
public DataStorage Storage { get; }
public WhatCanIReceive(IScraperStroage storage)
public WhatCanIReceive(DataStorage storage)
{
Storage = storage;
}

View File

@ -8,6 +8,7 @@ using System.Runtime.Serialization;
using skyscraper5.Skyscraper.IO.CrazycatStreamReader;
using skyscraper5.Skyscraper.Scraper;
using skyscraper5.Skyscraper.Scraper.Storage.Filesystem;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Skyscraper.IO
{
@ -402,7 +403,8 @@ namespace skyscraper5.Skyscraper.IO
srsc2 = new StreamReaderScraperController(streamReader);
srsc2.RecordingOutputDirectory = new DirectoryInfo("recordings");
srsc2.Recording = true;
srsc2.ScraperStroage = new FilesystemScraperStorage(new DirectoryInfo("srtest_results"));
srsc2.DataStorage = new FilesystemStorage(new DirectoryInfo("srtest_results"));
srsc2.ObjectStorage = (ObjectStorage)srsc2.DataStorage;
}
foreach (BlindScanResult blindScanResult in blindScanResults.Transponders)

View File

@ -8,6 +8,7 @@ using skyscraper5.Mpeg2;
using skyscraper5.Skyscraper.IO.CrazycatStreamReader;
using skyscraper5.Skyscraper.Scraper;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Skyscraper.IO
{
@ -23,7 +24,8 @@ namespace skyscraper5.Skyscraper.IO
private const string RECORDING_FILENAME_MASK = "skyscraper_{0}.ts";
public IScraperStroage ScraperStroage { get; set; }
public DataStorage DataStorage { get; set; }
public ObjectStorage ObjectStorage { get; set; }
public bool Recording { get; set; }
@ -234,7 +236,7 @@ namespace skyscraper5.Skyscraper.IO
}
//Use the Filter
skyscraperContext = new SkyscraperContext(new TsContext(), ScraperStroage);
skyscraperContext = new SkyscraperContext(new TsContext(), DataStorage,ObjectStorage);
skyscraperContext.TcpProxyEnabled = true;
byte[] singlePacketBuffer = new byte[188];
while (!StopConditionMet())

View File

@ -17,6 +17,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Skyscraper.Plugins
{
@ -32,7 +33,6 @@ namespace skyscraper5.Skyscraper.Plugins
descriptorMap = new Dictionary<string, ConstructorInfo[]>();
_streamTypeAutodetectionContestants = new List<Type>();
_t2MiPacketConstructorInfos = new ConstructorInfo[256];
scraperStorageFactories = new Dictionary<ScrapeStorageFactoryIdAttribute, IScraperStorageFactory>();
tunerFactories = new Dictionary<TunerFactoryIdAttribute, ITunerFactory>();
_docsisMacManagementMessageTypes = new Dictionary<MacManagementMessageTypeAttribute, Type>();
_userDefinedDescriptors = new Dictionary<UserDefinedDescriptorAttribute, ConstructorInfo>();
@ -145,11 +145,13 @@ namespace skyscraper5.Skyscraper.Plugins
return _instance;
}
private Type storageIdAttributeTyoe = typeof(StorageIdAttribute);
private Type objectStorageFactoryType = typeof(ObjectStorageFactory);
private Type dataStorageFactoryType = typeof(DataStorageFactory);
private Type dnsParserPluginType = typeof(IDnsParser);
private Type pluginLoadHookType = typeof(IPluginLoadHook);
private Type docsisMacManagementType = typeof(MacManagementMessage);
private Type tunerFactoryType = typeof(ITunerFactory);
private Type scraperStorageFactoryType = typeof(IScraperStorageFactory);
private Type t2MiPacketType = typeof(T2MiPacket);
private Type mpePluginType = typeof(ISkyscraperMpePlugin);
private Type gpsReceiverFactoryType = typeof(IGpsReceiverFactory);
@ -164,7 +166,6 @@ namespace skyscraper5.Skyscraper.Plugins
private Dictionary<string, bool[]> descriptorBannedTables;
private List<Type> _streamTypeAutodetectionContestants;
private ConstructorInfo[] _t2MiPacketConstructorInfos;
private Dictionary<ScrapeStorageFactoryIdAttribute, IScraperStorageFactory> scraperStorageFactories;
private Dictionary<TunerFactoryIdAttribute, ITunerFactory> tunerFactories;
private Dictionary<MacManagementMessageTypeAttribute, Type> _docsisMacManagementMessageTypes;
private Dictionary<UserDefinedDescriptorAttribute, ConstructorInfo> _userDefinedDescriptors;
@ -182,6 +183,21 @@ namespace skyscraper5.Skyscraper.Plugins
if (!isSkyscraperPlugin)
continue;
bool isStorageFactory = false;
if (type.IsAssignableTo(objectStorageFactoryType))
{
HandleObjectStorageFactory(type);
isStorageFactory = true;
}
if (type.IsAssignableTo(dataStorageFactoryType))
{
HandleDataStorageFactory(type);
isStorageFactory = true;
}
if (isStorageFactory)
continue;
if (type.IsAssignableTo(mpePluginType))
{
ISkyscraperMpePlugin mpePlugin = (ISkyscraperMpePlugin)Activator.CreateInstance(type);
@ -210,11 +226,6 @@ namespace skyscraper5.Skyscraper.Plugins
HandleT2MiPacketType(type);
continue;
}
else if (type.IsAssignableTo(scraperStorageFactoryType))
{
HandleScraperStorageFactory(type);
continue;
}
else if (type.IsAssignableTo(tunerFactoryType))
{
HandleTunerFactory(type);
@ -268,6 +279,45 @@ namespace skyscraper5.Skyscraper.Plugins
_mpePlugins.Sort(sorter);
}
#region Scraper Storages
private Dictionary<int, DataStorageFactory> _dataStorages;
private Dictionary<int, ObjectStorageFactory> _objectStorages;
private void HandleDataStorageFactory(Type type)
{
Attribute idAttribute = type.GetCustomAttributes(storageIdAttributeTyoe).FirstOrDefault();
if (idAttribute == null)
{
logger.ErrorFormat("{0} does not have an a {1}", type, storageIdAttributeTyoe.Name);
return;
}
int id = ((StorageIdAttribute)idAttribute).Id;
if (_dataStorages == null)
_dataStorages = new Dictionary<int, DataStorageFactory>();
DataStorageFactory child = (DataStorageFactory)Activator.CreateInstance(type);
_dataStorages.Add(id, child);
}
private void HandleObjectStorageFactory(Type type)
{
Attribute idAttribute = type.GetCustomAttributes(storageIdAttributeTyoe).FirstOrDefault();
if (idAttribute == null)
{
logger.ErrorFormat("{0} does not have an a {1}", type, storageIdAttributeTyoe.Name);
return;
}
int id = ((StorageIdAttribute)idAttribute).Id;
if (_objectStorages == null)
_objectStorages = new Dictionary<int, ObjectStorageFactory>();
ObjectStorageFactory child = (ObjectStorageFactory)Activator.CreateInstance(type);
_objectStorages.Add(id, child);
}
#endregion
#region DNS Plugin
private void HandleDnsParser(Type type)
{
@ -401,23 +451,7 @@ namespace skyscraper5.Skyscraper.Plugins
tunerFactories.Add(attribute, issf);
}
#endregion
#region Storage Factory
private Type scraperStorageFactoryIdType = typeof(ScrapeStorageFactoryIdAttribute);
private void HandleScraperStorageFactory(Type type)
{
object[] customAttributes = type.GetCustomAttributes(scraperStorageFactoryIdType, false);
if (customAttributes.Length == 0)
return;
ScrapeStorageFactoryIdAttribute attribute = (ScrapeStorageFactoryIdAttribute)customAttributes[0];
IScraperStorageFactory issf = (IScraperStorageFactory)Activator.CreateInstance(type);
scraperStorageFactories.Add(attribute, issf);
}
#endregion
#region T2-MI Packet Types
private Type[] t2MiConstructorPattern = new Type[] { typeof(T2MIHeader), typeof(byte[]) };
@ -536,14 +570,7 @@ namespace skyscraper5.Skyscraper.Plugins
new ReadOnlyDictionary<TunerFactoryIdAttribute, ITunerFactory>(tunerFactories);
return result;
}
public ReadOnlyDictionary<ScrapeStorageFactoryIdAttribute, IScraperStorageFactory> GetScraperStorageFactories()
{
ReadOnlyDictionary<ScrapeStorageFactoryIdAttribute, IScraperStorageFactory> result =
new ReadOnlyDictionary<ScrapeStorageFactoryIdAttribute, IScraperStorageFactory>(
scraperStorageFactories);
return result;
}
public ConstructorInfo[] GetT2MiPacketTypes()
{
ConstructorInfo[] t2MiPacketConstructorInfos = _t2MiPacketConstructorInfos;
@ -596,6 +623,16 @@ namespace skyscraper5.Skyscraper.Plugins
return output;
}
public ReadOnlyDictionary<int, ObjectStorageFactory> GetObjectStorages()
{
return _objectStorages.AsReadOnly();
}
public ReadOnlyDictionary<int, DataStorageFactory> GetDataStorages()
{
return _dataStorages.AsReadOnly();
}
public void AutoconfigureObject(string categoryName, object targetObject)
{
if (Ini == null)

View File

@ -9,17 +9,20 @@ using System.Threading.Tasks;
using skyscraper5.Mpeg2;
using skyscraper5.Skyscraper.Scraper;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Skyscraper.RecordingImporter
{
internal class TsFileCollectionImporter
{
public IScraperStroage ScraperStorage { get; }
public DataStorage DataStorage { get; }
public ObjectStorage ObjectStorage { get; }
public DirectoryInfo RootDirectory { get; }
public TsFileCollectionImporter(IScraperStroage scraperStorage, DirectoryInfo rootDirectory)
public TsFileCollectionImporter(DataStorage dataStorage, ObjectStorage objectStorage, DirectoryInfo rootDirectory)
{
ScraperStorage = scraperStorage;
DataStorage = dataStorage;
ObjectStorage = objectStorage;
RootDirectory = rootDirectory;
}
@ -43,10 +46,10 @@ namespace skyscraper5.Skyscraper.RecordingImporter
private void Import(FileInfo fi)
{
if (ScraperStorage.ImportFileKnown(fi))
if (DataStorage.ImportFileKnown(fi))
return;
SkyscraperContext skyscraper = new SkyscraperContext(new TsContext(), ScraperStorage);
SkyscraperContext skyscraper = new SkyscraperContext(new TsContext(), DataStorage,ObjectStorage);
skyscraper.InitalizeFilterChain();
FileStream fileStream = fi.OpenRead();
@ -59,7 +62,7 @@ namespace skyscraper5.Skyscraper.RecordingImporter
Console.WriteLine("Took {0} seconds. " + stopwatch.Elapsed.TotalSeconds);
Console.WriteLine("File was: {0}", fi.Name);
ScraperStorage.ImportMarkFileAsKnown(fi, stopwatch.Elapsed, skyscraper.SpecialTsType);
DataStorage.ImportMarkFileAsKnown(fi, stopwatch.Elapsed, skyscraper.SpecialTsType);
}
}
}

View File

@ -39,7 +39,6 @@ using skyscraper5.Skyscraper.Plugins;
using skyscraper5.Skyscraper.Scraper.FrameGrabber;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper5.Skyscraper.Scraper.Storage.InMemory;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper5.Skyscraper.Scraper.Storage.Utilities;
using skyscraper5.Skyscraper.Scraper.StreamAutodetection;
using skyscraper5.Skyscraper.Scraper.Utils;
@ -73,6 +72,7 @@ using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using skyscraper8.Skyscraper.Scraper.Storage;
using Tsubasa.IO;
using Platform = skyscraper5.Dvb.SystemSoftwareUpdate.Model.Platform;
using RntParser = skyscraper5.Dvb.TvAnytime.RntParser;
@ -93,7 +93,9 @@ namespace skyscraper5.Skyscraper.Scraper
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);
public TsContext DvbContext { get; }
public IScraperStroage ScraperStorage { get; }
public DataStorage DataStorage { get; }
public ObjectStorage ObjectStorage { get; }
public bool SourceIsDisk { get; set; }
@ -103,7 +105,7 @@ namespace skyscraper5.Skyscraper.Scraper
public PsiDecoder Pid0x11Decoder { get; private set; }
public PsiDecoder Pid0x12Decoder { get; private set; }
public IPsiDecoderTransformer PmtDecoderTransformer { get; set; }
public SkyscraperContext(TsContext dvbContext, IScraperStroage scraperStorage = null, int skipAtStart = 0, int? currentNetworkId = null, int? currentTransportStreamId = null)
public SkyscraperContext(TsContext dvbContext, DataStorage dataStorage = null, ObjectStorage objectStorage = null, int skipAtStart = 0, int? currentNetworkId = null, int? currentTransportStreamId = null)
{
TsDescriptorUnpacker descriptorUnpacker = TsDescriptorUnpacker.GetInstance();
for (byte i = 0x80; i < 0xfe; i++)
@ -162,9 +164,18 @@ namespace skyscraper5.Skyscraper.Scraper
//PID 0x1F
//won't need these. We operate on broadcasted stuff, so we shouldn't encounter partial TS
if (scraperStorage == null)
scraperStorage = new InMemoryScraperStorage();
ScraperStorage = scraperStorage;
if (dataStorage == null)
{
throw new ArgumentNullException(nameof(dataStorage));
}
DataStorage = dataStorage;
if (objectStorage == null)
{
throw new ArgumentNullException(nameof(objectStorage));
}
ObjectStorage = objectStorage;
CurrentNetworkId = currentNetworkId;
CurrentTransportStreamId = currentTransportStreamId;
DsmCcsToLookFor = new Dictionary<ushort, byte>();
@ -398,7 +409,7 @@ namespace skyscraper5.Skyscraper.Scraper
SpecialTsType = 1;
if (CurrentNetworkId.HasValue && CurrentTransportStreamId.HasValue)
{
ScraperStorage.StorePatEntry(CurrentNetworkId.Value, CurrentTransportStreamId.Value, pmtPid, programId);
DataStorage.StorePatEntry(CurrentNetworkId.Value, CurrentTransportStreamId.Value, pmtPid, programId);
}
if (DvbContext.IsPidProcessorPresent(pmtPid))
@ -433,9 +444,9 @@ namespace skyscraper5.Skyscraper.Scraper
if (CurrentNetworkId.HasValue && CurrentTransportStreamId.HasValue)
{
if (!ScraperStorage.TestForPmtEvent(CurrentNetworkId.Value, CurrentTransportStreamId.Value, result))
if (!DataStorage.TestForPmtEvent(CurrentNetworkId.Value, CurrentTransportStreamId.Value, result))
{
if (ScraperStorage.StorePmtEvent(CurrentNetworkId.Value, CurrentTransportStreamId.Value, result))
if (DataStorage.StorePmtEvent(CurrentNetworkId.Value, CurrentTransportStreamId.Value, result))
logworthy = true;
}
@ -502,7 +513,7 @@ namespace skyscraper5.Skyscraper.Scraper
{
if (CurrentNetworkId.HasValue && CurrentTransportStreamId.HasValue)
{
if (!ScraperStorage.TestForFramegrab(CurrentNetworkId.Value, CurrentTransportStreamId.Value, result.ProgramNumber, mappingStream.ElementaryPid))
if (!ObjectStorage.TestForFramegrab(CurrentNetworkId.Value, CurrentTransportStreamId.Value, result.ProgramNumber, mappingStream.ElementaryPid))
{
ffmpegFrameGrabber ffmfg = new ffmpegFrameGrabber(CurrentNetworkId.Value, CurrentTransportStreamId.Value, result, mappingStream, this);
ffmfg.TsProxyEndPoint = DvbContext.GetTcpProxyEndPoint();
@ -976,7 +987,7 @@ namespace skyscraper5.Skyscraper.Scraper
private EitEvent[] runningEvents;
public void OnEitEvent(EitEvent eitEvent)
{
if (ScraperStorage.StoreEitEvent(eitEvent))
if (DataStorage.StoreEitEvent(eitEvent))
LogEvent(SkyscraperContextEvent.EitEvent, eitEvent.EventName);
UiJunction?.NotifyEvent(eitEvent);
@ -1024,14 +1035,14 @@ namespace skyscraper5.Skyscraper.Scraper
throw new NotImplementedException(transportStream.DeliveryMethod.ToString());
}
if (!ScraperStorage.TestForNitTransportStream(networkId, transportStream))
if (!DataStorage.TestForNitTransportStream(networkId, transportStream))
{
ScraperStorage.StoreNitTransportStream(networkId, transportStream);
DataStorage.StoreNitTransportStream(networkId, transportStream);
LogEvent(SkyscraperContextEvent.OnNitTransportStream, name);
return;
}
if (ScraperStorage.UpdateNitTransportStream(networkId, transportStream))
if (DataStorage.UpdateNitTransportStream(networkId, transportStream))
{
LogEvent(SkyscraperContextEvent.OnNitTransportStreamUpdate, name);
return;
@ -1060,14 +1071,14 @@ namespace skyscraper5.Skyscraper.Scraper
}
}
if (!ScraperStorage.TestForNitNetwork(nitNetwork))
if (!DataStorage.TestForNitNetwork(nitNetwork))
{
ScraperStorage.StoreNitNetwork(nitNetwork);
DataStorage.StoreNitNetwork(nitNetwork);
LogEvent(SkyscraperContextEvent.OnNitNetwork, nitNetwork.Name);
return;
}
if (ScraperStorage.UpdateNitNetwork(nitNetwork))
if (DataStorage.UpdateNitNetwork(nitNetwork))
{
LogEvent(SkyscraperContextEvent.OnNitNetworkUpdate, nitNetwork.Name);
return;
@ -1120,22 +1131,22 @@ namespace skyscraper5.Skyscraper.Scraper
if (!currentTime.HasValue)
return;
ScraperStorage.StoreTeletextPage(networkId, transportStreamId, programNumber, magazine, currentTime.Value);
DataStorage.StoreTeletextPage(networkId, transportStreamId, programNumber, magazine, currentTime.Value);
}
public void OnBatBouquet(BatBouquet batBouquet)
{
UiJunction?.NotifyBat(batBouquet);
if (ScraperStorage.TestForBatBouquet(batBouquet))
if (DataStorage.TestForBatBouquet(batBouquet))
{
if (ScraperStorage.UpdateBatBouquet(batBouquet))
if (DataStorage.UpdateBatBouquet(batBouquet))
{
LogEvent(SkyscraperContextEvent.BatBouquetUpdate, batBouquet.BouquetName);
}
}
else
{
ScraperStorage.StoreBatBouquet(batBouquet);
DataStorage.StoreBatBouquet(batBouquet);
LogEvent(SkyscraperContextEvent.BatBouquet, batBouquet.BouquetName);
}
}
@ -1144,27 +1155,27 @@ namespace skyscraper5.Skyscraper.Scraper
{
UiJunction?.NotifyBatTs(batBouquet.BouquetId, child);
string name = String.Format("{0},{1}", batBouquet.BouquetId, child.OriginalNetworkId);
if (ScraperStorage.TestForBatTransportStream(batBouquet.BouquetId, child))
if (DataStorage.TestForBatTransportStream(batBouquet.BouquetId, child))
{
if (ScraperStorage.UpdateBatTransportStream(batBouquet.BouquetId, child))
if (DataStorage.UpdateBatTransportStream(batBouquet.BouquetId, child))
{
LogEvent(SkyscraperContextEvent.BatTransportStreamUpdate, name);
}
}
else
{
ScraperStorage.StoreBatTransportStream(batBouquet.BouquetId, child);
DataStorage.StoreBatTransportStream(batBouquet.BouquetId, child);
LogEvent(SkyscraperContextEvent.BatTransportStream, name);
}
}
public void OnSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService)
{
if (ScraperStorage.TestForSdtService(transportStreamId, originalNetworkId, sdtService))
if (DataStorage.TestForSdtService(transportStreamId, originalNetworkId, sdtService))
{
if (!IsChild)
{
if (ScraperStorage.UpdateSdtService(transportStreamId, originalNetworkId, sdtService))
if (DataStorage.UpdateSdtService(transportStreamId, originalNetworkId, sdtService))
{
LogEvent(SkyscraperContextEvent.OnSdtServiceUpdate, sdtService.ServiceName);
}
@ -1172,7 +1183,7 @@ namespace skyscraper5.Skyscraper.Scraper
}
else
{
ScraperStorage.StoreSdtService(transportStreamId, originalNetworkId, sdtService);
DataStorage.StoreSdtService(transportStreamId, originalNetworkId, sdtService);
LogEvent(SkyscraperContextEvent.OnSdtService, sdtService.ServiceName);
}
@ -1199,7 +1210,7 @@ namespace skyscraper5.Skyscraper.Scraper
if (!CurrentTransportStreamId.HasValue)
return;
if (ScraperStorage.UpdateRdsPty(CurrentNetworkId.Value, CurrentTransportStreamId.Value, programNumber, pty))
if (DataStorage.UpdateRdsPty(CurrentNetworkId.Value, CurrentTransportStreamId.Value, programNumber, pty))
{
LogEvent(SkyscraperContextEvent.RdsPty, String.Format("{0} -> {1}", programNumber, pty.ToString()));
}
@ -1213,8 +1224,7 @@ namespace skyscraper5.Skyscraper.Scraper
if (!CurrentTransportStreamId.HasValue)
return;
if (ScraperStorage.MarkAsRdsTrafficInformationProgramme(CurrentNetworkId.Value,
CurrentTransportStreamId.Value, programNumber))
if (DataStorage.MarkAsRdsTrafficInformationProgramme(CurrentNetworkId.Value, CurrentTransportStreamId.Value, programNumber))
{
LogEvent(SkyscraperContextEvent.RdsTrafficInfoDetected, String.Format("{0}", programNumber));
}
@ -1231,7 +1241,7 @@ namespace skyscraper5.Skyscraper.Scraper
if (!CurrentTransportStreamId.HasValue)
return;
if (ScraperStorage.UpdateTimeOffsetTable(CurrentNetworkId.Value, CurrentTransportStreamId.Value, utcTime,
if (DataStorage.UpdateTimeOffsetTable(CurrentNetworkId.Value, CurrentTransportStreamId.Value, utcTime,
ltod))
LogEvent(SkyscraperContextEvent.TotTime, utcTime.ToString());
}
@ -1247,7 +1257,7 @@ namespace skyscraper5.Skyscraper.Scraper
if (!CurrentTransportStreamId.HasValue)
return;
if (ScraperStorage.UpdateTimeAndDate(CurrentNetworkId.Value, CurrentTransportStreamId.Value, utcTime))
if (DataStorage.UpdateTimeAndDate(CurrentNetworkId.Value, CurrentTransportStreamId.Value, utcTime))
LogEvent(SkyscraperContextEvent.TdtTime, utcTime.ToString());
}
@ -1274,9 +1284,9 @@ namespace skyscraper5.Skyscraper.Scraper
}
}
if (!ScraperStorage.TestForAitApplication(aitApplication.ApplicationIdentifier))
if (!DataStorage.TestForAitApplication(aitApplication.ApplicationIdentifier))
{
ScraperStorage.StoreAitApplication(aitApplication);
DataStorage.StoreAitApplication(aitApplication);
LogEvent(SkyscraperContextEvent.AitApplication, aitApplication.TryGetName());
}
}
@ -1290,7 +1300,7 @@ namespace skyscraper5.Skyscraper.Scraper
if (!CurrentNetworkId.HasValue)
return;
if (ScraperStorage.ObjectCarouselFileArrival(vfsFile, CurrentTransportStreamId.Value, CurrentNetworkId.Value))
if (ObjectStorage.ObjectCarouselFileArrival(vfsFile, CurrentTransportStreamId.Value, CurrentNetworkId.Value))
{
LogEvent(SkyscraperContextEvent.FileArrival, String.Format("PID {0:X4}, Path {1}", vfsFile.SourcePid, vfsFile.ToString()));
}
@ -1331,9 +1341,9 @@ namespace skyscraper5.Skyscraper.Scraper
if (!fromPmt)
{
UiJunction?.NotifyCat(caDescriptor);
if (!ScraperStorage.TestForCaSystem(CurrentNetworkId.Value, CurrentTransportStreamId.Value, caDescriptor.CaPid))
if (!DataStorage.TestForCaSystem(CurrentNetworkId.Value, CurrentTransportStreamId.Value, caDescriptor.CaPid))
{
ScraperStorage.StoreCaSystem(CurrentNetworkId.Value, CurrentTransportStreamId.Value, caDescriptor);
DataStorage.StoreCaSystem(CurrentNetworkId.Value, CurrentTransportStreamId.Value, caDescriptor);
LogEvent(SkyscraperContextEvent.CaSystem, String.Format("{0} on PID {1:X4}", CaSystemNames.GetHumanReadableName(caDescriptor.CaSystemId), caDescriptor.CaPid));
}
}
@ -1372,7 +1382,7 @@ namespace skyscraper5.Skyscraper.Scraper
{
foreach (Platform platform in target.Platforms)
{
ScraperStorage.StoreUpdateNotification(0, common, compatibility, platform);
DataStorage.StoreUpdateNotification(0, common, compatibility, platform);
}
}
@ -1411,10 +1421,10 @@ namespace skyscraper5.Skyscraper.Scraper
if (!CurrentTransportStreamId.HasValue)
return false;
if (ScraperStorage.IsDsmCcModuleBlacklisted(CurrentNetworkId.Value, CurrentTransportStreamId.Value, elementaryPid, moduleId, moduleVersion))
if (DataStorage.IsDsmCcModuleBlacklisted(CurrentNetworkId.Value, CurrentTransportStreamId.Value, elementaryPid, moduleId, moduleVersion))
return false;
if (ScraperStorage.IsDsmCcModuleWanted(CurrentNetworkId.Value, CurrentTransportStreamId.Value, elementaryPid, moduleId, moduleVersion))
if (ObjectStorage.IsDsmCcModuleWanted(CurrentNetworkId.Value, CurrentTransportStreamId.Value, elementaryPid, moduleId, moduleVersion))
return true;
return false;
@ -1436,7 +1446,7 @@ namespace skyscraper5.Skyscraper.Scraper
if (dedupModules.Contains(key))
return;
if (ScraperStorage.IsDsmCcModuleWanted(CurrentNetworkId.Value, CurrentTransportStreamId.Value, elementaryPid, moduleInfoModuleId, moduleInfoModuleVersion))
if (ObjectStorage.IsDsmCcModuleWanted(CurrentNetworkId.Value, CurrentTransportStreamId.Value, elementaryPid, moduleInfoModuleId, moduleInfoModuleVersion))
{
if (!_dataCarouselProgresses.ContainsKey(key))
{
@ -1487,7 +1497,7 @@ namespace skyscraper5.Skyscraper.Scraper
throw new NotImplementedException();
UiJunction?.SetMemorySaverMode(true);
ScraperStorage.DataCarouselModuleArrival(CurrentNetworkId.Value, CurrentTransportStreamId.Value, elementaryPid, moduleModuleId, moduleModuleVersion, result);
ObjectStorage.DataCarouselModuleArrival(CurrentNetworkId.Value, CurrentTransportStreamId.Value, elementaryPid, moduleModuleId, moduleModuleVersion, result);
UiJunction?.SetMemorySaverMode(false);
LogEvent(SkyscraperContextEvent.ModuleDownloadComplete, String.Format("Module {0}, Version {1}", moduleModuleId, moduleModuleVersion));
@ -1506,7 +1516,7 @@ namespace skyscraper5.Skyscraper.Scraper
return;
if (!currentTime.HasValue)
return;
ScraperStorage.StoreDsmCcDoItNowEvent(currentTime.Value, CurrentNetworkId.Value, CurrentNetworkId.Value, programMapping.ProgramNumber, descriptorListStreamEventDescriptor, pid);
DataStorage.StoreDsmCcDoItNowEvent(currentTime.Value, CurrentNetworkId.Value, CurrentNetworkId.Value, programMapping.ProgramNumber, descriptorListStreamEventDescriptor, pid);
//These "do-it-now" Events are specific for _EVERY_ application and probably not
//worth extending the scraping time. They are most likely subtitles or commands
@ -1522,7 +1532,7 @@ namespace skyscraper5.Skyscraper.Scraper
public void SetRdsProgrammeServiceName(int programNumber, string programmeService2)
{
if (ScraperStorage.UpdateRdsProgrammeServiceName(CurrentNetworkId.Value, CurrentTransportStreamId.Value,
if (DataStorage.UpdateRdsProgrammeServiceName(CurrentNetworkId.Value, CurrentTransportStreamId.Value,
programNumber, programmeService2))
{
LogEvent(SkyscraperContextEvent.RdsProgrammeServiceName,
@ -1538,10 +1548,10 @@ namespace skyscraper5.Skyscraper.Scraper
if (!CurrentTransportStreamId.HasValue)
return false;
if (!ScraperStorage.TestForKnownRdsData(CurrentNetworkId.Value, CurrentTransportStreamId.Value,
if (!DataStorage.TestForKnownRdsData(CurrentNetworkId.Value, CurrentTransportStreamId.Value,
programNumber))
{
ScraperStorage.EnableRdsCollection(CurrentNetworkId.Value, CurrentTransportStreamId.Value,
DataStorage.EnableRdsCollection(CurrentNetworkId.Value, CurrentTransportStreamId.Value,
programNumber);
LogEvent(SkyscraperContextEvent.BeginRdsRecording,
String.Format("{0:X4},{1:X4},{2:X4}", CurrentNetworkId.Value, CurrentTransportStreamId.Value,
@ -1553,7 +1563,7 @@ namespace skyscraper5.Skyscraper.Scraper
public void SetRdsRadioText(int programNumber, string text)
{
if (ScraperStorage.UpdateRdsRadioText(CurrentNetworkId.Value, CurrentTransportStreamId.Value, programNumber,
if (DataStorage.UpdateRdsRadioText(CurrentNetworkId.Value, CurrentTransportStreamId.Value, programNumber,
text))
{
LogEvent(SkyscraperContextEvent.RdsText, String.Format("{0:X4} [{1}]", programNumber, text));
@ -1569,10 +1579,10 @@ namespace skyscraper5.Skyscraper.Scraper
if (!CurrentTransportStreamId.HasValue)
return;
if (!ScraperStorage.TestForScte35SpliceInsert(CurrentNetworkId.Value, CurrentTransportStreamId.Value,
if (!DataStorage.TestForScte35SpliceInsert(CurrentNetworkId.Value, CurrentTransportStreamId.Value,
ProgramNumber, spliceInsert))
{
ScraperStorage.StoreScte35SpliceInsert(CurrentNetworkId.Value, CurrentTransportStreamId.Value, ProgramNumber, spliceInsert);
DataStorage.StoreScte35SpliceInsert(CurrentNetworkId.Value, CurrentTransportStreamId.Value, ProgramNumber, spliceInsert);
LogEvent(SkyscraperContextEvent.Scte35Splice,
String.Format("Program {0:X4}, Splice at {1:X16}", ProgramNumber, spliceInsert.SpliceTime));
}
@ -1590,7 +1600,7 @@ namespace skyscraper5.Skyscraper.Scraper
if (!currentTime.HasValue)
return;
ScraperStorage.SetScte35TimeSignal(CurrentNetworkId.Value, CurrentTransportStreamId.Value, currentTime.Value, programNumber, timeSignal);
DataStorage.SetScte35TimeSignal(CurrentNetworkId.Value, CurrentTransportStreamId.Value, currentTime.Value, programNumber, timeSignal);
LogEvent(SkyscraperContextEvent.Scte35TimeSignal, String.Format("Program {0:X4}, Time Signal {1:X16}", programNumber, timeSignal.Value));
}
@ -1602,9 +1612,9 @@ namespace skyscraper5.Skyscraper.Scraper
if (!CurrentTransportStreamId.HasValue)
return;
if (!ScraperStorage.IsCompliant(CurrentNetworkId.Value, CurrentTransportStreamId.Value, compliance))
if (!DataStorage.IsCompliant(CurrentNetworkId.Value, CurrentTransportStreamId.Value, compliance))
{
ScraperStorage.MarkAsCompliant(CurrentNetworkId.Value, CurrentTransportStreamId.Value, compliance);
DataStorage.MarkAsCompliant(CurrentNetworkId.Value, CurrentTransportStreamId.Value, compliance);
LogEvent(SkyscraperContextEvent.Compliance, compliance);
}
}
@ -1617,7 +1627,7 @@ namespace skyscraper5.Skyscraper.Scraper
if (!CurrentTransportStreamId.HasValue)
return;
if (ScraperStorage.SetStationIdentification(CurrentNetworkId.Value, CurrentTransportStreamId.Value,
if (DataStorage.SetStationIdentification(CurrentNetworkId.Value, CurrentTransportStreamId.Value,
stationIdentification))
{
LogEvent(SkyscraperContextEvent.StationIdentification, stationIdentification);
@ -1689,7 +1699,7 @@ namespace skyscraper5.Skyscraper.Scraper
private bool ProcessDns(IpTrafficInfo trafficInfo, byte[] ipv4Packet)
{
if (DnsCache == null)
DnsCache = new SkyscraperDnsCache(ScraperStorage);
DnsCache = new SkyscraperDnsCache(DataStorage);
//Handle DNS
bool result = false;
if (trafficInfo.Protocol == 0x11)
@ -1735,7 +1745,7 @@ namespace skyscraper5.Skyscraper.Scraper
if (mpePlugins == null)
{
mpePlugins = PluginManager.GetInstance().GetMpePlugins();
object[] connector = ScraperStorage.GetPluginConnector();
object[] connector = StorageConnectionManager.GetPluginConnectors(DataStorage, ObjectStorage);
foreach (ISkyscraperMpePlugin plugin in mpePlugins)
{
try
@ -1796,7 +1806,7 @@ namespace skyscraper5.Skyscraper.Scraper
if (!currentTime.HasValue)
return;
if (ScraperStorage.StoreRunningStatus(transportStreamId, originalNetworkId, serviceId, eventId, runningStatus, currentTime.Value))
if (DataStorage.StoreRunningStatus(transportStreamId, originalNetworkId, serviceId, eventId, runningStatus, currentTime.Value))
{
LogEvent(SkyscraperContextEvent.RunningStatusChange, String.Format("({0:X4},{1:X4},{2:X4},{3:X4}) -> {4}", originalNetworkId, transportStreamId, serviceId, eventId, runningStatus));
}
@ -1855,7 +1865,7 @@ namespace skyscraper5.Skyscraper.Scraper
}
if (childSkyscrapers[pid][basebandFramePlpId] == null)
{
childSkyscrapers[pid][basebandFramePlpId] = new SkyscraperContext(new TsContext(), ScraperStorage);
childSkyscrapers[pid][basebandFramePlpId] = new SkyscraperContext(new TsContext(), DataStorage,ObjectStorage);
childSkyscrapers[pid][basebandFramePlpId].IsChild = true;
childSkyscrapers[pid][basebandFramePlpId].ChildName = String.Format("PLP {0}", basebandFramePlpId);
@ -1901,10 +1911,10 @@ namespace skyscraper5.Skyscraper.Scraper
return;
DateTime resolveTime = t2Timestamp.ResolveTime();
DateTime knownTimestamp = ScraperStorage.T2MiGetTimestamp(CurrentNetworkId.Value, CurrentTransportStreamId.Value, pid);
DateTime knownTimestamp = DataStorage.T2MiGetTimestamp(CurrentNetworkId.Value, CurrentTransportStreamId.Value, pid);
if (resolveTime > knownTimestamp)
{
ScraperStorage.T2MiSetTimestamp(CurrentNetworkId.Value, CurrentTransportStreamId.Value, pid, resolveTime);
DataStorage.T2MiSetTimestamp(CurrentNetworkId.Value, CurrentTransportStreamId.Value, pid, resolveTime);
}
}
@ -1962,14 +1972,14 @@ namespace skyscraper5.Skyscraper.Scraper
foreach (AddressingFunction function in individualAddressing.Commands)
{
if (!ScraperStorage.T2MiTestForTransmitter(CurrentNetworkId, CurrentTransportStreamId, relatedPid, function.TxIdentifier))
ScraperStorage.T2MiRememberTransmitter(CurrentNetworkId, CurrentTransportStreamId, relatedPid, function.TxIdentifier);
if (!DataStorage.T2MiTestForTransmitter(CurrentNetworkId, CurrentTransportStreamId, relatedPid, function.TxIdentifier))
DataStorage.T2MiRememberTransmitter(CurrentNetworkId, CurrentTransportStreamId, relatedPid, function.TxIdentifier);
switch (function.Tag)
{
case 0x00:
_0x00_TransmitterTimeOffset tto = (_0x00_TransmitterTimeOffset)function;
ScraperStorage.T2MiSetTransmitterTimeOffset(CurrentNetworkId, CurrentTransportStreamId, relatedPid, function.TxIdentifier, tto.TimeOffset);
DataStorage.T2MiSetTransmitterTimeOffset(CurrentNetworkId, CurrentTransportStreamId, relatedPid, function.TxIdentifier, tto.TimeOffset);
break;
default:
throw new NotImplementedException(String.Format("Individual Addressing function 0x{0:X2}", function.Tag));
@ -2021,23 +2031,23 @@ namespace skyscraper5.Skyscraper.Scraper
if (item.Value == 0.0)
continue;
ScraperStorage.FailDsmCcDownload(item.Key, item.Value);
DataStorage.FailDsmCcDownload(item.Key, item.Value);
}
}
}
ScraperStorage.WaitForCompletion();
DataStorage.WaitForCompletion();
}
public bool TestForFrame(int currentNetworkId, int transportStreamId, ushort mappingProgramNumber, int mappingStreamElementaryPid)
{
return ScraperStorage.TestForFramegrab(currentNetworkId, transportStreamId, mappingProgramNumber, mappingStreamElementaryPid);
return ObjectStorage.TestForFramegrab(currentNetworkId, transportStreamId, mappingProgramNumber, mappingStreamElementaryPid);
}
public void NotifyCompletedFrame(int currentNetworkId, int transportStreamId, ushort mappingProgramNumber,
int mappingStreamElementaryPid, byte[] imageData)
{
ScraperStorage.StoreFramegrab(currentNetworkId, transportStreamId, mappingProgramNumber, (ushort)mappingStreamElementaryPid, imageData);
ObjectStorage.StoreFramegrab(currentNetworkId, transportStreamId, mappingProgramNumber, (ushort)mappingStreamElementaryPid, imageData);
LogEvent(SkyscraperContextEvent.GotFramegrab, String.Format("Program {0:X4}, PID {1:X4}", mappingProgramNumber, mappingStreamElementaryPid));
UiJunction?.ShowFramegrab(currentNetworkId, transportStreamId, mappingProgramNumber, mappingStreamElementaryPid, imageData);
}
@ -2047,9 +2057,9 @@ namespace skyscraper5.Skyscraper.Scraper
IEnumerable<IpMacNotification> ipMacNotifications = IpMacNotification.FlatMap(platform, target, operational);
foreach (IpMacNotification notification in ipMacNotifications)
{
if (!ScraperStorage.TestForIpMacNotification(notification))
if (!DataStorage.TestForIpMacNotification(notification))
{
ScraperStorage.StoreIpMacNotification(notification);
DataStorage.StoreIpMacNotification(notification);
LogEvent(SkyscraperContextEvent.IpMacNotification, String.Format("{0} -> {1}", platform.Name, notification.TargetName));
}
}
@ -2068,9 +2078,9 @@ namespace skyscraper5.Skyscraper.Scraper
foreach (RctLinkInfo rctLinkInfo in result.LinkInfo)
{
if (!ScraperStorage.TestForRelatedContent(lEvent, rctLinkInfo))
if (!DataStorage.TestForRelatedContent(lEvent, rctLinkInfo))
{
ScraperStorage.SetRelatedContent(lEvent, rctLinkInfo);
DataStorage.SetRelatedContent(lEvent, rctLinkInfo);
LogEvent(SkyscraperContextEvent.RelatedContent, String.Format("Program {0}, Event {1} -> {2}", resultProgramNumber, lEvent.EventId, rctLinkInfo.GetIdentifierString()));
}
}
@ -2089,11 +2099,11 @@ namespace skyscraper5.Skyscraper.Scraper
public void OnParticipantDetected(PhysicalAddress pa)
{
int? currentLocation = ScraperStorage.GetCurrentLocationId();
int? currentLocation = DataStorage.GetCurrentLocationId();
if (currentLocation.HasValue)
{
LogEvent(SkyscraperContextEvent.DocsisParticipant, BitConverter.ToString(pa.GetAddressBytes()));
ScraperStorage.StoreDocsisParticipant(pa, currentLocation.Value);
DataStorage.StoreDocsisParticipant(pa, currentLocation.Value);
}
else
{
@ -2112,16 +2122,16 @@ namespace skyscraper5.Skyscraper.Scraper
if (!mmm.Frequency.HasValue)
return;
int? currentLocation = ScraperStorage.GetCurrentLocationId();
int? currentLocation = DataStorage.GetCurrentLocationId();
if (!currentLocation.HasValue)
{
WarnMissingLocation();
return;
}
if (!ScraperStorage.TestForDocsisUpstreamChannel(mmm.Source, mmm.Frequency.Value,currentLocation.Value))
if (!DataStorage.TestForDocsisUpstreamChannel(mmm.Source, mmm.Frequency.Value,currentLocation.Value))
{
ScraperStorage.StoreDocsisUpstreamChannel(mmm, currentLocation.Value);
DataStorage.StoreDocsisUpstreamChannel(mmm, currentLocation.Value);
LogEvent(SkyscraperContextEvent.DocsisUpstreamChannel, String.Format("{0} -> {1}", mmm.Source.ToString(), mmm.Frequency.Value));
}
}
@ -2133,30 +2143,30 @@ namespace skyscraper5.Skyscraper.Scraper
if (!downstreamActiveChannel.Frequency.HasValue)
return;
int? currentLocation = ScraperStorage.GetCurrentLocationId();
int? currentLocation = DataStorage.GetCurrentLocationId();
if (!currentLocation.HasValue)
{
WarnMissingLocation();
return;
}
if (!ScraperStorage.TestForDocsisDownstreamChannel(physicalAddress, downstreamActiveChannel,currentLocation.Value))
if (!DataStorage.TestForDocsisDownstreamChannel(physicalAddress, downstreamActiveChannel,currentLocation.Value))
{
ScraperStorage.StoreDocsisDownstreamChannel(physicalAddress, downstreamActiveChannel,currentLocation.Value);
DataStorage.StoreDocsisDownstreamChannel(physicalAddress, downstreamActiveChannel,currentLocation.Value);
LogEvent(SkyscraperContextEvent.DocsisDownstreamChannel, String.Format("{0} -> {1}", physicalAddress.ToString(), downstreamActiveChannel.Frequency.Value));
}
}
public void OnLearnedIpFromMac(PhysicalAddress arpHeaderSenderHardwareAddress, IPAddress arpHeaderSenderProtocolAddress)
{
int? currentLocation = ScraperStorage.GetCurrentLocationId();
int? currentLocation = DataStorage.GetCurrentLocationId();
if (!currentLocation.HasValue)
{
WarnMissingLocation();
return;
}
if (ScraperStorage.SetCmtsIp(arpHeaderSenderHardwareAddress, arpHeaderSenderProtocolAddress))
if (DataStorage.SetCmtsIp(arpHeaderSenderHardwareAddress, arpHeaderSenderProtocolAddress))
{
LogEvent(SkyscraperContextEvent.LearnedCmtsIp,String.Format("{0} -> {1}",arpHeaderSenderHardwareAddress.ToString(),arpHeaderSenderProtocolAddress.ToString()));
}
@ -2170,7 +2180,7 @@ namespace skyscraper5.Skyscraper.Scraper
childSkyscrapers[pid] = new SkyscraperContext[1];
if (childSkyscrapers[pid][0] == null)
{
childSkyscrapers[pid][0] = new SkyscraperContext(new TsContext(), ScraperStorage);
childSkyscrapers[pid][0] = new SkyscraperContext(new TsContext(), DataStorage, ObjectStorage);
childSkyscrapers[pid][0].IsChild = true;
childSkyscrapers[pid][0].ChildName = String.Format("Abertis Tunnel on PID {0:X4}", pid);
}
@ -2213,10 +2223,10 @@ namespace skyscraper5.Skyscraper.Scraper
{
foreach(Cmt.CmtEntry entry in cmt.Entries)
{
if (!ScraperStorage.TestForCmtEntry(interactiveNetworkId,entry))
if (!DataStorage.TestForCmtEntry(interactiveNetworkId,entry))
{
LogEvent(SkyscraperContextEvent.CorrectionMessage, String.Format("Network ID = {0}, Group ID = {1}, Logon ID = {2}", interactiveNetworkId, entry.GroupId, entry.LoginId));
ScraperStorage.InsertCmtEntry(interactiveNetworkId, entry);
DataStorage.InsertCmtEntry(interactiveNetworkId, entry);
}
}
}
@ -2225,10 +2235,10 @@ namespace skyscraper5.Skyscraper.Scraper
{
foreach(Fct.Frame frame in fct.Frames)
{
if (!ScraperStorage.TestForFrameComposition(interactiveNetworkId,frame))
if (!DataStorage.TestForFrameComposition(interactiveNetworkId,frame))
{
LogEvent(SkyscraperContextEvent.FrameComposition, String.Format("Network ID = {0}, Frame = {1}", interactiveNetworkId, frame.FrameId));
ScraperStorage.InsertFctFrame(interactiveNetworkId, frame);
DataStorage.InsertFctFrame(interactiveNetworkId, frame);
}
}
}
@ -2254,10 +2264,10 @@ namespace skyscraper5.Skyscraper.Scraper
{
foreach(_0x4a_LinkageDescriptor linkage in rmt.Linkages)
{
if (!ScraperStorage.TestForRmtLinkage(linkage))
if (!DataStorage.TestForRmtLinkage(linkage))
{
LogEvent(SkyscraperContextEvent.RmtLinkage, String.Format("{0} -> {1},{2}", linkage.InteractiveNetworkId, linkage.OriginalNetworkId, linkage.TransportStreamId));
ScraperStorage.InsertRmtLinkage(linkage);
DataStorage.InsertRmtLinkage(linkage);
}
}
}
@ -2265,10 +2275,10 @@ namespace skyscraper5.Skyscraper.Scraper
{
foreach(Rmt.TransportStream transportStream in rmt.TransportStreams)
{
if (!ScraperStorage.TestForRmtTransportStream(rmt.NetworkId, transportStream))
if (!DataStorage.TestForRmtTransportStream(rmt.NetworkId, transportStream))
{
LogEvent(SkyscraperContextEvent.RmtTransportStream, String.Format("{0} -> {1},{2}", rmt.NetworkId, transportStream.OriginalNetworkId, transportStream.TransportStreamId));
ScraperStorage.InsertRmtTransportStream(rmt.NetworkId, transportStream);
DataStorage.InsertRmtTransportStream(rmt.NetworkId, transportStream);
}
}
}
@ -2278,10 +2288,10 @@ namespace skyscraper5.Skyscraper.Scraper
{
foreach (Spt.Satellite satellite in spt.Satellites)
{
if (!ScraperStorage.TestForSatellitePosition(interactiveNetworkId,satellite))
if (!DataStorage.TestForSatellitePosition(interactiveNetworkId,satellite))
{
LogEvent(SkyscraperContextEvent.SatellitePosition, String.Format("NID = {0}, Satellite ID = {1}", interactiveNetworkId, satellite.Id));
ScraperStorage.StoreSatellitePosition(interactiveNetworkId, satellite);
DataStorage.StoreSatellitePosition(interactiveNetworkId, satellite);
}
}
}
@ -2290,10 +2300,10 @@ namespace skyscraper5.Skyscraper.Scraper
{
foreach(Sct.Superframe superframe in sct.Superframes)
{
if (!ScraperStorage.TestForSuperframeComposition(interactiveNetworkId,superframe))
if (!DataStorage.TestForSuperframeComposition(interactiveNetworkId,superframe))
{
LogEvent(SkyscraperContextEvent.SuperframeComposition, String.Format("Network ID = {0}, Superframe ID = {1}", interactiveNetworkId, superframe.SuperframeId));
ScraperStorage.StoreSuperframeComposition(interactiveNetworkId, superframe);
DataStorage.StoreSuperframeComposition(interactiveNetworkId, superframe);
}
}
}
@ -2304,10 +2314,10 @@ namespace skyscraper5.Skyscraper.Scraper
{
foreach (Tbtp.TbtpFrame.BtpEntity btp in frame.BTP)
{
if (ScraperStorage.TestForTerminalBurstTimePlan(interactiveNetworkId,tbtp.GroupId,btp.LogonId))
if (DataStorage.TestForTerminalBurstTimePlan(interactiveNetworkId,tbtp.GroupId,btp.LogonId))
{
LogEvent(SkyscraperContextEvent.TerminalBurstTimePlan, String.Format("Network ID = {0}, Group ID = {1}, Logon ID = {2}", interactiveNetworkId, tbtp.GroupId, btp.LogonId));
ScraperStorage.StoreTerminalBurstTimePlan(interactiveNetworkId, tbtp.GroupId, tbtp.SuperframeCount, frame.FrameNumber, btp);
DataStorage.StoreTerminalBurstTimePlan(interactiveNetworkId, tbtp.GroupId, tbtp.SuperframeCount, frame.FrameNumber, btp);
}
}
}
@ -2320,12 +2330,12 @@ namespace skyscraper5.Skyscraper.Scraper
public void OnCorrectionMessage(PhysicalAddress mac, _0xa1_CorrectionMessageDescriptor cmd)
{
if (!ScraperStorage.TestForTim(mac))
if (!DataStorage.TestForTim(mac))
{
LogEvent(SkyscraperContextEvent.Tim, String.Format("for participant {0}", mac.ToString()));
ScraperStorage.CreateTim(mac);
DataStorage.CreateTim(mac);
}
if (ScraperStorage.CorrectTim(mac, cmd))
if (DataStorage.CorrectTim(mac, cmd))
{
LogEvent(SkyscraperContextEvent.TimCorrection, String.Format("for participant {0}", mac.ToString()));
}
@ -2333,12 +2343,12 @@ namespace skyscraper5.Skyscraper.Scraper
public void OnContentionControl(PhysicalAddress mac, _0xab_ContentionControlDescriptor ccdNew)
{
if (!ScraperStorage.TestForTim(mac))
if (!DataStorage.TestForTim(mac))
{
LogEvent(SkyscraperContextEvent.Tim, String.Format("for participant {0}", mac.ToString()));
ScraperStorage.CreateTim(mac);
DataStorage.CreateTim(mac);
}
if (ScraperStorage.ContentionTim(mac,ccdNew))
if (DataStorage.ContentionTim(mac,ccdNew))
{
LogEvent(SkyscraperContextEvent.TimContentionControl, String.Format("for participant {0}", mac.ToString()));
}
@ -2346,12 +2356,12 @@ namespace skyscraper5.Skyscraper.Scraper
public void OnCorrectionControl(PhysicalAddress mac, _0xac_CorrectionControlDescriptor descriptor)
{
if (!ScraperStorage.TestForTim(mac))
if (!DataStorage.TestForTim(mac))
{
LogEvent(SkyscraperContextEvent.Tim, String.Format("for participant {0}", mac.ToString()));
ScraperStorage.CreateTim(mac);
DataStorage.CreateTim(mac);
}
if (ScraperStorage.CorrectionControlTim(mac,descriptor))
if (DataStorage.CorrectionControlTim(mac,descriptor))
{
LogEvent(SkyscraperContextEvent.TimCorrectionControl, String.Format("for participant {0}", mac.ToString()));
}
@ -2362,12 +2372,12 @@ namespace skyscraper5.Skyscraper.Scraper
{
if (currentTimeForTim == null)
return;
if (!ScraperStorage.TestForTim(mac))
if (!DataStorage.TestForTim(mac))
{
LogEvent(SkyscraperContextEvent.Tim, String.Format("for participant {0}", mac.ToString()));
ScraperStorage.CreateTim(mac);
DataStorage.CreateTim(mac);
}
if (ScraperStorage.NetworkLayerInfoTim(mac,nlid,currentTimeForTim.Value))
if (DataStorage.NetworkLayerInfoTim(mac,nlid,currentTimeForTim.Value))
{
if (networkLayerInfos == null)
networkLayerInfos = new List<PhysicalAddress>();
@ -2381,22 +2391,22 @@ namespace skyscraper5.Skyscraper.Scraper
void InteractionChannelHandler.OnTransmissionModeSupport(ushort interactiveNetworkId, Tmst tmst)
{
byte[] knownTmst = ScraperStorage.GetTmst(interactiveNetworkId);
byte[] knownTmst = DataStorage.GetTmst(interactiveNetworkId);
if (knownTmst == null)
{
LogEvent(SkyscraperContextEvent.TransmissionModeSupport, String.Format("Network ID = {0}, Modes = {1}", interactiveNetworkId, BitConverter.ToString(tmst.Modes)));
ScraperStorage.InsertTmst(interactiveNetworkId, tmst.Modes);
DataStorage.InsertTmst(interactiveNetworkId, tmst.Modes);
}
else if (Array.Equals(knownTmst,tmst.Modes))
{
LogEvent(SkyscraperContextEvent.TransmissionModeUpdate,String.Format("Network ID = {0}, Old Modes = {2}, New Modes = {1}", interactiveNetworkId, BitConverter.ToString(tmst.Modes), BitConverter.ToString(knownTmst)));
ScraperStorage.UpdateTmst(interactiveNetworkId, tmst.Modes);
DataStorage.UpdateTmst(interactiveNetworkId, tmst.Modes);
}
}
public int GetRmtTransmissionStandard(ushort networkId)
{
return ScraperStorage.GetRmtTransmissionStandard(networkId);
return DataStorage.GetRmtTransmissionStandard(networkId);
}
public void AutodetectionRuleOut(int pid, Contestant contestant, ProgramContext programContext)
@ -2406,10 +2416,10 @@ namespace skyscraper5.Skyscraper.Scraper
void SgtEventHandler.AnnounceSgtList(SgtList list)
{
if (!ScraperStorage.TestForSgtList(list))
if (!DataStorage.TestForSgtList(list))
{
LogEvent(SkyscraperContextEvent.SgtList, String.Format("List #{0} ({1})", list.ServiceListId, list.GetName()));
ScraperStorage.InsertSgtList(list);
DataStorage.InsertSgtList(list);
}
}
@ -2420,16 +2430,17 @@ namespace skyscraper5.Skyscraper.Scraper
void SgtEventHandler.OnSgtService(SgtService child)
{
if (!ScraperStorage.TestForSgtService(child))
if (!DataStorage.TestForSgtService(child))
{
LogEvent(SkyscraperContextEvent.SgtService, String.Format("LCN #{0} in List #{1} ({2})", child.Lcn, child.ServiceListId, child.GetName()));
ScraperStorage.InsertSgtService(child);
DataStorage.InsertSgtService(child);
}
}
public void ProcessVirtualFilesystem(IFilesystem vfs, ProgramMappingStream programMappingStream)
{
yo3explorerToSkyscraperContextBridge context = new yo3explorerToSkyscraperContextBridge();
context.DataStorage = DataStorage;
if (!currentTime.HasValue)
return;
context.CurrentTime = currentTime.Value;
@ -2437,7 +2448,6 @@ namespace skyscraper5.Skyscraper.Scraper
context.OriginalNetworkId = CurrentNetworkId;
context.TransportStreamId = CurrentTransportStreamId;
context.PID = programMappingStream.ElementaryPid;
context.DataStorage = ScraperStorage;
yo3explorerState state = yo3explorerState.GetInstance();
@ -2455,7 +2465,7 @@ namespace skyscraper5.Skyscraper.Scraper
string extension = Path.GetExtension(listener.FileAssociation.ContentLocation).ToLowerInvariant();
if (!DvbNipUtilities.IsContinuousFileType(extension))
LogEvent(SkyscraperContextEvent.FluteFileArrival, listener.FileAssociation.ContentLocation);
ScraperStorage.DvbNipFileArrival(carrier, listener);
ObjectStorage.DvbNipFileArrival(carrier, listener);
}
public void OnMulticastGatewayConfiguration(NipActualCarrierInformation carrier, MulticastGatewayConfigurationType multicastGatewayConfiguration)
@ -2464,10 +2474,10 @@ namespace skyscraper5.Skyscraper.Scraper
{
foreach (MulticastSessionType multicastSession in multicastGatewayConfiguration.MulticastSession)
{
if (!ScraperStorage.DvbNipTestForMulticastSession(multicastSession))
if (!DataStorage.DvbNipTestForMulticastSession(multicastSession))
{
LogEvent(SkyscraperContextEvent.DvbNipMulticastSession, multicastSession.serviceIdentifier);
ScraperStorage.DvbNipInsertMulticastSession(multicastSession);
DataStorage.DvbNipInsertMulticastSession(multicastSession);
}
}
}
@ -2480,13 +2490,13 @@ namespace skyscraper5.Skyscraper.Scraper
continue;
MulticastEndpointAddressType endpointAddress = multicastGatewayConfigurationTransportSession.EndpointAddress[0];
if (!ScraperStorage.DvbNipTestForMulticastGatewayConfigurationTransportSession(carrier, endpointAddress))
if (!DataStorage.DvbNipTestForMulticastGatewayConfigurationTransportSession(carrier, endpointAddress))
{
string name = String.Format("{0} -> {1}:{2}, TSI = {3}", endpointAddress.NetworkSourceAddress,
endpointAddress.NetworkDestinationGroupAddress, endpointAddress.TransportDestinationPort,
endpointAddress.MediaTransportSessionIdentifier);
LogEvent(SkyscraperContextEvent.DvbNipMulticastGatewayConfigurationTransportSession, name);
ScraperStorage.DvbNipInsertMulticastGatewayConfigurationTransportSession(carrier, endpointAddress);
DataStorage.DvbNipInsertMulticastGatewayConfigurationTransportSession(carrier, endpointAddress);
}
}
}
@ -2500,9 +2510,9 @@ namespace skyscraper5.Skyscraper.Scraper
public void OnNipCarrierDetected(NipActualCarrierInformation currentCarrierInformation)
{
LogEvent(SkyscraperContextEvent.NipCarrierDetected, String.Format("{0}", currentCarrierInformation.NipStreamProviderName));
if (!ScraperStorage.DvbNipTestForCarrier(currentCarrierInformation))
if (!DataStorage.DvbNipTestForCarrier(currentCarrierInformation))
{
ScraperStorage.DvbNipInsertCarrier(currentCarrierInformation);
DataStorage.DvbNipInsertCarrier(currentCarrierInformation);
}
}
@ -2511,7 +2521,7 @@ namespace skyscraper5.Skyscraper.Scraper
if (announcedFileContentLocation.StartsWith("urn:dvb"))
return true;
return !ScraperStorage.DvbNipTestForFile(announcedFileContentLocation);
return !ObjectStorage.DvbNipTestForFile(announcedFileContentLocation);
}
public void OnPrivateDataSignallingManifest(NipActualCarrierInformation currentCarrierInformation, PrivateDataSignallingManifestType privateDataSignallingManifest)
@ -2521,7 +2531,7 @@ namespace skyscraper5.Skyscraper.Scraper
privateDataProvider.privateDataProviderID.FlipEndian();
uint privateDataSpecifier = BitConverter.ToUInt32(privateDataProvider.privateDataProviderID);
List<string> privateDataSessions = privateDataProvider.PrivateDataSession.SelectMany(x => x.TagRef).ToList();
bool added = ScraperStorage.DvbNipPrivateDataSpecifier(currentCarrierInformation, privateDataSignallingManifest.VersionUpdate, privateDataSpecifier, privateDataSessions);
bool added = DataStorage.DvbNipPrivateDataSpecifier(currentCarrierInformation, privateDataSignallingManifest.VersionUpdate, privateDataSpecifier, privateDataSessions);
if (added)
{
LogEvent(SkyscraperContextEvent.NipPrivateDataSpecifier, String.Format("{0} -> {1}", currentCarrierInformation.NipStreamProviderName, privateDataSpecifier));
@ -2533,7 +2543,7 @@ namespace skyscraper5.Skyscraper.Scraper
{
long sourceHash = DvbIUtils.GetSourceHash(ServiceListEntryPointSource.DvbNip, currentCarrierInformation.NipNetworkId, currentCarrierInformation.NipCarrierId, currentCarrierInformation.NipLinkId);
serviceListNotifier.SetSourceHash(sourceHash);
DvbIDataStorage dataStorage = ScraperStorage;
DvbIDataStorage dataStorage = DataStorage;
if (dataStorage.TestForDvbiServiceListEntryPoints(sourceHash))
{
@ -2585,7 +2595,7 @@ namespace skyscraper5.Skyscraper.Scraper
ServiceListType serviceList)
{
List<DvbIService> services = DvbIUtils.FlattenServiceList(serviceList).ToList();
DvbIDataStorage dataStorage = ScraperStorage;
DvbIDataStorage dataStorage = DataStorage;
foreach (DvbIService service in services)
{
if (dataStorage.TestForDvbiService(service.Id))
@ -2623,10 +2633,10 @@ namespace skyscraper5.Skyscraper.Scraper
foreach (BroadcastNetworkType network in broadcastNetworks)
{
if (!ScraperStorage.DvbNipTestForNetwork(network))
if (!DataStorage.DvbNipTestForNetwork(network))
{
LogEvent(SkyscraperContextEvent.DvbNipNetwork, network.NetworkName);
ScraperStorage.DvbNipInsertNetwork(network);
DataStorage.DvbNipInsertNetwork(network);
}
}
}
@ -2635,13 +2645,13 @@ namespace skyscraper5.Skyscraper.Scraper
{
foreach (BroadcastMediaStreamType broadcastMediaStreamType in serviceInformationFile.BroadcastMediaStream)
{
if (!ScraperStorage.DvbNipTestForService(broadcastMediaStreamType))
if (!DataStorage.DvbNipTestForService(broadcastMediaStreamType))
{
string id = String.Format("{0},{1},{2},{3}", broadcastMediaStreamType.NIPNetworkID,
broadcastMediaStreamType.NIPCarrierID, broadcastMediaStreamType.NIPLinkID,
broadcastMediaStreamType.NIPServiceID);
LogEvent(SkyscraperContextEvent.DvbNipService, id);
ScraperStorage.DvbNipInsertService(broadcastMediaStreamType);
DataStorage.DvbNipInsertService(broadcastMediaStreamType);
}
}
}

View File

@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using skyscraper5.Mpeg2;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Skyscraper.Scraper
{
@ -15,10 +16,10 @@ namespace skyscraper5.Skyscraper.Scraper
}
public static ISkyscraperContext CreateSkyscraper(IScraperStroage storage)
public static ISkyscraperContext CreateSkyscraper(DataStorage dataStorage,ObjectStorage objectStorage)
{
TsContext tsContext = new TsContext();
SkyscraperContext result = new SkyscraperContext(tsContext, storage);
SkyscraperContext result = new SkyscraperContext(tsContext, dataStorage,objectStorage);
return result;
}
}

View File

@ -5,14 +5,13 @@ using skyscraper5.Dvb.Descriptors;
using skyscraper5.Dvb.Psi.Model;
using skyscraper5.Dvb.SystemSoftwareUpdate.Model;
using skyscraper5.Dvb.TvAnytime;
using skyscraper5.Mhp;
using skyscraper5.Mhp.Si;
using skyscraper5.Mhp.Si.Model;
using skyscraper5.Mpeg2.Descriptors;
using skyscraper5.Mpeg2.Psi.Model;
using skyscraper5.Rds.Messages;
using skyscraper5.Scte35;
using skyscraper5.Scte35.Descriptors;
using skyscraper5.Skyscraper;
using skyscraper5.Skyscraper.Equipment;
using skyscraper5.Skyscraper.Gps;
using skyscraper5.Skyscraper.Headless;
@ -26,19 +25,13 @@ using skyscraper5.Teletext;
using skyscraper8.DvbI;
using skyscraper8.DvbNip;
using skyscraper8.Ses;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using Platform = skyscraper5.Dvb.SystemSoftwareUpdate.Model.Platform;
namespace skyscraper5.Skyscraper.Scraper.Storage.Split
namespace skyscraper8.Skyscraper.Scraper.Storage
{
public interface DataStorage : IDbBlindscanJobStorage, IDnsDataSource
public interface DataStorage : IDbBlindscanJobStorage, IDnsDataSource, DvbIDataStorage
{
bool StoreTeletextPage(int networkId, int transportStreamId, ushort programNumber, TeletextMagazine magazine, DateTime timestamp);
bool TestForNitNetwork(NitNetwork nitNetwork);
@ -116,8 +109,6 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Split
List<DishType> UiDishTypesListAll();
void UiDishTypesAdd(DishType defaultDishType);
object[] GetPluginConnector();
void Ping();
IEnumerable<Tuple<int, int, ProgramMapping>> SelectAllPmt();
SdtService SelectSdtById(int networkId, int tsId, ushort programMappingProgramNumber);
IEnumerable<Tuple<int, int, SdtService>> SelectAllSdt();
@ -195,5 +186,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Split
bool DvbNipTestForCarrier(NipActualCarrierInformation currentCarrierInformation);
void DvbNipInsertCarrier(NipActualCarrierInformation currentCarrierInformation);
}
object[] GetPluginConnector();
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper8.Skyscraper.Scraper.Storage
{
public interface DataStorageFactory
{
DataStorage CreateDataStorage();
}
}

View File

@ -4,18 +4,45 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Skyscraper.IO;
using skyscraper5.Skyscraper.Plugins;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem
{
[SkyscraperPlugin]
[ScrapeStorageFactoryId(1,"Filesystem",false)]
public class FilesystemScraperStorageFactory : IScraperStorageFactory
[StorageId(2)]
[StorageName("Filesystem")]
public class FilesystemScraperStorageFactory : DataStorageFactory, ObjectStorageFactory
{
public string Directory { get; set; }
public IScraperStroage CreateScraperStroage()
public DataStorage CreateDataStorage()
{
return new FilesystemScraperStorage(new DirectoryInfo(Directory));
DirectoryInfo di = new DirectoryInfo(Directory);
if (!di.Exists)
di.EnsureExists();
return new FilesystemStorage(di);
}
public ObjectStorage CreateObjectStorage()
{
DirectoryInfo di = new DirectoryInfo(Directory);
if (!di.Exists)
di.EnsureExists();
return new FilesystemStorage(di);
}
public bool IsEquivalent(DataStorageFactory dataStorageFactory)
{
FilesystemScraperStorageFactory other = dataStorageFactory as FilesystemScraperStorageFactory;
if (other == null)
return false;
if (!other.Directory.Equals(this.Directory))
return false;
return true;
}
}
}

View File

@ -37,17 +37,18 @@ using skyscraper8.DvbI;
using skyscraper8.DvbNip;
using skyscraper8.Ietf.FLUTE;
using skyscraper8.Ses;
using skyscraper8.Skyscraper.Scraper.Storage;
using Platform = skyscraper5.Dvb.SystemSoftwareUpdate.Model.Platform;
namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem
{
internal class FilesystemScraperStorage : IScraperStroage
internal class FilesystemStorage : DataStorage, ObjectStorage
{
private readonly DirectoryInfo rootDirectory;
private readonly string importFilesKnownFilename;
private readonly JsonSerializerSettings jsonSerializerSettings;
public FilesystemScraperStorage(DirectoryInfo rootDirectory)
public FilesystemStorage(DirectoryInfo rootDirectory)
{
EnsureDirectoryExists(rootDirectory);
this.rootDirectory = rootDirectory;

View File

@ -1,200 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.NetworkInformation;
using skyscraper5.Docsis.MacManagement;
using skyscraper5.DsmCc.Descriptors;
using skyscraper5.Dvb.DataBroadcasting.IntModel;
using skyscraper5.Dvb.DataBroadcasting.SkyscraperVfs;
using skyscraper5.Dvb.Descriptors;
using skyscraper5.Dvb.Psi.Model;
using skyscraper5.Dvb.SystemSoftwareUpdate.Model;
using skyscraper5.Dvb.TvAnytime;
using skyscraper5.Mhp;
using skyscraper5.Mhp.Si;
using skyscraper5.Mhp.Si.Model;
using skyscraper5.Mpeg2.Descriptors;
using skyscraper5.Mpeg2.Psi.Model;
using skyscraper5.Rds.Messages;
using skyscraper5.Scte35;
using skyscraper5.Skyscraper.Equipment;
using skyscraper5.Skyscraper.Gps;
using skyscraper5.Skyscraper.Headless;
using skyscraper5.Skyscraper.Scraper.Storage.Split;
using skyscraper5.Skyscraper.Scraper.Storage.Utilities;
using skyscraper5.src.InteractionChannel.Model;
using skyscraper5.src.InteractionChannel.Model.Descriptors;
using skyscraper5.src.Skyscraper.FrequencyListGenerator;
using skyscraper5.src.Skyscraper.Scraper.Dns;
using skyscraper5.Teletext;
using skyscraper8.DvbI;
using skyscraper8.DvbNip;
using skyscraper8.Ietf.FLUTE;
using skyscraper8.Ses;
using Platform = skyscraper5.Dvb.SystemSoftwareUpdate.Model.Platform;
namespace skyscraper5.Skyscraper.Scraper.Storage
{
public interface IScraperStroage : DataStorage, ObjectStorage, IDbBlindscanJobStorage, IDnsDataSource, DvbIDataStorage
{
bool TestForNitNetwork(NitNetwork nitNetwork);
void StoreNitNetwork(NitNetwork nitNetwork);
bool UpdateNitNetwork(NitNetwork nitNetwork);
bool TestForNitTransportStream(ushort networkId, NitTransportStream transportStream);
void StoreNitTransportStream(ushort networkId, NitTransportStream transportStream);
bool UpdateNitTransportStream(ushort networkId, NitTransportStream transportStream);
bool StorePatEntry(int currentNetworkId, int currentTransportStreamId, int pmtPid, ushort programId);
bool TestForPmtEvent(int currentNetworkId, int currentTransportStreamId, ProgramMapping result);
bool StorePmtEvent(int currentNetworkId, int currentTransportStreamId, ProgramMapping mapping);
bool StoreTeletextPage(int networkId, int transportStreamId, ushort programNumber, TeletextMagazine magazine, DateTime timestamp);
bool TestForSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService);
bool UpdateSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService);
void StoreSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService);
bool TestForBatBouquet(BatBouquet batBouquet);
bool UpdateBatBouquet(BatBouquet batBouquet);
void StoreBatBouquet(BatBouquet batBouquet);
bool TestForBatTransportStream(ushort batBouquetBouquetId, BatTransportStream child);
bool UpdateBatTransportStream(ushort batBouquetBouquetId, BatTransportStream child);
void StoreBatTransportStream(ushort batBouquetBouquetId, BatTransportStream child);
bool UpdateTimeOffsetTable(int currentNetworkId, int currentTransportStreamId, DateTime utcTime, LocalTimeOffsetDescriptor ltod);
bool UpdateTimeAndDate(int currentNetworkId, int currentTransportStreamId, DateTime utcTime);
bool StoreEitEvent(EitEvent eitEvent);
bool TestForAitApplication(ApplicationIdentifier aitApplicationApplicationIdentifier);
void StoreAitApplication(AitApplication aitApplication);
bool ObjectCarouselFileArrival(VfsFile vfsFile, int transportStreamId, int networkId);
bool TestForCaSystem(int currentNetworkId, int currentTransportStreamId, int caDescriptorCaPid);
void StoreCaSystem(int currentNetworkId, int currentTransportStreamId, CaDescriptor caDescriptor);
void StoreUpdateNotification(int hashCode, UpdateNotificationGroup common, Compatibility compatibility, Platform platform);
void DataCarouselModuleArrival(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleModuleId, byte moduleModuleVersion, Stream result);
bool TestForKnownRdsData(int currentNetworkId, int currentTransportStreamId, int programNumber);
void EnableRdsCollection(int currentNetworkId, int currentTransportStreamId, int programNumber);
bool UpdateRdsProgrammeServiceName(int currentNetworkId, int currentTransportStreamId, int programNumber, string programmeService2);
bool UpdateRdsRadioText(int currentNetworkId, int currentTransportStreamId, int programNumber, string text);
bool UpdateRdsPty(int currentNetworkId, int currentTransportStreamId, int programNumber, PTY.ProgrammeTypeCodes pty);
bool MarkAsRdsTrafficInformationProgramme(int currentNetworkId, int currentTransportStreamId, int programNumber);
bool TestForScte35SpliceInsert(int currentNetworkId, int currentTransportStreamId, ushort programNumber, SpliceInsert spliceInsert);
void StoreScte35SpliceInsert(int currentNetworkId, int currentTransportStreamId, ushort programNumber, SpliceInsert spliceInsert);
bool IsCompliant(int currentNetworkId, int currentTransportStreamId, string compliance);
void MarkAsCompliant(int currentNetworkId, int currentTransportStreamId, string compliance);
bool SetStationIdentification(int currentNetworkId, int currentTransportStreamId, string stationIdentification);
bool IsDsmCcModuleWanted(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleId, byte moduleVersion);
void StoreDsmCcDoItNowEvent(DateTime value, int currentNetworkId, int currentTransportStreamId, int programNumber, StreamEventDescriptor descriptorListStreamEventDescriptor, int pid);
bool StoreRunningStatus(uint transportStreamId, uint originalNetworkId, uint serviceId, uint eventId, RunningStatus runningStatus, DateTime currentTime);
void SetScte35TimeSignal(int currentNetworkId, int currentTransportStreamId, DateTime currentTime, ushort programNumber, TimeSignal timeSignal);
bool TestForFramegrab(int currentNetworkId, int transportStreamId, ushort mappingProgramNumber, int mappingStreamElementaryPid);
bool TestForIpMacNotification(IpMacNotification notification);
void StoreIpMacNotification(IpMacNotification notification);
bool ImportFileKnown(FileInfo fi);
void ImportMarkFileAsKnown(FileInfo fi, TimeSpan elapsed, int tstype);
DateTime T2MiGetTimestamp(int currentNetworkId, int currentTransportStreamId, int pid);
void T2MiSetTimestamp(int currentNetworkId, int currentTransportStreamId, int pid, DateTime resolveTime);
bool TestForRelatedContent(EitEvent lEvent, RctLinkInfo rctLinkInfo);
void SetRelatedContent(EitEvent lEvent, RctLinkInfo rctLinkInfo);
List<SatellitePosition> UiSatellitesListAll();
void UiSatellitesAdd(SatellitePosition newPosition);
void UiSatellitesDelete(SatellitePosition satellitePosition);
bool UiTunerTestFor(TunerMetadata tuner);
void UiTunerUpdate(TunerMetadata tuner);
void UiTunerInsert(TunerMetadata tuner);
void UiTunerGetConfiguration(TunerMetadata foundTuner);
void StoreFramegrab(int currentNetworkId, int transportStreamId, ushort mappingProgramNumber, ushort mappingProgramNumber1, byte[] imageData);
bool TestForDocsisUpstreamChannel(PhysicalAddress mmmSource, uint mmmFrequency, int currentLocation);
void StoreDocsisUpstreamChannel(UpstreamChannelDescriptor mmm, int currentLocation);
bool TestForDocsisDownstreamChannel(PhysicalAddress physicalAddress, MacDomainDescriptor.DownstreamActiveChannel downstreamActiveChannel, int currentLocation);
void StoreDocsisDownstreamChannel(PhysicalAddress physicalAddress, MacDomainDescriptor.DownstreamActiveChannel downstreamActiveChannel, int currentLocation);
bool SetCmtsIp(PhysicalAddress arpHeaderSenderHardwareAddress, IPAddress arpHeaderSenderProtocolAddress);
bool IsDsmCcModuleBlacklisted(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleId, byte moduleVersion);
int? GetCurrentLocationId();
void StoreDocsisParticipant(PhysicalAddress pa, int currentLocation);
HeadlessJob GetQueuedJob();
void SetQueuedJobComplete(HeadlessJob headlessJob);
void WaitForCompletion();
/// <summary>
/// Tells the underlaying storage which UI Version is used.
/// 1 -> deprecated and buggy. Didn't know anything about dish types and LNB types
/// 2 -> current
/// </summary>
/// <param name="v">The underlaying UI Version to assume</param>
void UiSetVersion(int v);
bool T2MiTestForTransmitter(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier);
void T2MiRememberTransmitter(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier);
void T2MiSetTransmitterTimeOffset(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier, ushort timeOffset);
List<LnbType> UiLnbTypesListAll();
void UiLnbTypesAdd(LnbType defaultLnbType);
List<DishType> UiDishTypesListAll();
void UiDishTypesAdd(DishType defaultDishType);
object[] GetPluginConnector();
/// <summary>
/// Checks whether the storage engine is working properly.
/// </summary>
void Ping();
IEnumerable<Tuple<int, int, ProgramMapping>> SelectAllPmt();
SdtService SelectSdtById(int networkId, int tsId, ushort programMappingProgramNumber);
IEnumerable<Tuple<int, int, SdtService>> SelectAllSdt();
void BeamsDisableAll();
void BeamsEnable(int id, float satpos, string name, DateTime processTimestamp);
void BeamFootprintStore(int databasePointerId, DateTime databasePointerBeamsProcessTimestamp, string name, string getPolygonString, string id);
bool TestForBeamFootprint(int databasePointerId, DateTime databasePointerBeamsProcessTimestamp, string name, string id);
void BeamsDisableSpecific(int databasePointerId, float databasePointerSatpos, string databasePointerName, DateTime databasePointerBeamsProcessTimestamp);
IEnumerable<SatelliteBeam> BeamsSelectEnabled();
List<SatelliteBeamFootprint> BeamsSelectFootprints(int satelliteBeamId, DateTime satelliteBeamProcessTimestamp);
void FailDsmCcDownload(DatabaseKeyDsmCcModule key, double value);
IReadOnlyList<string> ListImportFileByTag1(int tag1);
bool TestForTerminalBurstTimePlan(ushort interactiveNetworkId, uint groupId, uint logonId);
void StoreTerminalBurstTimePlan(ushort interactiveNetworkId, uint gtoupId, uint superframeCount, uint frameNumber, Tbtp.TbtpFrame.BtpEntity btp);
bool TestForCmtEntry(ushort interactiveNetworkId, Cmt.CmtEntry entry);
void InsertCmtEntry(ushort interactiveNetworkId, Cmt.CmtEntry entry);
/// <summary>
/// Returns the Transmission Standard for an Interaction channel.
/// </summary>
/// <remarks>Make sure this returns 0 if you don't have the necessary data to determine the Transmission Standard.</remarks>
/// <param name="networkId">The network id of the Interaction channel in question.</param>
/// <returns>The Transmission Standard for an Interaction channel.</returns>
int GetRmtTransmissionStandard(ushort networkId);
byte[] GetTmst(ushort interactiveNetworkId);
void InsertTmst(ushort interactiveNetworkId, byte[] modes);
void UpdateTmst(ushort interactiveNetworkId, byte[] modes);
bool TestForRmtLinkage(_0x4a_LinkageDescriptor linkage);
void InsertRmtLinkage(_0x4a_LinkageDescriptor linkage);
bool TestForRmtTransportStream(ushort networkId, Rmt.TransportStream transportStream);
void InsertRmtTransportStream(ushort networkId, Rmt.TransportStream transportStream);
bool TestForSuperframeComposition(ushort interactiveNetworkId, Sct.Superframe superframe);
void StoreSuperframeComposition(ushort interactiveNetworkId, Sct.Superframe superframe);
bool TestForFrameComposition(ushort interactiveNetworkId, Fct.Frame frame);
void InsertFctFrame(ushort interactiveNetworkId, Fct.Frame frame);
bool TestForSatellitePosition(ushort interactiveNetworkId, Spt.Satellite satellite);
void StoreSatellitePosition(ushort interactiveNetworkId, Spt.Satellite satellite);
bool TestForTim(PhysicalAddress mac);
void CreateTim(PhysicalAddress mac);
bool CorrectTim(PhysicalAddress mac, _0xa1_CorrectionMessageDescriptor cmd);
bool ContentionTim(PhysicalAddress mac, _0xab_ContentionControlDescriptor ccdNew);
bool CorrectionControlTim(PhysicalAddress mac, _0xac_CorrectionControlDescriptor descriptor);
bool NetworkLayerInfoTim(PhysicalAddress mac, _0xa0_NetworkLayerInfoDescriptor nlid, DateTime timestamp);
IEnumerable<DbBlindscanJob> GetDbBlindscanJobs();
bool TestForSgtList(SgtList list);
void InsertSgtList(SgtList list);
bool TestForSgtService(SgtService child);
void InsertSgtService(SgtService child);
bool DvbNipTestForFile(string announcedFileContentLocation);
void DvbNipFileArrival(NipActualCarrierInformation carrier, FluteListener listener);
bool DvbNipPrivateDataSpecifier(NipActualCarrierInformation currentCarrierInformation, DateTime versionUpdate, uint privateDataSpecifier, List<string> privateDataSessions);
bool DvbNipTestForNetwork(BroadcastNetworkType network);
void DvbNipInsertNetwork(BroadcastNetworkType network);
bool DvbNipTestForService(BroadcastMediaStreamType broadcastMediaStreamType);
void DvbNipInsertService(BroadcastMediaStreamType broadcastMediaStreamType);
bool DvbNipTestForMulticastSession(MulticastSessionType multicastSession);
void DvbNipInsertMulticastSession(MulticastSessionType multicastSession);
bool DvbNipTestForMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, MulticastEndpointAddressType multicastEndpointAddressType);
void DvbNipInsertMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, MulticastEndpointAddressType multicastGatewayConfigurationTransportSession);
bool DvbNipTestForCarrier(NipActualCarrierInformation currentCarrierInformation);
void DvbNipInsertCarrier(NipActualCarrierInformation currentCarrierInformation);
}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper5.Skyscraper.Scraper.Storage
{
public interface IScraperStorageFactory
{
IScraperStroage CreateScraperStroage();
}
}

View File

@ -37,12 +37,13 @@ using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using skyscraper8.Ietf.FLUTE;
using skyscraper8.Skyscraper.Scraper.Storage;
using skyscraper8.Skyscraper.Scraper.Storage.Utilities;
using Platform = skyscraper5.Dvb.SystemSoftwareUpdate.Model.Platform;
namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory
{
internal class InMemoryScraperStorage : IScraperStroage
internal class InMemoryScraperStorage : DataStorage
{
public InMemoryScraperStorage()
{
@ -413,18 +414,6 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory
aitApplicationCoordinates.Add(aitApplicationCoordinate);
}
public bool ObjectCarouselFileArrival(VfsFile vfsFile, int transportStreamId, int networkId)
{
string outPath = String.Format("{0}{1}{2}{1}{3}{4}", networkId, Path.DirectorySeparatorChar,
transportStreamId, vfsFile.SourcePid, vfsFile.ToString());
FileInfo outFileInfo = new FileInfo(outPath);
if (outFileInfo.Exists)
return false;
EnsureDirectoryExists(outFileInfo.Directory);
File.WriteAllBytes(outFileInfo.FullName, vfsFile.FileContent);
return true;
}
public bool TestForCaSystem(int currentNetworkId, int currentTransportStreamId, int caDescriptorCaPid)
{
InMemoryCaSystem find = caSystems.Find(x =>
@ -450,27 +439,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory
updateHashes.Add(hashCode);
updates.Add(new Tuple<int, Compatibility, Platform>(hashCode, compatibility, platform));
}
public void DataCarouselModuleArrival(int currentNetworkId, int currentTransportStreamId, int elementaryPid,
ushort moduleModuleId, byte moduleModuleVersion, Stream result)
{
string outPath = String.Format("{0}{1}{2}{1}{3}{1}{4}_{5}.bin", currentNetworkId,
Path.DirectorySeparatorChar, currentTransportStreamId, elementaryPid, moduleModuleId,
moduleModuleVersion);
FileInfo fi = new FileInfo(outPath);
if (fi.Exists)
return;
EnsureDirectoryExists(fi.Directory);
FileStream fileStream = fi.OpenWrite();
result.CopyTo(fileStream);
fileStream.Close();
fileStream.Dispose();
DsmCcModuleXmlMemory.GetInstance().MarkComplete(currentNetworkId, currentTransportStreamId, elementaryPid,
moduleModuleId, moduleModuleVersion);
}
public bool TestForKnownRdsData(int currentNetworkId, int currentTransportStreamId, int programNumber)
{
if (rdsDataPresent == null)
@ -602,14 +571,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory
stationIdentification[currentNetworkId][currentTransportStreamId] = newSi;
return result;
}
public bool IsDsmCcModuleWanted(int currentNetworkId, int currentTransportStreamId, int elementaryPid,
ushort moduleId, byte moduleVersion)
{
return DsmCcModuleXmlMemory.GetInstance().IsWanted(currentNetworkId, currentTransportStreamId,
elementaryPid, moduleId, moduleVersion);
}
public void StoreDsmCcDoItNowEvent(DateTime timestamp, int currentNetworkId, int currentTransportStreamId,
int programNumber, StreamEventDescriptor descriptorListStreamEventDescriptor, int pid)
{
@ -629,23 +591,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory
{
}
public bool TestForFramegrab(int currentNetworkId, int transportStreamId, ushort mappingProgramNumber,
int mappingStreamElementaryPid)
{
FileInfo fi = new FileInfo(Path.Combine("screenshots", currentNetworkId.ToString(),
transportStreamId.ToString(), String.Format("{0}.jpg", mappingProgramNumber)));
return fi.Exists;
}
public void StoreFramegrab(int currentNetworkId, int transportStreamId, ushort mappingProgramNumber, ushort pid,
byte[] imageData)
{
FileInfo fi = new FileInfo(Path.Combine("screenshots", currentNetworkId.ToString(),
transportStreamId.ToString(), String.Format("{0}.jpg", mappingProgramNumber)));
fi.Directory.EnsureExists();
File.WriteAllBytes(fi.FullName, imageData);
}
private HashSet<DocsisUpstreamChannelCoordinate> _docsisUpstreamChannelCoordinates;
@ -1362,29 +1308,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory
sgtServices.Add(child);
}
public bool DvbNipTestForFile(string announcedFileContentLocation)
{
string saneFilename = DvbNipUtilities.MakeFilename(announcedFileContentLocation);
FileInfo fi = new FileInfo(saneFilename);
return fi.Exists;
}
public void DvbNipFileArrival(NipActualCarrierInformation carrier, FluteListener listener)
{
string filename = DvbNipUtilities.MakeFilename(listener.FileAssociation.ContentLocation);
FileInfo fi = new FileInfo(filename);
fi.Directory.EnsureExists();
FileStream outStream = fi.OpenWrite();
Stream inStream = listener.ToStream();
inStream.CopyTo(outStream);
outStream.Flush(true);
outStream.Close();
outStream.Dispose();
inStream.Close();
inStream.Dispose();
}
private class NipPds
{
public class NipSubPds

View File

@ -4,16 +4,19 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Skyscraper.Plugins;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory
{
[SkyscraperPlugin]
[ScrapeStorageFactoryId(0,"In-Memory",true)]
public class InMemoryScraperStorageFactory : IScraperStorageFactory
[StorageVolatile]
[StorageName("In-Memory")]
[StorageId(1)]
public class InMemoryScraperStorageFactory : DataStorageFactory
{
public IScraperStroage CreateScraperStroage()
public DataStorage CreateDataStorage()
{
return new InMemoryScraperStorage();
return new InMemoryScraperStorage();
}
}
}

View File

@ -9,7 +9,7 @@ using skyscraper5.Teletext;
using skyscraper8.DvbNip;
using skyscraper8.Ietf.FLUTE;
namespace skyscraper5.Skyscraper.Scraper.Storage.Split
namespace skyscraper8.Skyscraper.Scraper.Storage
{
public interface ObjectStorage
{

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper8.Skyscraper.Scraper.Storage
{
public interface ObjectStorageFactory
{
ObjectStorage CreateObjectStorage();
bool IsEquivalent(DataStorageFactory dataStorageFactory);
}
}

View File

@ -1,77 +0,0 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.XPath;
using skyscraper5.Skyscraper.Plugins;
namespace skyscraper5.Skyscraper.Scraper.Storage
{
public sealed class ScraperStorageFactoryConnectionManager
{
private ScraperStorageFactoryConnectionManager()
{
factories = PluginManager.GetInstance().GetScraperStorageFactories();
if (factories.Count == 0)
{
throw new NullReferenceException("We didn't get an ScraperStorages. There's something wrong here.");
}
}
private static ScraperStorageFactoryConnectionManager _instance;
public static ScraperStorageFactoryConnectionManager GetInstance()
{
if (_instance == null)
{
_instance = new ScraperStorageFactoryConnectionManager();
}
return _instance;
}
private ReadOnlyDictionary<ScrapeStorageFactoryIdAttribute, IScraperStorageFactory> factories;
public ReadOnlyCollection<KeyValuePair<ScrapeStorageFactoryIdAttribute, IScraperStorageFactory>> GetKnownFactories()
{
ReadOnlyCollection<KeyValuePair<ScrapeStorageFactoryIdAttribute, IScraperStorageFactory>> readOnlyCollection = factories.ToList().AsReadOnly();
return readOnlyCollection;
}
public static void ConfigureFactoryFromIni(KeyValuePair<ScrapeStorageFactoryIdAttribute, IScraperStorageFactory> bootingStorage, Ini ini)
{
string catName = String.Format("storage{0}", bootingStorage.Key.Id);
PluginManager.GetInstance().AutoconfigureObject(catName, bootingStorage.Value);
}
public IScraperStorageFactory AutoGetDefaultFactory()
{
Ini ini = PluginManager.GetInstance().Ini;
int factoryId = ini.ReadValue("startup", "storage", -1);
if (factoryId == -1)
throw new NoStorageFactoryConfiguredException();
IScraperStorageFactory result = null;
foreach (KeyValuePair<ScrapeStorageFactoryIdAttribute,IScraperStorageFactory> entry in GetKnownFactories())
{
if (factoryId == entry.Key.Id)
{
ConfigureFactoryFromIni(entry, ini);
result = entry.Value;
break;
}
}
if (result == null)
throw new StorageFactoryPluginNotLoadedException();
return result;
}
}
}

View File

@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper5.Skyscraper.Scraper.Storage
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class ScrapeStorageFactoryIdAttribute : Attribute
{
public int Id { get; }
public string DisplayName { get; }
public bool VolatileStorage { get; }
public string TemporaryUUID { get; }
public ScrapeStorageFactoryIdAttribute(int id, string displayName, bool volatileStorage)
{
Id = id;
DisplayName = displayName;
VolatileStorage = volatileStorage;
TemporaryUUID = Guid.NewGuid().ToString();
}
}
}

View File

@ -0,0 +1,129 @@
using log4net;
using skyscraper5.Skyscraper;
using skyscraper5.Skyscraper.Plugins;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Skyscraper.Scraper.Storage;
namespace skyscraper8.Skyscraper.Scraper.Storage
{
internal class StorageConnectionManager
{
private StorageConnectionManager()
{
plugins = PluginManager.GetInstance();
ini = plugins.Ini;
}
private readonly PluginManager plugins;
private static StorageConnectionManager _instance;
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);
private static Type storageNameAttributeType = typeof(StorageNameAttribute);
private readonly Ini ini;
public static StorageConnectionManager GetInstance()
{
if (_instance == null)
_instance = new StorageConnectionManager();
return _instance;
}
public IEnumerable<Tuple<int,bool,string>> GetAllKnownFactoryNames()
{
ReadOnlyDictionary<int, DataStorageFactory> dataStorages = plugins.GetDataStorages();
foreach (KeyValuePair<int, DataStorageFactory> dataStorageFactory in dataStorages)
{
yield return new Tuple<int, bool, string>(dataStorageFactory.Key, true, GetName(dataStorageFactory.Value));
}
ReadOnlyDictionary<int, ObjectStorageFactory> objectStorages = plugins.GetObjectStorages();
foreach (KeyValuePair<int, ObjectStorageFactory> objectStorageFactory in objectStorages)
{
yield return new Tuple<int, bool, string>(objectStorageFactory.Key, false, GetName(objectStorageFactory.Value));
}
}
public string GetName(object o)
{
Type type = o.GetType();
Attribute attribute = type.GetCustomAttribute(storageNameAttributeType);
StorageNameAttribute storageNameAttribute = attribute as StorageNameAttribute;
if (storageNameAttribute == null)
{
logger.WarnFormat("{0} does not have a {1}.", type.Name, storageNameAttributeType.Name);
return type.Name;
}
return storageNameAttribute.Name;
}
public DataStorageFactory GetDefaultDataStorageFactory()
{
int requiredDataStorageId = ini.ReadValue("startup", "dataStorage", -1);
if (requiredDataStorageId == -1)
{
throw new ScraperStorageException("Could not determine the data storage factory from ini file. Configure it using the UI!");
}
string iniCategoryName = String.Format("dataStorage{0}", requiredDataStorageId);
if (!ini.ContainsKey(iniCategoryName))
{
throw new ScraperStorageException("Could not find configuration for the storage factory. Configure it using the UI!");
}
ReadOnlyDictionary<int, DataStorageFactory> dataStorages = plugins.GetDataStorages();
KeyValuePair<int, DataStorageFactory> valuePair = dataStorages.First(x => x.Key == requiredDataStorageId);
if (valuePair.Value == null)
{
throw new ScraperStorageException(String.Format("Storage Factory {0} was not loaded. Reconfigure with the UI!", requiredDataStorageId));
}
string factoryCname = String.Format("dataStorage{0}", requiredDataStorageId);
PluginManager.GetInstance().AutoconfigureObject(factoryCname, valuePair.Value);
return valuePair.Value;
}
public ObjectStorageFactory GetDefaultObjectStorageFactory()
{
int requiredObjectStorageId = ini.ReadValue("startup", "objectStorage", -1);
if (requiredObjectStorageId == -1)
{
throw new ScraperStorageException("Could not determine the object storage factory from ini file. Configure it using the UI!");
}
string iniCategoryName = String.Format("objectStorage{0}", requiredObjectStorageId);
if (!ini.ContainsKey(iniCategoryName))
{
throw new ScraperStorageException("Could not find configuration for the object storage factory. Configure it using the UI!");
}
ReadOnlyDictionary<int, ObjectStorageFactory> dataStorages = plugins.GetObjectStorages();
KeyValuePair<int, ObjectStorageFactory> valuePair = dataStorages.First(x => x.Key == requiredObjectStorageId);
if (valuePair.Value == null)
{
throw new ScraperStorageException(String.Format("Object Storage Factory {0} was not loaded. Reconfigure with the UI!", requiredObjectStorageId));
}
string factoryCname = String.Format("objectStorage{0}", requiredObjectStorageId);
PluginManager.GetInstance().AutoconfigureObject(factoryCname, valuePair.Value);
return valuePair.Value;
}
public static object[] GetPluginConnectors(DataStorage dataStorage, ObjectStorage objectStorage)
{
object[] dataConnector = dataStorage.GetPluginConnector();
object[] objectConnector = objectStorage.GetPluginConnector();
object[] result = new object[dataConnector.Length + objectConnector.Length];
Array.Copy(dataConnector, 0, result, 0, dataConnector.Length);
Array.Copy(objectConnector, 0, result, dataConnector.Length, objectConnector.Length);
return result;
}
}
}

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.Scraper.Storage
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class StorageIdAttribute : Attribute
{
public int Id { get; }
public StorageIdAttribute(int id)
{
Id = id;
}
}
}

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.Scraper.Storage
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class StorageNameAttribute : Attribute
{
public string Name { get; }
public StorageNameAttribute(string name)
{
Name = name;
}
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper8.Skyscraper.Scraper.Storage
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class StorageVolatileAttribute : Attribute
{
public StorageVolatileAttribute()
{
}
}
}

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper8.Skyscraper.Scraper.Storage;
namespace skyscraper8.yo3explorer
{
@ -15,7 +16,7 @@ namespace skyscraper8.yo3explorer
public int? OriginalNetworkId { get; internal set; }
public int? TransportStreamId { get; internal set; }
public int PID { get; internal set; }
public IScraperStroage DataStorage { get; internal set; }
public DataStorage DataStorage { get; set; }
public long GetSourceHash()
{