update 20260406

This commit is contained in:
Stefan Hutter
2026-04-06 12:40:02 +02:00
parent e82057b6e4
commit 7a28e0c2bb
519 changed files with 318370 additions and 634840 deletions

View File

@@ -1,50 +1,51 @@
using System;
using API_NetFramework.Models;
using Database;
using DOCGEN;
using edoka_dms;
using Microsoft.Ajax.Utilities;
using Microsoft.Extensions.Options;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OnDocAPI_NetFramework.Controllers;
using OnDocAPI_NetFramework.Helper;
using SecuringWebApiUsingApiKey.Middleware;
using Syncfusion.CompoundFile.DocIO.Native;
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIO.DLS.XML;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Text;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
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.Net.Mail;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Runtime.Serialization.Json;
using System.Security.Cryptography;
using edoka_dms;
using SecuringWebApiUsingApiKey.Middleware;
using System.Linq.Expressions;
using System.Data;
using System.Web.Management;
using System.Web;
using System.IO;
using OnDocAPI_NetFramework.Controllers;
using Versandstrasse;
using System.ComponentModel;
using System.Text;
using System.Text.Json.Serialization;
using Microsoft.Ajax.Utilities;
using System.Collections;
using Microsoft.Extensions.Options;
using System.Web;
using System.Web.Helpers;
using Syncfusion.CompoundFile.DocIO.Native;
using System.Web.UI.WebControls;
using System.Drawing.Text;
using System.Runtime.InteropServices.ComTypes;
using System.Reflection;
using Newtonsoft.Json.Linq;
using System.Runtime.Serialization.Json;
using System.Web.Http;
using System.Web.Http.Results;
using Syncfusion.DocIO.DLS.XML;
using System.Reflection.Emit;
using System.Web.UI.WebControls.WebParts;
using System.Diagnostics;
using OnDocAPI_NetFramework.Helper;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Web.Management;
using System.Web.ModelBinding;
using System.Net.Mail;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Versandstrasse;
@@ -130,11 +131,92 @@ namespace API_NetFramework.Controllers
}
[Route("API/GetDocumentIL")]
[HttpGet]
public IHttpActionResult GetDocumentIL(string dokid)
{
APIErrorSimple apireturn = new APIErrorSimple();
APIOK apiok = new APIOK();
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
{
apireturn.code = "ONDOC-ERR-DokumentGenerator-01";
apireturn.status = "401";
apireturn.message = "Invalid Token or API-Key";
apireturn.traceid = "";
apireturn.field = "";
try
{
//return BadRequest(Newtonsoft.Json.JsonConvert.SerializeObject(apireturn));
return Content(HttpStatusCode.BadRequest, apireturn);
}
catch
{
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
}
finally { apireturn = null; apiok = null; }
}
try
{
APILogging.Log((HttpRequestMessage)Request, "Start GetDokumentIL DokumentID:" + dokid, LogLevelType.Debug);
DOCGEN.DocGet gd = new DocGet(connectionstring);
clsdok dok = new clsdok("", "", "", "");
try
{
dok = gd.GetDocAsPDF(dokid);
}
catch { }
if (dok.dokument == "")
{
DB db = new DB(connectionstring);
string sql = "SELECT dbo.BinaryToBase64(dokument) FROM dbo.OnDoc_CLM_Dokumente INNER JOIN dbo.Doks ON dbo.OnDoc_CLM_Dokumente.dokumentid = dbo.Doks.DokumentID ";
sql = sql + " where dbo.ondoc_clm_dokumente.aktiv=1 and dbo.ondoc_clm_dokumente.clmdokumentid='" + dokid + "'";
db.Get_Tabledata(sql, false, true);
dok.dokument = db.dsdaten.Tables[0].Rows[0][0].ToString();
db = null;
}
dok.extension = "pdf";
dok.doktype = "P";
apiok.code = "200";
apiok.status = "200";
apiok.message = "Dokumentid: " + dokid;
apiok.documentid = dokid;
apiok.file = dok.dokument;
return Ok(apiok);
}
catch (Exception e)
{
apireturn.code = "ONDOC-ERR-DokumentGenerator-03";
apireturn.status = "401";
apireturn.message = "Dokument mit ID '" + dokid + "' nicht vorhanden";
apireturn.traceid = "";
apireturn.field = "";
try
{
//return BadRequest(Newtonsoft.Json.JsonConvert.SerializeObject(apireturn));
return Content(HttpStatusCode.BadRequest, apireturn);
}
catch
{
return Content(HttpStatusCode.BadRequest, apireturn);
}
finally { apireturn = null; apiok = null; }
}
finally { apireturn = null; apiok = null; }
}
[HttpPost]
[Route("API/DokumentGenerator")]
public IHttpActionResult DokumentGenerator()
{
APIErrorSimple apireturn = new APIErrorSimple();
APIOK apiok = new APIOK();
try
@@ -159,7 +241,7 @@ namespace API_NetFramework.Controllers
m.typ = 1;
m.subject = "ONDOC-ERR-DokumentGenerator-01";
m.message = "Invalid Token or API-Key";
m.guid=guid; ;
m.guid = guid; ;
m.dokumentid = "";
m.empfaenger = "";
m.bezeichnung = "";
@@ -188,7 +270,8 @@ namespace API_NetFramework.Controllers
//Send_Confirmation("True", "", "OnDocAPI-Error - DokumentGenerator - GUID: " + guid, "Fehler: Invalid Token or API-Key", true);
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
}
finally { apireturn = null; apiok = null; };
finally { apireturn = null; apiok = null; }
;
}
HttpRequestMessage rmsg = (HttpRequestMessage)Request;
@@ -243,7 +326,7 @@ namespace API_NetFramework.Controllers
Send_Confirmation(ref m);
//Send_Confirmation("TRUE", "", "OnDoc-API-Error - DokumentGenerator - GUID: " + guid, "Invalid Token or API-Key", true);
return Content(HttpStatusCode.BadRequest, apireturn);
return Content(HttpStatusCode.BadRequest, apireturn);
}
catch { return BadRequest(); }
@@ -257,11 +340,11 @@ namespace API_NetFramework.Controllers
[Route("API/CreateDoks")]
public IHttpActionResult CreateDoks()
{
APIErrorSimple apireturn = new APIErrorSimple();
APIOK apiok = new APIOK();
string mailbody = "";
try
{
guid = Guid.NewGuid().ToString();
@@ -281,7 +364,7 @@ namespace API_NetFramework.Controllers
m0.typ = 1;
m0.subject = "ONDOC-ERR-CreateDoks-01";
m0.message = "Invalid Token or API-Key";
m0.guid = guid ;
m0.guid = guid;
m0.dokumentid = "";
m0.empfaenger = "";
m0.bezeichnung = "";
@@ -311,7 +394,8 @@ namespace API_NetFramework.Controllers
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
}
finally { apireturn = null; apiok = null; };
finally { apireturn = null; apiok = null; }
;
//return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
}
@@ -322,14 +406,14 @@ namespace API_NetFramework.Controllers
var key = rmsg.Headers.Authorization.Parameter.ToString();
string result = Request.Content.ReadAsStringAsync().Result;
DokumentCreate paket = new DokumentCreate();
paket = JsonConvert.DeserializeObject<DokumentCreate>(result);
mailbody = "Guten Tag<br><br>Dokumentpaket " + paket.Paketbezeichnung + " ";
if (string.IsNullOrEmpty(paket.VersandOption)) { paket.VersandOption = "B1_Post"; }
Logging.APIDocLog.Info("Input Json", "CreateDoks", guid, result);
result = "";
// Logging.APIDocLog.Info("Herkunftsapplikation", "CreateDoks", guid, paket.Herkunftsapplikation);
// Logging.APIDocLog.Info("Ersteller", "CreateDoks", guid, paket.Dokumente[0].TGNrErsteller);
// Logging.APIDocLog.Info("Herkunftsapplikation", "CreateDoks", guid, paket.Herkunftsapplikation);
// Logging.APIDocLog.Info("Ersteller", "CreateDoks", guid, paket.Dokumente[0].TGNrErsteller);
string CheckResult = "";
@@ -382,12 +466,13 @@ namespace API_NetFramework.Controllers
paket = null;
return Content(HttpStatusCode.BadRequest, apireturn);
}
finally { apireturn = null; apiok = null; };
finally { apireturn = null; apiok = null; }
;
}
try
{
mailbody = mailbody + "Parnternr:" + paket.Dokumente[0].PartnerNr+" ";
mailbody = mailbody + "Parnternr:" + paket.Dokumente[0].PartnerNr + " ";
int anhangnr = 0;
foreach (APIDokument dokument in paket.Dokumente)
{
@@ -405,11 +490,11 @@ namespace API_NetFramework.Controllers
clsDocData dokdata = new clsDocData();
Model.clsdocgendata docgendata = new Model.clsdocgendata();
DocCreate doccreate = new DocCreate();
OnDocAPI_NetFramework.Helper.Helper.CopyProperties(dokdata, docgendata);
OnDocAPI_NetFramework.Helper.Helper.CopyProperties(dokument, doccreate);
doccreate.Reference = paket.Reference;
doccreate.ResultFileType=paket.ResultFileType;
doccreate.ResultFileType = paket.ResultFileType;
dokument.DokumentID = gendoc(ref doccreate, ref dokdata, ref docgendata, key.ToString());
dokument.DokumentID = dokdata.Dokumentid;
dokdata = null;
@@ -466,7 +551,8 @@ namespace API_NetFramework.Controllers
Send_Confirmation(ref m1);
return Content(HttpStatusCode.BadRequest, apireturn);
}
finally { apireturn = null; apiok = null; };
finally { apireturn = null; apiok = null; }
;
}
@@ -602,7 +688,7 @@ namespace API_NetFramework.Controllers
m0.forceadminmail = false;
m0.Herkunftsapplikation = paket.Herkunftsapplikation;
Send_Confirmation(ref m0);
return Content(HttpStatusCode.BadRequest, apireturn);
}
}
@@ -625,8 +711,8 @@ namespace API_NetFramework.Controllers
m.partnernr = paket.Dokumente[0].PartnerNr; ;
m.sendmail = paket.ConfirmationMail == "true";
m.forceadminmail = false;
Send_Confirmation(ref m);
Send_Confirmation(ref m);
return Ok((apireturn));
}
catch (Exception ex)
@@ -651,11 +737,12 @@ namespace API_NetFramework.Controllers
m.partnernr = "";
m.sendmail = true;
m.forceadminmail = true;
Send_Confirmation(ref m);
Send_Confirmation(ref m);
return Content(HttpStatusCode.BadRequest, apireturn);
}
finally { apireturn = null; apiok = null; };
finally { apireturn = null; apiok = null; }
;
}
[HttpPost]
@@ -711,7 +798,8 @@ namespace API_NetFramework.Controllers
Send_Confirmation(ref m1);
return Content(HttpStatusCode.BadRequest, apireturn);
}
finally { apireturn = null; apiok = null; };
finally { apireturn = null; apiok = null; }
;
}
HttpRequestMessage rmsg = (HttpRequestMessage)Request;
string OwnHost = System.Configuration.ConfigurationManager.AppSettings["OwnHost"].ToString();
@@ -725,7 +813,7 @@ namespace API_NetFramework.Controllers
DocCreate doccreate = new DocCreate();
//dynamic data = JsonConvert.DeserializeObject(result);
doccreate = JsonConvert.DeserializeObject<DocCreate>(result);
mailbody = "Guten Tag<br><br>Dokumenterstellung " + doccreate.Bezeichnung+" für Partner:"+doccreate.PartnerNr + " ";
mailbody = "Guten Tag<br><br>Dokumenterstellung " + doccreate.Bezeichnung + " für Partner:" + doccreate.PartnerNr + " ";
result = "";
@@ -767,7 +855,7 @@ namespace API_NetFramework.Controllers
if (doccreate.TGNrUnterschriftLinks != "-1" && doccreate.UnterschriftLinksGeprueft == "false") { checkinondoc = true; }
if (doccreate.TGNrUnterschriftRechts != "-1" && doccreate.UnterschriftRechtsGeprueft == "false") { checkinondoc = true; }
}
if (checkinondoc==true) { dokdata.print_signature = false; }
if (checkinondoc == true) { dokdata.print_signature = false; }
string dokumentid = gendoc(ref doccreate, ref dokdata, ref docgendata, key.ToString());
dokumentid = dokdata.Dokumentid;
@@ -833,7 +921,7 @@ namespace API_NetFramework.Controllers
}
}
if (checkinondoc)
{
string approval1 = "0";
@@ -842,14 +930,14 @@ namespace API_NetFramework.Controllers
if (doccreate.TGNrVerantwortlich == doccreate.TGNrUnterschriftLinks) { approval1 = "1"; }
if (doccreate.TGNrVerantwortlich == doccreate.TGNrUnterschriftRechts) { approval2 = "1"; }
db.Exec_SQL("update dokument set toapprove=1,approved=0,approval1=" + approval1 + ", approval2=" + approval2 + ", signiert=0 where dokumentid='" + dokumentid + "'");
if (doccreate.TGNrUnterschriftLinks!="-1" && doccreate.UnterschriftLinksGeprueft == "false")
if (doccreate.TGNrUnterschriftLinks != "-1" && doccreate.UnterschriftLinksGeprueft == "false")
{
db.Get_Tabledata("Select mitarbeiternr from mitarbeiter where aktiv=1 and tgnummer='" + doccreate.TGNrUnterschriftLinks + "'", false, true);
int manr = Convert.ToInt32(db.dsdaten.Tables[0].Rows[0][0]);
db.Get_Tabledata_for_Update("Select top 1 * from dokument_Bewilligung where dokumentid='" + dokumentid + "' order by id desc", false, true);
DataRow dr = db.daten.Tables[0].NewRow();
dr["dokumentid"] = dokumentid;
dr["mitarbeiter_bewilligung"] = manr;
dr["bewilligt"] = false;
@@ -862,9 +950,9 @@ namespace API_NetFramework.Controllers
dr["notiz"] = "API-Dokument zur Unterzeichnung";
db.daten.Tables[0].Rows.Add(dr);
db.Update_Data();
db.Get_Tabledata("Select top 1 bewilligungid from dokumenet_bewillung where dokumentid='" + dokumentid + "' or by id desc", false, true);
db.Get_Tabledata("Select top 1 bewilligungid from dokumenet_bewillung where dokumentid='" + dokumentid + "' order by id desc", false, true);
send_mail(20, manr.ToString(), "", "", dokumentid, "", "OnDoc", db.dsdaten.Tables[0].Rows[0][0].ToString());
}
if (doccreate.TGNrUnterschriftRechts != "-1" && doccreate.UnterschriftRechtsGeprueft == "false")
{
@@ -943,7 +1031,7 @@ namespace API_NetFramework.Controllers
doccreate = null;
dokdata = null;
//return BadRequest(Newtonsoft.Json.JsonConvert.SerializeObject(apireturn));
return Content(HttpStatusCode.BadRequest, apireturn);
}
}
@@ -968,7 +1056,7 @@ namespace API_NetFramework.Controllers
apireturn.message = "Dokument generiert";
apireturn.traceid = "";
apireturn.field = "GUID=" + guid;
mailInhalt m = new mailInhalt();
m.typ = 0;
@@ -986,7 +1074,7 @@ namespace API_NetFramework.Controllers
apiok.code = "200";
apiok.status = "200";
apiok.message = "Dokumentpaket vorbereitet";
apiok.documentid = "";
apiok.documentid = "";
apiok.file = "";
return Ok((apiok));
}
@@ -1002,29 +1090,119 @@ namespace API_NetFramework.Controllers
//return BadRequest(Newtonsoft.Json.JsonConvert.SerializeObject(apireturn));
return Content(HttpStatusCode.BadRequest, apireturn);
}
finally { apireturn = null; apiok = null; };
}
private bool CheckUseField(string instring, ref List<CLMDocItem> clmdocitemlist)
{
string[] fields = instring.Split(';');
string fieldvalue = get_item_value(fields[0], ref clmdocitemlist);
fieldvalue = "'" + fieldvalue + "'";
switch (fields[1])
{
case "=":
if (fieldvalue == fields[2]) return true;
break;
case "!=":
if (fieldvalue != fields[2]) return true;
break;
default:
return false;
}
return false;
finally { apireturn = null; apiok = null; }
}
private bool CheckUseField(string instring, ref List<CLMDocItem> clmdocitemlist, ref string returnvalue)
{
//[quellfeld];[Operator];[Vergleichswert];[Rückgabewert bei true]
//Rückgabewert:[Fixwert], Replace("","")
string[] fields = instring.Split(';');
string fieldvalue = get_item_value(fields[0], ref clmdocitemlist);
//if (instring.ToLower().Contains("replace"))
//{
// string[] replacevalue = instring.Split(';');
// fieldvalue = fieldvalue.Replace(replacevalue[1], replacevalue[2]);
// returnvalue = fieldvalue;
// return true;
//}
try
{
if (fields.Length<2)
{
return true;
}
}
catch { return true; }
string vergleichsart = "";
string vergleichswert = "";
string returnwert = "";
try { vergleichsart = fields[1].Replace("'",""); } catch { }
try { vergleichswert = fields[2].Replace("'",""); } catch { }
try { returnwert = fields[3].Replace("'", ""); } catch { }
if (returnwert == "")
{
switch (vergleichsart)
{
case "=":
if (fieldvalue == vergleichswert) { returnvalue = fieldvalue; return true; }
break;
case "!=":
if (fieldvalue != vergleichswert) { returnvalue = fieldvalue; return true; }
break;
default:
return false;
}
return false;
}
else
{
switch (vergleichsart)
{
case "=":
if (fieldvalue == vergleichswert) { returnvalue = updatestring(returnwert,fieldvalue); return true; } else { return true; }
break;
case "!=":
if (fieldvalue != vergleichswert) { returnvalue = updatestring(returnwert,fieldvalue); return true; }
break;
default:
return false;
}
}
return true;
//try
//{
// switch (fields[1])
// {
// case "=":
// if (fieldvalue == fields[2]) { returnvalue = fieldvalue; return true; }
// break;
// case "!=":
// if (fieldvalue != fields[2]) { returnvalue = fieldvalue; return true; }
// break;
// default:
// return false;
// }
// if (fields.Length > 2) { returnvalue = fields[3].Replace("'", ""); }
// return false;
//}
//catch { return true; }
}
private string updatestring (string rule,string inputvalue)
{
if (rule.ToUpper().Contains("REPLACE"))
{
string p1 = "";
string p2 = "";
string[] parameters = rule.Split('|');
try { p1 = parameters[1].Replace("'", ""); } catch { p1 = ""; }
try { p2 = parameters[2].Replace("'", ""); } catch { p2 = ""; }
try
{
inputvalue = inputvalue.Replace(p1, p2);
}
catch
{
inputvalue = p2;
}
return inputvalue;
}
if (rule.ToUpper().Contains("FIX"))
{
string[] parameters = rule.Split('|');
return parameters[1].Replace("'", "");
}
return inputvalue;
}
private string Get_OnDoc_Value(string type, string inputvalue1, string inputvalue2)
{
Database.DB db = new DB(connectionstring);
@@ -1082,7 +1260,8 @@ namespace API_NetFramework.Controllers
//return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
return Content(HttpStatusCode.BadRequest, apireturn);
}
finally { apireturn = null; apiok = null; clmdocitemlist = null; dataj = null; };
finally { apireturn = null; apiok = null; clmdocitemlist = null; dataj = null; }
;
}
HttpRequestMessage rmsg = (HttpRequestMessage)Request;
@@ -1114,11 +1293,17 @@ namespace API_NetFramework.Controllers
Logging.APIDocLog.Debug("Create CLMDocItem", "CreateCLM", guid, "");
db.Get_Tabledata("Select dokumenttypneu from mondoc_clm_dokumenttyp_mapping where dokumenttypalt=" + dataj.Dokumenttyp.ToString(), false, true);
db.Get_Tabledata("Select dokumenttypneu from ondoc_clm_dokumenttyp_mapping where aktiv=1 and dokumenttypalt=" + dataj.Dokumenttyp.ToString(), false, true);
if (db.dsdaten.Tables[0].Rows.Count > 0)
{
dataj.Dokumenttyp = db.dsdaten.Tables[0].Rows[0][0].ToString();
}
db.clear_parameter();
db.add_parameter("@dokumenttypnr", dataj.Dokumenttyp.ToString());
db.Get_Tabledata("sp_get_ondoc_clm_vorlagenfeld", true, false);
string tmpname = "";
List<CLMDocItem>dokumentdaten = new List<CLMDocItem>();
List<CLMDocItem> dokumentdaten = new List<CLMDocItem>();
CLMDocItem tmp = new CLMDocItem();
tmp.itemname = "";
dokumentdaten.Add(tmp);
@@ -1127,7 +1312,7 @@ namespace API_NetFramework.Controllers
{
CLMDocItem d = new CLMDocItem();
if (dr["feldname"].ToString() == "Vertragspartner")
if (dr["feldname"].ToString() == "Vertragspartner")
{
int a = 1;
}
@@ -1144,21 +1329,22 @@ namespace API_NetFramework.Controllers
d.left = dr["ess_img_left"].ToString();
d.width = dr["ess_img_width"].ToString();
d.height = dr["ess_img_height"].ToString();
d.itemvalue="";
d.itemvalue = "";
switch (d.type.ToString())
{
case "1":
case "1":
d.itemvalue = get_item_value(dr["ess_feldname"].ToString(), ref clmdocitemlist);
break;
break;
case "2":
d.itemvalue = get_item_value(dr["ess_feldname"].ToString(), ref clmdocitemlist);
break;
case "3":
d.itemvalue = get_item_value(dr["ess_feldname"].ToString(), ref clmdocitemlist);
break;
case "4":
d.itemvalue = get_item_value(dr["ess_feldname"].ToString(), ref clmdocitemlist);
break;
case "5":
d.itemvalue = get_item_value(dr["ess_feldname"].ToString(), ref clmdocitemlist);
@@ -1193,7 +1379,8 @@ namespace API_NetFramework.Controllers
case "17": //Datamatrix
if (dr["ess_feldname2"].ToString() != "")
{
if (CheckUseField(dr["ess_feldname2"].ToString(),ref clmdocitemlist))
string returnvalue = "";
if (CheckUseField(dr["ess_feldname2"].ToString(), ref clmdocitemlist, ref returnvalue))
{
clmdokumentid = db.get_dbkey("Dokument");
d.itemvalue = get_datamatrix_value(dr["ess_feldname"].ToString(), clmdokumentid, ref clmdocitemlist);
@@ -1215,6 +1402,20 @@ namespace API_NetFramework.Controllers
default:
break;
}
if (dr["ess_feldname2"].ToString() != "")
{
if (d.type.ToString() != "17")
{
string returnvalue = "";
if (CheckUseField(dr["ess_feldname2"].ToString(), ref clmdocitemlist, ref returnvalue))
{
if (returnvalue != "") { d.itemvalue = returnvalue; }
}
else
{ d.itemvalue = ""; }
}
}
if (dr["ess_feldname"].ToString().Contains("@T:"))
{
string[] arr = dr["ess_feldname"].ToString().Split(new string[] { "$Format:" }, StringSplitOptions.None);
@@ -1225,7 +1426,7 @@ namespace API_NetFramework.Controllers
get_tabledata(dr["ess_feldname"].ToString(), ref clmdocitemlist, out value, out tablename);
d.itemname = tablename;
d.itemvalue = value;
d.itemname = tablename;
@@ -1237,7 +1438,7 @@ namespace API_NetFramework.Controllers
}
dokumentdaten.Add(d);
}
db = null;
clmdocitemlist.RemoveAll((y) => string.IsNullOrEmpty(y.type));
//foreach (CLMDocItem d in dokumentdaten)
@@ -1262,11 +1463,11 @@ namespace API_NetFramework.Controllers
clsdok dok = new clsdok("", "", "", "");
Logging.APIDocLog.Debug("Start GenDocCLM", "CreateCLM", guid, "");
gendocCLM(ref dokumentdaten, ref dataj, ref dok, key, clmdokumentid,archivstatus, result);
gendocCLM(ref dokumentdaten, ref dataj, ref dok, key, clmdokumentid, archivstatus, result);
Logging.APIDocLog.Info("Dokument abgeschlossen", "CreateDok", guid, clmdokumentid);
apiok.code = "200";
apiok.status = "200";
apiok.status = "200";
apiok.message = "";
apiok.documentid = dataj.Id.ToString();
apiok.file = dok.dokument;
@@ -1285,7 +1486,8 @@ namespace API_NetFramework.Controllers
//return BadRequest(Newtonsoft.Json.JsonConvert.SerializeObject(apireturn));
return Content(HttpStatusCode.BadRequest, apireturn);
}
finally { apireturn = null; apiok = null; clmdocitemlist = null; dataj = null; };
finally { apireturn = null; apiok = null; clmdocitemlist = null; dataj = null; }
;
}
private void get_tabledata(string ifeldname, ref List<CLMDocItem> docitemlist, out string value, out string tablename)
@@ -1299,7 +1501,7 @@ namespace API_NetFramework.Controllers
var newlist = docitemlist.FindAll(s => s.itemname.Contains(Tablename));
string suchText = Tablename+"[";
string suchText = Tablename + "[";
var treffer = docitemlist
.Where(p => p.itemname.Contains(suchText))
.ToList()
@@ -1318,8 +1520,8 @@ namespace API_NetFramework.Controllers
char ch = ']';
int offset = x.IndexOf(ch);
string prefix = x.Substring(0, offset);
int r= Convert.ToInt32(prefix);
if (r > rowcounter) { rowcounter = r; }
int r = Convert.ToInt32(prefix);
if (r > rowcounter) { rowcounter = r; }
}
@@ -1398,6 +1600,7 @@ namespace API_NetFramework.Controllers
if (!(ParamCheck("yesno", dokument.OhneUnterschrift))) { return "Parameter Form ohne Unterschrift " + dokument.OhneUnterschrift + " ist ungültig"; }
if (!(ParamCheck("yesno", dokument.PrintLogo))) { return "Parameter PrintLogo " + dokument.PrintLogo + " ist ungültig"; }
if (!(ParamCheck("yesno", dokument.UnterschriftLinksGeprueft))) { return "Parameter UnterschriftLinksGeprueft" + dokument.UnterschriftLinksGeprueft + " ist ungültig"; }
if (!(ParamCheck("profil", dokument.TGNrVerantwortlich))) { return "Profil " + dokument.TGNrVerantwortlich + " hat kein Team im Standardprofil oder kein Standardprofil"; }
if (!(ParamCheck("yesno", dokument.UnterschriftRechtsGeprueft))) { return "Parameter UnterschriftRechtsGeprueft" + dokument.UnterschriftRechtsGeprueft + " ist ungültig"; }
if (dokument.TGNrUnterschriftLinks.ToString() == "") { dokument.TGNrUnterschriftLinks = "-1"; }
if (dokument.TGNrUnterschriftRechts.ToString() == "") { dokument.TGNrUnterschriftRechts = "-1"; }
@@ -1477,6 +1680,7 @@ namespace API_NetFramework.Controllers
if (!(ParamCheck("filetype", doccreate.ResultFileType))) { return "Parameter Result_Filetype " + doccreate.ResultFileType + " ist ungültig"; }
if (!(ParamCheck("yesno", doccreate.ConfirmationMail))) { return "Parameter ConfirmationMail " + doccreate.ConfirmationMail + " ist ungültig"; }
if (!(ParamCheck("yesno", doccreate.ConfirmationMail))) { return "Parameter ConfirmationMail " + doccreate.ConfirmationMail + " ist ungültig"; }
if (!(ParamCheck("profil", doccreate.TGNrVerantwortlich))) { return "Profil " + doccreate.TGNrVerantwortlich + " hat kein Team im Standardprofil oder kein Standardprofil"; }
if (!(ParamCheck("versandoption", doccreate.VersandOption))) { return "Versandoption " + doccreate.VersandOption + " ist ungültig"; }
if (doccreate.ConfirmationMail.ToUpper() == "TRUE" && doccreate.ConfirmationMailAddress.ToString() == "") { return "E-Mailadresse für Confirmation fehlt"; }
if (doccreate.TGNrUnterschriftLinks.ToString() == "") { doccreate.TGNrUnterschriftLinks = "-1"; }
@@ -1544,18 +1748,20 @@ namespace API_NetFramework.Controllers
case "tgul":
case "tgur":
case "tgnr":
if (ParamType == "tgcreator" && ParamValue == "") { return false; } else { if (ParamValue == "") { return true; } };
if (ParamType == "tgcreator" && ParamValue == "") { return false; } else { if (ParamValue == "") { return true; } }
;
db.Get_Tabledata("Select count(*) from mitarbeiter where tgnummer='" + ParamValue + "'", false, true);
if (db.dsdaten.Tables[0].Rows[0][0].ToString() == "0") { return false; }
break;
case "yesno":
if (ParamValue != "true" && ParamValue != "false" && ParamValue != "") { return false; };
if (ParamValue != "true" && ParamValue != "false" && ParamValue != "") { return false; }
;
break;
case "filetype":
if (ParamValue != "WORD" && ParamValue != "PDF") { return false; }
break;
case "versandoption":
if (ParamValue != "A_POST" && ParamValue != "B1_POST" && ParamValue != "B2_POST" && ParamValue != "EINSCHREIBEN" && ParamValue != "") { return false; }
if (ParamValue != "A_POST" && ParamValue != "B1_POST" && ParamValue != "B2_POST" && ParamValue != "EINSCHREIBEN" && ParamValue != "") { return false; }
break;
case "doktypversandstrasse":
db.Get_Tabledata("Select versandstrasse_moeglich, versandstrasse_firstdoc from dokumenttyp where dokumenttypnr=" + ParamValue, false, true);
@@ -1565,6 +1771,11 @@ namespace API_NetFramework.Controllers
db.Get_Tabledata("Select versandstrasse_moeglich, versandstrasse_firstdoc from dokumenttyp where dokumenttypnr=" + ParamValue, false, true);
if (Convert.ToInt32(db.dsdaten.Tables[0].Rows[0][1]) == 0) { return false; }
break;
case "profil":
db.Get_Tabledata("SELECT isnull(dbo.profil.team,0) as team FROM dbo.mitarbeiter INNER JOIN dbo.profil ON dbo.mitarbeiter.mitarbeiternr = dbo.profil.mitarbeiternr WHERE (dbo.mitarbeiter.aktiv=1 and dbo.profil.aktiv=1 and dbo.profil.standard=1 and dbo.mitarbeiter.tgnummer = '" + ParamValue + "')", false, true);
if (db.dsdaten.Tables[0].Rows.Count == 0) { return false; }
if (db.dsdaten.Tables[0].Rows[0][0].ToString() == "0") { return false; }
break;
default:
return false;
break;
@@ -1582,7 +1793,7 @@ namespace API_NetFramework.Controllers
}
private string gendoc(ref DocCreate doccreate, ref clsDocData dokdata, ref Model.clsdocgendata docgendata, string key)
{
string OwnHost = System.Configuration.ConfigurationManager.AppSettings["OwnHost"].ToString();
string imagepath = System.Configuration.ConfigurationManager.AppSettings["VSImagePath"].ToString();
@@ -1724,23 +1935,25 @@ namespace API_NetFramework.Controllers
if (doccreate.FaksimileUnterschrift == "true")
{
dokdata.As_Faksimile = "True"; dokdata.sign = true; docgendata.digitaleunterschrift = true;
if (dokdata.Unterschrift_Links != "-1") {
if (dokdata.Unterschrift_Links != "-1")
{
dokdata.approval1 = 1;
dokdata.img_unterschrift_links = get_unterschrift(dokdata.Unterschrift_Links);
}
if (dokdata.Unterschrift_Rechts != "-1") {
if (dokdata.Unterschrift_Rechts != "-1")
{
dokdata.approval2 = 1;
dokdata.img_unterschrift_rechts = get_unterschrift(dokdata.Unterschrift_Rechts);
}
dokdata.approved = 1;
}
dokdata.APIValues = doccreate.APIValues;
dokdata.TextToReplace = doccreate.TextToReplace;
if (doccreate.PrintLogo == "true")
{
if (doccreate.PrintLogo == "true")
{
dokdata.PrintLogo = true;
dokdata.img_logo = GetImageAsBase64(4, -1, 0);
DB db1 = new DB(connectionstring);
@@ -1756,7 +1969,8 @@ namespace API_NetFramework.Controllers
}
catch (Exception ex) { string a = ex.Message; }
db1 = null;
} else { dokdata.PrintLogo = false; }
}
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"; }
@@ -1785,7 +1999,7 @@ namespace API_NetFramework.Controllers
}
private void gendocCLM(ref List<CLMDocItem> clmdocitemlist, ref dynamic dataj, ref clsdok dok, string key, string clmdokumentid, string archivstatus = "Aktiv",string json="")
private void gendocCLM(ref List<CLMDocItem> clmdocitemlist, ref dynamic dataj, ref clsdok dok, string key, string clmdokumentid, string archivstatus = "Aktiv", string json = "")
{
string OwnHost = System.Configuration.ConfigurationManager.AppSettings["OwnHost"].ToString();
string imagepath = System.Configuration.ConfigurationManager.AppSettings["VSImagePath"].ToString();
@@ -1793,14 +2007,14 @@ namespace API_NetFramework.Controllers
string dokumentid = clmdokumentid;
dokdata.Dokumentid = clmdokumentid;
string bezeichnung = "";
;
Database.DB db = new DB(connectionstring);
db.Get_Tabledata("Select * from dokumenttyp where dokumenttypnr=" + dataj.Dokumenttyp.ToString(), false, true);
System.Data.DataRow dr = db.dsdaten.Tables[0].Rows[0];
bezeichnung = db.dsdaten.Tables[0].Rows[0]["Bezeichnung"].ToString();
dokdata.Barcode = Convert.ToBoolean(dr["Vertrag"]) == true;
if (dokdata.Barcode==false) { archivstatus = "In Aufbewahrung"; }
if (dokdata.Barcode == false) { archivstatus = "In Aufbewahrung"; }
dokdata.Barcode = false;
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();
@@ -1958,7 +2172,7 @@ namespace API_NetFramework.Controllers
db.Exec_SQL("update dokument set dokumentname = dokumentname + '.pdf' where dokumentid = '" + dokumentid + "'");
}
// db.Save_To_DB(dokumentid, "", dok.dokument);
// dok = dget.GetDocAsPDF(dokumentid);
dok.extension = "pdf";
@@ -1979,7 +2193,7 @@ namespace API_NetFramework.Controllers
dr1[7] = json;
dr1[8] = guid;
db.daten.Tables[0].Rows.Add(dr1);
db.Update_Data();
dr1 = null;
//sql = "Insert OnDoc_CLM_Dokumente (dokumentid,clmdokumentid,erstellt_am,aktiv,archivstatus) values(";
@@ -2008,7 +2222,7 @@ namespace API_NetFramework.Controllers
}
private void send_vs(ref Versandpaket vp, string mitarbeiternr, bool direktversenden, string url, string key, string dokumentid, string partnernr, DokumentCreate doccreate, ref APIErrorSimple apireturn, DocCreate EinzelDokument )
private void send_vs(ref Versandpaket vp, string mitarbeiternr, bool direktversenden, string url, string key, string dokumentid, string partnernr, DokumentCreate doccreate, ref APIErrorSimple apireturn, DocCreate EinzelDokument)
{
string jsonstring = JsonConvert.SerializeObject(vp);
DB db = new DB(connectionstring);
@@ -2031,7 +2245,7 @@ namespace API_NetFramework.Controllers
//Paket
OnDocSignCheck = doccreate.OnDocSignCheck;
}
catch
catch
{
//Einzeldokument
OnDocSignCheck = EinzelDokument.OnDocSignCheck;
@@ -2119,20 +2333,20 @@ namespace API_NetFramework.Controllers
//yxyy
if (Convert.ToInt32(dr2[4]) == 0)
{
db.Get_Tabledata("Select mitarbeiternr from mitarbeiter where tgnummer='"+ doccreate.Dokumente[0].TGNrUnterschriftLinks + "'",false,true);
send_mail(21, db.dsdaten.Tables[0].Rows[0][0].ToString(), "", "",paketid.ToString(), "", "", "");
db.Get_Tabledata("Select mitarbeiternr from mitarbeiter where tgnummer='" + doccreate.Dokumente[0].TGNrUnterschriftLinks + "'", false, true);
send_mail(21, db.dsdaten.Tables[0].Rows[0][0].ToString(), "", "", paketid.ToString(), "", "", "");
}
if (Convert.ToInt32(dr2[7]) == 0)
{
db.Get_Tabledata("Select mitarbeiternr from mitarbeiter where tgnummer='" + doccreate.Dokumente[0].TGNrUnterschriftRechts + "'", false, true);
send_mail(21, db.dsdaten.Tables[0].Rows[0][0].ToString(), "", "",paketid.ToString(), "", "", "");
send_mail(21, db.dsdaten.Tables[0].Rows[0][0].ToString(), "", "", paketid.ToString(), "", "", "");
}
}
db = null;
}
else
else
{
if (EinzelDokument.OnDocSignCheck == "true")
{
@@ -2185,7 +2399,7 @@ namespace API_NetFramework.Controllers
Logging.DocLog.Info("Versandpaket vorbereitet", "OnDoc-API", dokumentid, partnernr, "");
if (!direktversenden)
{
apireturn.status = "200";
apireturn.status = "200";
return;
}
@@ -2244,7 +2458,7 @@ namespace API_NetFramework.Controllers
{
char d = '$';
if (inhalt.Count(x => x == d) > 1 )
if (inhalt.Count(x => x == d) > 1)
{
string result = "";
try
@@ -2253,11 +2467,12 @@ namespace API_NetFramework.Controllers
string[] inhalte = inhalt.Split(' ');
foreach (string s in inhalte)
{
if (s.Contains("$")){
if (s.Contains("$"))
{
foreach (CLMDocItem di in clmdocitemlist)
{
string chkvalue = s.Replace("$.", "").Replace(",", "").Replace("-", "").Replace("/", "").Replace("\n", "").Replace(". ", "").Trim();
if (di.itemname == chkvalue)
{
result = result.Replace(chkvalue, di.itemvalue);
@@ -2267,14 +2482,16 @@ namespace API_NetFramework.Controllers
}
}
else {
else
{
}
result = result.Replace("$.", "");
}
return result;
}
catch {
catch
{
return "";
}
@@ -2321,7 +2538,7 @@ namespace API_NetFramework.Controllers
if (di.itemname == part.Replace("&", ""))
{
if (datamatrixstring.Length > 0) { datamatrixstring = datamatrixstring + "$"; }
datamatrixstring = datamatrixstring + di.itemvalue.Replace(".","");
datamatrixstring = datamatrixstring + di.itemvalue.Replace(".", "");
}
}
@@ -2401,7 +2618,7 @@ namespace API_NetFramework.Controllers
}
}
private string GetImageAsBase64(int imageid, int ImageWidth = 0, int ImageHeight = 0)
private string GetImageAsBase64(int imageid, int ImageWidth = 0, int ImageHeight = 0)
{
string path = System.Configuration.ConfigurationManager.AppSettings["ImagePath"];
string filename = "";
@@ -2534,7 +2751,7 @@ namespace API_NetFramework.Controllers
}
catch (Exception ex)
{
APILogging.Log((HttpRequestMessage)Request, "Mail Versand NOK: " + ex.Message + " " +inhalt.empfaenger, LogLevelType.Debug);
APILogging.Log((HttpRequestMessage)Request, "Mail Versand NOK: " + ex.Message + " " + inhalt.empfaenger, LogLevelType.Debug);
if (ex.InnerException != null)
{
APILogging.Log((HttpRequestMessage)Request, "Mail Versand NOK - Exception Inner: " + ex.InnerException, LogLevelType.Debug);
@@ -2546,13 +2763,13 @@ namespace API_NetFramework.Controllers
catch (Exception e)
{
inhalt = null;
APILogging.Log((HttpRequestMessage)Request, "Mail Versand NOK: " + e.Message + " " , LogLevelType.Debug);
APILogging.Log((HttpRequestMessage)Request, "Mail Versand NOK: " + e.Message + " ", LogLevelType.Debug);
}
}
private void send_bewilligungsmail(int mailid, string empfaenger, string betreff, string message, string dokumentid, string ondoclink, string absender, string bewilligungid)
{
}
private void send_mail(int mailid, string empfaenger, string betreff, string message, string dokumentid, string ondoclink, string absender, string bewilligungid)
{