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>
|
||||
public partial class ValueMappingsControl : UserControl
|
||||
{
|
||||
private ObservableCollection<ValueMapping> _mappings = new ObservableCollection<ValueMapping>();
|
||||
private readonly ObservableCollection<ValueMapping> _mappings = new ObservableCollection<ValueMapping>();
|
||||
private DataGridCellInfo activeCellAtEdit;
|
||||
|
||||
public ValueMappingsControl()
|
||||
@ -58,14 +58,13 @@ namespace ENI2.Controls
|
||||
|
||||
private async void DelItem_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ValueMapping vm = this.dataGridValueMappings.SelectedItem as ValueMapping;
|
||||
if(vm != null)
|
||||
if (this.dataGridValueMappings.SelectedItem is ValueMapping vm)
|
||||
{
|
||||
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)
|
||||
{
|
||||
int result = await DBManagerAsync.DeleteAsync(vm);
|
||||
if(result == 1)
|
||||
if (result == 1)
|
||||
{
|
||||
_mappings.Remove(vm);
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup />
|
||||
<PropertyGroup>
|
||||
<ManifestCertificateThumbprint>F2C2D0164244EC89955EF50201EE24C2A300FF0B</ManifestCertificateThumbprint>
|
||||
<ManifestCertificateThumbprint>62DE8527C377957850DB503DA52FF66F664BD459</ManifestCertificateThumbprint>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignManifests>true</SignManifests>
|
||||
|
||||
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using System.Data;
|
||||
using System.Data.SQLite;
|
||||
using log4net;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
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 });
|
||||
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);
|
||||
int updateCnt = 0, insertCnt = 0;
|
||||
|
||||
for (int i = 0; i < csvLines.Length; i++)
|
||||
{
|
||||
string line = csvLines[i];
|
||||
string[] elems = line.Split(',');
|
||||
string[] elems = Regex.Split(line, ",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");
|
||||
if (elems.Length < 12) continue;
|
||||
string country = elems[1].Trim().Replace("\"", "");
|
||||
if (country.Length < 2) continue;
|
||||
@ -100,12 +106,30 @@ namespace bsmd.Tool
|
||||
lcode.Value = code;
|
||||
|
||||
// Eingabeformat: https://service.unece.org/trade/locode/Service/LocodeColumn.htm
|
||||
|
||||
object lookupResult = lookupCmd.ExecuteScalar();
|
||||
if ((lookupResult != null) && (lookupResult != DBNull.Value))
|
||||
int? lid = null;
|
||||
using (SQLiteDataReader lookupReader = lookupCmd.ExecuteReader())
|
||||
{
|
||||
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)
|
||||
{
|
||||
int lid = Convert.ToInt32(lookupResult);
|
||||
|
||||
p3.Value = elems[3].Trim().Replace("\"", "");
|
||||
p4.Value = elems[4].Trim().Replace("\"", "");
|
||||
p5.Value = elems[5].Trim().Replace("\"", "");
|
||||
@ -181,13 +205,11 @@ namespace bsmd.Tool
|
||||
}
|
||||
|
||||
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
|
||||
foreach (int deleteId in deleteIds)
|
||||
{
|
||||
delCmd.Parameters.AddWithValue("@DELID", deleteId);
|
||||
delIdParam.Value = deleteId;
|
||||
if (delCmd.ExecuteNonQuery() != 1)
|
||||
_log.WarnFormat("{0} affected no rows", deleteId);
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ namespace bsmd.database
|
||||
#region Fields
|
||||
|
||||
private static readonly Dictionary<MappingType, Dictionary<string, ValueMapping>> _dicts = new Dictionary<MappingType, Dictionary<string, ValueMapping>>();
|
||||
private static Dictionary<MappingType, List<string>> _invalidKeys = null;
|
||||
|
||||
#endregion
|
||||
|
||||
@ -48,6 +49,22 @@ namespace bsmd.database
|
||||
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 string Key { get; set; }
|
||||
|
||||
BIN
misc/db.sqlite
BIN
misc/db.sqlite
Binary file not shown.
Loading…
Reference in New Issue
Block a user