add resharper and hover effect for modules; change navigation bar
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
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 {
|
||||
|
||||
@@ -39,17 +34,11 @@ namespace Server_Dashboard {
|
||||
com.Parameters.Add("@valid", SqlDbType.NVarChar, 250);
|
||||
com.Parameters["@valid"].Direction = ParameterDirection.Output;
|
||||
//Execute query and return number of rows affected
|
||||
int sqlResponse = com.ExecuteNonQuery();
|
||||
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 (Convert.ToInt32(com.Parameters["@Valid"].Value) == 0) {
|
||||
//Error, not successful
|
||||
return 1;
|
||||
} else {
|
||||
//Successful
|
||||
return 0;
|
||||
}
|
||||
//if its any number above 0 it was successful
|
||||
return Convert.ToInt32(com.Parameters["@Valid"].Value) == 0 ? 1 : 0;
|
||||
//Catch any error
|
||||
} catch (SqlException ex) {
|
||||
return ex.Number;
|
||||
@@ -66,7 +55,7 @@ namespace Server_Dashboard {
|
||||
//Open the connection
|
||||
con.Open();
|
||||
//SQL Query
|
||||
string query = "SELECT ID, Username, Email, RegistrationDate FROM UserData WHERE Username = @username";
|
||||
const 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
|
||||
@@ -78,9 +67,9 @@ namespace Server_Dashboard {
|
||||
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
|
||||
//if its any number above 0 it was successful
|
||||
//Catch any error
|
||||
} catch (SqlException ex) {
|
||||
} catch (SqlException) {
|
||||
return null;
|
||||
} finally {
|
||||
//Always close the connection
|
||||
@@ -95,7 +84,7 @@ namespace Server_Dashboard {
|
||||
//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";
|
||||
const string query = "SELECT Creator, CreationTime, ModuleName, MI.Image, ModuleData.ID 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
|
||||
@@ -107,9 +96,9 @@ namespace Server_Dashboard {
|
||||
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
|
||||
//if its any number above 0 it was successful
|
||||
//Catch any error
|
||||
} catch (SqlException ex) {
|
||||
} catch (SqlException) {
|
||||
return null;
|
||||
} finally {
|
||||
//Always close the connection
|
||||
@@ -118,20 +107,20 @@ namespace Server_Dashboard {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function will fetch every Serverdata for each module
|
||||
/// This function will fetch every server data for each module
|
||||
/// This will need some optimization, for now we just asynchronously
|
||||
/// fetch the serverdata for each module
|
||||
/// fetch the server data for each module
|
||||
/// </summary>
|
||||
/// <param name="mid">ModuleID to fetch the data from</param>
|
||||
/// <returns></returns>
|
||||
public static DataTable GetServerData(string mid) {
|
||||
public static DataTable GetServerData(int 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";
|
||||
const 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
|
||||
@@ -143,9 +132,9 @@ namespace Server_Dashboard {
|
||||
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
|
||||
//if its any number above 0 it was successful
|
||||
//Catch any error
|
||||
} catch (SqlException ex) {
|
||||
} catch (SqlException) {
|
||||
return null;
|
||||
} finally {
|
||||
//Always close the connection
|
||||
@@ -156,21 +145,21 @@ namespace Server_Dashboard {
|
||||
/// <summary>
|
||||
/// Creates a new Module for the current user
|
||||
/// </summary>
|
||||
/// <param name="ipAdress">Server IP Address</param>
|
||||
/// <param name="ipAddress">Server IP Address</param>
|
||||
/// <param name="moduleName">Module name, default is Module</param>
|
||||
/// <param name="serverName">Server name, default is Server</param>
|
||||
/// <param name="username">Username of the current user</param>
|
||||
/// <param name="moduleIcon">module icon as byte[]</param>
|
||||
/// <param name="port">port, defalt ist 22</param>
|
||||
/// <param name="port">port, default ist 22</param>
|
||||
/// <returns></returns>
|
||||
public static int CreateNewModule(string ipAdress, string moduleName, string serverName, string username, byte[] moduleIcon, string port = "22") {
|
||||
public static int CreateNewModule(string ipAddress, string moduleName, string serverName, string username, byte[] moduleIcon, string port = "22") {
|
||||
//Creates the database connection
|
||||
using SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString);
|
||||
try {
|
||||
//Open the connection
|
||||
con.Open();
|
||||
//SQL Query
|
||||
string query = "EXEC AddNewModuleToUser @UserName = @username, @DateTime = @time, @ModuleName = @moduleName, @ServerName = @serverName, @ModuleIcon = @moduleIcon, @IPAddress = @ipAdress, @Port = @port";
|
||||
const string query = "EXEC AddNewModuleToUser @UserName = @username, @DateTime = @time, @ModuleName = @moduleName, @ServerName = @serverName, @ModuleIcon = @moduleIcon, @IPAddress = @ipAddress, @Port = @port";
|
||||
//Creates a new command
|
||||
using SqlCommand com = new SqlCommand(query, con);
|
||||
//For security reasons the values are added with this function
|
||||
@@ -183,20 +172,14 @@ namespace Server_Dashboard {
|
||||
if (moduleIcon == null)
|
||||
com.Parameters["@moduleIcon"].Value = DBNull.Value;
|
||||
//com.Parameters.AddWithValue("@moduleIcon", moduleIcon);
|
||||
com.Parameters.AddWithValue("@ipAdress", ipAdress);
|
||||
com.Parameters.AddWithValue("@ipAddress", ipAddress);
|
||||
com.Parameters.AddWithValue("@port", port);
|
||||
//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 (sqlResponse == 0) {
|
||||
//Error, not successful
|
||||
return 1;
|
||||
} else {
|
||||
//Successful
|
||||
return 0;
|
||||
}
|
||||
//if its any number above 0 it was successful
|
||||
return sqlResponse == 0 ? 1 : 0;
|
||||
//Catch any error
|
||||
} catch (SqlException ex) {
|
||||
return ex.Number;
|
||||
@@ -207,7 +190,7 @@ namespace Server_Dashboard {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Currently obscolete, would check the Username and Cookie
|
||||
/// Currently obsolete, would check the Username and Cookie
|
||||
/// </summary>
|
||||
/// <param name="cookie">Locally stored user cookie</param>
|
||||
/// <param name="username">Locally stored username</param>
|
||||
@@ -219,7 +202,7 @@ namespace Server_Dashboard {
|
||||
//Open the connection
|
||||
con.Open();
|
||||
//SQL Query
|
||||
string query = "((SELECT Cookie FROM UserData WHERE Username = @username) = @cookie)";
|
||||
const 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
|
||||
@@ -231,13 +214,7 @@ namespace Server_Dashboard {
|
||||
//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 (sqlResponse == 0) {
|
||||
//Error, not successful
|
||||
return 1;
|
||||
} else {
|
||||
//Successful
|
||||
return 0;
|
||||
}
|
||||
return sqlResponse == 0 ? 1 : 0;
|
||||
//Catch any error
|
||||
} catch (SqlException ex) {
|
||||
return ex.Number;
|
||||
@@ -258,7 +235,7 @@ namespace Server_Dashboard {
|
||||
//Open the connection
|
||||
con.Open();
|
||||
//SQL Query
|
||||
string query = "UPDATE UserData SET Cookie = null WHERE Username = @username";
|
||||
const 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
|
||||
@@ -268,14 +245,8 @@ namespace Server_Dashboard {
|
||||
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 (sqlResponse == 0) {
|
||||
//Error, not successful
|
||||
return 1;
|
||||
} else {
|
||||
//Successful
|
||||
return 0;
|
||||
}
|
||||
//if its any number above 0 it was successful
|
||||
return sqlResponse == 0 ? 1 : 0;
|
||||
//Catch any error
|
||||
} catch (SqlException ex) {
|
||||
return ex.Number;
|
||||
@@ -293,30 +264,31 @@ namespace Server_Dashboard {
|
||||
/// <returns>[0] is false, [1] is true, [2] connection error</returns>
|
||||
public static int AddCookie(string username, string cookie) {
|
||||
//Creates the database connection
|
||||
using SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString);
|
||||
using SqlConnection con =
|
||||
new SqlConnection(ConfigurationManager.ConnectionStrings["ServerDashboardDB"].ConnectionString);
|
||||
try {
|
||||
//Open the connection
|
||||
con.Open();
|
||||
|
||||
//SQL Query
|
||||
string query = "UPDATE UserData SET Cookie = @cookie WHERE Username = @username";
|
||||
const 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.Add("@cookie", SqlDbType.NVarChar, -1).Value = cookie;
|
||||
com.Parameters.AddWithValue("@username", username);
|
||||
|
||||
//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 (sqlResponse == 0) {
|
||||
//Error, not successful
|
||||
return 1;
|
||||
} else {
|
||||
//Successful
|
||||
return 0;
|
||||
}
|
||||
//if its any number above 0 it was successful
|
||||
return sqlResponse == 0 ? 1 : 0;
|
||||
|
||||
//Catch any error
|
||||
} catch (SqlException ex) {
|
||||
return ex.Number;
|
||||
@@ -324,8 +296,8 @@ namespace Server_Dashboard {
|
||||
//Always close the connection
|
||||
con.Close();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user