update 20260303
This commit is contained in:
@@ -1,34 +1,39 @@
|
||||
using System;
|
||||
using API_NetFramework.Models;
|
||||
using CSVNET;
|
||||
using Database;
|
||||
using DOCGEN;
|
||||
using DOCGEN.Klassen;
|
||||
using edoka_dms;
|
||||
using Helper;
|
||||
using Logging;
|
||||
using Microsoft.Ajax.Utilities;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.SqlServer.Server;
|
||||
using Model;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using SecuringWebApiUsingApiKey.Middleware;
|
||||
using Swashbuckle.Swagger;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using DOCGEN;
|
||||
using Model;
|
||||
using Database;
|
||||
using Newtonsoft.Json;
|
||||
using API_NetFramework.Models;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Mime;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using System.Security.Cryptography;
|
||||
using System.Net.Http.Headers;
|
||||
using SecuringWebApiUsingApiKey.Middleware;
|
||||
using DOCGEN.Klassen;
|
||||
using CSVNET;
|
||||
using System.Data;
|
||||
using Helper;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using System.Web.UI.WebControls;
|
||||
using edoka_dms;
|
||||
using Microsoft.Ajax.Utilities;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
|
||||
namespace API_NetFramework.Controllers
|
||||
@@ -46,6 +51,7 @@ namespace API_NetFramework.Controllers
|
||||
}
|
||||
|
||||
|
||||
|
||||
public enum uploadtype
|
||||
{
|
||||
fast = 1,
|
||||
@@ -147,7 +153,7 @@ namespace API_NetFramework.Controllers
|
||||
[HttpGet]
|
||||
[Route("API/ArchiveDocFromDatabase")]
|
||||
|
||||
public IHttpActionResult ArchivDocFromDatabase(string DokumentID, string pdfdoc = "")
|
||||
public IHttpActionResult ArchivDocFromDatabase(string DokumentID, string pdfdoc = "", string force = "")
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
@@ -179,9 +185,13 @@ namespace API_NetFramework.Controllers
|
||||
//db.Get_Tabledata("Select erstellunginoffice from dokumenttyp where dokumenttypnr="+doktypnr.ToString(), false, true);
|
||||
|
||||
SQL = "Select erstellunginoffice from dokumenttyp where dokumenttypnr=@doktypnr";
|
||||
db.clear_parameter();
|
||||
db.add_parameter("@doktypnr", doktypnr);
|
||||
db.Get_Tabledata_Addvar(SQL, false, true);
|
||||
|
||||
if (force=="TRUE")
|
||||
{
|
||||
db.dsdaten.Tables[0].Rows[0]["Erstellunginoffice"] = false;
|
||||
}
|
||||
if (Convert.ToBoolean(db.dsdaten.Tables[0].Rows[0]["Erstellunginoffice"]))
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, DokumentID + " ErstellungInOffec - EDKB02DMS", LogLevelType.Debug);
|
||||
@@ -221,7 +231,8 @@ namespace API_NetFramework.Controllers
|
||||
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
;
|
||||
return Content(HttpStatusCode.OK, DokumentID + " archiviert");
|
||||
}
|
||||
|
||||
@@ -302,7 +313,7 @@ namespace API_NetFramework.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
dok = dg.GetDocAsPDF(DokumentID);
|
||||
extension = "PDF";
|
||||
}
|
||||
@@ -330,7 +341,7 @@ namespace API_NetFramework.Controllers
|
||||
onbasedoc.attributes.Add(na);
|
||||
}
|
||||
onbasedoc.dokumentDatei = dok.dokument;
|
||||
|
||||
|
||||
|
||||
if (pdfdoc != "")
|
||||
{
|
||||
@@ -484,7 +495,8 @@ namespace API_NetFramework.Controllers
|
||||
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
@@ -558,7 +570,8 @@ namespace API_NetFramework.Controllers
|
||||
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
@@ -713,7 +726,7 @@ namespace API_NetFramework.Controllers
|
||||
onbasedoc.dokumentDatum = db.dsdaten.Tables[0].Rows[0]["DokumentDatum"].ToString();
|
||||
onbasedoc.dokumentTyp = db.dsdaten.Tables[0].Rows[0]["dokumenttyp"].ToString();
|
||||
onbasedoc.dateiTyp = db.dsdaten.Tables[0].Rows[0]["dateityp"].ToString();
|
||||
|
||||
|
||||
|
||||
onbasedoc.attributes = new List<Model.OnBaseDocUpload.attribute>();
|
||||
foreach (System.Data.DataRow rw in db.dsdaten.Tables[1].Rows)
|
||||
@@ -814,7 +827,7 @@ namespace API_NetFramework.Controllers
|
||||
oba.O2ODochandle = "";
|
||||
oba.Status = "";
|
||||
oba.ReferenceId = versandpaket.ReferenceID;
|
||||
|
||||
|
||||
//if (oba.GASCouvert == "") { oba.GASCouvert = "false"; } else { oba.GASCouvert = "true"; }
|
||||
foreach (Versanddokument vd in versandpaket.Dokument)
|
||||
{
|
||||
@@ -832,7 +845,7 @@ namespace API_NetFramework.Controllers
|
||||
oba.Returnaddress = versandpaket.GASAdresse;
|
||||
oba.O2ODochandle = "";
|
||||
oba.Status = "";
|
||||
oba.ReferenceId = versandpaket.ReferenceID;
|
||||
oba.ReferenceId = versandpaket.ReferenceID;
|
||||
|
||||
foreach (Versanddokument vd in versandpaket.Dokument)
|
||||
{
|
||||
@@ -1030,5 +1043,248 @@ namespace API_NetFramework.Controllers
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("API/ArchivDocIL")]
|
||||
public IHttpActionResult ArchivDocIL()
|
||||
{
|
||||
int a = 0;
|
||||
APIErrorSimple apireturn = new APIErrorSimple();
|
||||
APIOK apiok = new APIOK();
|
||||
ArchiveDoc archivdoc = new ArchiveDoc();
|
||||
try
|
||||
{
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
Logging.APIDocLog.Info("Start ArchivDocIL", "CreateDoc", guid, "");
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
apireturn.code = "ONDOC-ERR-ArchivDocIL-01";
|
||||
apireturn.status = "401";
|
||||
apireturn.message = "Invalid Token or API-Key";
|
||||
apireturn.traceid = "";
|
||||
apireturn.field = "";
|
||||
|
||||
return Content(HttpStatusCode.BadRequest, apireturn);
|
||||
}
|
||||
|
||||
|
||||
string ArchivAktiv;
|
||||
ArchivAktiv = System.Configuration.ConfigurationManager.AppSettings["ArchivierungAktiv"].ToString();
|
||||
if (ArchivAktiv != "True")
|
||||
{
|
||||
apireturn.code = "ONDOC-ERR-ArchivDocIL-02";
|
||||
apireturn.status = "401";
|
||||
apireturn.message = "Archivierung z.Zt. inaktiv";
|
||||
apireturn.traceid = "";
|
||||
apireturn.field = "";
|
||||
|
||||
return Content(HttpStatusCode.BadRequest, apireturn);
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
HttpRequestMessage rmsg = (HttpRequestMessage)Request;
|
||||
string OwnHost = System.Configuration.ConfigurationManager.AppSettings["OwnHost"].ToString();
|
||||
string imagepath = System.Configuration.ConfigurationManager.AppSettings["VSImagePath"].ToString();
|
||||
|
||||
var key = rmsg.Headers.Authorization.Parameter.ToString();
|
||||
string result = Request.Content.ReadAsStringAsync().Result;
|
||||
var root = JsonConvert.DeserializeObject<JsonTable>(result);
|
||||
Logging.APIDocLog.Info("Input JSON", "CreateDoc", guid, result);
|
||||
|
||||
|
||||
archivdoc = JsonConvert.DeserializeObject<ArchiveDoc>(result);
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start ArchivDocFromIRIS DokumentID: " + archivdoc.DokumentID, LogLevelType.Debug);
|
||||
int i = 0;
|
||||
if (archivdoc.DokumentID != "")
|
||||
{
|
||||
if (!archivdoc.Dokument.Contains("OFFEDK"))
|
||||
{
|
||||
string savedokumentid = archivdoc.DokumentID;
|
||||
DB db = new DB(connectionstring);
|
||||
try
|
||||
{
|
||||
db.Get_Tabledata("Select dokumentid from OnDoc_CLM_Dokumente where clmdokumentid='" + archivdoc.DokumentID + "'", false, true);
|
||||
archivdoc.DokumentID = db.dsdaten.Tables[0].Rows[0][0].ToString(); ;
|
||||
}
|
||||
catch
|
||||
{
|
||||
apireturn.code = "ONDOC-ERR-ArchivDocIL-04";
|
||||
apireturn.status = "401";
|
||||
apireturn.message = "Dokument nicht gefunden für ID :" + archivdoc.DokumentID;
|
||||
apireturn.traceid = "";
|
||||
apireturn.field = "";
|
||||
return Content(HttpStatusCode.BadRequest, apireturn);
|
||||
}
|
||||
finally { db = null; }
|
||||
}
|
||||
int i1 = 0;
|
||||
// var hres = ArchivDocFromDatabase(archivdoc.DokumentID);
|
||||
IHttpActionResult result1 = ArchivDocFromDatabase(archivdoc.DokumentID,"","TRUE");
|
||||
|
||||
// Execute the result
|
||||
HttpResponseMessage response = result1.ExecuteAsync(CancellationToken.None).Result;
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string content = response.Content.ReadAsStringAsync().Result;
|
||||
apiok.file = "";
|
||||
apiok.code = "OK";
|
||||
apiok.status = "200";
|
||||
apiok.documentid = archivdoc.DokumentID;
|
||||
return Content(HttpStatusCode.OK, apiok);
|
||||
}
|
||||
else
|
||||
{
|
||||
apireturn.code = "ONDOC-ERR-ArchivDocIL-05";
|
||||
apireturn.status = "401";
|
||||
apireturn.message = "Archivierung nicht OK:" + archivdoc.DokumentID;
|
||||
apireturn.traceid = "";
|
||||
apireturn.field = "";
|
||||
return Content(HttpStatusCode.BadRequest, apireturn);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//archivdoc.DokumentDatum = "07/16/2025";
|
||||
archivdoc.DokumentDatum = OnDocAPI_NetFramework.Helper.Helper.NormalizeDateToSystemFormat(archivdoc.DokumentDatum);
|
||||
|
||||
DateTime date = Convert.ToDateTime(archivdoc.DokumentDatum);
|
||||
archivdoc.DokumentDatum = date.ToString("dd.MM.yyyy");
|
||||
//DateTime d = Convert.ToDateTime(archivdoc.DokumentDatum);
|
||||
//archivdoc.DokumentDatum = d.ToString("dd.MM.yyyy");
|
||||
DB db = new DB(connectionstring);
|
||||
db.clear_parameter();
|
||||
db.add_parameter("@dokumenttypnr", archivdoc.DokumenttypNr);
|
||||
db.add_parameter("@partnernr", archivdoc.PartnerNr);
|
||||
db.add_parameter("@status", archivdoc.Status);
|
||||
db.add_parameter("@verantwortlich", archivdoc.TGResponsible);
|
||||
db.add_parameter("@ersteller", archivdoc.TGCreatedBy);
|
||||
|
||||
db.Get_Tabledata("dbo.sp_ondoc_get_archiv_parameter", true, false);
|
||||
OnBaseDocUpload.OnBaseDokument onbasedoc = new OnBaseDocUpload.OnBaseDokument();
|
||||
var Attribute = new List<Model.OnBaseDocUpload.attribute>();
|
||||
onbasedoc.attributes = new List<Model.OnBaseDocUpload.attribute>();
|
||||
onbasedoc.dokumentTyp = db.dsdaten.Tables[0].Rows[0][0].ToString();
|
||||
onbasedoc.bpNummer = db.dsdaten.Tables[0].Rows[0][2].ToString();
|
||||
onbasedoc.personNummer = db.dsdaten.Tables[0].Rows[0][3].ToString();
|
||||
onbasedoc.dokumentDatum = archivdoc.DokumentDatum.ToString();
|
||||
onbasedoc.dokumentDatei = archivdoc.Dokument;
|
||||
onbasedoc.dateiTyp = archivdoc.DokumentType;
|
||||
|
||||
Add_Attribute(ref onbasedoc, "EDOKA Dokument-ID", "");
|
||||
Add_Attribute(ref onbasedoc, "EDOKA Dokumenttyp Nr", archivdoc.DokumenttypNr);
|
||||
Add_Attribute(ref onbasedoc, "Bezeichnung", db.dsdaten.Tables[0].Rows[0][1].ToString());
|
||||
Add_Attribute(ref onbasedoc, "Dokumenttyp", db.dsdaten.Tables[0].Rows[0][0].ToString());
|
||||
if (db.dsdaten.Tables[0].Rows[0][3].ToString() == "")
|
||||
{
|
||||
Add_Attribute(ref onbasedoc, "BP Nummer", onbasedoc.bpNummer);
|
||||
}
|
||||
else
|
||||
{
|
||||
Add_Attribute(ref onbasedoc, "Person Nummer", onbasedoc.personNummer);
|
||||
}
|
||||
Add_Attribute(ref onbasedoc, "Partner Kurzname/Ort", db.dsdaten.Tables[0].Rows[0][5].ToString());
|
||||
if (db.dsdaten.Tables[0].Rows[0][4].ToString() == "In Aufbewahrung")
|
||||
{
|
||||
Add_Attribute(ref onbasedoc, "Status Korrespondenz", db.dsdaten.Tables[0].Rows[0][4].ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
Add_Attribute(ref onbasedoc, "Status Verträge", db.dsdaten.Tables[0].Rows[0][4].ToString());
|
||||
|
||||
}
|
||||
Add_Attribute(ref onbasedoc, "Original Filename", guid);
|
||||
Add_Attribute(ref onbasedoc, "Dokumentdatum", archivdoc.DokumentDatum);
|
||||
Add_Attribute(ref onbasedoc, "Verantwortlich Email", db.dsdaten.Tables[0].Rows[0][6].ToString());
|
||||
Add_Attribute(ref onbasedoc, "Verantwortlich Name", db.dsdaten.Tables[0].Rows[0][7].ToString());
|
||||
Add_Attribute(ref onbasedoc, "Verantwortlich Benutzername", archivdoc.TGResponsible);
|
||||
Add_Attribute(ref onbasedoc, "Created By", archivdoc.TGCreatedBy);
|
||||
Add_Attribute(ref onbasedoc, "Papierkorb", "NEIN");
|
||||
Add_Attribute(ref onbasedoc, "Herkunftsapplikation", archivdoc.Herkunftsapplikation);
|
||||
Add_Attribute(ref onbasedoc, "ExternalReference", archivdoc.Reference);
|
||||
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;
|
||||
ILResponse ilr = new ILResponse();
|
||||
if (SendToOnBase != "Yes")
|
||||
{
|
||||
if (SendToFile == "Yes")
|
||||
{
|
||||
if (debugfilename != "")
|
||||
{
|
||||
debugfilename = debugfilename + guid + ".json";
|
||||
System.IO.File.WriteAllText(debugfilename, jsonstring);
|
||||
debugfilename = debugfilename + ".pdf";
|
||||
Helper.clsFileHelper fh = new Helper.clsFileHelper();
|
||||
fh.SaveBase64ToFile(onbasedoc.dokumentDatei, debugfilename);
|
||||
fh = null;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
transferResult = Transfer_OnBase(uploadtype.fast, ref jsonstring, ref ilr);
|
||||
HttpResponseMessage response = transferResult.ExecuteAsync(CancellationToken.None).Result;
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string content = response.Content.ReadAsStringAsync().Result;
|
||||
apiok.file = "";
|
||||
apiok.code = "OK";
|
||||
apiok.status = "200";
|
||||
apiok.documentid = guid;
|
||||
return Content(HttpStatusCode.OK, apiok);
|
||||
}
|
||||
else
|
||||
{
|
||||
apireturn.code = "ONDOC-ERR-ArchivDocIL-06";
|
||||
apireturn.status = "401";
|
||||
apireturn.message = "Archivierung nicht OK:" + guid;
|
||||
apireturn.traceid = "";
|
||||
apireturn.field = "";
|
||||
return Content(HttpStatusCode.BadRequest, apireturn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return Content(HttpStatusCode.InternalServerError, "e.Message");
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
apireturn.code = "ONDOC-ERR-ArchivDocIL-03";
|
||||
apireturn.status = "401";
|
||||
apireturn.message = ex.Message; ;
|
||||
apireturn.traceid = "";
|
||||
apireturn.field = "";
|
||||
apireturn = null; apiok = null;
|
||||
return Content(HttpStatusCode.BadRequest, apireturn);
|
||||
}
|
||||
finally
|
||||
{
|
||||
apireturn = null; apiok = null; archivdoc = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private void Add_Attribute(ref OnBaseDocUpload.OnBaseDokument onbasedoc, string Attributname, string value)
|
||||
{
|
||||
OnBaseDocUpload.attribute na = new OnBaseDocUpload.attribute(Attributname, value);
|
||||
onbasedoc.attributes.Add(na);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user