fixes to the tool, changed signing key (expired)
This commit is contained in:
parent
545eb6d6f9
commit
5aec63ba4f
@ -23,7 +23,7 @@ namespace ENI2.Controls
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ValueMappingsControl : UserControl
|
public partial class ValueMappingsControl : UserControl
|
||||||
{
|
{
|
||||||
private ObservableCollection<ValueMapping> _mappings = new ObservableCollection<ValueMapping>();
|
private readonly ObservableCollection<ValueMapping> _mappings = new ObservableCollection<ValueMapping>();
|
||||||
private DataGridCellInfo activeCellAtEdit;
|
private DataGridCellInfo activeCellAtEdit;
|
||||||
|
|
||||||
public ValueMappingsControl()
|
public ValueMappingsControl()
|
||||||
@ -58,8 +58,7 @@ namespace ENI2.Controls
|
|||||||
|
|
||||||
private async void DelItem_Click(object sender, RoutedEventArgs e)
|
private async void DelItem_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ValueMapping vm = this.dataGridValueMappings.SelectedItem as ValueMapping;
|
if (this.dataGridValueMappings.SelectedItem is ValueMapping vm)
|
||||||
if(vm != null)
|
|
||||||
{
|
{
|
||||||
if (MessageBox.Show($"Are you sure to delete {vm.Key} -> {vm.Value}?", Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) ==
|
if (MessageBox.Show($"Are you sure to delete {vm.Key} -> {vm.Value}?", Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) ==
|
||||||
MessageBoxResult.Yes)
|
MessageBoxResult.Yes)
|
||||||
|
|||||||
@ -84,7 +84,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup />
|
<PropertyGroup />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ManifestCertificateThumbprint>F2C2D0164244EC89955EF50201EE24C2A300FF0B</ManifestCertificateThumbprint>
|
<ManifestCertificateThumbprint>62DE8527C377957850DB503DA52FF66F664BD459</ManifestCertificateThumbprint>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SignManifests>true</SignManifests>
|
<SignManifests>true</SignManifests>
|
||||||
|
|||||||
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.SQLite;
|
using System.Data.SQLite;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace bsmd.Tool
|
namespace bsmd.Tool
|
||||||
{
|
{
|
||||||
@ -81,13 +82,18 @@ namespace bsmd.Tool
|
|||||||
insertCmd.Parameters.AddRange(new[] { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18 });
|
insertCmd.Parameters.AddRange(new[] { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18 });
|
||||||
updateCmd.Parameters.AddRange(new[] { p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, idParam });
|
updateCmd.Parameters.AddRange(new[] { p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, idParam });
|
||||||
|
|
||||||
|
SQLiteCommand delCmd = new SQLiteCommand(connection);
|
||||||
|
delCmd.CommandText = "DELETE FROM locodes WHERE id = @ID";
|
||||||
|
SQLiteParameter delIdParam = new SQLiteParameter("@ID", DbType.Int32);
|
||||||
|
delCmd.Parameters.Add(delIdParam);
|
||||||
|
|
||||||
string[] csvLines = File.ReadAllLines(csvFilePath);
|
string[] csvLines = File.ReadAllLines(csvFilePath);
|
||||||
int updateCnt = 0, insertCnt = 0;
|
int updateCnt = 0, insertCnt = 0;
|
||||||
|
|
||||||
for (int i = 0; i < csvLines.Length; i++)
|
for (int i = 0; i < csvLines.Length; i++)
|
||||||
{
|
{
|
||||||
string line = csvLines[i];
|
string line = csvLines[i];
|
||||||
string[] elems = line.Split(',');
|
string[] elems = Regex.Split(line, ",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");
|
||||||
if (elems.Length < 12) continue;
|
if (elems.Length < 12) continue;
|
||||||
string country = elems[1].Trim().Replace("\"", "");
|
string country = elems[1].Trim().Replace("\"", "");
|
||||||
if (country.Length < 2) continue;
|
if (country.Length < 2) continue;
|
||||||
@ -100,12 +106,30 @@ namespace bsmd.Tool
|
|||||||
lcode.Value = code;
|
lcode.Value = code;
|
||||||
|
|
||||||
// Eingabeformat: https://service.unece.org/trade/locode/Service/LocodeColumn.htm
|
// Eingabeformat: https://service.unece.org/trade/locode/Service/LocodeColumn.htm
|
||||||
|
int? lid = null;
|
||||||
object lookupResult = lookupCmd.ExecuteScalar();
|
using (SQLiteDataReader lookupReader = lookupCmd.ExecuteReader())
|
||||||
if ((lookupResult != null) && (lookupResult != DBNull.Value))
|
|
||||||
{
|
{
|
||||||
int lid = Convert.ToInt32(lookupResult);
|
while (lookupReader.Read())
|
||||||
|
{
|
||||||
|
if (!lookupReader.IsDBNull(0))
|
||||||
|
{
|
||||||
|
int tmp_id = lookupReader.GetInt32(0);
|
||||||
|
if (!lid.HasValue) { lid = tmp_id; }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Dublette, die löschen wir gleich hier:
|
||||||
|
delIdParam.Value = tmp_id;
|
||||||
|
if(delCmd.ExecuteNonQuery() == 0)
|
||||||
|
{
|
||||||
|
_log.WarnFormat("Delete of {0} affected no rows.", tmp_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lid.HasValue && lid > 0)
|
||||||
|
{
|
||||||
p3.Value = elems[3].Trim().Replace("\"", "");
|
p3.Value = elems[3].Trim().Replace("\"", "");
|
||||||
p4.Value = elems[4].Trim().Replace("\"", "");
|
p4.Value = elems[4].Trim().Replace("\"", "");
|
||||||
p5.Value = elems[5].Trim().Replace("\"", "");
|
p5.Value = elems[5].Trim().Replace("\"", "");
|
||||||
@ -182,12 +206,10 @@ namespace bsmd.Tool
|
|||||||
|
|
||||||
Console.WriteLine($"deleting {deleteIds.Count} obsolete entries");
|
Console.WriteLine($"deleting {deleteIds.Count} obsolete entries");
|
||||||
|
|
||||||
SQLiteCommand delCmd = new SQLiteCommand(connection);
|
|
||||||
delCmd.CommandText = "DELETE FROM locodes where id = @DELID";
|
|
||||||
// diejenigen löschen, die nicht mehr in der Quell CSV Datei auftauchen
|
// diejenigen löschen, die nicht mehr in der Quell CSV Datei auftauchen
|
||||||
foreach (int deleteId in deleteIds)
|
foreach (int deleteId in deleteIds)
|
||||||
{
|
{
|
||||||
delCmd.Parameters.AddWithValue("@DELID", deleteId);
|
delIdParam.Value = deleteId;
|
||||||
if (delCmd.ExecuteNonQuery() != 1)
|
if (delCmd.ExecuteNonQuery() != 1)
|
||||||
_log.WarnFormat("{0} affected no rows", deleteId);
|
_log.WarnFormat("{0} affected no rows", deleteId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,6 +38,7 @@ namespace bsmd.database
|
|||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
private static readonly Dictionary<MappingType, Dictionary<string, ValueMapping>> _dicts = new Dictionary<MappingType, Dictionary<string, ValueMapping>>();
|
private static readonly Dictionary<MappingType, Dictionary<string, ValueMapping>> _dicts = new Dictionary<MappingType, Dictionary<string, ValueMapping>>();
|
||||||
|
private static Dictionary<MappingType, List<string>> _invalidKeys = null;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -48,6 +49,22 @@ namespace bsmd.database
|
|||||||
get { return _dicts; }
|
get { return _dicts; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Dictionary<MappingType, List<string>> InvalidKeys
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_invalidKeys == null)
|
||||||
|
{
|
||||||
|
_invalidKeys = new Dictionary<MappingType, List<string>>();
|
||||||
|
// get the keys initialized that cannot be assigned
|
||||||
|
foreach (MappingType type in Enum.GetValues(typeof(MappingType)))
|
||||||
|
_invalidKeys[type] = new List<string>();
|
||||||
|
_invalidKeys[MappingType.COUNTRY].Add("UK");
|
||||||
|
}
|
||||||
|
return _invalidKeys;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public MappingType EntryType { get; private set; }
|
public MappingType EntryType { get; private set; }
|
||||||
|
|
||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
|
|||||||
BIN
misc/db.sqlite
BIN
misc/db.sqlite
Binary file not shown.
Loading…
Reference in New Issue
Block a user