80 lines
2.2 KiB
C#
80 lines
2.2 KiB
C#
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.";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|