From cdb86331e58ecb17f7e4bc65f98ae50fce6fb109 Mon Sep 17 00:00:00 2001 From: Rene Schwarz Date: Mon, 9 Aug 2021 15:08:26 +0200 Subject: [PATCH] add auto module fetch on startup and finished module creation form for real now --- .../DesignTimeBuild/.dtbcache.v2 | Bin 99326 -> 99326 bytes .vs/Server Dashboard/v16/.suo | Bin 254464 -> 226816 bytes .../DashboardModules/ServerInformation.cs | 44 --------- Server Dashboard/Database/DatabaseHandler.cs | 87 ++++++++++++++++-- .../ModuleData/ModuleData.cs} | 15 ++- .../ServerData/ServerInformation.cs | 26 ++++++ .../ServerData/ServerModules/CPU.cs | 13 +++ .../ServerData/ServerModules/Drives.cs | 13 +++ .../ServerData/ServerModules/GPU.cs | 13 +++ .../ServerData/ServerModules/Motherboard.cs | 13 +++ .../ServerModules/NetworkInterface.cs | 13 +++ .../ServerData/ServerModules/RAM.cs | 14 +++ Server Dashboard/User/User.cs | 26 ++++++ .../Dashboard/DashboardModuleViewModel.cs | 52 +++++------ .../Dashboard/DashboardViewModel.cs | 38 +++++--- .../ViewModels/Login/LoginViewModel.cs | 4 +- Server Dashboard/Views/DashboardWindow.xaml | 2 +- .../Debug/netcoreapp3.1/Server Dashboard.dll | Bin 1118720 -> 1120768 bytes .../Debug/netcoreapp3.1/Server Dashboard.pdb | Bin 29228 -> 30848 bytes ...r Dashboard.csproj.CoreCompileInputs.cache | 2 +- ...er Dashboard.csprojAssemblyReference.cache | Bin 156447 -> 424 bytes .../Debug/netcoreapp3.1/Server Dashboard.dll | Bin 1118720 -> 1120768 bytes .../Server Dashboard.g.resources | Bin 1077427 -> 1077432 bytes .../Debug/netcoreapp3.1/Server Dashboard.pdb | Bin 29228 -> 30848 bytes .../Server Dashboard_MarkupCompile.cache | 2 +- .../Server Dashboard_MarkupCompile.i.cache | 4 +- .../Server Dashboard_MarkupCompile.i.lref | 8 -- .../netcoreapp3.1/Views/DashboardWindow.baml | Bin 8501 -> 8506 bytes .../netcoreapp3.1/Views/DashboardWindow.g.cs | 2 +- .../Views/DashboardWindow.g.i.cs | 2 +- 30 files changed, 269 insertions(+), 124 deletions(-) delete mode 100644 Server Dashboard/DashboardModules/ServerInformation.cs rename Server Dashboard/{DashboardModules/DashboardModule.cs => User/ModuleData/ModuleData.cs} (76%) create mode 100644 Server Dashboard/User/ModuleData/ServerData/ServerInformation.cs create mode 100644 Server Dashboard/User/ModuleData/ServerData/ServerModules/CPU.cs create mode 100644 Server Dashboard/User/ModuleData/ServerData/ServerModules/Drives.cs create mode 100644 Server Dashboard/User/ModuleData/ServerData/ServerModules/GPU.cs create mode 100644 Server Dashboard/User/ModuleData/ServerData/ServerModules/Motherboard.cs create mode 100644 Server Dashboard/User/ModuleData/ServerData/ServerModules/NetworkInterface.cs create mode 100644 Server Dashboard/User/ModuleData/ServerData/ServerModules/RAM.cs create mode 100644 Server Dashboard/User/User.cs delete mode 100644 Server Dashboard/obj/Debug/netcoreapp3.1/Server Dashboard_MarkupCompile.i.lref diff --git a/.vs/Server Dashboard/DesignTimeBuild/.dtbcache.v2 b/.vs/Server Dashboard/DesignTimeBuild/.dtbcache.v2 index 82db2c58f29a92996777b138de3d2971012dc53d..cf13afc4a7fba2217099bd0775673fee4237dc6d 100644 GIT binary patch delta 1181 zcmbu-$!il~7{~FMDF%8F3+h1-#DgBRlsA*i5)jFs;6+4mo6I|}T9?+=UF)Pqjl0#j z@B31Bq@=h02ep5Pr{wCP_Vr|1zSK1Q~_7C*+F0y8~E|x8hWo^YaY{w2nC?SSM0)w5{h27}I9xNkcFY7++ zM<4njc?U3nK^#PSh}~fv!BHH;ah$+ONP!`oLW(kmaT?OJ6skbN&p?7D<1Eghiu3sU zxeJ_MgiYkkO&nO4_@RUKGOHB5f(++ZSta}$BzOc8*2y&~{I8;a3UZ5eo!t#A`WOjGf-o~+$T@#2X z0+mV}OBuBz^~SYapcQ9YwWl5+RIOBr3h04DEA@5iLly1p+OZv))6UL(-}is>&;0*9 zy;A%1N-g_w%`NuA-7!OvEZx#=MVFB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Information.cs deleted file mode 100644 index 399e567..0000000 --- a/Server Dashboard/DashboardModules/ServerInformation.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Text; - -namespace Server_Dashboard { - - /// - /// Server information class, this will probably scale pretty big later on - /// This will hold all the information the socket will gather - /// - internal class ServerInformation { - - //The ServerName - public string ServerName { get; set; } - - //The unix or windows username - public string OSUserName { get; set; } - - //Cpu Temp in C - public string CpuTemp { get; set; } - - //Gpu Temp in C - public string GpuTemp { get; set; } - - //Server uptime - public string Uptime { get; set; } - - //When the server was first deployed - public string DeployDate { get; set; } - - //Public IPv4 Adress - public string PublicIpAdress { get; set; } - - //Private IP adress from the servers network - public string PrivateIpAdress { get; set; } - - //GPU usage in % - public string GpuUsage { get; set; } - - //CPU usage in % - public string CpuUsage { get; set; } - } -} \ No newline at end of file diff --git a/Server Dashboard/Database/DatabaseHandler.cs b/Server Dashboard/Database/DatabaseHandler.cs index bdcc3e5..8bc1a22 100644 --- a/Server Dashboard/Database/DatabaseHandler.cs +++ b/Server Dashboard/Database/DatabaseHandler.cs @@ -5,6 +5,7 @@ using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Reflection; +using System.Threading.Tasks; using System.Windows.Media.Imaging; namespace Server_Dashboard { @@ -65,12 +66,77 @@ namespace Server_Dashboard { //Open the connection con.Open(); //SQL Query - string query = "SELECT UserID, Username, Email, CreationTime, ModuleName, MI.Image FROM UserData LEFT JOIN ModuleData MD on UserData.ID = MD.UserID LEFT JOIN ModuleIcon MI on MD.ID = MI.Module WHERE Username = @username"; + string query = "SELECT ID, Username, Email, RegistrationDate FROM UserData WHERE Username = @username"; //Creates a new command using SqlCommand com = new SqlCommand(query, con);//For security reasons the values are added with this function //this will avoid SQL Injections com.Parameters.AddWithValue("@username", username); //Execute query and return number of rows affected + DataTable resultTable = new DataTable() { TableName = "Userdata" }; + using SqlDataAdapter sda = new SqlDataAdapter(com); + sda.Fill(resultTable); + return resultTable; + //Checks if there are any rows successful + //If the query returns 0 the query wasn't successful + //if its any number above 0 it was successfull + //Catch any error + } catch (SqlException ex) { + return null; + } finally { + //Always close the connection + con.Close(); + } + } + + public static DataTable GetUserModuleData(int uid) { + //Creates the database connection + using SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString); + try { + //Open the connection + con.Open(); + //SQL Query + string query = "SELECT Creator, CreationTime, ModuleName, MI.Image FROM ModuleData LEFT JOIN ModuleIcon MI on ModuleData.ID = MI.Module WHERE UserID = @userID"; + //Creates a new command + using SqlCommand com = new SqlCommand(query, con);//For security reasons the values are added with this function + //this will avoid SQL Injections + com.Parameters.AddWithValue("@userID", uid); + //Execute query and return number of rows affected + DataTable resultTable = new DataTable(); + using SqlDataAdapter sda = new SqlDataAdapter(com); + sda.Fill(resultTable); + return resultTable; + //Checks if there are any rows successful + //If the query returns 0 the query wasn't successful + //if its any number above 0 it was successfull + //Catch any error + } catch (SqlException ex) { + return null; + } finally { + //Always close the connection + con.Close(); + } + } + + /// + /// This function will fetch every Serverdata for each module + /// This will need some optimization, for now we just asynchronously + /// fetch the serverdata for each module + /// + /// ModuleID to fetch the data from + /// + public static DataTable GetServerData(string mid) { + //Creates the database connection + using SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString); + try { + //Open the connection + con.Open(); + //SQL Query + string query = "SELECT * FROM ServerData WHERE ModuleID = @mid"; + //Creates a new command + using SqlCommand com = new SqlCommand(query, con);//For security reasons the values are added with this function + //this will avoid SQL Injections + com.Parameters.AddWithValue("@mid", mid); + //Execute query and return number of rows affected DataTable resultTable = new DataTable(); using SqlDataAdapter sda = new SqlDataAdapter(com); sda.Fill(resultTable); @@ -113,7 +179,10 @@ namespace Server_Dashboard { com.Parameters.AddWithValue("@time", DateTime.Now); com.Parameters.AddWithValue("@moduleName", moduleName); com.Parameters.AddWithValue("@serverName", serverName); - com.Parameters.Add("@moduleIcon", SqlDbType.VarBinary, int.MaxValue).Value = moduleIcon; + com.Parameters.Add("@moduleIcon", SqlDbType.VarBinary, -1).Value = moduleIcon; + if (moduleIcon == null) + com.Parameters["@moduleIcon"].Value = DBNull.Value; + //com.Parameters.AddWithValue("@moduleIcon", moduleIcon); com.Parameters.AddWithValue("@ipAdress", ipAdress); com.Parameters.AddWithValue("@port", port); //Execute query and return number of rows affected @@ -150,21 +219,19 @@ namespace Server_Dashboard { //Open the connection con.Open(); //SQL Query - string query = "EXEC CheckUserCookie @Cookie = @cookie, @UserName = @username, @Valid = @valid OUTPUT"; + string query = "((SELECT Cookie FROM UserData WHERE Username = @username) = @cookie)"; //Creates a new command using SqlCommand com = new SqlCommand(query, con); //For security reasons the values are added with this function //this will avoid SQL Injections com.Parameters.AddWithValue("@cookie", cookie); com.Parameters.AddWithValue("@username", username); - com.Parameters.Add("@valid", SqlDbType.Bit); - com.Parameters["@valid"].Direction = ParameterDirection.Output; //Execute query and return number of rows affected int sqlResponse = com.ExecuteNonQuery(); //Checks if there are any rows successful //If the query returns 0 the query wasn't successful //if its any number above 0 it was successfull - if ((int)com.Parameters["@Valid"].Value == 0) { + if (sqlResponse == 0) { //Error, not successful return 1; } else { @@ -191,7 +258,7 @@ namespace Server_Dashboard { //Open the connection con.Open(); //SQL Query - string query = "EXEC DeleteUserCookie @Username = @username"; + string query = "UPDATE UserData SET Cookie = null WHERE Username = @username"; //Creates a new command using SqlCommand com = new SqlCommand(query, con); //For security reasons the values are added with this function @@ -224,19 +291,19 @@ namespace Server_Dashboard { /// The delicious locally stored cookie /// The User who deserves a cookie :3 /// [0] is false, [1] is true, [2] connection error - public static int AddCookie(string cookie, string username) { + public static int AddCookie(string username, string cookie) { //Creates the database connection using SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString); try { //Open the connection con.Open(); //SQL Query - string query = "EXEC AddCookieToUser @Cookie = @cookie, @UserName = @username"; + string query = "UPDATE UserData SET Cookie = @cookie WHERE Username = @username"; //Creates a new command using SqlCommand com = new SqlCommand(query, con); //For security reasons the values are added with this function //this will avoid SQL Injections - com.Parameters.AddWithValue("@cookie", cookie); + com.Parameters.Add("@cookie", SqlDbType.NVarChar, -1).Value = cookie; com.Parameters.AddWithValue("@username", username); //Execute query and return number of rows affected int sqlResponse = com.ExecuteNonQuery(); diff --git a/Server Dashboard/DashboardModules/DashboardModule.cs b/Server Dashboard/User/ModuleData/ModuleData.cs similarity index 76% rename from Server Dashboard/DashboardModules/DashboardModule.cs rename to Server Dashboard/User/ModuleData/ModuleData.cs index d046943..213ca75 100644 --- a/Server Dashboard/DashboardModules/DashboardModule.cs +++ b/Server Dashboard/User/ModuleData/ModuleData.cs @@ -5,10 +5,7 @@ using System.Windows.Media.Imaging; namespace Server_Dashboard { - /// - /// Dashboard Module class that holds all the information that gets displayed - /// - internal class DashboardModule { + internal class ModuleData { //The name the user gives the module public string ModuleName { get; set; } @@ -16,9 +13,6 @@ namespace Server_Dashboard { //The user who created it public string Creator { get; set; } - //All the information that the server had - public ServerInformation ServerInfo { get; set; } - //The status indicator public string StatusIndicator { get; set; } @@ -32,13 +26,16 @@ namespace Server_Dashboard { public BitmapImage ModuleIcon { get; set; } //Creation date with System.DateTime.Now - public string CreationDate { get; set; } + public DateTime CreationDate { get; set; } + + //List that contains all the serverinformation over a period of time(lifespan of the module) + public List ServerInformation { get; set; } /// /// This will set the Module status indicator red or green if the server is available or not /// /// - public DashboardModule(bool serverAvailable) { + public ModuleData(bool serverAvailable) { ServerAvailable = serverAvailable; StatusIndicator = ServerAvailable ? "#20c657" : "#e53935"; StatusIndicatorBG = ServerAvailable ? "#94eeb0" : "#ef9a9a"; diff --git a/Server Dashboard/User/ModuleData/ServerData/ServerInformation.cs b/Server Dashboard/User/ModuleData/ServerData/ServerInformation.cs new file mode 100644 index 0000000..fb2cdbe --- /dev/null +++ b/Server Dashboard/User/ModuleData/ServerData/ServerInformation.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text; + +namespace Server_Dashboard { + + /// + /// Server information class, this will probably scale pretty big later on + /// This will hold all the information the socket will gather + /// + internal class ServerInformation { + public string ServerName { get; set; } + public string OSUserName { get; set; } + public double CpuTemp { get; set; } + public double GpuTemp { get; set; } + public DateTime Uptime { get; set; } + public DateTime DeployDate { get; set; } + public string PublicIpAdress { get; set; } + public string PrivateIpAdress { get; set; } + public int GpuUsage { get; set; } + public int CpuUsage { get; set; } + public double NetworkUP { get; set; } + public double NetworkDown { get; set; } + } +} \ No newline at end of file diff --git a/Server Dashboard/User/ModuleData/ServerData/ServerModules/CPU.cs b/Server Dashboard/User/ModuleData/ServerData/ServerModules/CPU.cs new file mode 100644 index 0000000..96d8db0 --- /dev/null +++ b/Server Dashboard/User/ModuleData/ServerData/ServerModules/CPU.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Server_Dashboard { + + /// + /// This class represents a single CPU and will be added + /// to a list to account for a multi CPU system + /// + internal class CPU { + } +} \ No newline at end of file diff --git a/Server Dashboard/User/ModuleData/ServerData/ServerModules/Drives.cs b/Server Dashboard/User/ModuleData/ServerData/ServerModules/Drives.cs new file mode 100644 index 0000000..1bca239 --- /dev/null +++ b/Server Dashboard/User/ModuleData/ServerData/ServerModules/Drives.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Server_Dashboard { + + /// + /// This class represents a single drive on a server, this will be added + /// to a list to account for multiple drives + /// + internal class Drives { + } +} \ No newline at end of file diff --git a/Server Dashboard/User/ModuleData/ServerData/ServerModules/GPU.cs b/Server Dashboard/User/ModuleData/ServerData/ServerModules/GPU.cs new file mode 100644 index 0000000..0330175 --- /dev/null +++ b/Server Dashboard/User/ModuleData/ServerData/ServerModules/GPU.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Server_Dashboard { + + /// + /// This class represents a single GPU and will be added to a list + /// to account for multiple GPU's + /// + internal class GPU { + } +} \ No newline at end of file diff --git a/Server Dashboard/User/ModuleData/ServerData/ServerModules/Motherboard.cs b/Server Dashboard/User/ModuleData/ServerData/ServerModules/Motherboard.cs new file mode 100644 index 0000000..aba76f6 --- /dev/null +++ b/Server Dashboard/User/ModuleData/ServerData/ServerModules/Motherboard.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Server_Dashboard { + + /// + /// This class represents the mainboard + /// It will hold information about the chipset, number of hardware etc... + /// + internal class Motherboard { + } +} \ No newline at end of file diff --git a/Server Dashboard/User/ModuleData/ServerData/ServerModules/NetworkInterface.cs b/Server Dashboard/User/ModuleData/ServerData/ServerModules/NetworkInterface.cs new file mode 100644 index 0000000..efd380e --- /dev/null +++ b/Server Dashboard/User/ModuleData/ServerData/ServerModules/NetworkInterface.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Server_Dashboard { + + /// + /// This class represents a single network interface and will be added + /// to a list to account for multiple networking interfaces + /// + internal class NetworkInterface { + } +} \ No newline at end of file diff --git a/Server Dashboard/User/ModuleData/ServerData/ServerModules/RAM.cs b/Server Dashboard/User/ModuleData/ServerData/ServerModules/RAM.cs new file mode 100644 index 0000000..a41bcf4 --- /dev/null +++ b/Server Dashboard/User/ModuleData/ServerData/ServerModules/RAM.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Server_Dashboard { + + /// + /// This class represents RAM + /// TODO: figure out if it makes sense to create a class for the entire system memory + /// or for each and every stick + /// + internal class RAM { + } +} \ No newline at end of file diff --git a/Server Dashboard/User/User.cs b/Server Dashboard/User/User.cs new file mode 100644 index 0000000..eec1ddd --- /dev/null +++ b/Server Dashboard/User/User.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Text; + +namespace Server_Dashboard { + + /// + /// User class to store user informations + /// + internal class User { + public int UID { get; set; } + public string UserName { get; set; } + public string Email { get; set; } + public DateTime RegistrationDate { get; set; } + + public User(DataTable userData) { + foreach (DataRow row in userData.Rows) { + UID = (int)row[0]; + UserName = (string)row[1]; + Email = (string)row[2]; + RegistrationDate = (DateTime)row[3]; + } + } + } +} \ No newline at end of file diff --git a/Server Dashboard/ViewModels/Dashboard/DashboardModuleViewModel.cs b/Server Dashboard/ViewModels/Dashboard/DashboardModuleViewModel.cs index 3ab69ab..f14c8a0 100644 --- a/Server Dashboard/ViewModels/Dashboard/DashboardModuleViewModel.cs +++ b/Server Dashboard/ViewModels/Dashboard/DashboardModuleViewModel.cs @@ -14,46 +14,40 @@ namespace Server_Dashboard { internal class DashboardModuleViewModel : BaseViewModel { //List with all Modules inside - public ObservableCollection Modules { get; set; } + public ObservableCollection Modules { get; set; } //Creates Default Modules, remove before release and when implementing the actual data comming from the socket - public DashboardModuleViewModel(DataTable userdata) { - GetModules(userdata); + public DashboardModuleViewModel(DataTable moduleData) { + Modules = new ObservableCollection(); + foreach (DataRow row in moduleData.Rows) { + if (row[0] != null) { + byte[] iconBytes = row[3] == DBNull.Value ? null : (byte[])row[3]; + Modules.Add(new ModuleData(true) { + ModuleName = (string)row?[2], + Creator = (string)row?[0], + ModuleIcon = ConvertByteToBitmapImage(iconBytes), + CreationDate = (DateTime)row?[1], + ServerInformation = null + }); + } + } } - public void GetModules(DataTable userdata) { - Modules = new ObservableCollection(); - foreach (DataRow row in userdata.Rows) { - BitmapImage moduleIcon = null; - if (row[5] != DBNull.Value) { - using MemoryStream ms = new MemoryStream((byte[])row[5]); - moduleIcon = new BitmapImage(); + private BitmapImage ConvertByteToBitmapImage(byte[] icon) { + if (icon != null) { + try { + using MemoryStream ms = new MemoryStream(icon); + BitmapImage moduleIcon = new BitmapImage(); moduleIcon.BeginInit(); moduleIcon.StreamSource = ms; moduleIcon.CreateOptions = BitmapCreateOptions.PreservePixelFormat; moduleIcon.CacheOption = BitmapCacheOption.OnLoad; moduleIcon.EndInit(); moduleIcon.Freeze(); - } - Modules.Add(new DashboardModule(true) { - ModuleName = (string)row[4], - Creator = (string)row[1], - ModuleIcon = moduleIcon, - CreationDate = DateTime.Now.ToString(), - ServerInfo = new ServerInformation() { - GpuUsage = "20", - CpuUsage = "20", - CpuTemp = "88.88", - DeployDate = DateTime.Now.ToString(), - GpuTemp = "69.69", - ServerName = "Ubuntu", - OSUserName = "crylia ", - PrivateIpAdress = "192.168.1.1", - PublicIpAdress = "85.69.102.58", - Uptime = DateTime.Now.ToString() - } - }); + return moduleIcon; + } catch { } } + return null; } } } \ No newline at end of file diff --git a/Server Dashboard/ViewModels/Dashboard/DashboardViewModel.cs b/Server Dashboard/ViewModels/Dashboard/DashboardViewModel.cs index 140d0b1..909f52f 100644 --- a/Server Dashboard/ViewModels/Dashboard/DashboardViewModel.cs +++ b/Server Dashboard/ViewModels/Dashboard/DashboardViewModel.cs @@ -6,6 +6,8 @@ using System.Windows.Input; using Server_Dashboard_Socket; using System; using System.Data; +using System.Collections.Generic; +using System.Linq; namespace Server_Dashboard { @@ -16,28 +18,28 @@ namespace Server_Dashboard { #region Private Values - private readonly DashboardModuleViewModel dmvm; + private DashboardModuleViewModel dmvm; #endregion Private Values #region Properties //The Username displayed defaults to Username - private string userName; + private User user; - public string UserName { - get { return userName; } + public User User { + get { return user; } set { - if (userName != value) - userName = value; - OnPropertyChanged(nameof(userName)); + if (user != value) + user = value; + OnPropertyChanged(nameof(user)); } } //List that contains every Module - private ObservableCollection modules; + private ObservableCollection modules; - public ObservableCollection Modules { + public ObservableCollection Modules { get { return modules; } set { if (value != modules) @@ -51,15 +53,13 @@ namespace Server_Dashboard { #region Constructor public DashboardViewModel(string username) { - UserName = username; //Command inits OpenLinkCommand = new RelayCommand(OpenLink); OpenNewModuleWindowCommand = new RelayCommand(OpenNewModuleWindow); - DataTable Userdata = DatabaseHandler.GetUserData(username); - dmvm = new DashboardModuleViewModel(Userdata); - //Sets the local module to the dashboardviewmodule modules - Modules = dmvm.Modules; + DataTable userData = DatabaseHandler.GetUserData(username); + User = new User(userData); + GetModules(); } #endregion Constructor @@ -88,12 +88,20 @@ namespace Server_Dashboard { private void OpenNewModuleWindow(object param) { //Creates a new CreateModulePopup and sets this view model as datacontext CreateModulePopup cmp = new CreateModulePopup { - DataContext = new CreateModuleViewModel(UserName) + DataContext = new CreateModuleViewModel(User.UserName) }; //Opens it in the middle of the screen, setting the parent window as owner causes the //application to crash when NOT in debug mode(???) cmp.WindowStartupLocation = WindowStartupLocation.CenterScreen; cmp.ShowDialog(); + GetModules(); + } + + private void GetModules() { + DataTable moduleData = DatabaseHandler.GetUserModuleData(User.UID); + dmvm = new DashboardModuleViewModel(moduleData); + //Sets the local module to the dashboardviewmodule modules + Modules = dmvm.Modules; } #endregion Commands diff --git a/Server Dashboard/ViewModels/Login/LoginViewModel.cs b/Server Dashboard/ViewModels/Login/LoginViewModel.cs index ad09c4f..c20bb79 100644 --- a/Server Dashboard/ViewModels/Login/LoginViewModel.cs +++ b/Server Dashboard/ViewModels/Login/LoginViewModel.cs @@ -140,9 +140,9 @@ namespace Server_Dashboard { DatabaseHandler.DeleteCookie(Username); } //If the remember user option is checked and the cookie is not set save everything locally - if (RememberUser && String.IsNullOrEmpty(Settings.Default.Cookies)) { + if (RememberUser && Settings.Default.Username != Username) { //Creates a new GUID with the username at the end, this is the cookie - var cookie = new Guid().ToString() + Username; + var cookie = $"{Guid.NewGuid().ToString()}+user:{Username}"; //Saves cookie, Username Remember me option to the local storage (Settings.settings) Settings.Default.Cookies = cookie; Settings.Default.Username = Username; diff --git a/Server Dashboard/Views/DashboardWindow.xaml b/Server Dashboard/Views/DashboardWindow.xaml index 717c80c..4d22f1b 100644 --- a/Server Dashboard/Views/DashboardWindow.xaml +++ b/Server Dashboard/Views/DashboardWindow.xaml @@ -67,7 +67,7 @@ -