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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -257,6 +257,7 @@ namespace API_NetFramework.Controllers
|
||||
[Route("API/CreateDoks")]
|
||||
public IHttpActionResult CreateDoks()
|
||||
{
|
||||
|
||||
APIErrorSimple apireturn = new APIErrorSimple();
|
||||
APIOK apiok = new APIOK();
|
||||
string mailbody = "";
|
||||
@@ -406,6 +407,7 @@ namespace API_NetFramework.Controllers
|
||||
OnDocAPI_NetFramework.Helper.Helper.CopyProperties(dokdata, docgendata);
|
||||
OnDocAPI_NetFramework.Helper.Helper.CopyProperties(dokument, doccreate);
|
||||
doccreate.Reference = paket.Reference;
|
||||
doccreate.ResultFileType=paket.ResultFileType;
|
||||
dokument.DokumentID = gendoc(ref doccreate, ref dokdata, ref docgendata, key.ToString());
|
||||
dokument.DokumentID = dokdata.Dokumentid;
|
||||
dokdata = null;
|
||||
@@ -516,7 +518,7 @@ namespace API_NetFramework.Controllers
|
||||
vp.GASAdresse = paket.GASAdresse;
|
||||
if (string.IsNullOrEmpty(vp.GASAdresse)) { vp.GASAdresse = ""; }
|
||||
vp.Mitteilung = "";
|
||||
vp.PaketNr = new Guid().ToString();
|
||||
vp.PaketNr = guid;
|
||||
if (vp.GASAdresse != "") { vp.GAS = "1"; } else { vp.GAS = ""; }
|
||||
vp.GASSize = paket.GASCouvert;
|
||||
vp.Versandoption = paket.VersandOption;
|
||||
@@ -658,6 +660,7 @@ namespace API_NetFramework.Controllers
|
||||
[Route("API/CreateDok")]
|
||||
public IHttpActionResult CreateDok()
|
||||
{
|
||||
//eINZELDOKUMENT
|
||||
APIErrorSimple apireturn = new APIErrorSimple();
|
||||
APIOK apiok = new APIOK();
|
||||
string mailbody = "";
|
||||
@@ -765,6 +768,7 @@ namespace API_NetFramework.Controllers
|
||||
if (checkinondoc==true) { dokdata.print_signature = false; }
|
||||
string dokumentid = gendoc(ref doccreate, ref dokdata, ref docgendata, key.ToString());
|
||||
dokumentid = dokdata.Dokumentid;
|
||||
|
||||
if (doccreate.ResultSender == "true")
|
||||
{
|
||||
DocGet dg = new DocGet(this.connectionstring);
|
||||
@@ -856,7 +860,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);
|
||||
send_mail(20, manr.ToString(), "", "", dokumentid, "", "OnDoc", db.dsdaten.Tables[0].Rows[0][0].ToString());
|
||||
|
||||
}
|
||||
if (doccreate.TGNrUnterschriftRechts != "-1" && doccreate.UnterschriftRechtsGeprueft == "false")
|
||||
{
|
||||
@@ -878,6 +884,7 @@ namespace API_NetFramework.Controllers
|
||||
dr["notiz"] = "API-Dokument zur Unterzeichnung";
|
||||
db.daten.Tables[0].Rows.Add(dr);
|
||||
db.Update_Data();
|
||||
send_mail(20, manr.ToString(), "", "", dokumentid, "", "OnDoc", db.dsdaten.Tables[0].Rows[0][0].ToString());
|
||||
|
||||
}
|
||||
db = null;
|
||||
@@ -911,11 +918,12 @@ namespace API_NetFramework.Controllers
|
||||
vsdoc = vs.Prepare_PDF(dokumentid, "", connectionstring, OwnHost, key.ToString(), imagepath);
|
||||
|
||||
Versandpaket vp = new Versandpaket();
|
||||
vp.PaketNr = Guid.NewGuid().ToString();
|
||||
vp.PaketNr = guid;
|
||||
vp.partnernr = Convert.ToInt32(docgendata.partnernr);
|
||||
vp.GASAdresse = doccreate.GASAdresse;
|
||||
if (string.IsNullOrEmpty(vp.GASAdresse)) { vp.GASAdresse = ""; }
|
||||
if (vp.GASAdresse.ToString().Trim() == "") { vp.GAS = ""; } else { vp.GAS = "true"; }
|
||||
if (vp.GASAdresse.ToString().Trim() == "") { vp.GAS = ""; } else { vp.GAS = "1"; }
|
||||
vp.GASSize = doccreate.GASCouvert;
|
||||
vp.Versandoption = doccreate.VersandOption; ;
|
||||
List<Versanddokument> vdoc = new List<Versanddokument>();
|
||||
Versanddokument vd = new Versanddokument(dokumentid, doccreate.PartnerNr + " - " + dokdata.Bezeichnung, doccreate.PartnerNr);
|
||||
@@ -950,8 +958,6 @@ namespace API_NetFramework.Controllers
|
||||
// message = message + " Dokument über Versandstrasse bereit gestellt.";
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//}
|
||||
Logging.APIDocLog.Info("Dokument abgeschlossen", "CreateDok", guid, dokumentid);
|
||||
apireturn.code = "OK";
|
||||
@@ -1108,6 +1114,7 @@ namespace API_NetFramework.Controllers
|
||||
CLMDocItem tmp = new CLMDocItem();
|
||||
tmp.itemname = "";
|
||||
dokumentdaten.Add(tmp);
|
||||
string archivstatus = "Aktiv";
|
||||
foreach (DataRow dr in db.dsdaten.Tables[0].Rows)
|
||||
{
|
||||
CLMDocItem d = new CLMDocItem();
|
||||
@@ -1126,11 +1133,15 @@ 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="";
|
||||
switch (d.type.ToString())
|
||||
{
|
||||
case "1":
|
||||
d.itemvalue = get_item_value(dr["ess_feldname"].ToString(), ref clmdocitemlist);
|
||||
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);
|
||||
@@ -1185,6 +1196,7 @@ namespace API_NetFramework.Controllers
|
||||
{
|
||||
d.itemvalue = get_datamatrix_value(dr["ess_feldname"].ToString(), clmdokumentid, ref clmdocitemlist);
|
||||
}
|
||||
if (d.itemvalue != "") { archivstatus = "Pendent"; }
|
||||
break;
|
||||
case "18": //Pruefziffer
|
||||
d.itemvalue = pruefziffer(get_item_value(dr["ess_feldname"].ToString(), ref clmdocitemlist));
|
||||
@@ -1217,7 +1229,11 @@ namespace API_NetFramework.Controllers
|
||||
|
||||
db = null;
|
||||
clmdocitemlist.RemoveAll((y) => string.IsNullOrEmpty(y.type));
|
||||
//foreach (CLMDocItem d in dokumentdaten)
|
||||
//{
|
||||
// System.IO.File.AppendAllText(@"d:\apps\apilog.txt", d.itemname + ":" + d.itemvalue + ":" + d.field + ":" + d.bmstart + ":" + d.bmend + Environment.NewLine);
|
||||
|
||||
//}
|
||||
string CheckResult = "";
|
||||
CheckResult = CLM_Verify(ref dokumentdaten, ref result);
|
||||
if (CheckResult != "")
|
||||
@@ -1235,7 +1251,7 @@ namespace API_NetFramework.Controllers
|
||||
clsdok dok = new clsdok("", "", "", "");
|
||||
Logging.APIDocLog.Debug("Start GenDocCLM", "CreateCLM", guid, "");
|
||||
|
||||
gendocCLM(ref dokumentdaten, ref dataj, ref dok, key, clmdokumentid);
|
||||
gendocCLM(ref dokumentdaten, ref dataj, ref dok, key, clmdokumentid,archivstatus);
|
||||
|
||||
Logging.APIDocLog.Info("Dokument abgeschlossen", "CreateDok", guid, clmdokumentid);
|
||||
apiok.code = "200";
|
||||
@@ -1421,7 +1437,7 @@ namespace API_NetFramework.Controllers
|
||||
|
||||
if (paket.Versandstrasse == "true")
|
||||
{
|
||||
if (paket.VersandOption == "") { return "Versandoption fehlt (A_Post, B1_Post, B2_Post"; }
|
||||
if (paket.VersandOption == "") { return "Versandoption fehlt (A_Post, B1_Post, B2_Post, Einschreiben"; }
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -1475,7 +1491,7 @@ namespace API_NetFramework.Controllers
|
||||
//{
|
||||
// return "Versandstrasse mit zwei Unterschriften kann nicht automatisch angesteuert werden";
|
||||
//}
|
||||
if (doccreate.VersandOption == "") { return "Versandoption fehlt (A_Post, B1_Post, B2_Post"; }
|
||||
if (doccreate.VersandOption == "") { return "Versandoption fehlt (A_Post, B1_Post, B2_Post, Einschreiben"; }
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -1528,7 +1544,7 @@ namespace API_NetFramework.Controllers
|
||||
if (ParamValue != "WORD" && ParamValue != "PDF") { return false; }
|
||||
break;
|
||||
case "versandoption":
|
||||
if (ParamValue != "A_POST" && ParamValue != "B1_POST" && ParamValue != "B2_POST" && 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);
|
||||
@@ -1758,7 +1774,7 @@ namespace API_NetFramework.Controllers
|
||||
|
||||
|
||||
}
|
||||
private void gendocCLM(ref List<CLMDocItem> clmdocitemlist, ref dynamic dataj, ref clsdok dok, string key, string clmdokumentid)
|
||||
private void gendocCLM(ref List<CLMDocItem> clmdocitemlist, ref dynamic dataj, ref clsdok dok, string key, string clmdokumentid, string archivstatus = "Aktiv")
|
||||
{
|
||||
string OwnHost = System.Configuration.ConfigurationManager.AppSettings["OwnHost"].ToString();
|
||||
string imagepath = System.Configuration.ConfigurationManager.AppSettings["VSImagePath"].ToString();
|
||||
@@ -1766,12 +1782,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"; }
|
||||
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();
|
||||
@@ -1926,6 +1944,7 @@ namespace API_NetFramework.Controllers
|
||||
if (dok.extension.ToUpper() != "PDF")
|
||||
{
|
||||
dok.dokument = dget.Convert_Word_To_PDF(dok.dokument);
|
||||
db.Exec_SQL("update dokument set dokumentname = dokumentname + '.pdf' where dokumentid = '" + dokumentid + "'");
|
||||
}
|
||||
// db.Save_To_DB(dokumentid, "", dok.dokument);
|
||||
|
||||
@@ -1936,6 +1955,16 @@ namespace API_NetFramework.Controllers
|
||||
if (System.Configuration.ConfigurationManager.AppSettings["CLMSaveOnDoc"].ToString() == "True" || clmdokumentid != "")
|
||||
{
|
||||
db.Save_To_DB(dokumentid, "", dok.dokument);
|
||||
string sql = "delete from ondoc_clm_dokumente where clmdokumentid ='" + dataj.Id + "'";
|
||||
db.Exec_SQL(sql);
|
||||
sql = "Insert OnDoc_CLM_Dokumente (dokumentid,clmdokumentid,erstellt_am,aktiv,archivstatus) values(";
|
||||
sql=sql+"'"+dokumentid+"','"+dataj.Id+"',getdate(),1,'"+archivstatus+"')";
|
||||
db.Exec_SQL(sql);
|
||||
//string sql = "Insert OnDoc_CLM_DocReference ";
|
||||
//sql = sql + "(ondocdokumentid, clmdokumentid, erstellt_am,aktiv) ";
|
||||
//sql = sql + "values('"+ dokdata.Dokumentid+","
|
||||
|
||||
//db.Exec_SQL("Insert OnDoc_CLM_DocReference")
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2062,7 +2091,20 @@ namespace API_NetFramework.Controllers
|
||||
dr2[12] = doccreate.Paketbezeichnung.ToString();
|
||||
db.daten.Tables[0].Rows.Add(dr2);
|
||||
db.Update_Data();
|
||||
//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(), "", "", "");
|
||||
}
|
||||
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(), "", "", "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
db = null;
|
||||
}
|
||||
else
|
||||
@@ -2174,26 +2216,63 @@ namespace API_NetFramework.Controllers
|
||||
|
||||
private string get_item_value(string inhalt, ref List<CLMDocItem> clmdocitemlist)
|
||||
{
|
||||
if (inhalt.Contains("Typ"))
|
||||
|
||||
char d = '$';
|
||||
if (inhalt.Count(x => x == d) > 1 )
|
||||
{
|
||||
string a = "1";
|
||||
}
|
||||
string result = "";
|
||||
try
|
||||
{
|
||||
foreach (CLMDocItem di in clmdocitemlist)
|
||||
string result = "";
|
||||
try
|
||||
{
|
||||
if (di.itemname == inhalt.Replace("$.", ""))
|
||||
result = inhalt;
|
||||
string[] inhalte = inhalt.Split(' ');
|
||||
foreach (string s in inhalte)
|
||||
{
|
||||
result = di.itemvalue;
|
||||
break;
|
||||
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);
|
||||
//result = result + di.itemvalue;
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
}
|
||||
result = result.Replace("$.", "");
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch {
|
||||
return "";
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch
|
||||
else
|
||||
{
|
||||
return "";
|
||||
|
||||
string result = "";
|
||||
try
|
||||
{
|
||||
foreach (CLMDocItem di in clmdocitemlist)
|
||||
{
|
||||
if (di.itemname == inhalt.Replace("$.", ""))
|
||||
{
|
||||
result = di.itemvalue;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
private string get_datamatrix_value(string inhalt, string clmdokumentid, ref List<CLMDocItem> clmdocitemlist)
|
||||
@@ -2371,7 +2450,7 @@ namespace API_NetFramework.Controllers
|
||||
public void Send_Confirmation(ref mailInhalt inhalt)// string sendmail, string receipt, string subject, string message, bool onlyadmin = false, string code = "", string statu="",string msg="")
|
||||
{
|
||||
|
||||
inhalt = null;
|
||||
//inhalt = null;
|
||||
if (inhalt.sendmail != true && inhalt.forceadminmail != true) { inhalt = null; return; }
|
||||
try
|
||||
{
|
||||
@@ -2436,12 +2515,81 @@ namespace API_NetFramework.Controllers
|
||||
}
|
||||
|
||||
}
|
||||
inhalt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
inhalt = null;
|
||||
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)
|
||||
{
|
||||
DB db = new DB(connectionstring);
|
||||
try
|
||||
{
|
||||
db.clear_parameter();
|
||||
db.add_parameter("@mailid", mailid.ToString());
|
||||
db.add_parameter("@empf", empfaenger);
|
||||
db.add_parameter("@dokid", dokumentid);
|
||||
db.add_parameter("@absender", absender);
|
||||
db.add_parameter("@bewilligungid", bewilligungid);
|
||||
db.Get_Tabledata("sp_ondoc_maildaten", true, false);
|
||||
if (message == null) { message = ""; }
|
||||
if (betreff == null) { betreff = ""; }
|
||||
if (betreff == "") { betreff = db.dsdaten.Tables[0].Rows[0][1].ToString(); }
|
||||
if (message == "") { message = db.dsdaten.Tables[0].Rows[0][2].ToString(); }
|
||||
if (Convert.ToInt32(db.dsdaten.Tables[0].Rows[0][3]) == 0)
|
||||
{
|
||||
db = null;
|
||||
return;
|
||||
}
|
||||
empfaenger = db.dsdaten.Tables[0].Rows[0][0].ToString();
|
||||
db = null;
|
||||
|
||||
MailMessage mail = new MailMessage();
|
||||
SmtpClient SmtpServer = new SmtpClient();
|
||||
mail.To.Add(empfaenger);
|
||||
mail.From = new MailAddress("OnDoc@tkb.ch");
|
||||
mail.Subject = betreff;
|
||||
mail.IsBodyHtml = true;
|
||||
mail.Body = message;
|
||||
SmtpServer.Host = "smtp.tgcorp.ch";
|
||||
SmtpServer.Port = 25;
|
||||
SmtpServer.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
|
||||
try
|
||||
{
|
||||
SmtpServer.Send(mail);
|
||||
APILogging.Log((HttpRequestMessage)Request, "SMTPMail Versand: " + empfaenger, LogLevelType.Debug);
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Mail Versand NOK: " + ex.Message + " " + empfaenger, LogLevelType.Debug);
|
||||
if (ex.InnerException != null)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Mail Versand NOK - Exception Inner: " + ex.InnerException, LogLevelType.Debug);
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Mail Versand NOK - Exception Inner: " + ex.InnerException, LogLevelType.Debug);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
db = null;
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user