Update 20241112
This commit is contained in:
@@ -13,6 +13,12 @@ using API_NetFramework.Models;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Net.Mime;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
|
||||
namespace API_NetFramework.Controllers
|
||||
{
|
||||
@@ -20,11 +26,45 @@ namespace API_NetFramework.Controllers
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks></remarks>
|
||||
///
|
||||
public class ILResponse
|
||||
{
|
||||
public int StatusCode;
|
||||
public int senderror { get; set; } = 0;
|
||||
public string response { get; set; } = "";
|
||||
}
|
||||
|
||||
public enum uploadtype
|
||||
{
|
||||
fast = 1,
|
||||
slow = 2,
|
||||
docupload = 3
|
||||
}
|
||||
|
||||
public class ArchivController : ApiController
|
||||
{
|
||||
// GET: OnBase
|
||||
string tokenfunction = "Archiv";
|
||||
string connectionstring = ConfigurationManager.ConnectionStrings["EDOKAConnectionstring"].ConnectionString;
|
||||
|
||||
private void Update_IL_Log(ref ILResponse ilr, string dokumentid)
|
||||
{
|
||||
DB dB = new DB(ConfigurationManager.ConnectionStrings["JournalConnectionstring"].ConnectionString);
|
||||
string sql = "Insert OnDoc_IL_Log (dokumentid, ilresponse,error, erstellt_am) values ('" + dokumentid + "',";
|
||||
sql = sql + "'" + ilr.response.ToString() + "',";
|
||||
if (ilr.senderror != 0) { sql = sql + "1,"; } else { sql = sql + "0,"; }
|
||||
sql = sql + "'" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "')";
|
||||
dB.Exec_SQL(sql);
|
||||
dB = null;
|
||||
}
|
||||
|
||||
private void update_dokumentstatus(string dokumentid)
|
||||
{
|
||||
DB db = new DB(connectionstring);
|
||||
db.dokument_abschliessen(dokumentid);
|
||||
db = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Archiviert das Dokument aus OnDoc in OnBase
|
||||
/// </summary>
|
||||
@@ -37,7 +77,7 @@ namespace API_NetFramework.Controllers
|
||||
[HttpGet]
|
||||
[Route("API/ArchiveDocFromDatabase")]
|
||||
|
||||
public IHttpActionResult ArchivDoc_From_Database(string DokumentID)
|
||||
public IHttpActionResult ArchivDocFromDatabase(string DokumentID)
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
@@ -45,13 +85,84 @@ namespace API_NetFramework.Controllers
|
||||
}
|
||||
try
|
||||
{
|
||||
return Ok();
|
||||
DB db = new DB(connectionstring);
|
||||
db.clear_parameter();
|
||||
db.add_parameter("@dokumentid", DokumentID);
|
||||
db.Get_Tabledata("[sp_Get_OnDoc_Parameters]", true, false);
|
||||
OnBaseDocUpload.OnBaseDokument onbasedoc = new OnBaseDocUpload.OnBaseDokument();
|
||||
|
||||
DocGet dg = new DocGet(connectionstring);
|
||||
clsdok dok = new clsdok("", "", "");
|
||||
|
||||
dok = dg.GetDocAsPDF(DokumentID);
|
||||
|
||||
if (db.dsdaten.Tables[0].Rows[0]["BpNummer"].ToString() == "")
|
||||
{
|
||||
onbasedoc.personNummer = db.dsdaten.Tables[0].Rows[0]["PersonNummer"].ToString();
|
||||
onbasedoc.bpNummer = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
onbasedoc.bpNummer = db.dsdaten.Tables[0].Rows[0]["BpNummer"].ToString();
|
||||
onbasedoc.personNummer = "";
|
||||
}
|
||||
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();
|
||||
var Attribute = new List<Model.OnBaseDocUpload.attribute>();
|
||||
foreach (System.Data.DataRow rw in db.dsdaten.Tables[1].Rows)
|
||||
{
|
||||
var p = new OnBaseDocUpload.attribute()
|
||||
{
|
||||
fieldname = rw["fieldname"].ToString(),
|
||||
fieldvalue = rw["fieldvalue"].ToString()
|
||||
};
|
||||
Attribute.Add(p);
|
||||
}
|
||||
onbasedoc.attributes = Attribute;
|
||||
onbasedoc.dokumentDatei = dok.dokument;
|
||||
db = null;
|
||||
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 + DokumentID + ".json";
|
||||
System.IO.File.WriteAllText(debugfilename, jsonstring);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log nachführen
|
||||
Update_IL_Log(ref ilr,DokumentID);
|
||||
if (ilr.senderror == 1)
|
||||
{
|
||||
return Content(HttpStatusCode.InternalServerError, ilr.response);
|
||||
}
|
||||
else
|
||||
{
|
||||
update_dokumentstatus(DokumentID);
|
||||
return Content(HttpStatusCode.OK, DokumentID + " archiviert");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +179,7 @@ namespace API_NetFramework.Controllers
|
||||
/// </returns>
|
||||
/// <remarks></remarks>
|
||||
//
|
||||
public IHttpActionResult ArchivDocBase64(string Dokument, string Dokumenttyp)
|
||||
public IHttpActionResult ArchivDocBase64(string DokumentID, string Dokumenttyp)
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
@@ -76,6 +187,7 @@ namespace API_NetFramework.Controllers
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -136,7 +248,25 @@ namespace API_NetFramework.Controllers
|
||||
}
|
||||
try
|
||||
{
|
||||
return Ok();
|
||||
if (dokumentid.Substring(0, 6).ToUpper() == "ONDOC00")
|
||||
{
|
||||
return (ArchivDocFromDatabase(dokumentid));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
DB db = new DB(connectionstring);
|
||||
db.clear_parameter();
|
||||
db.add_parameter("@dokumentid", dokumentid);
|
||||
db.Get_Tabledata("[OnDoc_IRIS_Archivierung]", true, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//return Content(HttpStatusCode.OK, "");
|
||||
|
||||
APILogging.Log((HttpRequestMessage)Request, dokumentid+" Archivierung ausgelöst", LogLevelType.Info);
|
||||
return Ok(dokumentid);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -149,6 +279,10 @@ namespace API_NetFramework.Controllers
|
||||
|
||||
public IHttpActionResult ArchivSBDoc(string sbnr, string intid, int partnernr )
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
string json = "";
|
||||
if (HttpContext.Current.Request.InputStream.Length > 0)
|
||||
{
|
||||
@@ -157,23 +291,86 @@ namespace API_NetFramework.Controllers
|
||||
json = inputStream.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
string debugfilename = @"X:\\jsontemp\" + sbnr.ToString() + "_" + intid.ToString() + "_"+partnernr.ToString()+".json";
|
||||
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 = json;
|
||||
|
||||
|
||||
ILResponse ilr = new ILResponse();
|
||||
//jsonstring = Newtonsoft.Json.JsonConvert.SerializeObject(od);
|
||||
IHttpActionResult transferResult = null;
|
||||
if (SendToOnBase != "Yes")
|
||||
{
|
||||
transferResult = Transfer_OnBase(uploadtype.slow, ref jsonstring, ref ilr);
|
||||
if (SendToFile == "Yes")
|
||||
{
|
||||
System.IO.File.WriteAllText(debugfilename, jsonstring);
|
||||
if (debugfilename != "")
|
||||
{
|
||||
debugfilename=debugfilename+ sbnr.ToString() + "_" + intid.ToString() + "_" + partnernr.ToString() + ".json";
|
||||
System.IO.File.WriteAllText(debugfilename, jsonstring);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return Content(HttpStatusCode.OK, "");
|
||||
|
||||
//Log nachführen
|
||||
Update_IL_Log(ref ilr, "SB_" + sbnr.ToString() + "_" + intid.ToString());
|
||||
return transferResult;
|
||||
//return Content(HttpStatusCode.OK, "");
|
||||
}
|
||||
|
||||
public IHttpActionResult Transfer_OnBase(uploadtype utype, ref string jsonstring, ref ILResponse ilr)
|
||||
{
|
||||
//ILResponse ilr = new ILResponse();
|
||||
string response;
|
||||
WebRequest request;
|
||||
|
||||
string url="";
|
||||
switch (utype){
|
||||
case uploadtype.fast:
|
||||
url= System.Configuration.ConfigurationManager.AppSettings["ILFast"];
|
||||
break;
|
||||
case uploadtype.slow:
|
||||
url = System.Configuration.ConfigurationManager.AppSettings["ILSlow"];
|
||||
break;
|
||||
case uploadtype.docupload:
|
||||
url = System.Configuration.ConfigurationManager.AppSettings["ILDocupload"];
|
||||
break;
|
||||
}
|
||||
|
||||
var data = Encoding.UTF8.GetBytes(jsonstring);
|
||||
request = WebRequest.Create(url);
|
||||
request.ContentLength = data.Length;
|
||||
request.ContentType = "application/json";
|
||||
request.Method = "POST";
|
||||
try
|
||||
{
|
||||
using (Stream requestStream = request.GetRequestStream())
|
||||
{
|
||||
requestStream.Write(data, 0, data.Length);
|
||||
requestStream.Close();
|
||||
|
||||
using (Stream responseStream = request.GetResponse().GetResponseStream())
|
||||
{
|
||||
using (var reader = new StreamReader(responseStream))
|
||||
{
|
||||
response = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
ilr.StatusCode = 0;
|
||||
ilr.senderror = 0;
|
||||
ilr.response=response;
|
||||
return Content(HttpStatusCode.OK, ilr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ilr.StatusCode = 1;
|
||||
ilr.senderror = 1;
|
||||
ilr.response = ex.Message;
|
||||
return Content(HttpStatusCode.InternalServerError, ilr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ using Database;
|
||||
using Newtonsoft.Json;
|
||||
using API_NetFramework.Models;
|
||||
using System.Security.Cryptography;
|
||||
using edoka_dms;
|
||||
|
||||
|
||||
namespace API_NetFramework.Controllers
|
||||
@@ -102,6 +103,11 @@ namespace API_NetFramework.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
DocGet dg = new DocGet(connectionstring);
|
||||
clsdok dok = new clsdok("", "", "");
|
||||
|
||||
dok = dg.GetDocAsPDF(dokid);
|
||||
|
||||
db.Exec_SQL("Update dokument set loeschgrund='Archiviert' where dokumentid='" + dokid + "'");
|
||||
db = null;
|
||||
return Ok("Archivierung ausgelöst");
|
||||
|
||||
@@ -51,11 +51,13 @@ namespace API_NetFramework.Controllers
|
||||
string filename = path + TGNummer + ".pdf";
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Unterschrift-Bezug - nicht vorhanden: " + TGNummer, LogLevelType.Info);
|
||||
return Content(HttpStatusCode.NotFound, "Image " + filename + " not found");
|
||||
}
|
||||
try
|
||||
{
|
||||
byte[] b = System.IO.File.ReadAllBytes(filename);
|
||||
APILogging.Log((HttpRequestMessage)Request, "Unterschrift-Bezug: "+ TGNummer, LogLevelType.Info);
|
||||
return Ok(Convert.ToBase64String(b));
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
Reference in New Issue
Block a user