66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using Microsoft.Ajax.Utilities;
|
|
using Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace OnDocAPI_NetFramework.DocGenerators
|
|
{
|
|
public class CreateCLM
|
|
{
|
|
APIErrorSimple apireturn = new APIErrorSimple();
|
|
APIOK apiok = new APIOK();
|
|
|
|
List<CLMDocItem> clmdocitemlist = new List<CLMDocItem>();
|
|
string clmdokumentid = "";
|
|
|
|
string OwnHost = System.Configuration.ConfigurationManager.AppSettings["OwnHost"].ToString();
|
|
string imagepath = System.Configuration.ConfigurationManager.AppSettings["VSImagePath"].ToString();
|
|
|
|
public void CreateCLMDoc(string json)
|
|
{
|
|
dynamic dataj = null;
|
|
|
|
dataj = JsonConvert.DeserializeObject(json);
|
|
var jo = JObject.Parse(json);
|
|
var x = dataj.Produkt;
|
|
//Console.WriteLine(dataj.Bp.Zustaendiger.TgNummer);
|
|
var valueTuples = GetNodes(jo).ToList();
|
|
foreach (var valueTuple in valueTuples)
|
|
{
|
|
CLMDocItem d = new CLMDocItem();
|
|
d.itemname = valueTuple.Item1;
|
|
d.itemtag = valueTuple.Item2;
|
|
d.itemvalue = valueTuple.Item3;
|
|
d.doclinkname = "";
|
|
clmdocitemlist.Add(d);
|
|
|
|
}
|
|
var res = "";
|
|
|
|
}
|
|
|
|
private IEnumerable<(string path, string key, string value)> GetNodes(JToken token)
|
|
{
|
|
foreach (var jt in token.Children())
|
|
{
|
|
if (!jt.Children().Any())
|
|
{
|
|
yield return (
|
|
path: jt.Path,
|
|
key: jt.Path.Split('.').Last(),
|
|
value: jt.ToString()
|
|
);
|
|
}
|
|
|
|
foreach (var (path, key, value) in GetNodes(jt))
|
|
{
|
|
yield return (path, key, value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |