pull/1/head
Basimodo 2021-06-11 09:51:34 +07:00
parent 55589929b9
commit 3fc8987dd2
3 changed files with 20 additions and 9 deletions

@ -25,7 +25,7 @@ namespace Gremlin.GremlinData.DBClasses
internal static class DbHelper
{
private static readonly DateTime FarInTheFuture = DateTime.Parse("2050-12-31t00:00:00.000000z", CultureInfo.CurrentCulture);
static ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = Environment.ProcessorCount };
static readonly ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = Environment.ProcessorCount };
public static bool CheckDatabaseConnection(string connectionString)
{

@ -10,12 +10,13 @@ using static Gremlin.Context;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Windows;
namespace Gremlin.GremlinData.DBClasses
{
public class GenericImporter
{
private TextFieldParser _csvParser;
private readonly TextFieldParser _csvParser;
public GenericImporter()
{
@ -52,10 +53,13 @@ namespace Gremlin.GremlinData.DBClasses
DataIdentificator dataIdentificator = new(mappingTable);
List<string> detectedDataTypes = dataIdentificator.Identify();
//TO DO: check for detectedDataTypes = empty (= dataset matches all qualifiers of a type)
//check for detectedDataTypes = empty (possible when DataIdentificator.Identify(MustMatchAllQualifer = true) and no dataset matches all qualifiers of a type)
if (detectedDataTypes.Count == 0)
{
MessageBox.Show($"DataIdentificator.Identify() konnte die Datenart nicht bestimmen!{Environment.NewLine}Versuchen Sie den Import mit einer dezidierten Importerfunktion.");
return false;
}
while (!csvParser.EndOfData)
{
//read
@ -68,15 +72,22 @@ namespace Gremlin.GremlinData.DBClasses
fields = csvParser.ReadFields(); // Read current line fields, pointer moves to the next line.
if (fields[0] == "") break; // Am Ende hängt eine leere Zeile, die im Parser einen Fehler auslösen würde.
//TO DO: vor der foreach "Account" bevorzugt behandeln (Sonderfall bei LSAG: Liste deduplizieren, und als erstes importieren, da sonst keine Contacts importiert werden können).
foreach (string detectedDataType in detectedDataTypes)
{
//"Account" überspringen, da das vor der foreach schon verarbeitet worden ist.
if (detectedDataType == "Account") continue;
Array GremlinTypeArray = GetNewGremlinTypeArray(Gremlin, detectedDataType, numberOfLines);
Type GremlinType = GetNewGremlinType(Gremlin, detectedDataType).GetType();
PropertyInfo[] GremlinTypeProperties = GremlinType.GetProperties();
int columnNumber;
foreach (PropertyInfo property in GremlinTypeProperties)
{
if (mappingTable.TryGetValue(property.Name, out columnNumber))
if (mappingTable.TryGetValue(property.Name, out int columnNumber))
{
//convert:
GremlinTypeConverter.Convert(fields[columnNumber]);

@ -37,7 +37,7 @@ namespace Gremlin.GremlinUtilities.GUClasses
{
_dataType = DataType;
_qualifiers = Qualifiers.ToList();
_numberOfQualifiers = _qualifiers.Count();
_numberOfQualifiers = _qualifiers.Count;
_matchedQualifiers = new();
}
@ -45,7 +45,7 @@ namespace Gremlin.GremlinUtilities.GUClasses
{
_matchedQualifiers.Add(QualifierFound);
_score++;
_allQualifierMatched = (_matchedQualifiers.Count == _qualifiers.Count) ? true : false;
_allQualifierMatched = (_matchedQualifiers.Count == _numberOfQualifiers);
}
public bool CheckForQualifier(string qualifier)