update 20260303
This commit is contained in:
@@ -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