some minor optimizations of the interface

pull/1/head
DJh2o2 2022-03-14 20:14:12 +07:00
parent 75e7123bf6
commit 3a2d6c257f
4 changed files with 179 additions and 181 deletions

@ -288,7 +288,7 @@ namespace Gremlin.GremlinData.DBClasses
ImportProducts(mappingTable);
break;
case "CustomDescription":
ImportCustomDescriptions(mappingTable);
ImportCustomDescriptions();// mappingTable);
break;
default:
return false;
@ -303,7 +303,7 @@ namespace Gremlin.GremlinData.DBClasses
return ImportFile();
}
private static bool ImportCustomDescriptions(Dictionary<string, int> mappingTable)
private static bool ImportCustomDescriptions()//Dictionary<string, int> mappingTable)
{
List<CustomDescription> CDsReadFromFile = new(2500);
Encoding = Encoding.GetEncoding("UTF-8"); //Custom-Descriptions-CSV hat festes Encoding.
@ -987,36 +987,36 @@ namespace Gremlin.GremlinData.DBClasses
return true;
}
private static void SetProperty(object gremlinEntity, PropertyInfo propertyInfo, string value)
{
propertyInfo.SetValue(gremlinEntity, value);
}
//private static void SetProperty(object gremlinEntity, PropertyInfo propertyInfo, string value)
//{
// propertyInfo.SetValue(gremlinEntity, value);
//}
private static Array GetNewGremlinTypeArray(Assembly assembly, string detectedDataType, int length)
{
Type GremlinType = GetNewGremlinType(assembly, detectedDataType).GetType();
//Create an one-dimensional array with n+1 or n+2 elements (n = number of datasets, plus heading and/or emptyline at EOF):
return Array.CreateInstance(GremlinType, length);
//private static Array GetNewGremlinTypeArray(Assembly assembly, string detectedDataType, int length)
//{
// Type GremlinType = GetNewGremlinType(assembly, detectedDataType).GetType();
// //Create an one-dimensional array with n+1 or n+2 elements (n = number of datasets, plus heading and/or emptyline at EOF):
// return Array.CreateInstance(GremlinType, length);
//Das geht alles nicht:
//List<GremlinType> test = new();
//List<typeof(GremlinType)> test = new();
//List<GremlinType.GetType()> test = new();
// //Das geht alles nicht:
// //List<GremlinType> test = new();
// //List<typeof(GremlinType)> test = new();
// //List<GremlinType.GetType()> test = new();
////Das geht:
////Create iList:
//Type listType = typeof(List<>).MakeGenericType(GremlinType);
//var list = (IList)Activator.CreateInstance(listType);
//list.Add(new Account() { AccountName = "Test" });
//list.Add(GremlinClassObject);
// ////Das geht:
// ////Create iList:
// //Type listType = typeof(List<>).MakeGenericType(GremlinType);
// //var list = (IList)Activator.CreateInstance(listType);
// //list.Add(new Account() { AccountName = "Test" });
// //list.Add(GremlinClassObject);
}
//}
private static object GetNewGremlinType(Assembly Gremlin, string detectedDataType)
{
return Activator.CreateInstance(Gremlin.ToString(), "Gremlin." + detectedDataType).Unwrap();
}
//private static object GetNewGremlinType(Assembly Gremlin, string detectedDataType)
//{
// return Activator.CreateInstance(Gremlin.ToString(), "Gremlin." + detectedDataType).Unwrap();
//}
public static Dictionary<string, string> ReadMappingDictionaryFromFile()
{
@ -1053,171 +1053,171 @@ namespace Gremlin.GremlinData.DBClasses
return result;
}
private static void BasimodosCodeDump()
{
//Unfertiger, generischer Code aus der ImportFile() Methode.
//Aufbewahren für später, wenn Zeit ist, das ordentlich zu machen.
//private static void BasimodosCodeDump()
//{
// //Unfertiger, generischer Code aus der ImportFile() Methode.
// //Aufbewahren für später, wenn Zeit ist, das ordentlich zu machen.
//while (!csvParser.EndOfData)
//{
// //read
// //new data instance
// //convert
// //validate
// //set metadata: SetMetadataForImport(IMetadata)
// //add to list
// //while (!csvParser.EndOfData)
// //{
// // //read
// // //new data instance
// // //convert
// // //validate
// // //set metadata: SetMetadataForImport(IMetadata)
// // //add to list
// 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.
// // 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).
// // //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;
// // 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();
// // Array GremlinTypeArray = GetNewGremlinTypeArray(Gremlin, detectedDataType, numberOfLines);
// // Type GremlinType = GetNewGremlinType(Gremlin, detectedDataType).GetType();
// // PropertyInfo[] GremlinTypeProperties = GremlinType.GetProperties();
// foreach (PropertyInfo property in GremlinTypeProperties)
// {
// if (mappingTable.TryGetValue(property.Name, out int columnNumber))
// {
// //convert:
// GremlinTypeConverter.Convert(fields[columnNumber]);
// }
// }
// }
// // foreach (PropertyInfo property in GremlinTypeProperties)
// // {
// // if (mappingTable.TryGetValue(property.Name, out int columnNumber))
// // {
// // //convert:
// // GremlinTypeConverter.Convert(fields[columnNumber]);
// // }
// // }
// // }
//}
// //}
//using (GremlinContext db = new())
//{
// //add to context
// //savechanges
// //using (GremlinContext db = new())
// //{
// // //add to context
// // //savechanges
// //}
//}
}
//#########################################################################################
//Kann gelöscht werden, sobald die generische Funktion zuverlässig funktioniert:
//#########################################################################################
private static string RecognizeDataStatic(Dictionary<string, int> mappingDictionary)
{
//Logik zur Kategorisierung des Datensatzes:
//Alle verpflichtenden Angaben zu einer Klasse vorhanen?
//Alle vom Importer erwarteten Angaben vorhanden?
//Bei den Enums zusätzlich noch proüfem, dass nur zwei Spalten vorhanden sind, sonst könnten LSAG-Daten falsch identifiziert werden.
//
//
//Products
if (//required by DB:
mappingDictionary.ContainsKey("ProductNumber")
&& mappingDictionary.ContainsKey("ListPrice")
//required by importer:
&& mappingDictionary.ContainsKey("Weight")
//unique identifier:
&& mappingDictionary.ContainsKey("BreakRangeFrom")
)
{
return "Product";
}
//LSAG Contact List Tool List
if (//required by DB:
mappingDictionary.ContainsKey("SAPAccountNumber")
&& mappingDictionary.ContainsKey("SAPContactNumber")
&& mappingDictionary.ContainsKey("AccountTypeCode")
&& mappingDictionary.ContainsKey("SubMarketCode")
&& mappingDictionary.ContainsKey("LastName")
&& mappingDictionary.ContainsKey("AccountName")
//required by importer:
//private static string RecognizeDataStatic(Dictionary<string, int> mappingDictionary)
//{
// //Logik zur Kategorisierung des Datensatzes:
// //Alle verpflichtenden Angaben zu einer Klasse vorhanen?
// //Alle vom Importer erwarteten Angaben vorhanden?
// //Bei den Enums zusätzlich noch proüfem, dass nur zwei Spalten vorhanden sind, sonst könnten LSAG-Daten falsch identifiziert werden.
// //
// //
// //Products
// if (//required by DB:
// mappingDictionary.ContainsKey("ProductNumber")
// && mappingDictionary.ContainsKey("ListPrice")
// //required by importer:
// && mappingDictionary.ContainsKey("Weight")
// //unique identifier:
// && mappingDictionary.ContainsKey("BreakRangeFrom")
// )
// {
// return "Product";
// }
//unique identifier:
&& mappingDictionary.ContainsKey("MA_ProductInterests")
)
{
return "LSAG Contact List Tool List";
}
// //LSAG Contact List Tool List
// if (//required by DB:
// mappingDictionary.ContainsKey("SAPAccountNumber")
// && mappingDictionary.ContainsKey("SAPContactNumber")
// && mappingDictionary.ContainsKey("AccountTypeCode")
// && mappingDictionary.ContainsKey("SubMarketCode")
// && mappingDictionary.ContainsKey("LastName")
// && mappingDictionary.ContainsKey("AccountName")
// //required by importer:
// //unique identifier:
// && mappingDictionary.ContainsKey("MA_ProductInterests")
// )
// {
// return "LSAG Contact List Tool List";
// }
//Accounts
if (//required by DB:
mappingDictionary.ContainsKey("AccountName")
&& mappingDictionary.ContainsKey("Street")
&& mappingDictionary.ContainsKey("ZIP")
&& mappingDictionary.ContainsKey("City")
&& mappingDictionary.ContainsKey("PhoneNumber")
&& mappingDictionary.ContainsKey("SAPAccountNumber")
&& mappingDictionary.ContainsKey("AccountCreatedInSAPOn")
&& mappingDictionary.ContainsKey("AccountTypeCode")
&& mappingDictionary.ContainsKey("SubMarketCode")
//required by importer:
)
{
return "Account";
}
// //Accounts
// if (//required by DB:
// mappingDictionary.ContainsKey("AccountName")
// && mappingDictionary.ContainsKey("Street")
// && mappingDictionary.ContainsKey("ZIP")
// && mappingDictionary.ContainsKey("City")
// && mappingDictionary.ContainsKey("PhoneNumber")
// && mappingDictionary.ContainsKey("SAPAccountNumber")
// && mappingDictionary.ContainsKey("AccountCreatedInSAPOn")
// && mappingDictionary.ContainsKey("AccountTypeCode")
// && mappingDictionary.ContainsKey("SubMarketCode")
// //required by importer:
// )
// {
// return "Account";
// }
//Contacts
if (//required by DB:
mappingDictionary.ContainsKey("LastName")
&& mappingDictionary.ContainsKey("SAPContactNumber")
//required by importer:
&& mappingDictionary.ContainsKey("FirstName")
&& mappingDictionary.ContainsKey("Gender")
)
{
return "Contact";
}
// //Contacts
// if (//required by DB:
// mappingDictionary.ContainsKey("LastName")
// && mappingDictionary.ContainsKey("SAPContactNumber")
// //required by importer:
// && mappingDictionary.ContainsKey("FirstName")
// && mappingDictionary.ContainsKey("Gender")
// )
// {
// return "Contact";
// }
//Custom Description
if (//required by DB:
mappingDictionary.ContainsKey("Heading")
//required by importer:
&& mappingDictionary.ContainsKey("ProductNumber")
&& mappingDictionary.ContainsKey("OptionNumber")
&& mappingDictionary.ContainsKey("DescriptionText")
//unique identifier:
&& mappingDictionary.ContainsKey("CoverletterText")
)
{
return "CustomDescription";
}
// //Custom Description
// if (//required by DB:
// mappingDictionary.ContainsKey("Heading")
// //required by importer:
// && mappingDictionary.ContainsKey("ProductNumber")
// && mappingDictionary.ContainsKey("OptionNumber")
// && mappingDictionary.ContainsKey("DescriptionText")
// //unique identifier:
// && mappingDictionary.ContainsKey("CoverletterText")
// )
// {
// return "CustomDescription";
// }
//Pseudo-Enums AccountTypes, SubMarkets, ProductLines for DB-initializing
if (mappingDictionary.Count == 2)
{
if (mappingDictionary.ContainsKey("AccountTypeCode")
&& mappingDictionary.ContainsKey("AccountTypeDescription")
&& mappingDictionary.Count == 2)
{
return "AccountType";
}
// //Pseudo-Enums AccountTypes, SubMarkets, ProductLines for DB-initializing
// if (mappingDictionary.Count == 2)
// {
// if (mappingDictionary.ContainsKey("AccountTypeCode")
// && mappingDictionary.ContainsKey("AccountTypeDescription")
// && mappingDictionary.Count == 2)
// {
// return "AccountType";
// }
if (mappingDictionary.ContainsKey("SubMarketCode")
&& mappingDictionary.ContainsKey("SubMarketDescription")
&& mappingDictionary.Count == 2)
{
return "SubMarket";
}
// if (mappingDictionary.ContainsKey("SubMarketCode")
// && mappingDictionary.ContainsKey("SubMarketDescription")
// && mappingDictionary.Count == 2)
// {
// return "SubMarket";
// }
if (mappingDictionary.ContainsKey("ProductLineCode")
&& mappingDictionary.ContainsKey("ProductLineDescription")
&& mappingDictionary.Count == 2)
{
return "ProductLine";
}
}
// if (mappingDictionary.ContainsKey("ProductLineCode")
// && mappingDictionary.ContainsKey("ProductLineDescription")
// && mappingDictionary.Count == 2)
// {
// return "ProductLine";
// }
// }
return "No entity type unambigiously identified!";
// return "No entity type unambigiously identified!";
}
//}
}
}

@ -26,7 +26,7 @@ namespace Gremlin.MVVM
private static void WriteTextToFile(StringBuilder texFile, string datei)
{
using (StreamWriter writer = new(datei, false, Encoding.UTF8))
using StreamWriter writer = new(datei, false, Encoding.UTF8);
{
writer.WriteLine(texFile.ToString());
}

@ -96,8 +96,8 @@
x:Name="LineItemsVM"
AutoGenerateColumns="True"
CanUserAddRows="False"
Height="300"
Width ="1280"
MinHeight="300"
MaxHeight="600"
Margin="10,5,10,5"
AlternatingRowBackground="LightGray"
/>

@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cal="http://www.caliburnproject.org"
xmlns:local="clr-namespace:Gremlin.MVVM" xmlns:local1="clr-namespace:Gremlin.MVVM.Views">
xmlns:local="clr-namespace:Gremlin.MVVM">
<StackPanel Orientation="Vertical">
<TextBox x:Name="SearchContact" Margin="10,5,10,5"/>
<DataGrid
@ -12,9 +12,7 @@
SelectionMode="Single"
SelectedItem="SelectedContact"
MaxHeight="200"
Width ="1280"
Margin="10,5,10,5"
/>
Margin="10,5,10,5"/>
<!--<local1:ContactView cal:Bind.Model="{Binding ContactsVM}"/>-->
<local:QuoteView cal:Bind.Model="{Binding QuoteVM}"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">