/// <summary> /// Inserts a data of the CSV file into the table of the database /// </summary> /// <param name="analyzerSettings">Settings of the analyzer</param> /// <param name="tableName">Table name of the database</param> /// <param name="filePath">Path to the "*.xel" files</param> /// <returns></returns> public static async Task InsertFileIntoTable(ISqlAnalyzerSettings analyzerSettings, string tableName, string filePath) { using (var connection = await GetSqlConnection(analyzerSettings)) { await InsertFileIntoTable(connection, tableName, filePath); } }
/// <summary> /// Creates, opens and returns the sql connection /// To use with the "using" operator /// </summary> public static async Task <SqlConnection> GetSqlConnection(ISqlAnalyzerSettings analyzerSettings) { var str = GetSqlConnectionStringBuilder(analyzerSettings); var connection = new SqlConnection(str.ToString()); await connection.OpenAsync(); return(connection); }
/// <summary> /// Returnes the SqlConnectionSqlBuilder by analyzerSettings /// </summary> /// <param name="analyzerSettings">Settings of the analyzer</param> /// <returns></returns> public static SqlConnectionStringBuilder GetSqlConnectionStringBuilder(ISqlAnalyzerSettings analyzerSettings) { SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder() { DataSource = analyzerSettings.SqlServer, IntegratedSecurity = analyzerSettings.IntegratedSecurity, UserID = analyzerSettings.SqlUser, Password = analyzerSettings.SqlUserPassword }; return(builder); }
/// <summary> /// Creates the application database /// </summary> /// <param name="analyzerSettings">Settings of the analyzer</param> /// <returns></returns> public static async Task CreateDatabase(ISqlAnalyzerSettings analyzerSettings) { using (var connection = await GetSqlConnection(analyzerSettings)) { var crCmd = connection.CreateCommand(); crCmd.CommandText = "CREATE DATABASE ExpertTools"; await crCmd.ExecuteNonQueryAsync(); var crsCmd = connection.CreateCommand(); crsCmd.CommandText = Properties.Resources.CreateDatabase; await crsCmd.ExecuteNonQueryAsync(); } }
/// <summary> /// Check the database existence /// </summary> /// <param name="analyzerSettings">Settings of the analyzer</param> /// <returns></returns> public static async Task CheckDatabase(ISqlAnalyzerSettings analyzerSettings) { using (var connection = await GetSqlConnection(analyzerSettings)) { var crCmd = connection.CreateCommand(); crCmd.CommandText = "SELECT * FROM sys.databases WHERE name = 'ExpertTools'"; if (await crCmd.ExecuteScalarAsync() != null) { throw new Exception("Database already exists! Please, delete the application database before running this script!"); } } }
/// <summary> /// Checks connection with the sql server instance /// </summary> /// <param name="analyzerSettings">Settings of the analyzer</param> /// <returns></returns> public static async Task CheckConnection(ISqlAnalyzerSettings analyzerSettings) { using (var connection = await GetSqlConnection(analyzerSettings)) { } }
/// <summary> /// Initialize a new instance of the XESession class /// </summary> /// <param name="analyzerSettings">analyzer settings</param> public XESession(ISqlAnalyzerSettings analyzerSettings) { _settings = analyzerSettings; }