[fix:] integrated refsid to data import
This commit is contained in:
@@ -116,6 +116,8 @@ public class DataImport
|
||||
.Where(p => p.PropertyType == typeof(bool) && p.Name.StartsWith("has_", StringComparison.OrdinalIgnoreCase))
|
||||
.ToArray();
|
||||
|
||||
var last_refsid = 1000000;
|
||||
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
var line = reader.ReadLine();
|
||||
@@ -126,10 +128,14 @@ public class DataImport
|
||||
|
||||
var fieldValues = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var refsid_existing = false;
|
||||
|
||||
foreach (var hasProp in hasProperties)
|
||||
{
|
||||
var fieldName = hasProp.Name.Substring(4);
|
||||
|
||||
if (fieldName == "refsid") refsid_existing = true;
|
||||
|
||||
var hasObj = hasProp.GetValue(patch);
|
||||
var has = hasObj is bool b && b;
|
||||
|
||||
@@ -172,10 +178,16 @@ public class DataImport
|
||||
return fieldValues.TryGetValue(name, out var v) ? v : "";
|
||||
}
|
||||
|
||||
var new_refsid = 0;
|
||||
if (!refsid_existing)
|
||||
new_refsid = GenerateNewRefsid();
|
||||
else
|
||||
new_refsid = ParseInt(GetField("refsid"));
|
||||
|
||||
try
|
||||
{
|
||||
var person = new KasPerson(
|
||||
ParseInt(GetField("refsid")),
|
||||
new_refsid,
|
||||
GetField("anrede"),
|
||||
GetField("titel"),
|
||||
GetField("vorname"),
|
||||
@@ -212,6 +224,12 @@ public class DataImport
|
||||
}
|
||||
|
||||
return (true, imported);
|
||||
|
||||
int GenerateNewRefsid()
|
||||
{
|
||||
last_refsid++;
|
||||
return last_refsid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user