Update 20260123
This commit is contained in:
@@ -20,8 +20,14 @@ using Syncfusion.Windows.Forms.PdfViewer;
|
||||
using Syncfusion.Windows.PdfViewer;
|
||||
using Newtonsoft;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.Diagnostics;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.Dynamic;
|
||||
using Model;
|
||||
using System.Drawing.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
|
||||
namespace ZZPDFTest
|
||||
@@ -270,57 +276,49 @@ namespace ZZPDFTest
|
||||
public string NewText { get; set; } = "";
|
||||
}
|
||||
|
||||
|
||||
private void button6_Click(object sender, EventArgs e)
|
||||
{
|
||||
pdfViewerControl1.Load(@"E:\Software-Projekte\OnDoc\Office_Vorlagen\20251110_PRIIP Arete Ethik Vorsorgefonds Global Balanced.pdf");
|
||||
}
|
||||
|
||||
private void button7_Click(object sender, EventArgs e)
|
||||
|
||||
|
||||
{
|
||||
|
||||
|
||||
string jsonstring = System.IO.File.ReadAllText(@"E:\Software-Projekte\OnDoc\APIJson\essdemo.json");
|
||||
|
||||
|
||||
|
||||
|
||||
dynamic dataj = JsonConvert.DeserializeObject(jsonstring);
|
||||
Console.WriteLine(dataj.Bp.Zustaendiger.TgNummer);
|
||||
|
||||
|
||||
|
||||
|
||||
//foreach (var bpis in JsonConvert.DeserializeObject<dynamic>(jsonstring))
|
||||
//{
|
||||
// Console.WriteLine(bpis.Name);
|
||||
// Console.WriteLine(bpis.Value);
|
||||
|
||||
//}
|
||||
|
||||
List<docitem> docitemlist = new List<docitem>();
|
||||
var jo = JObject.Parse(jsonstring);
|
||||
var valueTuples = GetNodes(jo).ToList();
|
||||
foreach ( var valueTuple in valueTuples)
|
||||
foreach (var valueTuple in valueTuples)
|
||||
{
|
||||
docitem d = new docitem();
|
||||
d.itemname= valueTuple.Item1;
|
||||
d.itemtag= valueTuple.Item2;
|
||||
d.itemvalue= valueTuple.Item3;
|
||||
d.itemname = valueTuple.Item1;
|
||||
d.itemtag = valueTuple.Item2;
|
||||
d.itemvalue = valueTuple.Item3;
|
||||
d.doclinkname = "";
|
||||
docitemlist.Add(d);
|
||||
|
||||
}
|
||||
Database.DB db = new Database.DB(@"Data Source=shu01\shu00;Initial Catalog=edoka_dms;Persist Security Info=True;User ID=sa;Password=*shu29;");
|
||||
|
||||
db.Get_Tabledata("Select * from vorlagenfeld where dokumenttypnr="+dataj.Dokumenttyp.ToString()+" and aktiv=1 and ess_field_class_id<>0",false,true);
|
||||
|
||||
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(docitem di in docitemlist)
|
||||
|
||||
|
||||
foreach (docitem di in docitemlist)
|
||||
{
|
||||
if ("$."+di.itemname == dr["ess_feldname"].ToString())
|
||||
if ("$." + di.itemname == dr["ess_feldname"].ToString())
|
||||
{
|
||||
di.bmstart = dr["beginntextmarke"].ToString();
|
||||
di.bmend= dr["endetextmarke"].ToString();
|
||||
di.field= dr["feldname"].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();
|
||||
@@ -328,8 +326,106 @@ namespace ZZPDFTest
|
||||
di.type = dr["ess_field_class_id"].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
if (dr["ess_feldname"].ToString().Contains("@T:"))
|
||||
{
|
||||
string value = "";
|
||||
string tablename = "";
|
||||
get_tabledata(dr["ess_feldname"].ToString(), ref docitemlist, out value, out tablename);
|
||||
docitem di = new docitem();
|
||||
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;
|
||||
docitemlist.Add(di);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
docitemlist.RemoveAll((x) => string.IsNullOrEmpty(x.type));
|
||||
}
|
||||
|
||||
private void get_tabledata(string ifeldname, ref List<docitem> 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 (docitem 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 (docitem 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 (docitem di in treffer)
|
||||
{
|
||||
docitemlist.Remove(di);
|
||||
}
|
||||
dt.AcceptChanges();
|
||||
string JSONresult;
|
||||
JSONresult = JsonConvert.SerializeObject(dt);
|
||||
tablename = Tablename;
|
||||
value= JSONresult;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class inttable
|
||||
{
|
||||
public string Tablename { get; set; }
|
||||
List<TableAttributes> Attributes { get; set; }
|
||||
}
|
||||
public class TableAttributes
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string value { get; set; }
|
||||
}
|
||||
|
||||
public class docitem
|
||||
@@ -347,7 +443,7 @@ namespace ZZPDFTest
|
||||
public string width;
|
||||
public string height;
|
||||
|
||||
|
||||
|
||||
}
|
||||
private IEnumerable<(string path, string key, string value)> GetNodes(JToken token)
|
||||
{
|
||||
@@ -371,5 +467,5 @@ namespace ZZPDFTest
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user