update 20241201
This commit is contained in:
252
Client - Kopie/DocMgmt/Dokumenterstellung.cs
Normal file
252
Client - Kopie/DocMgmt/Dokumenterstellung.cs
Normal file
@@ -0,0 +1,252 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using OnDoc.Klassen;
|
||||
using Model;
|
||||
using Syncfusion.Windows.Forms.Tools;
|
||||
using Syncfusion.WinForms.Controls;
|
||||
using Syncfusion.WinForms.DataGrid;
|
||||
using Syncfusion.WinForms.DataGrid.Interactivity;
|
||||
using Database;
|
||||
using OnDoc.UIControls;
|
||||
using BroadcastListener.Classes;
|
||||
using BroadcastListener.Interfaces;
|
||||
using static BroadcastListener.Classes.Factory;
|
||||
using OnDoc.Helper;
|
||||
using DOCGEN;
|
||||
using System.Globalization;
|
||||
|
||||
namespace OnDoc.DocMgmt
|
||||
{
|
||||
public partial class Dokumenterstellung : SfForm, IMessageListener1
|
||||
{
|
||||
public int partnernr { get; set; } = 0;
|
||||
public int profilnr { get; set; } = 0;
|
||||
public int dokumenttypnr { get; set; } = 0;
|
||||
public string interaktion { get; set; } = "";
|
||||
public string showdoc { get; set; } = "";
|
||||
|
||||
public int DocFunction = 0;
|
||||
public bool interop { get; set; } = false;
|
||||
public bool runmacros { get; set; } = false;
|
||||
public string dokumentid = "";
|
||||
|
||||
public Dokumenterstellung()
|
||||
{
|
||||
InitializeComponent();
|
||||
Broadcaster().AddListener(this);
|
||||
}
|
||||
|
||||
public Dokumenterstellung(int Partnernr, int Dokumenttpynr, int Profilnr)
|
||||
{
|
||||
InitializeComponent();
|
||||
partnernr = Partnernr;
|
||||
dokumenttypnr = Dokumenttpynr;
|
||||
profilnr = Profilnr;
|
||||
Broadcaster().AddListener(this);
|
||||
Closing += Form_Closing;
|
||||
}
|
||||
|
||||
public Dokumenterstellung(int Partnernr, int Dokumenttypnr, int Profilnr, string Interaktion, string Showdoc)
|
||||
{
|
||||
InitializeComponent();
|
||||
partnernr = Partnernr;
|
||||
dokumenttypnr = Dokumenttypnr;
|
||||
profilnr = Profilnr;
|
||||
interaktion= Interaktion;
|
||||
showdoc = Showdoc;
|
||||
Broadcaster().AddListener(this);
|
||||
Closing += Form_Closing;
|
||||
}
|
||||
|
||||
private void Form_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
Broadcaster().RemoveListener(this);
|
||||
}
|
||||
public void OnListen(string message, SenderInfo sender)
|
||||
{
|
||||
if (message == "BtnErstellung")
|
||||
{
|
||||
if (ucAllgemeineDokumentParam1.uniqid == sender.Details)
|
||||
{
|
||||
if (sender.Function == "Disable") { btnDokumenterstellen.Enabled = false; } else { btnDokumenterstellen.Enabled = true; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void Dokumenterstellung_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.Style.TitleBar.BackColor = Theaming.Titelbar();
|
||||
this.Style.TitleBar.ForeColor = Theaming.TitelFontColor();
|
||||
ucAllgemeineDokumentParam1.dokumenttypnr = dokumenttypnr;
|
||||
ucAllgemeineDokumentParam1.partnernr = partnernr;
|
||||
ucAllgemeineDokumentParam1.profilnr = profilnr;
|
||||
ucAllgemeineDokumentParam1.Refresh_Details();
|
||||
//if (ucAllgemeineDokumentParam1.check_bp_person() == false)
|
||||
//{
|
||||
// btnDokumenterstellen.Enabled = false;
|
||||
//}
|
||||
Security security = new Security();
|
||||
security.set_security(this);
|
||||
security = null;
|
||||
}
|
||||
|
||||
|
||||
private void sfButton2_Click(object sender, EventArgs e)
|
||||
{
|
||||
Cursor = Cursors.WaitCursor;
|
||||
Dokument_Erstellen();
|
||||
Cursor = Cursors.Default;
|
||||
|
||||
}
|
||||
public void Dokument_Erstellen()
|
||||
{
|
||||
if (ucAllgemeineDokumentParam1.check_fields()==false) {
|
||||
MessageBox.Show(ucAllgemeineDokumentParam1.check_error,"Feldwerte",MessageBoxButtons.OK,MessageBoxIcon.Error);
|
||||
return; };
|
||||
ucAllgemeineDokumentParam1.Update_DocGenData();
|
||||
clsDocData dokdata = new clsDocData();
|
||||
ucAllgemeineDokumentParam1.update_dokdata(ref dokdata);
|
||||
|
||||
DOCGEN.DocGen docgen = new DOCGEN.DocGen(AppParams.connectionstring);
|
||||
string dokumentid = docgen.GenDocID(dokdata);
|
||||
dokdata.Dokumentid = dokumentid;
|
||||
ucAllgemeineDokumentParam1.genertated_dokumentid = dokumentid;
|
||||
this.dokumentid=dokdata.Dokumentid;
|
||||
Logging.DocLog.Info("Dokumenterstellung", "frmDokumenterstellung", dokumentid, ucAllgemeineDokumentParam1.partnernr.ToString(), "Dokumenterstellung");
|
||||
if (dokumentid != "")
|
||||
{
|
||||
DOCGEN.Generator.DocGenerator_from_EDOKA Generator = new DOCGEN.Generator.DocGenerator_from_EDOKA(AppParams.connectionstring, AppParams.tempdir, AppParams.RESTURI, AppParams.apikey);
|
||||
clsdok dok = new clsdok("", "", "");
|
||||
dok = Generator.Generate_Doc_EDOKA(dokumentid, ref dokdata, ucAllgemeineDokumentParam1.ErstellungInOffice);
|
||||
|
||||
interop = ucAllgemeineDokumentParam1.interop;
|
||||
|
||||
if (ucAllgemeineDokumentParam1.docgendata.erstellungsart == Erstellungsart.DokumentBearbeiten || ucAllgemeineDokumentParam1.docgendata.erstellungsart == Erstellungsart.ErstellungInOffice)
|
||||
{
|
||||
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;
|
||||
DocFunction = 1;
|
||||
this.Close();
|
||||
return;
|
||||
}
|
||||
if (ucAllgemeineDokumentParam1.docgendata.erstellungsart == Erstellungsart.DokumentPreview)
|
||||
{
|
||||
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 (ucAllgemeineDokumentParam1.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 (ucAllgemeineDokumentParam1.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 (ucAllgemeineDokumentParam1.docgendata.versandstrasse_moeglich == true)
|
||||
{
|
||||
ribbonButtonVersandstrasse.Enabled = true;
|
||||
}
|
||||
else { ribbonButtonVersandstrasse.Enabled = false; }
|
||||
|
||||
PnlPreview.Visible = true;
|
||||
PnlPreview.Dock = DockStyle.Fill;
|
||||
|
||||
Database.DB db1 = new Database.DB(AppParams.connectionstring);
|
||||
db1.Get_Tabledata("Select coldstatus from dokument where dokumentid='"+dokumentid+"'",false,true);
|
||||
if (Convert.ToInt32(db1.dsdaten.Tables[0].Rows[0][0]) == 1)
|
||||
{
|
||||
ribbonButtonArchiv.Enabled = false;
|
||||
ribbonButtonVersandstrasse.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ribbonButtonArchiv.Enabled = true;
|
||||
ribbonButtonVersandstrasse.Enabled = true;
|
||||
}
|
||||
if (ucAllgemeineDokumentParam1.docgendata.versandstrasse_moeglich == false) { ribbonButtonVersandstrasse.Enabled = false; }
|
||||
docPreview1.Show_Doc(dokumentid);
|
||||
docPreview1.Hide_Editbuttons();
|
||||
}
|
||||
}
|
||||
|
||||
private void sfButton3_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Abort;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
DocFunction = 1;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
DocFunction = 2;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
DocFunction = 3;
|
||||
PnlPreview.Visible = false;
|
||||
|
||||
}
|
||||
|
||||
private void button4_Click(object sender, EventArgs e)
|
||||
{
|
||||
DocFunction = 4;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void button5_Click(object sender, EventArgs e)
|
||||
{
|
||||
DocFunction = 5;
|
||||
this.Close();
|
||||
|
||||
}
|
||||
|
||||
private void GrpFnkt_Enter(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void btnOfficePrint_Click(object sender, EventArgs e)
|
||||
{
|
||||
clsdok dok = new clsdok("", "", "");
|
||||
OfficePrinter.OnDocOffice op = new OfficePrinter.OnDocOffice();
|
||||
DocGet gd = new DocGet(AppParams.connectionstring);
|
||||
{
|
||||
dok = gd.GetDoc(dokumentid);
|
||||
}
|
||||
Helper.FileHelper fh = new Helper.FileHelper();
|
||||
string Filename = AppParams.tempdir + dokumentid + "." + dok.extension;
|
||||
fh.SaveBase64ToFile(dok.dokument, Filename );
|
||||
op.PrintInWord(Filename, AppParams.wordprintmacro);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user