update 20250406

This commit is contained in:
Stefan Hutter
2025-04-06 07:39:53 +02:00
parent 632b97c292
commit 42c86d957c
155 changed files with 1725 additions and 607 deletions

View File

@@ -41,7 +41,7 @@ namespace OnDoc.DocMgmt
private int profilnr {get;set;}
public int dokumentpaketnr { get; set; } = 0;
public int partnernr { get; set; } = 0;
private bool EinzelGenerierung { get; set; } = false;
public Dokumentpaket()
{
InitializeComponent();
@@ -471,155 +471,178 @@ namespace OnDoc.DocMgmt
progressBarAdv1.Visible = true;
Generate_Docs();
}
private void Generate_Docs(string idokumentid="",UCAllgemeineDokumentParam iuc = null) {
private void Generate_Docs(string idokumentid = "", UCAllgemeineDokumentParam iuc = null)
{
int counter = 0;
string filter = "dokumentid in ('";
foreach (TabPageAdv tab in TabControlDokuments.TabPages)
{
progressBarAdv1.Value = progressBarAdv1.Value + 1;
Application.DoEvents();
//Thread.Sleep(1000);
try {
progressBarAdv1.Value = progressBarAdv1.Value + 1;
Application.DoEvents();
//Thread.Sleep(1000);
UCAllgemeineDokumentParam uc = (UCAllgemeineDokumentParam)tab.Controls[0];
if (((idokumentid == "" || uc.genertated_dokumentid == idokumentid) && iuc==null) || uc==iuc)
{
//uc.Set_Edit_later();
uc.Update_DocGenData();
clsDocData dokdata = new clsDocData();
uc.update_dokdata(ref dokdata);
uc.update_partner();
DOCGEN.DocGen docgen = new DOCGEN.DocGen(AppParams.connectionstring);
string dokumentid = docgen.GenDocID(dokdata, false, "");
dokdata.Dokumentid = dokumentid;
uc.genertated_dokumentid = dokumentid;
uc.Show_Neugenerieren();
filter = filter + dokumentid + "','";
dokumentid = dokdata.Dokumentid;
if (uc.docgendata.erstellungsart == Erstellungsart.DokumentPreview) { uc.docgendata.erstellungsart = Erstellungsart.DokumentSpäterBearbeiten; }
if (dokumentid != "")
UCAllgemeineDokumentParam uc = (UCAllgemeineDokumentParam)tab.Controls[0];
if (((idokumentid == "" || uc.genertated_dokumentid == idokumentid) && iuc == null) || uc == iuc)
{
Logging.DocLog.Info("Dokument erstellt", "Dokumentpaket", dokumentid, uc.partnernr.ToString(), "Dokument erstellt");
DOCGEN.Generator.DocGenerator_from_EDOKA Generator = new DOCGEN.Generator.DocGenerator_from_EDOKA(AppParams.connectionstring, AppParams.tempdir, AppParams.RESTURI,AppParams.apikey,AppParams.Office_Fill_DocIO);
clsdok dok = new clsdok("", "", "", "");
if (dokdata.barcode_type == "1")
//uc.Set_Edit_later();
uc.Update_DocGenData();
clsDocData dokdata = new clsDocData();
uc.update_dokdata(ref dokdata);
uc.update_partner();
DOCGEN.DocGen docgen = new DOCGEN.DocGen(AppParams.connectionstring);
string dokumentid = docgen.GenDocID(dokdata, false, "");
dokdata.Dokumentid = dokumentid;
uc.genertated_dokumentid = dokumentid;
uc.Show_Neugenerieren();
filter = filter + dokumentid + "','";
dokumentid = dokdata.Dokumentid;
if (uc.docgendata.erstellungsart == Erstellungsart.DokumentPreview) { uc.docgendata.erstellungsart = Erstellungsart.DokumentSpäterBearbeiten; }
if (dokumentid != "")
{
DB dB = new DB(AppParams.connectionstring);
dB.clear_parameter();
dB.add_parameter("@dokumentid", dokumentid);
dB.add_parameter("@DokumentidBR", "");
dB.add_parameter("@BARCODEFONTNAME", "");
dB.add_parameter("@BARCODEFONTSIZE", "");
dB.add_parameter("@BarcodeKantenlaenge", "");
dB.Get_Tabledata("sp_get_OnDoc_barcodetype_and_value", true, false);
dokdata.barcode_content = dB.dsdaten.Tables[0].Rows[0][1].ToString();
dokdata.barcode_formatn = dB.dsdaten.Tables[0].Rows[0][3].ToString();
dokdata.barcode_text = dB.dsdaten.Tables[0].Rows[0][4].ToString();
dokdata.barcode_kantenlaenge = dB.dsdaten.Tables[0].Rows[0][5].ToString();
dokdata.Zusatz_Font = dB.dsdaten.Tables[0].Rows[0][6].ToString();
dokdata.Zusatz_FontSize = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0][7]);
dokdata.barcode_width = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0][8]);
dokdata.barcode_height = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0][9]);
//dokdata.barcode_type= dB.dsdaten.Tables[0].Rows[0][3].ToString();
string sql = "";
sql = "select bcpt, bcpl, bcw, bch, bchorizontal from OnDocBarcodeMpping ";
sql = sql + "where orig_bcpt = " + dokdata.barcode_top.ToString() + " and orig_bcpl=" + dokdata.barcode_left.ToString() + " ";
sql = sql + "and orig_bcw=" + dokdata.barcode_width.ToString() + " and orig_bch=" + dokdata.barcode_height.ToString();
dB.Get_Tabledata(sql, false, true);
if (dB.dsdaten.Tables[0].Rows.Count > 0)
Logging.DocLog.Info("Dokument erstellt", "Dokumentpaket", dokumentid, uc.partnernr.ToString(), "Dokument erstellt");
DOCGEN.Generator.DocGenerator_from_EDOKA Generator = new DOCGEN.Generator.DocGenerator_from_EDOKA(AppParams.connectionstring, AppParams.tempdir, AppParams.RESTURI, AppParams.apikey, AppParams.Office_Fill_DocIO);
clsdok dok = new clsdok("", "", "", "");
if (dokdata.barcode_type == "1")
{
Logging.Logging.Debug("Barcode-Übersteuerung" + dokdata.DokumenttypNr.ToString(), "Dokumenterstellung", "");
dokdata.barcode_left = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0]["bcpl"]);
dokdata.barcode_top = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0]["bcpt"]);
dokdata.barcode_width = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0]["bcw"]);
dokdata.barcode_height = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0]["bch"]);
DB dB = new DB(AppParams.connectionstring);
dB.clear_parameter();
dB.add_parameter("@dokumentid", dokumentid);
dB.add_parameter("@DokumentidBR", "");
dB.add_parameter("@BARCODEFONTNAME", "");
dB.add_parameter("@BARCODEFONTSIZE", "");
dB.add_parameter("@BarcodeKantenlaenge", "");
dB.Get_Tabledata("sp_get_OnDoc_barcodetype_and_value", true, false);
dokdata.barcode_content = dB.dsdaten.Tables[0].Rows[0][1].ToString();
dokdata.barcode_formatn = dB.dsdaten.Tables[0].Rows[0][3].ToString();
dokdata.barcode_text = dB.dsdaten.Tables[0].Rows[0][4].ToString();
dokdata.barcode_kantenlaenge = dB.dsdaten.Tables[0].Rows[0][5].ToString();
dokdata.Zusatz_Font = dB.dsdaten.Tables[0].Rows[0][6].ToString();
dokdata.Zusatz_FontSize = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0][7]);
dokdata.barcode_width = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0][8]);
dokdata.barcode_height = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0][9]);
//dokdata.barcode_type= dB.dsdaten.Tables[0].Rows[0][3].ToString();
string sql = "";
sql = "select bcpt, bcpl, bcw, bch, bchorizontal from OnDocBarcodeMpping ";
sql = sql + "where orig_bcpt = " + dokdata.barcode_top.ToString() + " and orig_bcpl=" + dokdata.barcode_left.ToString() + " ";
sql = sql + "and orig_bcw=" + dokdata.barcode_width.ToString() + " and orig_bch=" + dokdata.barcode_height.ToString();
dB.Get_Tabledata(sql, false, true);
if (dB.dsdaten.Tables[0].Rows.Count > 0)
{
Logging.Logging.Debug("Barcode-Übersteuerung" + dokdata.DokumenttypNr.ToString(), "Dokumenterstellung", "");
dokdata.barcode_left = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0]["bcpl"]);
dokdata.barcode_top = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0]["bcpt"]);
dokdata.barcode_width = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0]["bcw"]);
dokdata.barcode_height = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0]["bch"]);
}
dB = null;
}
if (uc.docgendata.erstellungsart == Erstellungsart.ErstellungInOffice)
{
//panelword.Visible = true;
lbldokumentname.Text = tab.Text;
Application.DoEvents();
dok = Generator.Generate_Doc_EDOKA(dokumentid, ref dokdata, true, AppParams.OfficeSpleep1, AppParams.vbvorlagenmanagement == "Yes");
//panelword.Visible = false;
Application.DoEvents();
}
else
{
dok = Generator.Generate_Doc_EDOKA(dokumentid, ref dokdata);
}
dB = null;
}
if (uc.docgendata.erstellungsart == Erstellungsart.ErstellungInOffice)
{
//panelword.Visible = true;
lbldokumentname.Text = tab.Text;
Application.DoEvents();
dok = Generator.Generate_Doc_EDOKA(dokumentid, ref dokdata,true,AppParams.OfficeSpleep1,AppParams.vbvorlagenmanagement=="Yes");
//panelword.Visible = false;
Application.DoEvents();
}
else
{
dok = Generator.Generate_Doc_EDOKA(dokumentid, ref dokdata);
}
if (uc.docgendata.erstellungsart == Erstellungsart.ErstellungInOffice)
{
string filename = AppParams.tempdir + dokumentid + "." + dok.extension;
filename = AppParams.tempdir + dok.dokumentname;
string filename_temp = filename + ".tmp";
System.IO.File.WriteAllBytes(filename_temp, Convert.FromBase64String(dok.dokument));
DB db = new DB(AppParams.connectionstring);
db.Save_To_DB(dokdata.Dokumentid, filename_temp);
db.Dok_in_Bearbeitung(1,dokdata.Dokumentid, AppParams.CurrentMitarbeiter);
db = null;
System.IO.File.Delete(filename_temp);
Logging.Logging.Debug("Before Processwatch","DonDoc",dokumentid);
clsProcessWatch.AddToList(dokdata.Dokumentid, filename, "Word");
}
if (uc.docgendata.erstellungsart == Erstellungsart.DokumentBearbeiten)
{
string filename = AppParams.tempdir + dokumentid + "." + dok.extension;
//filename = AppParams.tempdir + dok.dokumentname;
System.IO.File.WriteAllBytes(filename, Convert.FromBase64String(dok.dokument));
DB db = new DB(AppParams.connectionstring);
db.Save_To_DB(dokdata.Dokumentid, filename);
db = null;
switch (dok.doktype)
if (uc.docgendata.erstellungsart == Erstellungsart.ErstellungInOffice)
{
case "W":
System.Diagnostics.Process.Start("winword.exe", filename);
clsProcessWatch.AddToList(dokdata.Dokumentid, filename, "Word");
break;
case "X":
System.Diagnostics.Process.Start("excel.exe", " " + filename);
clsProcessWatch.AddToList(dokdata.Dokumentid, filename, "Excel");
break;
case "P":
System.Diagnostics.Process.Start(filename);
break;
default:
break;
}
}
if (uc.docgendata.erstellungsart == Erstellungsart.DokumentAlsPDF)
{
//Generator.DocToPDF(dokumentid, ref dok);
dok.extension = "pdf";
string filename = AppParams.tempdir + dokumentid + "." + dok.extension;
System.IO.File.WriteAllBytes(filename, Convert.FromBase64String(dok.dokument));
DB db = new DB(AppParams.connectionstring);
db.Save_To_DB(dokdata.Dokumentid, filename);
}
string filename = AppParams.tempdir + dokumentid + "." + dok.extension;
filename = AppParams.tempdir + dok.dokumentname;
string filename_temp = filename + ".tmp";
System.IO.File.WriteAllBytes(filename_temp, Convert.FromBase64String(dok.dokument));
DB db = new DB(AppParams.connectionstring);
db.Save_To_DB(dokdata.Dokumentid, filename_temp);
db.Dok_in_Bearbeitung(1, dokdata.Dokumentid, AppParams.CurrentMitarbeiter);
db = null;
System.IO.File.Delete(filename_temp);
Logging.Logging.Debug("Before Processwatch", "DonDoc", dokumentid);
clsProcessWatch.AddToList(dokdata.Dokumentid, filename, "Word");
}
if (uc.docgendata.erstellungsart == Erstellungsart.DokumentBearbeiten)
{
string filename = AppParams.tempdir + dokumentid + "." + dok.extension;
//filename = AppParams.tempdir + dok.dokumentname;
System.IO.File.WriteAllBytes(filename, Convert.FromBase64String(dok.dokument));
DB db = new DB(AppParams.connectionstring);
db.Save_To_DB(dokdata.Dokumentid, filename);
db = null;
switch (dok.doktype)
{
case "W":
System.Diagnostics.Process.Start("winword.exe", filename);
clsProcessWatch.AddToList(dokdata.Dokumentid, filename, "Word");
break;
case "X":
System.Diagnostics.Process.Start("excel.exe", " " + filename);
clsProcessWatch.AddToList(dokdata.Dokumentid, filename, "Excel");
break;
case "P":
System.Diagnostics.Process.Start(filename);
break;
default:
break;
}
}
if (uc.docgendata.erstellungsart == Erstellungsart.DokumentAlsPDF)
{
//Generator.DocToPDF(dokumentid, ref dok);
dok.extension = "pdf";
string filename = AppParams.tempdir + dokumentid + "." + dok.extension;
System.IO.File.WriteAllBytes(filename, Convert.FromBase64String(dok.dokument));
DB db = new DB(AppParams.connectionstring);
db.Save_To_DB(dokdata.Dokumentid, filename);
}
if (uc.docgendata.erstellungsart == Erstellungsart.DokumentSpäterBearbeiten)
{
string filename = AppParams.tempdir + dokumentid + "." + dok.extension;
System.IO.File.WriteAllBytes(filename, Convert.FromBase64String(dok.dokument));
DB db = new DB(AppParams.connectionstring);
db.Save_To_DB(dokdata.Dokumentid, filename);
db = null;
}
if (uc.docgendata.erstellungsart == Erstellungsart.DokumentSpäterBearbeiten)
{
string filename = AppParams.tempdir + dokumentid + "." + dok.extension;
System.IO.File.WriteAllBytes(filename, Convert.FromBase64String(dok.dokument));
DB db = new DB(AppParams.connectionstring);
db.Save_To_DB(dokdata.Dokumentid, filename);
db = null;
}
}
else
{
filter = filter + uc.genertated_dokumentid + "','";
}
counter = counter + 1;
if (this.EinzelGenerierung)
{
if (counter < TabControlDokuments.TabPages.Count)
{
if (MessageBox.Show("Nächstes Dokument generieren oder Generierung abbrechen?", "Dokumentgenerierung", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
{
progressBarAdv1.Visible = false;
filter = filter.Substring(0, filter.Length - 2) + ")";
dokList1.datafilter = filter;
dokList1.refresh_dokumente("view_dokumentpaket");
dokList1.refresh_dokumente();
return;
}
}
}
}
else
{
filter = filter + uc.genertated_dokumentid + "','";
}
catch { }
}
progressBarAdv1.Visible = false;
filter = filter.Substring(0, filter.Length - 2) + ")";
dokList1.datafilter = filter;
@@ -661,5 +684,12 @@ namespace OnDoc.DocMgmt
{
//int a = 1;
}
private void RibbonButtonEInzelgenerierung_Click(object sender, EventArgs e)
{
this.EinzelGenerierung = true;
RibbonButtonGenerieren_Click(sender, e);
this.EinzelGenerierung = false;
}
}
}