Update 20260319
This commit is contained in:
75
API_NetFramework/OnDocAPIHome.aspx.cs
Normal file
75
API_NetFramework/OnDocAPIHome.aspx.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Swashbuckle.Swagger;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace OnDocAPI_NetFramework
|
||||
{
|
||||
public partial class DemoSeite : System.Web.UI.Page
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
lblVersion.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
|
||||
var process = Process.GetCurrentProcess();
|
||||
TimeSpan uptime = DateTime.Now - process.StartTime;
|
||||
lblUptime.Text = uptime.Days + "d " + uptime.Hours + "h " + uptime.Minutes + "m " + uptime.Seconds + "s";
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnLogin_Click(object sender, EventArgs e)
|
||||
{
|
||||
string filePath = Server.MapPath("~/App_Data/users.json");
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
lblLoginError.Text = "Benutzerdaten nicht gefunden!";
|
||||
return;
|
||||
}
|
||||
|
||||
string json = File.ReadAllText(filePath);
|
||||
var serializer = new JavaScriptSerializer();
|
||||
var users = serializer.Deserialize<List<User>>(json);
|
||||
|
||||
string userId = txtUserID.Text.Trim();
|
||||
string password = txtPassword.Text.Trim();
|
||||
|
||||
var user = users.Find(u => u.UserID == userId && u.Password == password);
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
lblLoginError.Text = "";
|
||||
Button1.Visible = true;
|
||||
Button2.Visible = true;
|
||||
HttpContext.Current.Session["LoggedIn"] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
HttpContext.Current.Session["LoggedIn"] = false;
|
||||
//lblLoginError.Text = "Ungültige Benutzer-ID oder Passwort!";
|
||||
Button1.Visible = false;
|
||||
Button2.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void OpenPage1(object sender, EventArgs e) => Response.Redirect("/clm.aspx");
|
||||
protected void OpenPage2(object sender, EventArgs e) => Response.Redirect("/jsonviewer.aspx");
|
||||
|
||||
public class User
|
||||
{
|
||||
public string UserID { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user