mirror of
https://github.com/PredatH0r/ChanSort.git
synced 2026-05-07 00:06:51 +02:00
- replaced System.Data.SQLite with Microsoft.Data.Sqlite because MS removed the required VC2010 Redist x86 from their website
- updated bunch of other Nuget packages
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -59,11 +61,35 @@
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Data.Sqlite, Version=5.0.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Data.Sqlite.Core.5.0.5\lib\netstandard2.0\Microsoft.Data.Sqlite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.batteries_v2, Version=2.0.4.976, Culture=neutral, PublicKeyToken=8226ea5df37bcae9, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.4\lib\net461\SQLitePCLRaw.batteries_v2.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.core, Version=2.0.4.976, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.core.2.0.4\lib\netstandard2.0\SQLitePCLRaw.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.nativelibrary, Version=2.0.4.976, Culture=neutral, PublicKeyToken=502ed628492ab262, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.bundle_e_sqlite3.2.0.4\lib\net461\SQLitePCLRaw.nativelibrary.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.provider.dynamic_cdecl, Version=2.0.4.976, Culture=neutral, PublicKeyToken=b68184102cba0b3b, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.provider.dynamic_cdecl.2.0.4\lib\netstandard2.0\SQLitePCLRaw.provider.dynamic_cdecl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SQLite, Version=1.0.87.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\DLL\System.Data.SQLite.dll</HintPath>
|
||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
@@ -85,9 +111,11 @@
|
||||
<Compile Include="HisensePlugin.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="ChanSort.Loader.Hisense.ini">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ChanSort.Api\ChanSort.Api.csproj">
|
||||
@@ -112,6 +140,13 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets" Condition="Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SQLitePCLRaw.lib.e_sqlite3.2.0.4\build\net461\SQLitePCLRaw.lib.e_sqlite3.targets'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using ChanSort.Api;
|
||||
using System.Data.SQLite;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using ChanSort.Api;
|
||||
|
||||
namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
{
|
||||
@@ -79,12 +78,12 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
|
||||
#endregion
|
||||
|
||||
private readonly List<ChannelList> channelLists = new List<ChannelList>();
|
||||
private readonly Dictionary<long, Channel> channelsById = new Dictionary<long, Channel>();
|
||||
private readonly List<ChannelList> channelLists = new ();
|
||||
private readonly Dictionary<long, Channel> channelsById = new ();
|
||||
private List<string> tableNames;
|
||||
|
||||
// the fav_1 - fav_4 tables in channel.db of a H50B7700UW has different column names and a primary key/unique constraint which requires specific handling
|
||||
private bool hasCamelCaseFavSchema = false;
|
||||
private bool hasCamelCaseFavSchema;
|
||||
|
||||
#region ctor()
|
||||
|
||||
@@ -145,36 +144,34 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
using (var conn = new SQLiteConnection("Data Source=" + this.FileName))
|
||||
using (var conn = new SqliteConnection("Data Source=" + this.FileName))
|
||||
{
|
||||
conn.Open();
|
||||
using (var cmd = conn.CreateCommand())
|
||||
{
|
||||
this.RepairCorruptedDatabaseImage(cmd);
|
||||
this.LoadTableNames(cmd);
|
||||
using var cmd = conn.CreateCommand();
|
||||
this.RepairCorruptedDatabaseImage(cmd);
|
||||
this.LoadTableNames(cmd);
|
||||
|
||||
if (!tableNames.Contains("svl_1") && !tableNames.Contains("svl_2") && !tableNames.Contains("svl_3"))
|
||||
throw new FileLoadException("File doesn't contain svl_* tables");
|
||||
if (!tableNames.Contains("svl_1") && !tableNames.Contains("svl_2") && !tableNames.Contains("svl_3"))
|
||||
throw new FileLoadException("File doesn't contain svl_* tables");
|
||||
|
||||
this.LoadSatelliteData(cmd);
|
||||
this.LoadTslData(cmd);
|
||||
this.LoadSvlData(cmd);
|
||||
this.LoadFavorites(cmd);
|
||||
}
|
||||
this.LoadSatelliteData(cmd);
|
||||
this.LoadTslData(cmd);
|
||||
this.LoadSvlData(cmd);
|
||||
this.LoadFavorites(cmd);
|
||||
}
|
||||
|
||||
int totalCount = 0;
|
||||
foreach (var list in this.channelLists)
|
||||
totalCount += list.Count;
|
||||
if (totalCount == 0)
|
||||
Api.View.Default.MessageBox(Resources.Load_NoChannelsMsg, Resources.Load_NoChannelsCaption);
|
||||
View.Default.MessageBox(Resources.Load_NoChannelsMsg, Resources.Load_NoChannelsCaption);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RepairCorruptedDatabaseImage()
|
||||
|
||||
private void RepairCorruptedDatabaseImage(SQLiteCommand cmd)
|
||||
private void RepairCorruptedDatabaseImage(SqliteCommand cmd)
|
||||
{
|
||||
cmd.CommandText = "REINDEX";
|
||||
cmd.ExecuteNonQuery();
|
||||
@@ -184,22 +181,20 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
|
||||
#region LoadTableNames()
|
||||
|
||||
private void LoadTableNames(SQLiteCommand cmd)
|
||||
private void LoadTableNames(SqliteCommand cmd)
|
||||
{
|
||||
this.tableNames = new List<string>();
|
||||
cmd.CommandText = "SELECT name FROM sqlite_master WHERE type = 'table' order by name";
|
||||
using (var r = cmd.ExecuteReader())
|
||||
{
|
||||
while (r.Read())
|
||||
tableNames.Add(r.GetString(0));
|
||||
}
|
||||
using var r = cmd.ExecuteReader();
|
||||
while (r.Read())
|
||||
tableNames.Add(r.GetString(0));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LoadSatelliteData()
|
||||
|
||||
private void LoadSatelliteData(SQLiteCommand cmd)
|
||||
private void LoadSatelliteData(SqliteCommand cmd)
|
||||
{
|
||||
var regex = new Regex(@"^satl_\d$");
|
||||
foreach (var tableName in this.tableNames)
|
||||
@@ -207,16 +202,14 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
if (!regex.IsMatch(tableName))
|
||||
continue;
|
||||
cmd.CommandText = "select satl_rec_id, i2_orb_pos, ac_sat_name from " + tableName;
|
||||
using (var r = cmd.ExecuteReader())
|
||||
using var r = cmd.ExecuteReader();
|
||||
while (r.Read())
|
||||
{
|
||||
while (r.Read())
|
||||
{
|
||||
var sat = new Satellite(r.GetInt32(0));
|
||||
var pos = r.GetInt32(1);
|
||||
sat.OrbitalPosition = $"{(decimal) Math.Abs(pos) / 10:n1}{(pos < 0 ? 'W' : 'E')}";
|
||||
sat.Name = r.GetString(2);
|
||||
this.DataRoot.AddSatellite(sat);
|
||||
}
|
||||
var sat = new Satellite(r.GetInt32(0));
|
||||
var pos = r.GetInt32(1);
|
||||
sat.OrbitalPosition = $"{(decimal) Math.Abs(pos) / 10:n1}{(pos < 0 ? 'W' : 'E')}";
|
||||
sat.Name = r.GetString(2);
|
||||
this.DataRoot.AddSatellite(sat);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,7 +218,7 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
|
||||
#region LoadTslData()
|
||||
|
||||
private void LoadTslData(SQLiteCommand cmd)
|
||||
private void LoadTslData(SqliteCommand cmd)
|
||||
{
|
||||
var regex = new Regex(@"^tsl_(\d)$");
|
||||
foreach (var table in this.tableNames)
|
||||
@@ -273,8 +266,8 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadTslData(SQLiteCommand cmd, int tableNr, string joinTable, string joinFields,
|
||||
Action<Transponder, SQLiteDataReader, int> enhanceTransponderInfo)
|
||||
private void LoadTslData(SqliteCommand cmd, int tableNr, string joinTable, string joinFields,
|
||||
Action<Transponder, SqliteDataReader, int> enhanceTransponderInfo)
|
||||
{
|
||||
if (!this.tableNames.Contains(joinTable.Replace("#", tableNr.ToString())))
|
||||
return;
|
||||
@@ -283,20 +276,20 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
$"select tsl_#.tsl_rec_id, `t_desc.on_id`, `t_desc.ts_id`, `t_ref.satl_rec_id`, `t_desc.e_bcst_medium` {joinFields} "
|
||||
+ $" from tsl_# inner join {joinTable} on {joinTable}.tsl_rec_id=tsl_#.tsl_rec_id";
|
||||
cmd.CommandText = cmd.CommandText.Replace("#", tableNr.ToString());
|
||||
using (var r = cmd.ExecuteReader())
|
||||
using var r = cmd.ExecuteReader();
|
||||
while (r.Read())
|
||||
{
|
||||
while (r.Read())
|
||||
int id = (tableNr << 16) | r.GetInt32(0);
|
||||
var trans = new Transponder(id)
|
||||
{
|
||||
int id = (tableNr << 16) | r.GetInt32(0);
|
||||
var trans = new Transponder(id);
|
||||
trans.OriginalNetworkId = r.GetInt32(1);
|
||||
trans.TransportStreamId = r.GetInt32(2);
|
||||
trans.Satellite = this.DataRoot.Satellites.TryGet(r.GetInt32(3));
|
||||
OriginalNetworkId = r.GetInt32(1),
|
||||
TransportStreamId = r.GetInt32(2),
|
||||
Satellite = this.DataRoot.Satellites.TryGet(r.GetInt32(3))
|
||||
};
|
||||
|
||||
enhanceTransponderInfo(trans, r, 5);
|
||||
enhanceTransponderInfo(trans, r, 5);
|
||||
|
||||
this.DataRoot.AddTransponder(trans.Satellite, trans);
|
||||
}
|
||||
this.DataRoot.AddTransponder(trans.Satellite, trans);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,7 +297,7 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
|
||||
#region LoadSvlData()
|
||||
|
||||
private void LoadSvlData(SQLiteCommand cmd)
|
||||
private void LoadSvlData(SqliteCommand cmd)
|
||||
{
|
||||
var regex = new Regex(@"^svl_(\d)$");
|
||||
foreach (var table in this.tableNames)
|
||||
@@ -319,7 +312,7 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
return;
|
||||
}
|
||||
|
||||
this.LoadSvlData(cmd, x, "svl_#_data_analog", "", (ci, r, i0) => { });
|
||||
this.LoadSvlData(cmd, x, "svl_#_data_analog", "", (_, _, _) => { });
|
||||
this.LoadSvlData(cmd, x, "svl_#_data_dvb", ", b_free_ca_mode, s_svc_name, sdt_service_type, cur_lcn",
|
||||
(ci, r, i0) =>
|
||||
{
|
||||
@@ -345,8 +338,8 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadSvlData(SQLiteCommand cmd, int tableNr, string joinTable, string joinFields,
|
||||
Action<ChannelInfo, SQLiteDataReader, int> enhanceChannelInfo)
|
||||
private void LoadSvlData(SqliteCommand cmd, int tableNr, string joinTable, string joinFields,
|
||||
Action<ChannelInfo, SqliteDataReader, int> enhanceChannelInfo)
|
||||
{
|
||||
if (!this.tableNames.Contains(joinTable.Replace("#", tableNr.ToString())))
|
||||
return;
|
||||
@@ -355,57 +348,55 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
$"select svl_#.svl_rec_id, channel_id, svl_#.tsl_id, svl_#.tsl_rec_id, e_serv_type, ac_name, nw_mask, prog_id, `t_desc.e_bcst_medium` {joinFields}"
|
||||
+ $" from svl_# inner join {joinTable} on {joinTable}.svl_rec_id=svl_#.svl_rec_id inner join tsl_# on tsl_#.tsl_rec_id=svl_#.tsl_rec_id";
|
||||
cmd.CommandText = cmd.CommandText.Replace("#", tableNr.ToString());
|
||||
using (var r = cmd.ExecuteReader())
|
||||
using var r = cmd.ExecuteReader();
|
||||
while (r.Read())
|
||||
{
|
||||
while (r.Read())
|
||||
var id = ((long) tableNr << 32) | (uint) r.GetInt32(0);
|
||||
var prNr = (int) ((uint) r.GetInt32(1)) >> 18;
|
||||
var trans = this.DataRoot.Transponder.TryGet((r.GetInt32(2) << 16) | r.GetInt32(3));
|
||||
var stype = (ServiceType) r.GetInt32(4);
|
||||
var name = r.GetString(5);
|
||||
var nwMask = (NwMask) r.GetInt32(6);
|
||||
var sid = r.GetInt32(7);
|
||||
var bmedium = (BroadcastMedium) r.GetInt32(8);
|
||||
|
||||
var ssource = DetermineSignalSource(bmedium, stype);
|
||||
var ci = new Channel(ssource, id, prNr, name);
|
||||
if (trans != null)
|
||||
{
|
||||
var id = ((long) tableNr << 32) | (uint) r.GetInt32(0);
|
||||
var prNr = (int) ((uint) r.GetInt32(1)) >> 18;
|
||||
var trans = this.DataRoot.Transponder.TryGet((r.GetInt32(2) << 16) | r.GetInt32(3));
|
||||
var stype = (ServiceType) r.GetInt32(4);
|
||||
var name = r.GetString(5);
|
||||
var nwMask = (NwMask) r.GetInt32(6);
|
||||
var sid = r.GetInt32(7);
|
||||
var bmedium = (BroadcastMedium) r.GetInt32(8);
|
||||
|
||||
var ssource = DetermineSignalSource(bmedium, stype);
|
||||
var ci = new Channel(ssource, id, prNr, name);
|
||||
if (trans != null)
|
||||
{
|
||||
ci.Transponder = trans;
|
||||
ci.OriginalNetworkId = trans.OriginalNetworkId;
|
||||
ci.TransportStreamId = trans.TransportStreamId;
|
||||
ci.SymbolRate = trans.SymbolRate;
|
||||
ci.FreqInMhz = trans.FrequencyInMhz;
|
||||
ci.Satellite = trans.Satellite?.ToString();
|
||||
}
|
||||
|
||||
ci.ServiceId = sid;
|
||||
ci.ChannelId = r.GetInt32(1);
|
||||
ci.NwMask = (int)nwMask;
|
||||
|
||||
//ci.Skip = (nwMask & NwMask.Active) == 0;
|
||||
ci.Lock = (nwMask & NwMask.Lock) != 0;
|
||||
ci.Hidden = (nwMask & NwMask.Visible) == 0;
|
||||
ci.Favorites |= (Favorites) ((int) (nwMask & (NwMask.Fav1 | NwMask.Fav2 | NwMask.Fav3 | NwMask.Fav4)) >> 4);
|
||||
|
||||
if (stype == ServiceType.Radio)
|
||||
ci.ServiceTypeName = "Radio";
|
||||
else if (stype == ServiceType.Tv)
|
||||
ci.ServiceTypeName = "TV";
|
||||
else if (stype == ServiceType.App)
|
||||
ci.ServiceTypeName = "Data";
|
||||
|
||||
enhanceChannelInfo(ci, r, 9);
|
||||
|
||||
var list = this.channelLists[tableNr - 1];
|
||||
ci.Source = list.ShortCaption;
|
||||
this.DataRoot.AddChannel(list, ci);
|
||||
|
||||
// add the channel to all favorites lists
|
||||
this.DataRoot.AddChannel(this.channelLists[6], ci);
|
||||
this.channelsById[ci.RecordIndex] = ci;
|
||||
ci.Transponder = trans;
|
||||
ci.OriginalNetworkId = trans.OriginalNetworkId;
|
||||
ci.TransportStreamId = trans.TransportStreamId;
|
||||
ci.SymbolRate = trans.SymbolRate;
|
||||
ci.FreqInMhz = trans.FrequencyInMhz;
|
||||
ci.Satellite = trans.Satellite?.ToString();
|
||||
}
|
||||
|
||||
ci.ServiceId = sid;
|
||||
ci.ChannelId = r.GetInt32(1);
|
||||
ci.NwMask = (int)nwMask;
|
||||
|
||||
//ci.Skip = (nwMask & NwMask.Active) == 0;
|
||||
ci.Lock = (nwMask & NwMask.Lock) != 0;
|
||||
ci.Hidden = (nwMask & NwMask.Visible) == 0;
|
||||
ci.Favorites |= (Favorites) ((int) (nwMask & (NwMask.Fav1 | NwMask.Fav2 | NwMask.Fav3 | NwMask.Fav4)) >> 4);
|
||||
|
||||
if (stype == ServiceType.Radio)
|
||||
ci.ServiceTypeName = "Radio";
|
||||
else if (stype == ServiceType.Tv)
|
||||
ci.ServiceTypeName = "TV";
|
||||
else if (stype == ServiceType.App)
|
||||
ci.ServiceTypeName = "Data";
|
||||
|
||||
enhanceChannelInfo(ci, r, 9);
|
||||
|
||||
var list = this.channelLists[tableNr - 1];
|
||||
ci.Source = list.ShortCaption;
|
||||
this.DataRoot.AddChannel(list, ci);
|
||||
|
||||
// add the channel to all favorites lists
|
||||
this.DataRoot.AddChannel(this.channelLists[6], ci);
|
||||
this.channelsById[ci.RecordIndex] = ci;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,7 +404,7 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
|
||||
#region LoadFavorites()
|
||||
|
||||
private void LoadFavorites(SQLiteCommand cmd)
|
||||
private void LoadFavorites(SqliteCommand cmd)
|
||||
{
|
||||
// detect schema used by fav_x tables
|
||||
if (tableNames.Contains("fav_1"))
|
||||
@@ -483,7 +474,7 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
if (tvOutputFile != this.FileName)
|
||||
File.Copy(this.FileName, tvOutputFile, true);
|
||||
|
||||
using var conn = new SQLiteConnection("Data Source=" + tvOutputFile);
|
||||
using var conn = new SqliteConnection("Data Source=" + tvOutputFile);
|
||||
conn.Open();
|
||||
using var trans = conn.BeginTransaction();
|
||||
using var cmd = conn.CreateCommand();
|
||||
@@ -527,7 +518,7 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
|
||||
#region CreateFavTables()
|
||||
|
||||
private void CreateFavTables(SQLiteCommand cmd)
|
||||
private void CreateFavTables(SqliteCommand cmd)
|
||||
{
|
||||
for (int i = 1; i <= 4; i++)
|
||||
{
|
||||
@@ -546,7 +537,7 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
|
||||
#region ResetLcn()
|
||||
|
||||
private void ResetLcn(SQLiteCommand cmd)
|
||||
private void ResetLcn(SqliteCommand cmd)
|
||||
{
|
||||
var regex = new Regex(@"^svl_\d_data_dvb$");
|
||||
foreach (var table in this.tableNames)
|
||||
@@ -562,7 +553,7 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
|
||||
#region UpdateChannel()
|
||||
|
||||
private void UpdateChannel(SQLiteCommand cmd, Channel ci)
|
||||
private void UpdateChannel(SqliteCommand cmd, Channel ci)
|
||||
{
|
||||
if (ci == null || ci.IsProxy)
|
||||
return;
|
||||
@@ -583,10 +574,10 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
$", nw_mask=@nwMask" +
|
||||
$" where svl_rec_id=@id";
|
||||
cmd.Parameters.Clear();
|
||||
cmd.Parameters.Add("@id", DbType.Int32);
|
||||
cmd.Parameters.Add("@chnr", DbType.Int32);
|
||||
cmd.Parameters.Add("@name", DbType.String);
|
||||
cmd.Parameters.Add("@nwMask", DbType.Int32);
|
||||
cmd.Parameters.Add("@id", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@chnr", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@name", SqliteType.Text);
|
||||
cmd.Parameters.Add("@nwMask", SqliteType.Integer);
|
||||
cmd.Parameters["@id"].Value = id;
|
||||
cmd.Parameters["@chnr"].Value = ci.NewProgramNr;
|
||||
cmd.Parameters["@name"].Value = ci.Name;
|
||||
@@ -604,7 +595,7 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
#endregion
|
||||
|
||||
#region UpdateFavoritesWithUnderlinedColumnNames()
|
||||
private void UpdateFavoritesWithUnderlinedColumnNames(SQLiteCommand cmd, ChannelInfo ci)
|
||||
private void UpdateFavoritesWithUnderlinedColumnNames(SqliteCommand cmd, ChannelInfo ci)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -617,10 +608,10 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
{
|
||||
cmd.CommandText = $"update fav_{i + 1} set user_defined_ch_num=@chnr, user_defined_ch_name=@name where ui2_svc_id=@svcid and ui2_svc_rec_id=@recid";
|
||||
cmd.Parameters.Clear();
|
||||
cmd.Parameters.Add("@chnr", DbType.String); // for some reason this is a VARCHAR in the database
|
||||
cmd.Parameters.Add("@name", DbType.String);
|
||||
cmd.Parameters.Add("@svcid", DbType.Int32);
|
||||
cmd.Parameters.Add("@recid", DbType.Int32);
|
||||
cmd.Parameters.Add("@chnr", SqliteType.Text); // for some reason this is a VARCHAR in the database
|
||||
cmd.Parameters.Add("@name", SqliteType.Text);
|
||||
cmd.Parameters.Add("@svcid", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@recid", SqliteType.Integer);
|
||||
cmd.Parameters["@chnr"].Value = ci.GetPosition(i+1).ToString();
|
||||
cmd.Parameters["@name"].Value = ci.Name;
|
||||
cmd.Parameters["@svcid"].Value = ci.RecordIndex >> 32;
|
||||
@@ -636,7 +627,7 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
#endregion
|
||||
|
||||
#region UpdateFavoritesWithCamelCaseColumnNames()
|
||||
private void UpdateFavoritesWithCamelCaseColumnNames(SQLiteCommand cmd, Channel ci)
|
||||
private void UpdateFavoritesWithCamelCaseColumnNames(SqliteCommand cmd, Channel ci)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -645,12 +636,12 @@ namespace ChanSort.Loader.Hisense.ChannelDb
|
||||
|
||||
cmd.CommandText = $"insert into fav_{i + 1} (sortId, channelId, svlId, channelName, svlRecId, nwMask) values (@chnr,@chanid,@svcid,@name,@recid,@nwmask)";
|
||||
cmd.Parameters.Clear();
|
||||
cmd.Parameters.Add("@chnr", DbType.Int32);
|
||||
cmd.Parameters.Add("@chanid", DbType.Int32);
|
||||
cmd.Parameters.Add("@svcid", DbType.Int32);
|
||||
cmd.Parameters.Add("@name", DbType.String);
|
||||
cmd.Parameters.Add("@recid", DbType.Int32);
|
||||
cmd.Parameters.Add("@nwmask", DbType.Int32);
|
||||
cmd.Parameters.Add("@chnr", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@chanid", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@svcid", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@name", SqliteType.Text);
|
||||
cmd.Parameters.Add("@recid", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@nwmask", SqliteType.Integer);
|
||||
cmd.Parameters["@chnr"].Value = ci.GetPosition(i+1);
|
||||
cmd.Parameters["@chanid"].Value = ci.ChannelId;
|
||||
cmd.Parameters["@name"].Value = ci.Name;
|
||||
|
||||
@@ -2,15 +2,57 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SQLite;
|
||||
using System.IO;
|
||||
using ChanSort.Api;
|
||||
using Microsoft.Data.Sqlite;
|
||||
|
||||
namespace ChanSort.Loader.Hisense.ServicelistDb
|
||||
{
|
||||
public class ServicelistDbSerializer : SerializerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Fields of the ChannelInfo that will be shown in the UI
|
||||
/// </summary>
|
||||
private static readonly List<string> ColumnNames = new()
|
||||
{
|
||||
"OldPosition",
|
||||
"Position",
|
||||
"Source",
|
||||
"NewProgramNr",
|
||||
"Name",
|
||||
"ShortName",
|
||||
"Favorites",
|
||||
"Skip",
|
||||
"Lock",
|
||||
"Hidden",
|
||||
"Encrypted",
|
||||
"FreqInMhz",
|
||||
"OriginalNetworkId",
|
||||
"TransportStreamId",
|
||||
"ServiceId",
|
||||
//"ServiceType",
|
||||
"ServiceTypeName",
|
||||
"NetworkName",
|
||||
"Satellite"
|
||||
// "SymbolRate"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// mapping of FavoriteList.Pid => ChannelList.
|
||||
/// This dict does not include real user favorite lists (FAV1-FAV4).
|
||||
/// </summary>
|
||||
private readonly Dictionary<int, ChannelList> channelLists = new();
|
||||
|
||||
/// <summary>
|
||||
/// mapping of Service.Pid => ChannelInfo
|
||||
/// </summary>
|
||||
private readonly Dictionary<long, ChannelInfo> channelsById = new();
|
||||
|
||||
/// <summary>
|
||||
/// mapping of FavoriteList.Pid for FAV1-4 => index of the internal favorite list within userFavList (0-3)
|
||||
/// Pids that don't belong to the FAV1-4 are not included in this dictionary.
|
||||
/// </summary>
|
||||
private readonly Dictionary<int, int> favListIdToFavIndex = new();
|
||||
/*
|
||||
* The 2017 Hisense / Loewe data model for channel lists is a bit different than all other supported models and need some workarounds to be supported.
|
||||
* It is based on a flat "Services" table which doesn't hold program numbers and a FavoritesList/FavoritesItem table to assign numbers
|
||||
@@ -33,84 +75,25 @@ namespace ChanSort.Loader.Hisense.ServicelistDb
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// list of all table names in the database
|
||||
/// list of all table names in the database
|
||||
/// </summary>
|
||||
private readonly List<string> tableNames = new List<string>();
|
||||
private readonly List<string> tableNames = new();
|
||||
|
||||
/// <summary>
|
||||
/// mapping of Service.Pid => ChannelInfo
|
||||
/// This list is filled with all channels/services and serves as a holder for favorite lists 1-4
|
||||
/// </summary>
|
||||
private readonly Dictionary<long, ChannelInfo> channelsById = new Dictionary<long, ChannelInfo>();
|
||||
private readonly ChannelList userFavList = new(0, "Favorites");
|
||||
|
||||
/// <summary>
|
||||
/// mapping of FavoriteList.Pid => ChannelList.
|
||||
/// This dict does not include real user favorite lists (FAV1-FAV4).
|
||||
/// </summary>
|
||||
private readonly Dictionary<int, ChannelList> channelLists = new Dictionary<int, ChannelList>();
|
||||
|
||||
/// <summary>
|
||||
/// This list is filled with all channels/services and serves as a holder for favorite lists 1-4
|
||||
/// </summary>
|
||||
private readonly ChannelList userFavList = new ChannelList(0, "Favorites");
|
||||
|
||||
/// <summary>
|
||||
/// mapping of FavoriteList.Pid for FAV1-4 => index of the internal favorite list within userFavList (0-3)
|
||||
/// Pids that don't belong to the FAV1-4 are not included in this dictionary.
|
||||
/// </summary>
|
||||
private readonly Dictionary<int,int> favListIdToFavIndex = new Dictionary<int, int>();
|
||||
|
||||
/// <summary>
|
||||
/// FavoriteList.Pid of the $all list
|
||||
/// FavoriteList.Pid of the $all list
|
||||
/// </summary>
|
||||
private int pidAll;
|
||||
|
||||
/// <summary>
|
||||
/// FavoriteList.Pid of the $av list
|
||||
/// FavoriteList.Pid of the $av list
|
||||
/// </summary>
|
||||
private int pidAv;
|
||||
|
||||
/// <summary>
|
||||
/// Fields of the ChannelInfo that will be shown in the UI
|
||||
/// </summary>
|
||||
private static readonly List<string> ColumnNames = new List<string>
|
||||
{
|
||||
"OldPosition",
|
||||
"Position",
|
||||
"Source",
|
||||
"NewProgramNr",
|
||||
"Name",
|
||||
"ShortName",
|
||||
"Favorites",
|
||||
"Skip",
|
||||
"Lock",
|
||||
"Hidden",
|
||||
"Encrypted",
|
||||
"FreqInMhz",
|
||||
"OriginalNetworkId",
|
||||
"TransportStreamId",
|
||||
"ServiceId",
|
||||
//"ServiceType",
|
||||
"ServiceTypeName",
|
||||
"NetworkName",
|
||||
"Satellite"
|
||||
// "SymbolRate"
|
||||
};
|
||||
|
||||
#region class HisTransponder
|
||||
/// <summary>
|
||||
/// This class holds information from the Tuner table
|
||||
/// </summary>
|
||||
public class HisTransponder : Transponder
|
||||
{
|
||||
public SignalSource SignalSource { get; set; }
|
||||
public string Source { get; set; }
|
||||
|
||||
public HisTransponder(int id) : base(id)
|
||||
{
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ctor()
|
||||
|
||||
public ServicelistDbSerializer(string inputFile) : base(inputFile)
|
||||
@@ -132,7 +115,7 @@ namespace ChanSort.Loader.Hisense.ServicelistDb
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
using (var conn = new SQLiteConnection("Data Source=" + FileName))
|
||||
using (var conn = new SqliteConnection("Data Source=" + FileName))
|
||||
{
|
||||
conn.Open();
|
||||
using (var cmd = conn.CreateCommand())
|
||||
@@ -152,14 +135,14 @@ namespace ChanSort.Loader.Hisense.ServicelistDb
|
||||
}
|
||||
|
||||
if (channelsById.Count == 0)
|
||||
Api.View.Default.MessageBox(Resources.Load_NoChannelsMsg, Resources.Load_NoChannelsCaption);
|
||||
View.Default.MessageBox(Resources.Load_NoChannelsMsg, Resources.Load_NoChannelsCaption);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RepairCorruptedDatabaseImage()
|
||||
|
||||
private void RepairCorruptedDatabaseImage(SQLiteCommand cmd)
|
||||
private void RepairCorruptedDatabaseImage(SqliteCommand cmd)
|
||||
{
|
||||
cmd.CommandText = "REINDEX";
|
||||
cmd.ExecuteNonQuery();
|
||||
@@ -169,7 +152,7 @@ namespace ChanSort.Loader.Hisense.ServicelistDb
|
||||
|
||||
#region LoadTableNames()
|
||||
|
||||
private void LoadTableNames(SQLiteCommand cmd)
|
||||
private void LoadTableNames(SqliteCommand cmd)
|
||||
{
|
||||
cmd.CommandText = "SELECT name FROM sqlite_master WHERE type = 'table' order by name";
|
||||
using (var r = cmd.ExecuteReader())
|
||||
@@ -182,20 +165,25 @@ namespace ChanSort.Loader.Hisense.ServicelistDb
|
||||
#endregion
|
||||
|
||||
#region LoadLists()
|
||||
private void LoadLists(SQLiteCommand cmd)
|
||||
|
||||
private void LoadLists(SqliteCommand cmd)
|
||||
{
|
||||
cmd.CommandText = "select Pid, Name from FavoriteList";
|
||||
using (var r = cmd.ExecuteReader())
|
||||
{
|
||||
while (r.Read())
|
||||
{
|
||||
int listId = r.GetInt32(0);
|
||||
string name = r.GetString(1);
|
||||
var listId = r.GetInt32(0);
|
||||
var name = r.GetString(1);
|
||||
|
||||
if (name == "$all")
|
||||
{
|
||||
pidAll = listId;
|
||||
}
|
||||
else if (name == "$av")
|
||||
{
|
||||
pidAv = listId;
|
||||
}
|
||||
else if (name.StartsWith("FAV"))
|
||||
{
|
||||
// all real user favorite lists are using the "userFavList"
|
||||
@@ -220,66 +208,12 @@ namespace ChanSort.Loader.Hisense.ServicelistDb
|
||||
channelLists.Add(0, userFavList);
|
||||
DataRoot.AddChannelList(userFavList);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region LoadTunerData()
|
||||
|
||||
private void LoadTunerData(SQLiteCommand cmd)
|
||||
{
|
||||
List<Tuple<string,SignalSource,string>> inputs = new List<Tuple<string, SignalSource, string>>
|
||||
{
|
||||
Tuple.Create("C", SignalSource.DvbC, "symbolrate"),
|
||||
Tuple.Create("C2", SignalSource.DvbC, "bandwidth"),
|
||||
Tuple.Create("S", SignalSource.DvbS, "symbolrate"),
|
||||
Tuple.Create("S2", SignalSource.DvbS, "symbolrate"),
|
||||
Tuple.Create("T", SignalSource.DvbT, "bandwidth"),
|
||||
Tuple.Create("T2", SignalSource.DvbT, "bandwidth"),
|
||||
};
|
||||
|
||||
foreach (var input in inputs)
|
||||
{
|
||||
var table = input.Item1;
|
||||
var symrate = input.Item3;
|
||||
LoadTunerData(cmd, "DVB" + table + "Tuner", ", Frequency," + symrate, (t, r, i0) =>
|
||||
{
|
||||
t.Source = "DVB-" + input.Item1;
|
||||
t.SignalSource = input.Item2;
|
||||
t.FrequencyInMhz = (decimal) r.GetInt32(i0 + 0) / 1000;
|
||||
t.SymbolRate = r.GetInt32(i0 + 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadTunerData(SQLiteCommand cmd, string joinTable, string joinFields, Action<HisTransponder, SQLiteDataReader, int> enhanceTransponderInfo)
|
||||
{
|
||||
if (!tableNames.Contains(joinTable.ToLower()))
|
||||
return;
|
||||
|
||||
cmd.CommandText = $"select tuner.tunerid, oid, tid, satellite {joinFields} "
|
||||
+ $" from tuner inner join {joinTable} on {joinTable}.tunerid=tuner.tunerid";
|
||||
|
||||
using (var r = cmd.ExecuteReader())
|
||||
{
|
||||
while (r.Read())
|
||||
{
|
||||
var id = r.GetInt32(0);
|
||||
var trans = new HisTransponder(id);
|
||||
trans.OriginalNetworkId = r.GetInt32(1);
|
||||
trans.TransportStreamId = r.GetInt32(2);
|
||||
trans.Satellite = DataRoot.Satellites.TryGet(r.GetInt32(3));
|
||||
|
||||
enhanceTransponderInfo(trans, r, 4);
|
||||
|
||||
DataRoot.AddTransponder(trans.Satellite, trans);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LoadServiceData()
|
||||
|
||||
private void LoadServiceData(SQLiteCommand cmd)
|
||||
private void LoadServiceData(SqliteCommand cmd)
|
||||
{
|
||||
cmd.CommandText = @"
|
||||
select s.pid, s.type, anls.Frequency, digs.TunerId, digs.Sid, Name, ShortName, Encrypted, Visible, Selectable, ParentalLock, MediaType
|
||||
@@ -294,7 +228,9 @@ left outer join DVBService digs on digs.ServiceId=s.Pid
|
||||
{
|
||||
ChannelInfo ci = null;
|
||||
if (!r.IsDBNull(2)) // AnalogService
|
||||
{
|
||||
ci = new ChannelInfo(SignalSource.Analog, r.GetInt32(0), -1, r.GetString(5));
|
||||
}
|
||||
else if (!r.IsDBNull(3)) // DvbService
|
||||
{
|
||||
var trans = (HisTransponder) DataRoot.Transponder.TryGet(r.GetInt32(3));
|
||||
@@ -322,7 +258,9 @@ left outer join DVBService digs on digs.ServiceId=s.Pid
|
||||
ci.ServiceTypeName = "Radio";
|
||||
}
|
||||
else
|
||||
{
|
||||
ci.ServiceTypeName = mediaType.ToString();
|
||||
}
|
||||
}
|
||||
else if (r.GetInt32(1) == 0) // A/V input
|
||||
{
|
||||
@@ -335,11 +273,12 @@ left outer join DVBService digs on digs.ServiceId=s.Pid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LoadFavorites()
|
||||
|
||||
private void LoadFavorites(SQLiteCommand cmd)
|
||||
private void LoadFavorites(SqliteCommand cmd)
|
||||
{
|
||||
cmd.CommandText = @"
|
||||
select fi.FavoriteId, fi.ServiceId, fi.ChannelNum, fi.Selectable, fi.Visible, fi.isDeleted, fi.Protected, l.Lcn
|
||||
@@ -350,14 +289,14 @@ left outer join Lcn l on l.ServiceId=fi.ServiceId and l.FavoriteId=fi.FavoriteId
|
||||
{
|
||||
while (r.Read())
|
||||
{
|
||||
int favListId = r.GetInt32(0);
|
||||
var favListId = r.GetInt32(0);
|
||||
var ci = channelsById.TryGet(r.GetInt32(1));
|
||||
if (ci == null)
|
||||
continue;
|
||||
|
||||
int favListIdx = favListIdToFavIndex.TryGet(favListId, -1);
|
||||
|
||||
var favListIdx = favListIdToFavIndex.TryGet(favListId, -1);
|
||||
if (favListIdx >= 0)
|
||||
ci.SetOldPosition(favListIdx+1, r.GetInt32(2));
|
||||
ci.SetOldPosition(favListIdx + 1, r.GetInt32(2));
|
||||
|
||||
ci.SetOldPosition(favListIdx + 1, r.GetInt32(2)); // 0=main nr, 1-4=fav 1-4
|
||||
if (favListIdx < 0)
|
||||
@@ -388,9 +327,10 @@ left outer join Lcn l on l.ServiceId=fi.ServiceId and l.FavoriteId=fi.FavoriteId
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var ci in channelsById.Values)
|
||||
foreach (var ci in channelsById.Values)
|
||||
DataRoot.AddChannel(userFavList, ci);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// Saving ====================================
|
||||
@@ -402,7 +342,7 @@ left outer join Lcn l on l.ServiceId=fi.ServiceId and l.FavoriteId=fi.FavoriteId
|
||||
if (tvOutputFile != FileName)
|
||||
File.Copy(FileName, tvOutputFile, true);
|
||||
|
||||
using (var conn = new SQLiteConnection("Data Source=" + tvOutputFile))
|
||||
using (var conn = new SqliteConnection("Data Source=" + tvOutputFile))
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
@@ -429,11 +369,12 @@ left outer join Lcn l on l.ServiceId=fi.ServiceId and l.FavoriteId=fi.FavoriteId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ResetLcn()
|
||||
|
||||
private void ResetLcn(SQLiteCommand cmd)
|
||||
private void ResetLcn(SqliteCommand cmd)
|
||||
{
|
||||
cmd.CommandText = "delete from Lcn where FavoriteId<>" + pidAv;
|
||||
cmd.ExecuteNonQuery();
|
||||
@@ -442,20 +383,22 @@ left outer join Lcn l on l.ServiceId=fi.ServiceId and l.FavoriteId=fi.FavoriteId
|
||||
#endregion
|
||||
|
||||
#region UpdateServices()
|
||||
private void UpdateServices(SQLiteCommand cmd)
|
||||
|
||||
private void UpdateServices(SqliteCommand cmd)
|
||||
{
|
||||
cmd.CommandText = "update Service set Name=@name, ShortName=@sname, ParentalLock=@lock, Visible=@vis, Selectable=@sel, FavTag=@fav1, FavTag2=@fav1, FavTag3=@fav3, FavTag4=@fav4 where Pid=@servId";
|
||||
cmd.CommandText =
|
||||
"update Service set Name=@name, ShortName=@sname, ParentalLock=@lock, Visible=@vis, Selectable=@sel, FavTag=@fav1, FavTag2=@fav1, FavTag3=@fav3, FavTag4=@fav4 where Pid=@servId";
|
||||
cmd.Parameters.Clear();
|
||||
cmd.Parameters.Add("@servId", DbType.Int32);
|
||||
cmd.Parameters.Add("@name", DbType.String);
|
||||
cmd.Parameters.Add("@sname", DbType.String);
|
||||
cmd.Parameters.Add("@lock", DbType.Int32);
|
||||
cmd.Parameters.Add("@vis", DbType.Int32);
|
||||
cmd.Parameters.Add("@sel", DbType.Int32);
|
||||
cmd.Parameters.Add("@fav1", DbType.Int32);
|
||||
cmd.Parameters.Add("@fav2", DbType.Int32);
|
||||
cmd.Parameters.Add("@fav3", DbType.Int32);
|
||||
cmd.Parameters.Add("@fav4", DbType.Int32);
|
||||
cmd.Parameters.Add("@servId", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@name", SqliteType.Text);
|
||||
cmd.Parameters.Add("@sname", SqliteType.Text);
|
||||
cmd.Parameters.Add("@lock", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@vis", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@sel", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@fav1", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@fav2", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@fav3", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@fav4", SqliteType.Integer);
|
||||
cmd.Prepare();
|
||||
|
||||
foreach (var ci in channelsById.Values)
|
||||
@@ -473,20 +416,22 @@ left outer join Lcn l on l.ServiceId=fi.ServiceId and l.FavoriteId=fi.FavoriteId
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdatePhysicalChannelLists()
|
||||
private void UpdatePhysicalChannelLists(SQLiteCommand cmd)
|
||||
|
||||
private void UpdatePhysicalChannelLists(SqliteCommand cmd)
|
||||
{
|
||||
cmd.CommandText = "update FavoriteItem set ChannelNum=@ch, isDeleted=@del, Protected=@prot, Selectable=@sel, Visible=@vis where FavoriteId=@favId and ServiceId=@servId";
|
||||
cmd.Parameters.Clear();
|
||||
cmd.Parameters.Add("@favId", DbType.Int32);
|
||||
cmd.Parameters.Add("@servId", DbType.Int32);
|
||||
cmd.Parameters.Add("@ch", DbType.Int32);
|
||||
cmd.Parameters.Add("@del", DbType.Int32);
|
||||
cmd.Parameters.Add("@prot", DbType.Int32);
|
||||
cmd.Parameters.Add("@sel", DbType.Int32);
|
||||
cmd.Parameters.Add("@vis", DbType.Int32);
|
||||
cmd.Parameters.Add("@favId", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@servId", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@ch", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@del", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@prot", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@sel", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@vis", SqliteType.Integer);
|
||||
cmd.Prepare();
|
||||
|
||||
foreach (var entry in channelLists)
|
||||
@@ -524,10 +469,12 @@ left outer join Lcn l on l.ServiceId=fi.ServiceId and l.FavoriteId=fi.FavoriteId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateUserFavoriteLists()
|
||||
private void UpdateUserFavoriteLists(SQLiteCommand cmd)
|
||||
|
||||
private void UpdateUserFavoriteLists(SqliteCommand cmd)
|
||||
{
|
||||
// delete all FavoriteItem records that belong to the FAV1-4 lists
|
||||
cmd.Parameters.Clear();
|
||||
@@ -536,9 +483,9 @@ left outer join Lcn l on l.ServiceId=fi.ServiceId and l.FavoriteId=fi.FavoriteId
|
||||
|
||||
// (re-)insert the user's new favorites
|
||||
cmd.CommandText = "insert into FavoriteItem (FavoriteId, ServiceId, ChannelNum) values (@favId, @servId, @ch)";
|
||||
cmd.Parameters.Add("@favId", DbType.Int32);
|
||||
cmd.Parameters.Add("@servId", DbType.Int32);
|
||||
cmd.Parameters.Add("@ch", DbType.Int32);
|
||||
cmd.Parameters.Add("@favId", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@servId", SqliteType.Integer);
|
||||
cmd.Parameters.Add("@ch", SqliteType.Integer);
|
||||
foreach (var entry in favListIdToFavIndex)
|
||||
{
|
||||
var favIndex = entry.Value;
|
||||
@@ -561,5 +508,76 @@ left outer join Lcn l on l.ServiceId=fi.ServiceId and l.FavoriteId=fi.FavoriteId
|
||||
|
||||
#endregion
|
||||
|
||||
#region class HisTransponder
|
||||
|
||||
/// <summary>
|
||||
/// This class holds information from the Tuner table
|
||||
/// </summary>
|
||||
public class HisTransponder : Transponder
|
||||
{
|
||||
public HisTransponder(int id) : base(id)
|
||||
{
|
||||
}
|
||||
|
||||
public SignalSource SignalSource { get; set; }
|
||||
public string Source { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LoadTunerData()
|
||||
|
||||
private void LoadTunerData(SqliteCommand cmd)
|
||||
{
|
||||
var inputs = new List<Tuple<string, SignalSource, string>>
|
||||
{
|
||||
Tuple.Create("C", SignalSource.DvbC, "symbolrate"),
|
||||
Tuple.Create("C2", SignalSource.DvbC, "bandwidth"),
|
||||
Tuple.Create("S", SignalSource.DvbS, "symbolrate"),
|
||||
Tuple.Create("S2", SignalSource.DvbS, "symbolrate"),
|
||||
Tuple.Create("T", SignalSource.DvbT, "bandwidth"),
|
||||
Tuple.Create("T2", SignalSource.DvbT, "bandwidth")
|
||||
};
|
||||
|
||||
foreach (var input in inputs)
|
||||
{
|
||||
var table = input.Item1;
|
||||
var symrate = input.Item3;
|
||||
LoadTunerData(cmd, "DVB" + table + "Tuner", ", Frequency," + symrate, (t, r, i0) =>
|
||||
{
|
||||
t.Source = "DVB-" + input.Item1;
|
||||
t.SignalSource = input.Item2;
|
||||
t.FrequencyInMhz = (decimal) r.GetInt32(i0 + 0) / 1000;
|
||||
t.SymbolRate = r.GetInt32(i0 + 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadTunerData(SqliteCommand cmd, string joinTable, string joinFields, Action<HisTransponder, SqliteDataReader, int> enhanceTransponderInfo)
|
||||
{
|
||||
if (!tableNames.Contains(joinTable.ToLower()))
|
||||
return;
|
||||
|
||||
cmd.CommandText = $"select tuner.tunerid, oid, tid, satellite {joinFields} "
|
||||
+ $" from tuner inner join {joinTable} on {joinTable}.tunerid=tuner.tunerid";
|
||||
|
||||
using (var r = cmd.ExecuteReader())
|
||||
{
|
||||
while (r.Read())
|
||||
{
|
||||
var id = r.GetInt32(0);
|
||||
var trans = new HisTransponder(id);
|
||||
trans.OriginalNetworkId = r.GetInt32(1);
|
||||
trans.TransportStreamId = r.GetInt32(2);
|
||||
trans.Satellite = DataRoot.Satellites.TryGet(r.GetInt32(3));
|
||||
|
||||
enhanceTransponderInfo(trans, r, 4);
|
||||
|
||||
DataRoot.AddTransponder(trans.Satellite, trans);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
source/ChanSort.Loader.Hisense/app.config
Normal file
11
source/ChanSort.Loader.Hisense/app.config
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
13
source/ChanSort.Loader.Hisense/packages.config
Normal file
13
source/ChanSort.Loader.Hisense/packages.config
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Data.Sqlite" version="5.0.5" targetFramework="net48" />
|
||||
<package id="Microsoft.Data.Sqlite.Core" version="5.0.5" targetFramework="net48" />
|
||||
<package id="SQLitePCLRaw.bundle_e_sqlite3" version="2.0.4" targetFramework="net48" />
|
||||
<package id="SQLitePCLRaw.core" version="2.0.4" targetFramework="net48" />
|
||||
<package id="SQLitePCLRaw.lib.e_sqlite3" version="2.0.4" targetFramework="net48" />
|
||||
<package id="SQLitePCLRaw.provider.dynamic_cdecl" version="2.0.4" targetFramework="net48" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
|
||||
<package id="System.Memory" version="4.5.4" targetFramework="net48" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net48" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user