update 20250324

This commit is contained in:
Stefan Hutter
2025-03-24 21:19:13 +01:00
parent 9651721aa0
commit c767e2ed82
184 changed files with 908767 additions and 445 deletions

View File

@@ -24,6 +24,8 @@ using DOCGEN.Klassen;
using CSVNET;
using System.Data;
using Helper;
using System.Runtime.CompilerServices;
using System.Web.UI.WebControls;
namespace API_NetFramework.Controllers
@@ -140,7 +142,7 @@ namespace API_NetFramework.Controllers
[HttpGet]
[Route("API/ArchiveDocFromDatabase")]
public IHttpActionResult ArchivDocFromDatabase(string DokumentID)
public IHttpActionResult ArchivDocFromDatabase(string DokumentID, string pdfdoc = "")
{
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
{
@@ -305,6 +307,10 @@ namespace API_NetFramework.Controllers
onbasedoc.attributes.Add(na);
}
onbasedoc.dokumentDatei = dok.dokument;
if(pdfdoc != ""){
onbasedoc.dokumentDatum=pdfdoc;
}
db = null;
ILResponse ilr = new ILResponse();
string debugfilename = System.Configuration.ConfigurationManager.AppSettings["JSONDebugPath"];
@@ -539,5 +545,125 @@ namespace API_NetFramework.Controllers
return Content(HttpStatusCode.InternalServerError, ilr);
}
}
[HttpPost]
[Route("API/Send_Versandstrasse")]
public IHttpActionResult Send_Versandstrasse()
{
string json_versandpaket = Request.Content.ReadAsStringAsync().Result;
Versandpaket versandpaket = new Versandpaket();
versandpaket.Dokument = new List<Versanddokument>();
versandpaket = JsonConvert.DeserializeObject<Versandpaket>(json_versandpaket);
string inthandle = "";
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
{
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
}
string ArchivAktiv;
ArchivAktiv = System.Configuration.ConfigurationManager.AppSettings["ArchivierungAktiv"].ToString();
if (ArchivAktiv != "True")
{
string message = "Hinweismeldung: " + System.Configuration.ConfigurationManager.AppSettings["ArchivierungNoAktivMessage"].ToString();
return Content(HttpStatusCode.OK, message);
}
try
{
OnBase_Attributes oba = new OnBase_Attributes();
if (!versandpaket.send_onbase_doc)
{
oba.BPNummer = versandpaket.partnernr.ToString();
oba.DocumentHandle = "";
oba.DistributionOption = versandpaket.Versandoption.ToString();
oba.GASCouvert = versandpaket.GAS;
oba.Returnaddress = versandpaket.GASAdresse;
oba.O2ODochandle = "";
oba.Status = "";
}
else
{
foreach (Versanddokument vd in versandpaket.Dokument)
{
IHttpActionResult res = ArchivDocFromDatabase(vd.DokumentID, vd.dokument);
DB db = new DB(connectionstring);
db.clear_parameter();
db.add_parameter("@dokumentid", vd.DokumentID);
db.Get_Tabledata("sp_get_handle", true, false);
if (db.dsdaten.Tables[0].Rows.Count > 0)
{
inthandle = db.dsdaten.Tables[0].Rows[0][0].ToString();
oba.DocumentHandle = inthandle;
versandpaket.finaldoc = "";
}
db = null;
}
}
OnBaseDocUpload.OnBaseDokument onbasedoc = new OnBaseDocUpload.OnBaseDokument();
onbasedoc.bpNummer = oba.BPNummer;
onbasedoc.personNummer = "";
onbasedoc.dokumentDatum = DateTime.Now.ToString("dd.MM.yyyy");
onbasedoc.dokumentDatei = versandpaket.finaldoc;
onbasedoc.dateiTyp = "PDF";
onbasedoc.attributes = new List<OnBaseDocUpload.attribute>();
onbasedoc.attributes.Add(new OnBaseDocUpload.attribute("Document Handle",oba.DocumentHandle.ToString()));
onbasedoc.attributes.Add(new OnBaseDocUpload.attribute("O2O DistributionOption",oba.DistributionOption.ToString()));
onbasedoc.attributes.Add(new OnBaseDocUpload.attribute("O2O GasCouvert", oba.GASCouvert.ToString()));
onbasedoc.attributes.Add(new OnBaseDocUpload.attribute("O2O Returnaddress", oba.Returnaddress.ToString()));
onbasedoc.attributes.Add(new OnBaseDocUpload.attribute("O2O Dochandle", oba.O2ODochandle.ToString()));
onbasedoc.attributes.Add(new OnBaseDocUpload.attribute("O2O Status", oba.Status.ToString()));
ILResponse ilr = new ILResponse();
string debugfilename = System.Configuration.ConfigurationManager.AppSettings["JSONDebugPath"];
string SendToOnBase = System.Configuration.ConfigurationManager.AppSettings["SendToOnBase"];
string SendToFile = System.Configuration.ConfigurationManager.AppSettings["SendToFile"];
string debugdir = System.Configuration.ConfigurationManager.AppSettings["DebugDir"];
string jsonstring = Newtonsoft.Json.JsonConvert.SerializeObject(onbasedoc);
IHttpActionResult transferResult = null;
if (SendToOnBase != "Yes")
{
transferResult = Transfer_OnBase(uploadtype.fast, ref jsonstring, ref ilr);
if (SendToFile == "Yes")
{
if (debugfilename != "")
{
debugfilename = debugfilename + "VS_"+oba.BPNummer+"_"+DateTime.Now.ToString("yyyyMMddhhmmss")+".json";
System.IO.File.WriteAllText(debugfilename, jsonstring);
debugfilename = debugfilename + ".pdf";
Helper.clsFileHelper fh = new Helper.clsFileHelper();
fh.SaveBase64ToFile(onbasedoc.dokumentDatei, debugfilename);
fh = null;
}
}
}
APILogging.Log((HttpRequestMessage)Request, "Opload Versandstrasse:" + debugfilename, LogLevelType.Debug);
//Log nachführen
// Update_IL_Log(ref ilr, DokumentID);
if (ilr.senderror == 1)
{
return Content(HttpStatusCode.InternalServerError, ilr.response);
}
else
{
update_dokumentstatus(debugfilename);
return Content(HttpStatusCode.OK, oba.BPNummer.ToString() + " *archiviert*");
}
}
catch (Exception e)
{
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
return Content(HttpStatusCode.InternalServerError, e.Message);
}
finally
{
}
}
}
}