Update 20260123
This commit is contained in:
79
API_DocGen_Tester/Default.aspx.cs
Normal file
79
API_DocGen_Tester/Default.aspx.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Newtonsoft.Json;
|
||||
namespace API_DocGen_Tester
|
||||
{
|
||||
public partial class Default : System.Web.UI.Page
|
||||
{
|
||||
private string ConnectionString =>
|
||||
ConfigurationManager.ConnectionStrings["DbConnection"].ConnectionString;
|
||||
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
string content = hfContent.Value;
|
||||
|
||||
using (SqlConnection con = new SqlConnection(ConnectionString))
|
||||
{
|
||||
string sql = @"INSERT INTO FileStorage (FileName, Content)
|
||||
VALUES (@FileName, @Content)";
|
||||
|
||||
SqlCommand cmd = new SqlCommand(sql, con);
|
||||
cmd.Parameters.AddWithValue("@FileName", txtFileName.Text);
|
||||
cmd.Parameters.AddWithValue("@Content", content);
|
||||
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
lblStatus.Text = "Datei gespeichert.";
|
||||
}
|
||||
|
||||
protected void btnLoad_Click(object sender, EventArgs e)
|
||||
{
|
||||
string content = "";
|
||||
|
||||
using (SqlConnection con = new SqlConnection(ConnectionString))
|
||||
{
|
||||
string sql = @"SELECT TOP 1 Content
|
||||
FROM FileStorage
|
||||
WHERE FileName = @FileName
|
||||
ORDER BY CreatedAt DESC";
|
||||
|
||||
SqlCommand cmd = new SqlCommand(sql, con);
|
||||
cmd.Parameters.AddWithValue("@FileName", txtFileName.Text);
|
||||
|
||||
con.Open();
|
||||
object result = cmd.ExecuteScalar();
|
||||
|
||||
if (result != null)
|
||||
content = result.ToString();
|
||||
}
|
||||
|
||||
// Inhalt nach JS zurückgeben
|
||||
ScriptManager.RegisterStartupScript(
|
||||
this,
|
||||
GetType(),
|
||||
"setEditor",
|
||||
$"setEditorContent({content});",
|
||||
true);
|
||||
|
||||
lblStatus.Text = "Datei geladen.";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user