Briefkopf-Erstellung für LaTeX

pull/1/head
Sascha Woitschetzki 2021-06-14 12:50:48 +07:00 committed by Sascha Woitschetzki
parent 859c3bfad0
commit c43e00afc2
5 changed files with 26 additions and 17 deletions

@ -3,6 +3,7 @@ using Gremlin.GremlinData.EntityClasses;
using Gremlin.GremlinUI;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Gremlin.Models
@ -41,7 +42,12 @@ namespace Gremlin.Models
try
{
Dictionary<string, string> rsfruid = ReadSettingsForRegisteredUserID(registeredUserID);
return rsfruid == null ? "RUSettings not valid" : rsfruid.ContainsKey(settingKey) ? rsfruid[settingKey] : "NotFound";
if (!rsfruid.ContainsKey(settingKey) || rsfruid == null)
{
Debug.WriteLine($"SettingKey {settingKey} not found or null!");
return "NotFound";
}
return rsfruid[settingKey];
}
catch (Exception ex)
{

@ -1,5 +1,6 @@
using Gremlin.GremlinUI.ViewModels;
using Gremlin.Models;
using Gremlin.ViewModels;
using System.IO;
using System.Text;
using static Gremlin.GremlinData.EntityClasses.Enums;
@ -24,11 +25,9 @@ namespace Gremlin.Operations
private static StringBuilder CreateTexFile(QuoteVM quoteVM, bool? brutto)
{
float rand = Properties.Settings.Default.texRand;
//byte[] agilentLogo = Properties.Resources.agilentLogo;
//byte[] sign = Properties.Resources.signWoitschetzki;
string rand = RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "texRand");
StringBuilder texFile = new($"\\documentclass[a4paper,ngerman,parskip,10pt]{{scrlttr2}}" + $"\\usepackage{{lmodern}}" + $"\\usepackage[T1]{{fontenc}}" + $"\\usepackage[utf8]{{inputenc}}" + $"\\usepackage{{babel}}" + $"\\usepackage[hidelinks]{{hyperref}}");
StringBuilder texFile = new($"\\documentclass[a4paper,ngerman,parskip,10pt]{{scrlttr2}}" + $"\\usepackage{{lmodern}}" + $"\\usepackage[T1]{{fontenc}}" + $"\\usepackage[utf8]{{inputenc}}" + $"\\usepackage{{babel}}" + $"\\usepackage[hidelinks]{{hyperref}}\n");
_ = texFile.AppendLine($"\\usepackage[left={rand}cm, right={rand}cm, top={rand}cm, bottom={rand}cm]{{geometry}}");
_ = texFile.AppendLine($"\\usepackage[table]{{xcolor}}\r\n\\usepackage[right]{{eurosym}}\r\n\\usepackage[locale=DE]{{siunitx}}\r\n\\usepackage{{scrlayer-scrpage}}\r\n\\usepackage{{lastpage}}\r\n\\usepackage{{graphicx}}\r\n\\usepackage{{multirow}}\r\n\\usepackage{{longtable}}\r\n\\usepackage{{enumitem}}\r\n\\usepackage{{fp, xstring, spreadtab, numprint}}\r\n\\DeclareSIUnit{{\\sieuro}}{{\\mbox{{\\euro}}}}");
_ = texFile.AppendLine($"\\rohead{{{quoteVM.QuotationNumber}}}");
@ -40,7 +39,7 @@ namespace Gremlin.Operations
_ = texFile.AppendLine($"Mobil:&{RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "userMobile")}\\\\");
_ = texFile.AppendLine($"E-Mail:&\\href{{mailto:{RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "userMail")}}}{{{RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "userMail")}}}\\\\");
_ = texFile.AppendLine("\\textbf{Auftragsannahme:}&\\href{mailto:salesservices\\_germany@agilent.com}{salesservices\\_germany@agilent.com}\\\\\r\n\\hline\r\n\\end{tabular}\r\n}\\\\");
//_ = texFile.Append(ContactViewModel.CreateBriefkopf(contact));
_ = texFile.Append(ContactVM.CreateBriefkopf(quoteVM.Recipient, true));
_ = texFile.AppendLine("&\\\\\r\n&\\\\\r\n\\end{tabular}\r\n\\vspace{1cm}\\par ");
//Anrede

@ -53,7 +53,7 @@ namespace Gremlin.GremlinUI
string fileName = $"{quoteVM.QuotationNumber}";
string quotePath = tbQuotationPath.Text;
TexFileHandler.CreateTexAndOpen(quoteVM, cbBrutto.IsChecked, fileName, quotePath);
PDFHandler.CreatePDF(fileName, quotePath);
//PDFHandler.CreatePDF(fileName, quotePath);
}

@ -8,7 +8,6 @@ using System.Text;
using System.Windows.Data;
using Microsoft.EntityFrameworkCore;
using Gremlin.GremlinData.EntityClasses;
using System.ComponentModel;
namespace Gremlin.ViewModels
{
@ -145,17 +144,22 @@ namespace Gremlin.ViewModels
}
}
internal static StringBuilder CreateBriefkopf(ContactVM contactViewModel)
internal static StringBuilder CreateBriefkopf(ContactVM contactVM, bool tex = false)
{
StringBuilder briefkopf = new();
_ = contactViewModel.Gender == (byte)Enums.Gender.Male
? briefkopf.AppendLine($"Herr {contactViewModel.FirstName} {contactViewModel.LastName}")
: briefkopf.AppendLine($"Frau {contactViewModel.FirstName} {contactViewModel.LastName}");
_ = briefkopf.AppendLine($"{contactViewModel.AccountName}");
_ = briefkopf.AppendLine($"{contactViewModel.AccountStreet}");
_ = briefkopf.AppendLine($"{contactViewModel.AccountZIP} {contactViewModel.AccountCity}");
_ = contactVM.Gender == (byte)Enums.Gender.Male
? briefkopf.AppendLine($"Herr {contactVM.FirstName} {contactVM.LastName}")
: briefkopf.AppendLine($"Frau {contactVM.FirstName} {contactVM.LastName}");
if (tex)
_ = briefkopf.AppendLine($"\\\\");
_ = briefkopf.AppendLine($"{contactVM.AccountName}");
if (tex) { briefkopf.AppendLine($"\\\\"); }
_ = briefkopf.AppendLine($"{contactVM.AccountStreet}");
if (tex) { briefkopf.AppendLine($"\\\\"); }
_ = briefkopf.AppendLine($"{contactVM.AccountZIP} {contactVM.AccountCity}");
if (tex) { briefkopf.AppendLine($"\\\\"); }
return briefkopf;
}

@ -24,7 +24,7 @@
<Value Profile="(Default)" />
</Setting>
<Setting Name="texRand" Type="System.Single" Scope="User">
<Value Profile="(Default)">2.5</Value>
<Value Profile="(Default)">2</Value>
</Setting>
<Setting Name="userSettingID" Type="System.UInt32" Scope="User">
<Value Profile="(Default)">1</Value>