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