Cleanup SQL Connections and fix tickets
This commit is contained in:
@ -44,12 +44,12 @@
|
||||
{
|
||||
@foreach (var ticket in Model.Tickets)
|
||||
{
|
||||
if (ticket.ClosedBy == null)
|
||||
@if (ticket.ClosedBy == null)
|
||||
{
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h6>@ticket.CharacterName</h6>
|
||||
<a href="/?handler=Account&name=@ticket.OpenedBy.Username">@ticket.CharacterName</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="card-text">@ticket.Description</p>
|
||||
|
||||
@ -11,8 +11,7 @@ namespace NightmareCoreWeb2.Pages
|
||||
{
|
||||
public class AccountModel : PageModel
|
||||
{
|
||||
string connStr = $"SslMode=None;server={Program.MysqlServer};user={Program.MysqlUser};database={Program.MysqlDatabase};port={Program.MysqlPort};password={Program.MysqlPassword}";
|
||||
public string UserEmail { get; set; }
|
||||
public string UserEmail { get; set; }
|
||||
public string UserPassword { get; set; }
|
||||
public string CharacterListType { get; set; }
|
||||
public string AuthToken { get; set; }
|
||||
@ -29,22 +28,22 @@ namespace NightmareCoreWeb2.Pages
|
||||
public AccountModel(ILogger<AccountModel> logger)
|
||||
{
|
||||
|
||||
conn = new MySqlConnection(connStr);
|
||||
conn = new MySqlConnection(Program.connStr);
|
||||
_logger = logger;
|
||||
}
|
||||
public void OnGetAccount(string name)
|
||||
{
|
||||
|
||||
Account a = new Account(name, conn);
|
||||
//AuthToken = "OK";
|
||||
Account a = new Account(name);
|
||||
AuthToken = "OK";
|
||||
UserAccount = a;
|
||||
OnlineCharacters = a.Characters;
|
||||
foreach (var access in a.Access)
|
||||
{
|
||||
if (access.RealmID == -1 && access.RealmID >= 1)
|
||||
if (access.RealmID == -1 && access.SecurityLevel >= 1)
|
||||
{
|
||||
this.IsGM = true;
|
||||
this.Tickets = GMTicket.GetAllTickets(conn);
|
||||
this.Tickets = GMTicket.GetAllTickets();
|
||||
}
|
||||
}
|
||||
ViewData["Title"] = a.Username;
|
||||
@ -52,12 +51,12 @@ namespace NightmareCoreWeb2.Pages
|
||||
}
|
||||
public void OnGetCharacterAction(int guid, int action)
|
||||
{
|
||||
Character c = new Character(guid, conn);
|
||||
Character c = new Character(guid);
|
||||
if ((c.AtLogin & Character.AtLoginOptions.AT_LOGIN_FIRST) == 0)
|
||||
{
|
||||
c.AtLogin |= (Character.AtLoginOptions)action;
|
||||
}
|
||||
c.SetAtLogin(conn);
|
||||
c.SetAtLogin();
|
||||
|
||||
}
|
||||
public void OnGet()
|
||||
@ -68,7 +67,7 @@ namespace NightmareCoreWeb2.Pages
|
||||
Username = Request.Cookies["Username"];
|
||||
if (!string.IsNullOrEmpty(Username))
|
||||
{
|
||||
Account a = new Account(Username, conn);
|
||||
Account a = new Account(Username);
|
||||
AuthToken = "OK";
|
||||
UserAccount = a;
|
||||
OnlineCharacters = a.Characters;
|
||||
@ -77,7 +76,7 @@ namespace NightmareCoreWeb2.Pages
|
||||
if (access.RealmID == -1 && access.RealmID >= 1)
|
||||
{
|
||||
this.IsGM = true;
|
||||
this.Tickets = GMTicket.GetAllTickets(conn);
|
||||
this.Tickets = GMTicket.GetAllTickets();
|
||||
}
|
||||
}
|
||||
ViewData["Title"] = a.Username;
|
||||
|
||||
@ -8,15 +8,14 @@ namespace NightmareCoreWeb2.Pages
|
||||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
string connStr = $"SslMode=None;server={Program.MysqlServer};user={Program.MysqlUser};database={Program.MysqlDatabase};port={Program.MysqlPort};password={Program.MysqlPassword}";
|
||||
public List<Character> OnlineCharacters = new List<Character>();
|
||||
public Dictionary<string, string> Realms = new Dictionary<string, string>();
|
||||
|
||||
public string ActivateEmail {get; set;}
|
||||
public string ActivatePassword {get; set;}
|
||||
public string ActivateToken {get; set;}
|
||||
public string RequestTokenEmail {get; set;}
|
||||
public string CharacterListType {get; set;}
|
||||
public string ActivateEmail { get; set; }
|
||||
public string ActivatePassword { get; set; }
|
||||
public string ActivateToken { get; set; }
|
||||
public string RequestTokenEmail { get; set; }
|
||||
public string CharacterListType { get; set; }
|
||||
private MySqlConnection conn;
|
||||
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
@ -24,8 +23,8 @@ namespace NightmareCoreWeb2.Pages
|
||||
public IndexModel(ILogger<IndexModel> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
|
||||
conn = new MySqlConnection(connStr);
|
||||
|
||||
conn = new MySqlConnection(Program.connStr);
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
@ -45,10 +44,10 @@ namespace NightmareCoreWeb2.Pages
|
||||
OnlineCharacters.Add(c);
|
||||
}
|
||||
rdr.Close();
|
||||
sql = "SELECT name,flag FROM realmlist";
|
||||
sql = "SELECT name,flag FROM realmlist";
|
||||
cmd = new MySqlCommand(sql, conn);
|
||||
rdr = cmd.ExecuteReader();
|
||||
|
||||
|
||||
while (rdr.Read())
|
||||
{
|
||||
Realms.Add(rdr.GetString(0), rdr.GetString(1).Equals("2") ? "❌" : "✔️");
|
||||
@ -64,32 +63,39 @@ namespace NightmareCoreWeb2.Pages
|
||||
|
||||
}
|
||||
|
||||
public void OnGet() {
|
||||
public void OnGet()
|
||||
{
|
||||
ViewData["Title"] = "WotDN";
|
||||
}
|
||||
public void OnGetAccount(string name) {
|
||||
Account a = new Account(name, conn);
|
||||
public void OnGetAccount(string name)
|
||||
{
|
||||
Account a = new Account(name);
|
||||
ViewData["Title"] = name;
|
||||
CharacterListType = $"{name}'s Characters";
|
||||
OnlineCharacters = a.Characters;
|
||||
}
|
||||
|
||||
public void OnPostActivateAccount() {
|
||||
public void OnPostActivateAccount()
|
||||
{
|
||||
ActivateEmail = Request.Form["ActivateEmail"];
|
||||
ActivatePassword = Request.Form["ActivatePassword"];
|
||||
ActivateToken = Request.Form["ActivateToken"];
|
||||
}
|
||||
public void OnPostRequestToken() {
|
||||
public void OnPostRequestToken()
|
||||
{
|
||||
RequestTokenEmail = Request.Form["RequestTokenEmail"];
|
||||
}
|
||||
|
||||
public bool RequestToken() {
|
||||
public bool RequestToken()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public bool CreateAccount() {
|
||||
public bool CreateAccount()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public bool IsTokenValid(string username, string token) {
|
||||
public bool IsTokenValid(string username, string token)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user