Update 20260123
This commit is contained in:
@@ -35,6 +35,7 @@ using System.Reflection;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Web.Http.Results;
|
||||
using Syncfusion.DocIO.DLS.XML;
|
||||
|
||||
|
||||
namespace API_NetFramework.Controllers
|
||||
@@ -552,6 +553,8 @@ namespace API_NetFramework.Controllers
|
||||
Logging.APIDocLog.Info("Input JSON", "CreateCLM", guid, result);
|
||||
|
||||
var jo = JObject.Parse(Request.Content.ReadAsStringAsync().Result);
|
||||
var x = dataj.Produkt;
|
||||
Console.WriteLine(dataj.Bp.Zustaendiger.TgNummer);
|
||||
var valueTuples = GetNodes(jo).ToList();
|
||||
foreach (var valueTuple in valueTuples)
|
||||
{
|
||||
@@ -568,6 +571,7 @@ namespace API_NetFramework.Controllers
|
||||
db.Get_Tabledata("Select * from vorlagenfeld where dokumenttypnr=" + dataj.Dokumenttyp.ToString() + " and aktiv=1 and ess_field_class_id<>0", false, true);
|
||||
foreach (DataRow dr in db.dsdaten.Tables[0].Rows)
|
||||
{
|
||||
|
||||
foreach (CLMDocItem di in clmdocitemlist)
|
||||
{
|
||||
if ("$." + di.itemname == dr["ess_feldname"].ToString())
|
||||
@@ -580,10 +584,43 @@ namespace API_NetFramework.Controllers
|
||||
di.width = dr["ess_img_width"].ToString();
|
||||
di.height = dr["ess_img_height"].ToString();
|
||||
di.type = dr["ess_field_class_id"].ToString();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (dr["ess_feldname"].ToString().Contains("@T:"))
|
||||
{
|
||||
string[] arr = dr["ess_feldname"].ToString().Split(new string[] { "$Format:" }, StringSplitOptions.None);
|
||||
dr["ess_feldname"] = arr[0];
|
||||
string value = "";
|
||||
string tablename = "";
|
||||
string format = "";
|
||||
|
||||
get_tabledata(dr["ess_feldname"].ToString(), ref clmdocitemlist, out value, out tablename);
|
||||
|
||||
CLMDocItem di = new CLMDocItem();
|
||||
di.bmstart = dr["beginntextmarke"].ToString();
|
||||
di.bmend = dr["endetextmarke"].ToString();
|
||||
di.field = dr["feldname"].ToString();
|
||||
di.top = dr["ess_img_top"].ToString();
|
||||
di.left = dr["ess_img_left"].ToString();
|
||||
di.width = dr["ess_img_width"].ToString();
|
||||
di.height = dr["ess_img_height"].ToString();
|
||||
di.type = dr["ess_field_class_id"].ToString();
|
||||
di.itemname = tablename;
|
||||
di.itemvalue = value;
|
||||
di.itemname = tablename;
|
||||
try
|
||||
{
|
||||
di.format = arr[1];
|
||||
}
|
||||
catch { di.format = ""; }
|
||||
clmdocitemlist.Add(di);
|
||||
}
|
||||
|
||||
}
|
||||
clmdocitemlist.RemoveAll((y) => string.IsNullOrEmpty(y.type));
|
||||
|
||||
string CheckResult = "";
|
||||
CheckResult = CLM_Verify(ref clmdocitemlist, ref result);
|
||||
@@ -608,7 +645,7 @@ namespace API_NetFramework.Controllers
|
||||
apiok.message = "";
|
||||
apiok.documentid = dataj.Id.ToString();
|
||||
apiok.file = dok.dokument;
|
||||
return Ok(Newtonsoft.Json.JsonConvert.SerializeObject(apiok));
|
||||
return Ok((apiok));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -624,6 +661,68 @@ namespace API_NetFramework.Controllers
|
||||
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)
|
||||
{
|
||||
//@T: Produkt.Produktinfo:Name,Beschreibung
|
||||
string Feldname = ifeldname;
|
||||
string Source = Feldname.Replace("@T:", "");
|
||||
string Tablename = Source.Split(':')[0];
|
||||
Source = Source.Replace(Tablename + ":", "");
|
||||
string[] attributs = Source.Split(',');
|
||||
|
||||
var newlist = docitemlist.FindAll(s => s.itemname.Contains(Tablename));
|
||||
|
||||
string suchText = Tablename;
|
||||
var treffer = docitemlist
|
||||
.Where(p => p.itemname.Contains(suchText))
|
||||
.ToList()
|
||||
.OrderBy(p => p.itemname);
|
||||
|
||||
DataTable dt = new DataTable();
|
||||
foreach (string attrib in attributs)
|
||||
{
|
||||
dt.Columns.Add(attrib);
|
||||
}
|
||||
int rowcounter = 0;
|
||||
foreach (CLMDocItem di in treffer)
|
||||
{
|
||||
string x = di.itemname;
|
||||
x = x.Replace(Tablename + "[", "");
|
||||
char ch = ']';
|
||||
int offset = x.IndexOf(ch);
|
||||
string prefix = x.Substring(0, offset);
|
||||
rowcounter = Convert.ToInt32(prefix);
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < rowcounter + 1; i++)
|
||||
{
|
||||
DataRow dx = dt.NewRow();
|
||||
for (int j = 0; dt.Columns.Count > j; j++)
|
||||
{
|
||||
foreach (CLMDocItem di in newlist)
|
||||
{
|
||||
if (di.itemname == Tablename + "[" + i.ToString().Trim() + "]" + "." + dt.Columns[j].ColumnName)
|
||||
{
|
||||
dx[dt.Columns[j]] = di.itemvalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
dt.Rows.Add(dx);
|
||||
}
|
||||
foreach (CLMDocItem di in treffer)
|
||||
{
|
||||
docitemlist.Remove(di);
|
||||
}
|
||||
dt.AcceptChanges();
|
||||
string JSONresult;
|
||||
JSONresult = JsonConvert.SerializeObject(dt);
|
||||
tablename = Tablename;
|
||||
value = JSONresult;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#region Helper
|
||||
private IEnumerable<(string path, string key, string value)> GetNodes(JToken token)
|
||||
{
|
||||
@@ -1195,14 +1294,34 @@ namespace API_NetFramework.Controllers
|
||||
// dokdata.dokumentwerte = ToDataTable<CLMDocItem>
|
||||
dokumentid = db.Create_EDOKA_Doc(dokdata, false, "");
|
||||
dokdata.Dokumentid = dokumentid;
|
||||
|
||||
|
||||
dokdata.Erstellung_in_Office = false;
|
||||
DOCGEN.Generator.DocGenerator_from_EDOKA Generator = new DOCGEN.Generator.DocGenerator_from_EDOKA(this.connectionstring, OwnHost, key.ToString());
|
||||
dok = Generator.Generate_Doc_EDOKA(dokumentid, ref dokdata, false, 0, false, false);
|
||||
db.Save_To_DB(dokumentid, "", dok.dokument);
|
||||
DocGet dget = new DocGet(this.connectionstring);
|
||||
dok.dokument = dget.Convert_Word_To_PDF(dok.dokument);
|
||||
// db.Save_To_DB(dokumentid, "", dok.dokument);
|
||||
|
||||
|
||||
// dok = dget.GetDocAsPDF(dokumentid);
|
||||
dok.extension = "pdf";
|
||||
dok.doktype = "P";
|
||||
if (System.Configuration.ConfigurationManager.AppSettings["CLMSaveOnDoc"].ToString() == "True")
|
||||
{
|
||||
db.Save_To_DB(dokumentid, "", dok.dokument);
|
||||
} else
|
||||
{
|
||||
db.clear_parameter();
|
||||
db.add_parameter("@dokumentid", dokumentid);
|
||||
db.Get_Tabledata("ondoc_delete_apidoc", true, false);
|
||||
}
|
||||
deflist.Clear();
|
||||
dget = null;
|
||||
Generator = null;
|
||||
clmdocitemlist.Clear();
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende GenDoc DokumentID:" + dokumentid, LogLevelType.Debug);
|
||||
APILogging.DocLog((HttpRequestMessage)Request, docgendata.partnernr.ToString(), "Dokument über API erstellt", dokumentid, LogLevelType.Info);
|
||||
db = null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user