update 20250727

This commit is contained in:
Stefan Hutter
2025-07-27 13:24:50 +02:00
parent cb8acfea57
commit 2237be483d
192 changed files with 23435 additions and 107 deletions

View File

@@ -25,7 +25,7 @@ using System.Text;
using System.Text.Json.Serialization;
namespace API_NetFramework.Controllers
namespace API_NetFramework.Controllers
{
public class TestParam
{
@@ -46,7 +46,7 @@ namespace API_NetFramework.Controllers
}
try
{
APILogging.Log((HttpRequestMessage)Request, "Start GetDocument DokumentID:"+dokid, LogLevelType.Debug);
APILogging.Log((HttpRequestMessage)Request, "Start GetDocument DokumentID:" + dokid, LogLevelType.Debug);
DOCGEN.DocGet gd = new DocGet(connectionstring);
clsdok dok = new clsdok("", "", "", "");
@@ -60,7 +60,7 @@ namespace API_NetFramework.Controllers
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
return Content(HttpStatusCode.InternalServerError, e.Message);
}
}
//public object pageCollection { get; set; }
@@ -87,7 +87,7 @@ namespace API_NetFramework.Controllers
APILogging.Log((HttpRequestMessage)Request, "Start GetDocumentPDF DokumentID:" + dokid, LogLevelType.Debug);
DOCGEN.DocGet gd = new DocGet(connectionstring);
clsdok dok = new clsdok("", "", "", "");
clsdok dok = new clsdok("", "", "", "");
dok = gd.GetDocAsPDF(dokid);
dok.extension = "pdf";
dok.doktype = "P";
@@ -100,7 +100,7 @@ namespace API_NetFramework.Controllers
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
return Content(HttpStatusCode.InternalServerError, e.Message);
}
}
[HttpPost]
@@ -118,21 +118,22 @@ namespace API_NetFramework.Controllers
var key = rmsg.Headers.Authorization.Parameter.ToString();
string result = Request.Content.ReadAsStringAsync().Result;
DocCreate doccreate=new DocCreate();
DocCreate doccreate = new DocCreate();
doccreate = JsonConvert.DeserializeObject<DocCreate>(result);
clsDocData dokdata = new clsDocData();
string dokumentid = "";
string CheckResult = "";
CheckResult = CreateDoc_Verify(ref doccreate);
if (CheckResult != "")
{
return BadRequest(CheckResult);
if (CheckResult != "")
{
return BadRequest(CheckResult);
}
Database.DB db = new DB(connectionstring);
db.Get_Tabledata("Select * from dokumenttyp where dokumenttypnr=" + doccreate.VorlagenTypID, false, true);
System.Data.DataRow dr = db.dsdaten.Tables[0].Rows[0];
dokdata.Barcode = Convert.ToBoolean(dr["Vertrag"]) == true;
db.Get_Tabledata("Select beschreibung from physischesarchiv where physischesarchivnr = " + dr["physisches_archiv"].ToString(), false, true);
dokdata.barcode_zusatz = db.dsdaten.Tables[0].Rows[0][0].ToString();
if (dokdata.barcode_zusatz != "") { dokdata.barcode_zusatz = " " + dokdata.barcode_zusatz; }
@@ -146,17 +147,71 @@ namespace API_NetFramework.Controllers
}
catch { }
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"]);
dokdata.barcode_horizontal = Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["bchorizontal"]);
dokdata.barcode_type = db.dsdaten.Tables[0].Rows[0]["BarcodeType"].ToString();
dokdata.barcode_content = db.dsdaten.Tables[0].Rows[0]["DatamatrixContent"].ToString();
if (dokdata.Barcode)
{
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"]);
dokdata.barcode_horizontal = Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["bchorizontal"]);
dokdata.barcode_type = db.dsdaten.Tables[0].Rows[0]["BarcodeType"].ToString();
dokdata.barcode_content = db.dsdaten.Tables[0].Rows[0]["DatamatrixContent"].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)
{
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"]);
}
if (dokdata.barcode_type == "1")
{
DB dB = new DB(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();
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.Get_Tabledata("Select * from ondoc_appparams", false, true);
dokdata.barcode_font = db.dsdaten.Tables[0].Rows[0]["barcodefont"].ToString();
dokdata.barcode_fontsize = Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["barcodefontsize"].ToString());
dokdata.Zusatz_Font = db.dsdaten.Tables[0].Rows[0]["Zusatzfont"].ToString();
dokdata.Zusatz_FontSize = Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["ZusatzfontSize"].ToString());
dokdata.barcode_textposition = db.dsdaten.Tables[0].Rows[0]["barcodetextposition"].ToString(); ;
}
Model.clsdocgendata docgendata = new Model.clsdocgendata();
DataTable dokwertlist = new DataTable();
dokwertlist = db.Get_DokumentWertList("", Convert.ToInt32(doccreate.VorlagenTypID),1);
dokwertlist = db.Get_DokumentWertList("", Convert.ToInt32(doccreate.VorlagenTypID), 1);
docgendata.dokumentwerte = dokwertlist;
docgendata.partnernr = doccreate.Partnernr;
@@ -169,7 +224,7 @@ namespace API_NetFramework.Controllers
docgendata.ersteller = db.Get_Mitarbeiternr(doccreate.TGNrErsteller).ToString();
docgendata.team = db.Get_Teamnr(docgendata.ersteller).ToString();
docgendata.digitaleunterschrift = false;
docgendata.frormularOhneUnterschrift = doccreate.OhneUnterschrift=="Yes";
docgendata.frormularOhneUnterschrift = doccreate.OhneUnterschrift == "Yes";
docgendata.zustaendigkube = db.Get_Mitarbeiternr(doccreate.TGNrVerantwortlich).ToString();
docgendata.status = "-1";
docgendata.dokumentdatum = DateTime.Now.ToString("dd.MM.yyyy");
@@ -179,7 +234,7 @@ namespace API_NetFramework.Controllers
if (doccreate.Result_FileType == "WORD") { docgendata.erstellungsart = Erstellungsart.DokumentBearbeiten; } else { docgendata.erstellungsart = Erstellungsart.DokumentAlsPDF; }
if (docgendata.verantwortlich == "0") { docgendata.verantwortlich = docgendata.ersteller; }
dokdata.PartnerNr = docgendata.partnernr;
dokdata.UseEDOKA_Values = "True";
dokdata.DokumenttypNr = docgendata.dokumenttypnr;
@@ -208,26 +263,29 @@ namespace API_NetFramework.Controllers
dokdata.Unterschrift_Links = "-1";
dokdata.Unterschrift_Rechts = "-1";
}
if (doccreate.FaksimileUnterschrift == "Yes")
if (doccreate.FaksimileUnterschrift == "Yes")
{
dokdata.As_Faksimile = "True"; dokdata.sign = true; docgendata.digitaleunterschrift = true;
dokdata.As_Faksimile = "True"; dokdata.sign = true; docgendata.digitaleunterschrift = true;
if (dokdata.Unterschrift_Links != "-1") { dokdata.approval1 = 1; }
if (dokdata.Unterschrift_Rechts != "-1") { dokdata.approval2 = 1; }
if (dokdata.Unterschrift_Links!="-1" && dokdata.Unterschrift_Rechts == "-1")
if (dokdata.Unterschrift_Links != "-1" && dokdata.Unterschrift_Rechts == "-1")
{
if (dokdata.Ersteller == dokdata.Unterschrift_Links)
{
dokdata.approved = 1;
} else {
dokdata.sign = false;
if (dokdata.Ersteller == dokdata.Unterschrift_Links)
{
dokdata.approved = 1;
}
else
{
dokdata.sign = false;
dokdata.toapprove = 1;
dokdata.approved = 0;
dokdata.approval1 = 0;
dokdata.approval2 = 1;
docgendata.erstellungsart = Erstellungsart.DokumentBearbeiten;
}
} else
}
else
{
docgendata.erstellungsart = Erstellungsart.DokumentBearbeiten;
dokdata.toapprove = 1;
@@ -235,19 +293,19 @@ namespace API_NetFramework.Controllers
}
}
dokdata.APIValues = doccreate.APIValues;
if (doccreate.PrintLogo == "Yes") { dokdata.PrintLogo = true; } else { dokdata.PrintLogo = false; }
if (docgendata.erstellungsart == Erstellungsart.DokumentAlsPDF) { dokdata.Result_as_PDF = "True"; } else { dokdata.Result_as_PDF = "False"; }
if (docgendata.digitaleunterschrift == true) { dokdata.As_Faksimile = "True"; } else { dokdata.As_Faksimile = "False"; }
dokumentid = db.Create_EDOKA_Doc(dokdata, false, "");
dokdata.Dokumentid=dokumentid;
dokdata.Dokumentid = dokumentid;
DOCGEN.Generator.DocGenerator_from_EDOKA Generator = new DOCGEN.Generator.DocGenerator_from_EDOKA(this.connectionstring, OwnHost, key.ToString());
clsdok dok = new clsdok("", "", "", "");
dok = Generator.Generate_Doc_EDOKA(dokumentid, ref dokdata,false,0,false,false);
dok = Generator.Generate_Doc_EDOKA(dokumentid, ref dokdata, false, 0, false, false);
db.Save_To_DB(dokumentid, "", dok.dokument);
APILogging.Log((HttpRequestMessage)Request, "Ende GenDoc DokumentID:" + dokumentid, LogLevelType.Debug);
APILogging.DocLog((HttpRequestMessage)Request, doccreate.Partnernr, "Dokument über API erstellt", dokumentid, LogLevelType.Info);
@@ -259,10 +317,11 @@ namespace API_NetFramework.Controllers
clsVersandstrasse vs = new clsVersandstrasse();
string vsdoc = "";
vsdoc = vs.Prepare_PDF(dokumentid, "", connectionstring, OwnHost, key.ToString(), imagepath);
Versandpaket vp = new Versandpaket();
vp.partnernr = Convert.ToInt32(docgendata.partnernr);
vp.GASAdresse = doccreate.GAS_Adresse;
if (vp.GASAdresse.ToString().Trim() == "") { vp.GAS="";} else { vp.GAS="true";}
vp.Versandoption = doccreate.Versand_Option; ;
List<Versanddokument> vdoc = new List<Versanddokument>();
Versanddokument vd = new Versanddokument(dokumentid, doccreate.Partnernr + " - " + dokdata.Bezeichnung, doccreate.Partnernr);
@@ -272,14 +331,14 @@ namespace API_NetFramework.Controllers
vp.finaldoc = vsdoc;
vp.send_onbase_doc = true;
vp.verified = true;
send_vs(ref vp, dokdata.Ersteller,doccreate.Versand_Direkt=="Yes",OwnHost,key.ToString(),dokumentid,doccreate.Partnernr);
send_vs(ref vp, dokdata.Ersteller, doccreate.Versand_Direkt == "Yes", OwnHost, key.ToString(), dokumentid, doccreate.Partnernr);
}
if (doccreate.ConfirmationMail == "Yes")
{
string message = "Dokument '" + doccreate.Bezeichnung + "' für Partner " + doccreate.Partnernr + " erstellt."+Environment.NewLine;
string message = "Dokument '" + doccreate.Bezeichnung + "' für Partner " + doccreate.Partnernr + " erstellt." + Environment.NewLine;
if (doccreate.Result_Versandstrasse == "Yes")
{
if (doccreate.Versand_Direkt == "Yes")
@@ -296,7 +355,7 @@ namespace API_NetFramework.Controllers
return Ok(dokumentid);
}
private void send_vs(ref Versandpaket vp, string mitarbeiternr,bool direktversenden, string url, string key, string dokumentid, string partnernr)
private void send_vs(ref Versandpaket vp, string mitarbeiternr, bool direktversenden, string url, string key, string dokumentid, string partnernr)
{
string jsonstring = JsonConvert.SerializeObject(vp);
@@ -335,7 +394,7 @@ namespace API_NetFramework.Controllers
}
string URL = url + "api/Send_Versandstrasse?paketid=" + paketid.ToString();
WebRequest request;
@@ -362,7 +421,7 @@ namespace API_NetFramework.Controllers
}
if (response.ToString().Contains("*archiviert"))
{
}
}
@@ -374,7 +433,7 @@ namespace API_NetFramework.Controllers
}
catch (Exception ex)
{
Logging.DocLog.Info("Direktversand nicht möglich: "+ex.Message, "OnDoc-API", dokumentid, partnernr, "");
Logging.DocLog.Info("Direktversand nicht möglich: " + ex.Message, "OnDoc-API", dokumentid, partnernr, "");
}
}
@@ -402,8 +461,8 @@ namespace API_NetFramework.Controllers
if (!(ParamCheck("yesno", doccreate.ConfirmationMail))) { return "Parameter ConfirmationMail " + doccreate.ConfirmationMail + " ist ungültig"; }
if (!(ParamCheck("versandoption", doccreate.Versand_Option))) { return "Versandoption " + doccreate.Versand_Option + " ist ungültig"; }
if (doccreate.ConfirmationMail.ToUpper() == "YES" && doccreate.ConfirmationMailAddress.ToString() != "") { return "E-Mailadresse für Confirmation fehlt"; }
if (doccreate.TGNrUnterschriftLinks.ToString()=="") { doccreate.TGNrUnterschriftLinks = "-1"; }
if (doccreate.TGNrUnterschriftRechts.ToString() == "") { doccreate.TGNrUnterschriftRechts= "-1"; }
if (doccreate.TGNrUnterschriftLinks.ToString() == "") { doccreate.TGNrUnterschriftLinks = "-1"; }
if (doccreate.TGNrUnterschriftRechts.ToString() == "") { doccreate.TGNrUnterschriftRechts = "-1"; }
if (doccreate.FaksimileUnterschrift.ToUpper() == "YES")
{
if (doccreate.TGNrUnterschriftLinks.ToString() == "-1") { return "Faksimile Unterschrift benötigt mit den Parameter TGUnterschriftLinks"; }
@@ -421,20 +480,20 @@ namespace API_NetFramework.Controllers
if (doccreate.Result_Versandstrasse == "Yes")
{
if (ParamCheck("doktypversandstrasse", doccreate.VorlagenTypID) == false) { return "Vorlagentyp " + doccreate.VorlagenTypID + " ist nicht für die Versandstrasse konfiguriert"; }
if (doccreate.TGNrUnterschriftLinks.ToLower()!="-1" && doccreate.TGNrUnterschriftRechts.ToString() != "-1") { return "Versandstrasse mit zwei Unterschriften kann nicht automatisch angesteuert werden"; }
if (doccreate.Versand_Option=="") { return "Versandoption fehlt (A_Post, B1_Post, B2_Post"; }
}
if (doccreate.TGNrUnterschriftLinks.ToLower() != "-1" && doccreate.TGNrUnterschriftRechts.ToString() != "-1") { return "Versandstrasse mit zwei Unterschriften kann nicht automatisch angesteuert werden"; }
if (doccreate.Versand_Option == "") { return "Versandoption fehlt (A_Post, B1_Post, B2_Post"; }
}
return "";
}
catch (Exception ex) { return ex.Message; }
}
[HttpPost]
[Route("API/GenDoc")]
public IHttpActionResult GenDoc(string Partnernr, String Dokumenttypnr, string TGCreator="", string TGResp="", string TGUL="", string TGUR="", string Faksimile="", string FoU="", string PrintLogo="")
public IHttpActionResult GenDoc(string Partnernr, String Dokumenttypnr, string TGCreator = "", string TGResp = "", string TGUL = "", string TGUR = "", string Faksimile = "", string FoU = "", string PrintLogo = "")
{
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
{
@@ -442,7 +501,7 @@ namespace API_NetFramework.Controllers
}
try
{
APILogging.Log((HttpRequestMessage)Request, "Start GenDoc " , LogLevelType.Debug);
APILogging.Log((HttpRequestMessage)Request, "Start GenDoc ", LogLevelType.Debug);
if (!(ParamCheck("partnernr", Partnernr))) { return BadRequest("Partnernr " + Partnernr + " ist ungültig"); }
if (!(ParamCheck("dokumenttyp", Dokumenttypnr))) { return BadRequest("Dokumenttyp " + Dokumenttypnr + " ist ungültig"); }
@@ -453,7 +512,7 @@ namespace API_NetFramework.Controllers
if (!(ParamCheck("faksimile", Faksimile))) { return BadRequest("Parameter Faxsimile " + Faksimile + " ist ungültig"); }
if (!(ParamCheck("formohneunterschrift", FoU))) { return BadRequest("Parameter Form ohne Unterschrift " + FoU + " ist ungültig"); }
if (!(ParamCheck("printlogo", PrintLogo))) { return BadRequest("Parameter PrintLogo " + PrintLogo + " ist ungültig"); }
Database.DB db = new DB(connectionstring);
@@ -480,6 +539,8 @@ namespace API_NetFramework.Controllers
if (docgendata.verantwortlich == "0") { docgendata.verantwortlich = docgendata.ersteller; }
clsDocData dokdata = new clsDocData();
//Barcode-Parameter von Dokumenttyp
dokdata.PartnerNr = docgendata.partnernr;
dokdata.UseEDOKA_Values = "True";
dokdata.DokumenttypNr = docgendata.dokumenttypnr;
@@ -499,12 +560,12 @@ namespace API_NetFramework.Controllers
string dokumentid = "";
dokumentid = db.Create_EDOKA_Doc(dokdata, false, "");
dokdata.Dokumentid = dokumentid;
DOCGEN.Generator.DocGenerator_from_EDOKA Generator = new DOCGEN.Generator.DocGenerator_from_EDOKA(this.connectionstring);
clsdok dok = new clsdok("", "", "", "");
dok = Generator.Generate_Doc_EDOKA(dokumentid, ref dokdata);
db.Save_To_DB(dokumentid, "", dok.dokument);
APILogging.Log((HttpRequestMessage)Request, "Ende GenDoc DokumentID:"+dokumentid, LogLevelType.Debug);
APILogging.Log((HttpRequestMessage)Request, "Ende GenDoc DokumentID:" + dokumentid, LogLevelType.Debug);
return Ok(dokumentid);
}
@@ -514,14 +575,14 @@ namespace API_NetFramework.Controllers
return Content(HttpStatusCode.InternalServerError, e.Message);
}
}
private bool ParamCheck(string ParamType, string ParamValue)
{
DB db = new DB(connectionstring);
try
{
switch (ParamType)
{
case "partnernr":
@@ -573,6 +634,6 @@ namespace API_NetFramework.Controllers
}
}
}
}