- unified handling for deleting channels (action based on file format support either mark-as-deleted, remove-from-file, append-at-end)

- added unit tests
- internal code cleanup
This commit is contained in:
hbeham
2019-11-08 02:31:44 +01:00
parent caca802c0a
commit 34b281f5fc
105 changed files with 2024 additions and 1442 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ChanSort.Loader.Panasonic</RootNamespace>
<AssemblyName>ChanSort.Loader.Panasonic</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
@@ -23,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -31,6 +32,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
@@ -40,14 +42,16 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<OutputPath>..\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -60,7 +64,6 @@
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>

View File

@@ -8,7 +8,6 @@ namespace ChanSort.Loader.Panasonic
{
internal class DbChannel : ChannelInfo
{
internal int Bits;
internal byte[] RawName;
#region ctor()

View File

@@ -4,7 +4,6 @@ using System.Data;
using System.Data.SQLite;
using System.IO;
using System.Text;
using System.Windows.Forms;
using ChanSort.Api;
namespace ChanSort.Loader.Panasonic
@@ -41,9 +40,10 @@ namespace ChanSort.Loader.Panasonic
DepencencyChecker.AssertVc2010RedistPackageX86Installed();
this.Features.ChannelNameEdit = ChannelNameEditMode.None; // due to the chaos with binary data inside the "sname" string column, writing back a name has undesired side effects
this.Features.DeleteMode = DeleteMode.Physically;
this.Features.CanHaveGaps = false;
this.Features.EncryptedFlagEdit = true;
this.DataRoot.SortedFavorites = true;
this.Features.SortedFavorites = true;
this.DataRoot.AddChannelList(this.avbtChannels);
this.DataRoot.AddChannelList(this.avbcChannels);
@@ -63,8 +63,6 @@ namespace ChanSort.Loader.Panasonic
}
#endregion
public override string DisplayName => "Panasonic .db/.bin Loader";
#region Load()
public override void Load()
{
@@ -102,7 +100,8 @@ namespace ChanSort.Loader.Panasonic
var tempFile = this.FileName + ".tmp";
File.Delete(tempFile);
Application.ApplicationExit += CleanTempFile;
this.DeleteOnExit(tempFile);
if (cypherMode == CypherMode.Encryption)
this.CypherFile(this.FileName, tempFile, false);
else
@@ -202,18 +201,6 @@ namespace ChanSort.Loader.Panasonic
#endregion
#region CleanTempFile()
private void CleanTempFile(object sender, EventArgs e)
{
try
{
if (this.workFile != null)
File.Delete(this.workFile);
}
catch { }
}
#endregion
#region CreateDummySatellites()
private void CreateDummySatellites()
{
@@ -351,7 +338,7 @@ order by s.ntype,major_channel
var channel = channelInfo as DbChannel;
if (channel == null) // skip reference list proxy channels
continue;
if (channel.NewProgramNr < 0 || channel.OldProgramNr < 0)
if (channel.IsDeleted && channel.OldProgramNr >= 0)
continue;
cmd.Parameters["@rowid"].Value = channel.RecordIndex;
cmd.Parameters["@progNr"].Value = channel.NewProgramNr;
@@ -368,7 +355,7 @@ order by s.ntype,major_channel
cmd.Parameters.Add(new SQLiteParameter("@rowid", DbType.Int32));
foreach (ChannelInfo channel in channelList.Channels)
{
if (channel.NewProgramNr == -1 && channel.OldProgramNr >= 0)
if (channel.IsDeleted && channel.OldProgramNr >= 0)
{
cmd.Parameters["@rowid"].Value = channel.RecordIndex;
cmd.ExecuteNonQuery();