pull/1/head
DJh2o2 2023-01-09 09:27:55 +07:00
parent 3f306ea592
commit d8adbe7aab
19 changed files with 56 additions and 58 deletions

@ -1,5 +1,3 @@
// using DocumentFormat.OpenXml.Packaging;
// using DocumentFormat.OpenXml.Wordprocessing;
using Gremlin_BlazorServer.Data.EntityClasses; using Gremlin_BlazorServer.Data.EntityClasses;
using Gremlin_BlazorServer.Services; using Gremlin_BlazorServer.Services;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -26,7 +24,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
try try
{ {
mySqlConnection = new MySqlConnection(connectionString); mySqlConnection = new(connectionString);
mySqlConnection.Open(); mySqlConnection.Open();
isConnected = true; isConnected = true;
} }
@ -172,11 +170,11 @@ namespace Gremlin_BlazorServer.Data.DBClasses
EMail = "CustomerCare_Germany@agilent.com", EMail = "CustomerCare_Germany@agilent.com",
PhoneNumber = "+49 800 6031000", PhoneNumber = "+49 800 6031000",
DataStatus = Status.Active.ToString(), DataStatus = Status.Active.ToString(),
AccountType = new AccountType() AccountType = new()
{ {
AccountTypeCode = "SUP" AccountTypeCode = "SUP"
}, },
SubMarket = new SubMarket() SubMarket = new()
{ {
SubMarketCode = "VEN" SubMarketCode = "VEN"
} }
@ -194,11 +192,11 @@ namespace Gremlin_BlazorServer.Data.DBClasses
EMail = "", EMail = "",
PhoneNumber = "+44 1354 694377", PhoneNumber = "+44 1354 694377",
DataStatus = Status.Active.ToString(), DataStatus = Status.Active.ToString(),
AccountType = new AccountType() AccountType = new()
{ {
AccountTypeCode = "SUP" AccountTypeCode = "SUP"
}, },
SubMarket = new SubMarket() SubMarket = new()
{ {
SubMarketCode = "VAR" SubMarketCode = "VAR"
} }
@ -216,11 +214,11 @@ namespace Gremlin_BlazorServer.Data.DBClasses
EMail = "sales@huber-online.com", EMail = "sales@huber-online.com",
PhoneNumber = "0781 96030", PhoneNumber = "0781 96030",
DataStatus = Status.Active.ToString(), DataStatus = Status.Active.ToString(),
AccountType = new AccountType() AccountType = new()
{ {
AccountTypeCode = "SUP" AccountTypeCode = "SUP"
}, },
SubMarket = new SubMarket() SubMarket = new()
{ {
SubMarketCode = "SUP" SubMarketCode = "SUP"
} }
@ -238,11 +236,11 @@ namespace Gremlin_BlazorServer.Data.DBClasses
EMail = "info@vdh-online.com", EMail = "info@vdh-online.com",
PhoneNumber = "05265 945520", PhoneNumber = "05265 945520",
DataStatus = Status.Active.ToString(), DataStatus = Status.Active.ToString(),
AccountType = new AccountType() AccountType = new()
{ {
AccountTypeCode = "SUP" AccountTypeCode = "SUP"
}, },
SubMarket = new SubMarket() SubMarket = new()
{ {
SubMarketCode = "SUP" SubMarketCode = "SUP"
} }
@ -260,11 +258,11 @@ namespace Gremlin_BlazorServer.Data.DBClasses
EMail = "", EMail = "",
PhoneNumber = "+45 36 78 41 85", PhoneNumber = "+45 36 78 41 85",
DataStatus = Status.Active.ToString(), DataStatus = Status.Active.ToString(),
AccountType = new AccountType() AccountType = new()
{ {
AccountTypeCode = "SUP" AccountTypeCode = "SUP"
}, },
SubMarket = new SubMarket() SubMarket = new()
{ {
SubMarketCode = "SUP" SubMarketCode = "SUP"
} }
@ -283,11 +281,11 @@ namespace Gremlin_BlazorServer.Data.DBClasses
PhoneNumber = "07551 932696", PhoneNumber = "07551 932696",
FaxNumber = "07551-932699", FaxNumber = "07551-932699",
DataStatus = Status.Active.ToString(), DataStatus = Status.Active.ToString(),
AccountType = new AccountType() AccountType = new()
{ {
AccountTypeCode = "SUP" AccountTypeCode = "SUP"
}, },
SubMarket = new SubMarket() SubMarket = new()
{ {
SubMarketCode = "SUP" SubMarketCode = "SUP"
} }
@ -305,11 +303,11 @@ namespace Gremlin_BlazorServer.Data.DBClasses
EMail = "info.de@hellma.com", EMail = "info.de@hellma.com",
PhoneNumber = "07631 1820", PhoneNumber = "07631 1820",
DataStatus = Status.Active.ToString(), DataStatus = Status.Active.ToString(),
AccountType = new AccountType() AccountType = new()
{ {
AccountTypeCode = "SUP" AccountTypeCode = "SUP"
}, },
SubMarket = new SubMarket() SubMarket = new()
{ {
SubMarketCode = "SUP" SubMarketCode = "SUP"
} }
@ -327,11 +325,11 @@ namespace Gremlin_BlazorServer.Data.DBClasses
EMail = "", EMail = "",
PhoneNumber = "-/-", PhoneNumber = "-/-",
DataStatus = Status.Active.ToString(), DataStatus = Status.Active.ToString(),
AccountType = new AccountType() AccountType = new()
{ {
AccountTypeCode = "SUP" AccountTypeCode = "SUP"
}, },
SubMarket = new SubMarket() SubMarket = new()
{ {
SubMarketCode = "SUP" SubMarketCode = "SUP"
} }
@ -350,11 +348,11 @@ namespace Gremlin_BlazorServer.Data.DBClasses
PhoneNumber = "+1 608 274 2721", PhoneNumber = "+1 608 274 2721",
FaxNumber = "+1 608 274 0103", FaxNumber = "+1 608 274 0103",
DataStatus = Status.Active.ToString(), DataStatus = Status.Active.ToString(),
AccountType = new AccountType() AccountType = new()
{ {
AccountTypeCode = "SUP" AccountTypeCode = "SUP"
}, },
SubMarket = new SubMarket() SubMarket = new()
{ {
SubMarketCode = "SUP" SubMarketCode = "SUP"
} }
@ -614,7 +612,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
int year = Convert.ToInt32(fields[12].Substring(0, 4), CultureInfo.CurrentCulture); int year = Convert.ToInt32(fields[12].Substring(0, 4), CultureInfo.CurrentCulture);
int month = Convert.ToInt32(fields[12].Substring(4, 2), CultureInfo.CurrentCulture); int month = Convert.ToInt32(fields[12].Substring(4, 2), CultureInfo.CurrentCulture);
int day = Convert.ToInt32(fields[12].Substring(6, 2), CultureInfo.CurrentCulture); int day = Convert.ToInt32(fields[12].Substring(6, 2), CultureInfo.CurrentCulture);
importedContact.SapContactCreationDate = new DateTime(year, month, day); importedContact.SapContactCreationDate = new(year, month, day);
//Convert "No Phone Calls" //Convert "No Phone Calls"
if (fields[26] == "1") if (fields[26] == "1")
@ -766,7 +764,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
int year = Convert.ToInt32(fields[8].Substring(0, 4)); int year = Convert.ToInt32(fields[8].Substring(0, 4));
int month = Convert.ToInt32(fields[8].Substring(4, 2)); int month = Convert.ToInt32(fields[8].Substring(4, 2));
int day = Convert.ToInt32(fields[8].Substring(6, 2)); int day = Convert.ToInt32(fields[8].Substring(6, 2));
importedAccount.AccountCreatedInSapOn = new DateTime(year, month, day); importedAccount.AccountCreatedInSapOn = new(year, month, day);
} }
//keine Konvertierung nötig: //keine Konvertierung nötig:
@ -939,7 +937,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
int year = Convert.ToInt32(fields[columnNumberOf["AccountCreatedInSAPOn"]].Substring(0, 4)); int year = Convert.ToInt32(fields[columnNumberOf["AccountCreatedInSAPOn"]].Substring(0, 4));
int month = Convert.ToInt32(fields[columnNumberOf["AccountCreatedInSAPOn"]].Substring(4, 2)); int month = Convert.ToInt32(fields[columnNumberOf["AccountCreatedInSAPOn"]].Substring(4, 2));
int day = Convert.ToInt32(fields[columnNumberOf["AccountCreatedInSAPOn"]].Substring(6, 2)); int day = Convert.ToInt32(fields[columnNumberOf["AccountCreatedInSAPOn"]].Substring(6, 2));
importedAccount.AccountCreatedInSapOn = new DateTime(year, month, day); importedAccount.AccountCreatedInSapOn = new(year, month, day);
//Convert City von Großschreibung zu Normalschreibung //Convert City von Großschreibung zu Normalschreibung
importedAccount.City = fields[columnNumberOf["City"]].First().ToString() + fields[columnNumberOf["City"]].Substring(1).ToLower(); importedAccount.City = fields[columnNumberOf["City"]].First().ToString() + fields[columnNumberOf["City"]].Substring(1).ToLower();
@ -1029,7 +1027,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
year = Convert.ToInt32(fields[columnNumberOf["AccountCreatedInSAPOn"]].Substring(0, 4)); year = Convert.ToInt32(fields[columnNumberOf["AccountCreatedInSAPOn"]].Substring(0, 4));
month = Convert.ToInt32(fields[columnNumberOf["AccountCreatedInSAPOn"]].Substring(4, 2)); month = Convert.ToInt32(fields[columnNumberOf["AccountCreatedInSAPOn"]].Substring(4, 2));
day = Convert.ToInt32(fields[columnNumberOf["AccountCreatedInSAPOn"]].Substring(6, 2)); day = Convert.ToInt32(fields[columnNumberOf["AccountCreatedInSAPOn"]].Substring(6, 2));
importedContact.SapContactCreationDate = new DateTime(year, month, day); importedContact.SapContactCreationDate = new(year, month, day);
//Convert "No Phone Calls" //Convert "No Phone Calls"
if (fields[columnNumberOf["NoPhoneCalls"]] == "1") if (fields[columnNumberOf["NoPhoneCalls"]] == "1")
@ -1899,72 +1897,72 @@ namespace Gremlin_BlazorServer.Data.DBClasses
public static Account ResolveAccountByName(GremlinContext context, string accountName) public static Account ResolveAccountByName(GremlinContext context, string accountName)
{ {
try { return context.Accounts.Include(account => account.AccountType).Include(account => account.SubMarket).First(account => account.AccountName == accountName); } try { return context.Accounts.Include(account => account.AccountType).Include(account => account.SubMarket).First(account => account.AccountName == accountName); }
catch { return new Account(); } catch { return new(); }
} }
public static Account ResolveAccountById(GremlinContext context, uint accountId) public static Account ResolveAccountById(GremlinContext context, uint accountId)
{ {
try { return context.Accounts.First(account => account.SapAccountNumber == accountId); } try { return context.Accounts.First(account => account.SapAccountNumber == accountId); }
catch { return new Account(); } catch { return new(); }
} }
public static Account ResolveAccountById(GremlinContext context, string accountId) public static Account ResolveAccountById(GremlinContext context, string accountId)
{ {
try { return context.Accounts.First(account => account.SapAccountNumber == Convert.ToUInt32(accountId)); } try { return context.Accounts.First(account => account.SapAccountNumber == Convert.ToUInt32(accountId)); }
catch { return new Account(); } catch { return new(); }
} }
public static AccountType ResolveAccountType(GremlinContext context, string accountTypeCode) public static AccountType ResolveAccountType(GremlinContext context, string accountTypeCode)
{ {
try { return context.AccountTypes.First(account => account.AccountTypeCode == accountTypeCode); } try { return context.AccountTypes.First(account => account.AccountTypeCode == accountTypeCode); }
catch { return new AccountType(); } catch { return new(); }
} }
public static SubMarket ResolveSubmarket(GremlinContext context, string subMarketCode) public static SubMarket ResolveSubmarket(GremlinContext context, string subMarketCode)
{ {
try { return context.SubMarkets.First(submarket => submarket.SubMarketCode == subMarketCode); } try { return context.SubMarkets.First(submarket => submarket.SubMarketCode == subMarketCode); }
catch { return new SubMarket(); } catch { return new(); }
} }
public static Product GetProduct(GremlinContext context, string productNumber, string optionNumber) public static Product GetProduct(GremlinContext context, string productNumber, string optionNumber)
{ {
try { return context.Products.Include(product => product.ProductLine).Include(product => product.CustomDescription).First(product => product.ProductNumber == productNumber && product.OptionNumber == optionNumber); } try { return context.Products.Include(product => product.ProductLine).Include(product => product.CustomDescription).First(product => product.ProductNumber == productNumber && product.OptionNumber == optionNumber); }
catch { return new Product(); } catch { return new(); }
} }
public static Product ResolveProduct(GremlinContext context, string productNumber, string option) public static Product ResolveProduct(GremlinContext context, string productNumber, string option)
{ {
try { return context.Products.First(product => product.ProductNumber == productNumber && product.OptionNumber == option); } try { return context.Products.First(product => product.ProductNumber == productNumber && product.OptionNumber == option); }
catch { return new Product(); } catch { return new(); }
} }
public static ProductLine ResolveProductLine(GremlinContext context, string productLineCode) public static ProductLine ResolveProductLine(GremlinContext context, string productLineCode)
{ {
try { return context.ProductLines.First(productline => productline.ProductLineCode == productLineCode); } try { return context.ProductLines.First(productline => productline.ProductLineCode == productLineCode); }
catch { return new ProductLine(); } catch { return new(); }
} }
private static string RandomString(int length) private static string RandomString(int length)
{ {
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
return new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray()); return new(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
} }
public static Contact GetContact(GremlinContext context, string lastName) public static Contact GetContact(GremlinContext context, string lastName)
{ {
try { return context.Contacts.First(contact => contact.LastName == lastName); } try { return context.Contacts.First(contact => contact.LastName == lastName); }
catch { return new Contact(); } catch { return new(); }
} }
public static Contact GetContact(GremlinContext context, uint contactId) public static Contact GetContact(GremlinContext context, uint contactId)
{ {
try { return context.Contacts.First(contact => contact.ContactId == contactId); } try { return context.Contacts.First(contact => contact.ContactId == contactId); }
catch { return new Contact(); } catch { return new(); }
} }
internal static List<Contact> GetAllContacts(GremlinContext context) internal static List<Contact> GetAllContacts(GremlinContext context)
{ {
try { return context.Contacts.Where(contact => contact.LastName != "").ToList(); } try { return context.Contacts.Where(contact => contact.LastName != "").ToList(); }
catch { return new List<Contact>(); } catch { return new(); }
} }
} }
} }

@ -619,7 +619,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
int year = Convert.ToInt32(fields[columnNumberOf["SAPContactCreationDate"]].Substring(0, 4), CultureInfo.CurrentCulture); int year = Convert.ToInt32(fields[columnNumberOf["SAPContactCreationDate"]].Substring(0, 4), CultureInfo.CurrentCulture);
int month = Convert.ToInt32(fields[columnNumberOf["SAPContactCreationDate"]].Substring(4, 2), CultureInfo.CurrentCulture); int month = Convert.ToInt32(fields[columnNumberOf["SAPContactCreationDate"]].Substring(4, 2), CultureInfo.CurrentCulture);
int day = Convert.ToInt32(fields[columnNumberOf["SAPContactCreationDate"]].Substring(6, 2), CultureInfo.CurrentCulture); int day = Convert.ToInt32(fields[columnNumberOf["SAPContactCreationDate"]].Substring(6, 2), CultureInfo.CurrentCulture);
importedContact.SapContactCreationDate = new DateTime(year, month, day); importedContact.SapContactCreationDate = new(year, month, day);
//Convert "No Phone Calls" //Convert "No Phone Calls"
if (fields[columnNumberOf["NoPhoneCalls"]] == "1") if (fields[columnNumberOf["NoPhoneCalls"]] == "1")
@ -751,7 +751,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
int year = Convert.ToInt32(fields[columnNumber].Substring(0, 4)); int year = Convert.ToInt32(fields[columnNumber].Substring(0, 4));
int month = Convert.ToInt32(fields[columnNumber].Substring(4, 2)); int month = Convert.ToInt32(fields[columnNumber].Substring(4, 2));
int day = Convert.ToInt32(fields[columnNumber].Substring(6, 2)); int day = Convert.ToInt32(fields[columnNumber].Substring(6, 2));
importedAccount.AccountCreatedInSapOn = new DateTime(year, month, day); importedAccount.AccountCreatedInSapOn = new(year, month, day);
} }
} }

@ -9,7 +9,7 @@
public uint AccountId { get; set; } public uint AccountId { get; set; }
//navigation properties: //navigation properties:
public Account Account { get; set; } = new Account(); public Account Account { get; set; } = new();
public IList<Quote> Quotes { get; set; } = new List<Quote>(); public IList<Quote> Quotes { get; set; } = new List<Quote>();
//class properties: //class properties:

@ -9,7 +9,7 @@
public uint QuoteId { get; set; } public uint QuoteId { get; set; }
//navigation properties: //navigation properties:
public Quote Quote { get; set; } = new Quote(); public Quote Quote { get; set; } = new();
//class properties: //class properties:
public ushort Position { get; set; } public ushort Position { get; set; }

@ -6,8 +6,8 @@
public uint ProductId { get; set; } public uint ProductId { get; set; }
//navigation properties: //navigation properties:
public CustomDescription CustomDescription { get; set; } = new CustomDescription(); public CustomDescription CustomDescription { get; set; } = new();
public ProductLine ProductLine { get; set; }= new ProductLine(); public ProductLine ProductLine { get; set; }= new();
//foreign keys //foreign keys
public uint CustomDescriptionId { get; set; } = 999999999; public uint CustomDescriptionId { get; set; } = 999999999;

@ -10,7 +10,7 @@ namespace Gremlin_BlazorServer.Data.EntityClasses
public string ProductLineCode { get; set; } = string.Empty; public string ProductLineCode { get; set; } = string.Empty;
//navigation properties: //navigation properties:
public List<Product> Products { get; set; }= new List<Product>(); public List<Product> Products { get; set; }= new();
//class properties: //class properties:
public string ProductLineDescription { get; set; } = string.Empty; public string ProductLineDescription { get; set; } = string.Empty;

@ -9,11 +9,11 @@
public uint ContactId { get; set; } public uint ContactId { get; set; }
//navigation properties: //navigation properties:
public Contact Recipient { get; set; } = new Contact(); public Contact Recipient { get; set; } = new();
public IList<LineItem> LineItems { get; set; } = new List<LineItem>(); public IList<LineItem> LineItems { get; set; } = new List<LineItem>();
//class properties: //class properties:
public Contact SalesRep { get; set; } = new Contact(); public Contact SalesRep { get; set; } = new();
public string QuotationNumber { get; set; } = string.Empty; public string QuotationNumber { get; set; } = string.Empty;
public DateTime QuotationDate { get; set; } = DateTime.Now; public DateTime QuotationDate { get; set; } = DateTime.Now;
public DateTime ValidUntil { get; set; } = DateTime.Now.AddDays(60); public DateTime ValidUntil { get; set; } = DateTime.Now.AddDays(60);

@ -11,7 +11,7 @@
public uint RegisteredUserId { get; set; } public uint RegisteredUserId { get; set; }
//navigation properties //navigation properties
public RegisteredUser RegisteredUser { get; set; } = new RegisteredUser(); public RegisteredUser RegisteredUser { get; set; } = new();
//class properties //class properties
public string SettingKey { get; set; } = string.Empty; public string SettingKey { get; set; } = string.Empty;

@ -47,7 +47,7 @@
</form> </form>
@code { @code {
Account account = new Account(); Account account = new();
protected async void CreateAccount() protected async void CreateAccount()
{ {

@ -48,7 +48,7 @@
@code { @code {
[Parameter] [Parameter]
public string AccountId { get; set; } = default!; public string AccountId { get; set; } = default!;
Account account = new Account(); Account account = new();
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {

@ -53,7 +53,7 @@
@code { @code {
[Parameter] [Parameter]
public string AccountId { get; set; } = string.Empty; public string AccountId { get; set; } = string.Empty;
Account account = new Account(); Account account = new();
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {

@ -55,7 +55,7 @@
</form> </form>
@code { @code {
Contact contact = new Contact(); Contact contact = new();
protected async void CreateContact() protected async void CreateContact()
{ {

@ -56,7 +56,7 @@
@code { @code {
[Parameter] [Parameter]
public string ContactId { get; set; } = default!; public string ContactId { get; set; } = default!;
Contact contact = new Contact(); Contact contact = new();
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {

@ -56,7 +56,7 @@
@code { @code {
[Parameter] [Parameter]
public string ContactId { get; set; } = string.Empty; public string ContactId { get; set; } = string.Empty;
Contact contact = new Contact(); Contact contact = new();
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {

@ -46,7 +46,7 @@
</form> </form>
@code { @code {
CustomDescription customDescription = new CustomDescription(); CustomDescription customDescription = new();
protected async void CreateCustomDescription() protected async void CreateCustomDescription()
{ {

@ -48,7 +48,7 @@
@code { @code {
[Parameter] [Parameter]
public string CustomDescriptionId { get; set; } = string.Empty; public string CustomDescriptionId { get; set; } = string.Empty;
CustomDescription customDescription = new CustomDescription(); CustomDescription customDescription = new();
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {

@ -48,7 +48,7 @@
@code { @code {
[Parameter] [Parameter]
public string? CustomDescriptionId { get; set; } public string? CustomDescriptionId { get; set; }
CustomDescription customDescription = new CustomDescription(); CustomDescription customDescription = new();
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {

@ -49,7 +49,7 @@ namespace Gremlin_BlazorServer.Services
else else
{ {
Debug.WriteLine($"{productNumber}#{optionNumber}: keine CustomDescription gefunden!"); Debug.WriteLine($"{productNumber}#{optionNumber}: keine CustomDescription gefunden!");
return new CustomDescription(); return new();
} }
} }

@ -6,7 +6,7 @@ namespace Gremlin_BlazorServer.Services.GUClasses
{ {
//private readonly string _source; //Qualifier-Liste //private readonly string _source; //Qualifier-Liste
private readonly Dictionary<string, int> mappingTable; //Mapping Spaltenzahl <-> Property/(übersetzte) Spaltenüberschrift private readonly Dictionary<string, int> mappingTable; //Mapping Spaltenzahl <-> Property/(übersetzte) Spaltenüberschrift
public List<DataIdType> DataTypes { get; set; } = new List<DataIdType>(); public List<DataIdType> DataTypes { get; set; } = new();
public DataIdentificator(Dictionary<string, int> mappingTable) public DataIdentificator(Dictionary<string, int> mappingTable)