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

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

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