update 20251008
This commit is contained in:
94
OnDoc_JSONViewer/Form1.cs
Normal file
94
OnDoc_JSONViewer/Form1.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using Syncfusion.XPS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Newtonsoft;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Syncfusion.Windows.Forms.PdfViewer;
|
||||
|
||||
namespace OnDoc_JSONViewer
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
listBox1.Items.Clear();
|
||||
DirectoryInfo dir = new DirectoryInfo(textBox1.Text);
|
||||
foreach (FileInfo file in dir.GetFiles())
|
||||
{
|
||||
listBox1.Items.Add(file.Name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
string ext = System.IO.Path.GetExtension(listBox1.SelectedItem.ToString().ToUpper());
|
||||
string filename = textBox1.Text + @"\" + listBox1.SelectedItem.ToString();
|
||||
textBox2.Text = "";
|
||||
switch (ext)
|
||||
{
|
||||
case ".PDF":
|
||||
pdfViewerControl1.Load(filename);
|
||||
break;
|
||||
case ".JSON":
|
||||
string jsonstring;
|
||||
using (StreamReader streamReader = new StreamReader(filename, Encoding.UTF8))
|
||||
{
|
||||
jsonstring = streamReader.ReadToEnd();
|
||||
}
|
||||
// var prettyJson1 = JsonConvert.SerializeObject(jsonstring, Formatting.Indented);
|
||||
|
||||
//dynamic parsedJson1 = JsonConvert.DeserializeObject(jsonstring);
|
||||
//prettyJson1 = JsonConvert.SerializeObject(parsedJson1, Formatting.Indented);
|
||||
string source2 = jsonstring;
|
||||
dynamic data2 = JObject.Parse(source2);
|
||||
string data3 = JObject.Parse(jsonstring)["bpNummer"].ToString();
|
||||
string data4 = JObject.Parse(jsonstring)["personNummer"].ToString();
|
||||
textBox2.Text= data3 + Environment.NewLine+data4;
|
||||
if (toolStripCheckBox1.Checked == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
string source = jsonstring;
|
||||
dynamic data = JObject.Parse(source);
|
||||
string data1 = JObject.Parse(jsonstring)["dokumentDatei"].ToString();
|
||||
|
||||
|
||||
var stream = new MemoryStream(Convert.FromBase64String(data1));
|
||||
|
||||
|
||||
if (stream.Length > 0)
|
||||
{
|
||||
this.pdfViewerControl1.Load(stream);
|
||||
this.pdfViewerControl1.Visible = true;
|
||||
pdfViewerControl1.ZoomMode = ZoomMode.FitWidth;
|
||||
stream = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user