SGT Lists (not services) work in Postgresql now.
This commit is contained in:
parent
60cf0b4ffe
commit
65f62e82cb
1
.gitignore
vendored
1
.gitignore
vendored
@ -109,3 +109,4 @@ imgui.ini
|
|||||||
/GUIs/skyscraper8.UI.ImGui/bin/Debug/net8.0/skyscraper5.ini
|
/GUIs/skyscraper8.UI.ImGui/bin/Debug/net8.0/skyscraper5.ini
|
||||||
/.vs/skyscraper8/CopilotIndices/17.14.698.11175
|
/.vs/skyscraper8/CopilotIndices/17.14.698.11175
|
||||||
/GUIs/skyscraper8.UI.ImGui/bin/Debug/net8.0
|
/GUIs/skyscraper8.UI.ImGui/bin/Debug/net8.0
|
||||||
|
/.vs/skyscraper8/CopilotIndices/17.14.734.62261
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
using skyscraper5.Skyscraper.Scraper.Storage.Split;
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using NpgsqlTypes;
|
||||||
|
using skyscraper5.Skyscraper.Scraper.Storage.Split;
|
||||||
using skyscraper8.Ses;
|
using skyscraper8.Ses;
|
||||||
|
using skyscraper8.Skyscraper.Scraper.Storage.Utilities;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -10,20 +14,88 @@ namespace skyscraper5.Data.PostgreSql
|
|||||||
{
|
{
|
||||||
public partial class PostgresqlDataStore : DataStorage
|
public partial class PostgresqlDataStore : DataStorage
|
||||||
{
|
{
|
||||||
|
private List<ushort> _existingSgtLists;
|
||||||
|
|
||||||
public bool TestForSgtList(SgtList list)
|
public bool TestForSgtList(SgtList list)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (_existingSgtLists == null)
|
||||||
|
_existingSgtLists = new List<ushort>();
|
||||||
|
|
||||||
|
if (_existingSgtLists.Contains(list.ServiceListId))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
bool result;
|
||||||
|
using (NpgsqlConnection connection = new NpgsqlConnection(connectionStringBuilder.ToString()))
|
||||||
|
{
|
||||||
|
connection.Open();
|
||||||
|
NpgsqlCommand command = connection.CreateCommand();
|
||||||
|
command.CommandText = "SELECT dateadded FROM astra_sgt WHERE slid = @slid";
|
||||||
|
command.Parameters.AddParameter("@slid", NpgsqlDbType.Integer, (int)list.ServiceListId);
|
||||||
|
NpgsqlDataReader npgsqlDataReader = command.ExecuteReader();
|
||||||
|
if (result = npgsqlDataReader.Read())
|
||||||
|
{
|
||||||
|
_existingSgtLists.Add(list.ServiceListId);
|
||||||
|
}
|
||||||
|
npgsqlDataReader.Close();
|
||||||
|
command.Dispose();
|
||||||
|
connection.Close();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InsertSgtList(SgtList list)
|
public void InsertSgtList(SgtList list)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using (NpgsqlConnection connection = new NpgsqlConnection(connectionStringBuilder.ToString()))
|
||||||
|
{
|
||||||
|
connection.Open();
|
||||||
|
NpgsqlCommand command = connection.CreateCommand();
|
||||||
|
command.CommandText = "INSERT INTO astra_sgt VALUES (@slid,DEFAULT,@pds,@names,@cavailabilities)";
|
||||||
|
command.Parameters.AddWithValue("@slid", NpgsqlDbType.Integer, (int)list.ServiceListId);
|
||||||
|
command.Parameters.AddWithValue("@pds", NpgsqlDbType.Bigint, (long)list.PrivateDataSpecifier);
|
||||||
|
command.Parameters.AddWithValue("@names", NpgsqlDbType.Json, JsonConvert.SerializeObject(list.Names));
|
||||||
|
command.Parameters.AddWithValue("@cavailabilities", NpgsqlDbType.Json, JsonConvert.SerializeObject(list.CountryAvailabilities));
|
||||||
|
SetNulls(command);
|
||||||
|
command.ExecuteNonQuery();
|
||||||
|
connection.Close();
|
||||||
|
connection.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_existingSgtLists == null)
|
||||||
|
_existingSgtLists = new List<ushort>();
|
||||||
|
if (!_existingSgtLists.Contains(list.ServiceListId))
|
||||||
|
_existingSgtLists.Add(list.ServiceListId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashSet<DatabaseKeySgtService> _knownSgtServices;
|
||||||
public bool TestForSgtService(SgtService child)
|
public bool TestForSgtService(SgtService child)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (_knownSgtServices == null)
|
||||||
|
_knownSgtServices = new HashSet<DatabaseKeySgtService>();
|
||||||
|
|
||||||
|
DatabaseKeySgtService key = child.GetDatabaseKey();
|
||||||
|
if (_knownSgtServices.Contains(key))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
bool result;
|
||||||
|
using (NpgsqlConnection connection = new NpgsqlConnection(connectionStringBuilder.ToString()))
|
||||||
|
{
|
||||||
|
connection.Open();
|
||||||
|
NpgsqlCommand command = connection.CreateCommand();
|
||||||
|
command.CommandText = "SELECT dateadded FROM astra_sgt_services WHERE slid = @slid AND sid = @sid AND tsid = @tsid AND onid = @onid";
|
||||||
|
command.Parameters.AddWithValue("@slid", NpgsqlDbType.Integer, (int)child.ServiceListId);
|
||||||
|
command.Parameters.AddWithValue("@sid", NpgsqlDbType.Integer, (int)child.ServiceId);
|
||||||
|
command.Parameters.AddWithValue("@tsid", NpgsqlDbType.Integer, (int)child.TransportStreamId);
|
||||||
|
command.Parameters.AddWithValue("@onid", NpgsqlDbType.Integer, (int)child.OriginalNetworkId);
|
||||||
|
NpgsqlDataReader dataReader = command.ExecuteReader();
|
||||||
|
if (result = dataReader.Read())
|
||||||
|
{
|
||||||
|
_knownSgtServices.Add(key);
|
||||||
|
}
|
||||||
|
dataReader.Close();
|
||||||
|
command.Dispose();
|
||||||
|
connection.Close();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InsertSgtService(SgtService child)
|
public void InsertSgtService(SgtService child)
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Npgsql" Version="9.0.3" />
|
<PackageReference Include="Npgsql" Version="9.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using skyscraper5.Dvb.Descriptors;
|
using skyscraper5.Dvb.Descriptors;
|
||||||
using skyscraper8.Ses.Descriptors;
|
using skyscraper8.Ses.Descriptors;
|
||||||
|
using skyscraper8.Skyscraper.Scraper.Storage.Utilities;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -53,5 +54,10 @@ namespace skyscraper8.Ses
|
|||||||
|
|
||||||
return ServiceDescriptor.ServiceName;
|
return ServiceDescriptor.ServiceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DatabaseKeySgtService GetDatabaseKey()
|
||||||
|
{
|
||||||
|
return new DatabaseKeySgtService(ServiceListId, ServiceId, TransportStreamId, OriginalNetworkId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace skyscraper8.Skyscraper.Scraper.Storage.Utilities
|
||||||
|
{
|
||||||
|
public class DatabaseKeySgtService
|
||||||
|
{
|
||||||
|
public DatabaseKeySgtService(ushort serviceListId, ushort serviceId, ushort transportStreamId, ushort originalNetworkId)
|
||||||
|
{
|
||||||
|
ServiceListId = serviceListId;
|
||||||
|
ServiceId = serviceId;
|
||||||
|
TransportStreamId = transportStreamId;
|
||||||
|
OriginalNetworkId = originalNetworkId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ushort ServiceListId { get; }
|
||||||
|
public ushort ServiceId { get; }
|
||||||
|
public ushort TransportStreamId { get; }
|
||||||
|
public ushort OriginalNetworkId { get; }
|
||||||
|
|
||||||
|
public override bool Equals(object? obj)
|
||||||
|
{
|
||||||
|
return obj is DatabaseKeySgtService service &&
|
||||||
|
ServiceListId == service.ServiceListId &&
|
||||||
|
ServiceId == service.ServiceId &&
|
||||||
|
TransportStreamId == service.TransportStreamId &&
|
||||||
|
OriginalNetworkId == service.OriginalNetworkId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return HashCode.Combine(ServiceListId, ServiceId, TransportStreamId, OriginalNetworkId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user