diff --git a/src/Plugins/BotSharp.Plugin.ExcelHandler/BotSharp.Plugin.ExcelHandler.csproj b/src/Plugins/BotSharp.Plugin.ExcelHandler/BotSharp.Plugin.ExcelHandler.csproj
index d637ebc7..a57e28b0 100644
--- a/src/Plugins/BotSharp.Plugin.ExcelHandler/BotSharp.Plugin.ExcelHandler.csproj
+++ b/src/Plugins/BotSharp.Plugin.ExcelHandler/BotSharp.Plugin.ExcelHandler.csproj
@@ -12,6 +12,20 @@
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
@@ -19,11 +33,6 @@
-
-
-
-
-
diff --git a/src/Plugins/BotSharp.Plugin.ExcelHandler/Enums/UtilityName.cs b/src/Plugins/BotSharp.Plugin.ExcelHandler/Enums/UtilityName.cs
index 1b0db1a4..66ef3f36 100644
--- a/src/Plugins/BotSharp.Plugin.ExcelHandler/Enums/UtilityName.cs
+++ b/src/Plugins/BotSharp.Plugin.ExcelHandler/Enums/UtilityName.cs
@@ -1,9 +1,3 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
namespace BotSharp.Plugin.ExcelHandler.Enums;
public class UtilityName
diff --git a/src/Plugins/BotSharp.Plugin.ExcelHandler/ExcelHandlerPlugin.cs b/src/Plugins/BotSharp.Plugin.ExcelHandler/ExcelHandlerPlugin.cs
index 6b727f96..0111ea99 100644
--- a/src/Plugins/BotSharp.Plugin.ExcelHandler/ExcelHandlerPlugin.cs
+++ b/src/Plugins/BotSharp.Plugin.ExcelHandler/ExcelHandlerPlugin.cs
@@ -19,6 +19,7 @@ public class ExcelHandlerPlugin : IBotSharpPlugin
public string Id => "c56a8e29-b16f-4d75-8766-8309342130cb";
public string Name => "Excel Handler";
public string Description => "Load data from excel file and transform it into a list of JSON format.";
+ public string IconUrl => "https://w7.pngwing.com/pngs/162/301/png-transparent-microsoft-excel-logo-thumbnail.png";
public void RegisterDI(IServiceCollection services, IConfiguration config)
{
diff --git a/src/Plugins/BotSharp.Plugin.ExcelHandler/Functions/HandleExcelRequestFn.cs b/src/Plugins/BotSharp.Plugin.ExcelHandler/Functions/HandleExcelRequestFn.cs
index 53b39670..7538919f 100644
--- a/src/Plugins/BotSharp.Plugin.ExcelHandler/Functions/HandleExcelRequestFn.cs
+++ b/src/Plugins/BotSharp.Plugin.ExcelHandler/Functions/HandleExcelRequestFn.cs
@@ -72,7 +72,6 @@ public class HandleExcelRequestFn : IFunctionCallback
var resultList = GetResponeFromDialogs(dialogs);
message.Content = GenerateSqlExecutionSummary(resultList);
}
- message.StopCompletion = true;
return true;
}
@@ -131,7 +130,7 @@ public class HandleExcelRequestFn : IFunctionCallback
{
try
{
- _mySqlService.DeleteTableSqlQuery();
+ //_mySqlService.DeleteTableSqlQuery();
return true;
}
catch (Exception ex)
@@ -151,8 +150,6 @@ public class HandleExcelRequestFn : IFunctionCallback
foreach (var message in messageList.Where(x => x.isSuccessful))
{
stringBuilder.Append(message.Message);
- string tableSchemaInfo = _mySqlService.GenerateTableSchema();
- stringBuilder.Append(tableSchemaInfo);
stringBuilder.Append("\r\n\r\n");
}
}
diff --git a/src/Plugins/BotSharp.Plugin.ExcelHandler/Helpers/MySql/MySqlDbHelpers.cs b/src/Plugins/BotSharp.Plugin.ExcelHandler/Helpers/MySql/MySqlDbHelpers.cs
index 71843c9f..4b86f89f 100644
--- a/src/Plugins/BotSharp.Plugin.ExcelHandler/Helpers/MySql/MySqlDbHelpers.cs
+++ b/src/Plugins/BotSharp.Plugin.ExcelHandler/Helpers/MySql/MySqlDbHelpers.cs
@@ -36,8 +36,8 @@ namespace BotSharp.Plugin.ExcelHandler.Helpers.MySql
private void InitializeDatabase()
{
var settingService = _services.GetRequiredService();
- _mySqlDriverConnection = settingService.MySqlConnectionString;
- _databaseName = GetDatabaseName(settingService.MySqlConnectionString);
+ _mySqlDriverConnection = settingService.MySqlTempConnectionString;
+ _databaseName = GetDatabaseName(settingService.MySqlTempConnectionString);
}
private string GetDatabaseName(string connectionString)
diff --git a/src/Plugins/BotSharp.Plugin.ExcelHandler/Services/IMySqlService.cs b/src/Plugins/BotSharp.Plugin.ExcelHandler/Services/IMySqlService.cs
index 64d9c871..827a5112 100644
--- a/src/Plugins/BotSharp.Plugin.ExcelHandler/Services/IMySqlService.cs
+++ b/src/Plugins/BotSharp.Plugin.ExcelHandler/Services/IMySqlService.cs
@@ -1,16 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using BotSharp.Plugin.ExcelHandler.Models;
-using NPOI.SS.UserModel;
+namespace BotSharp.Plugin.ExcelHandler.Services;
-namespace BotSharp.Plugin.ExcelHandler.Services
+public interface IMySqlService : IDbService
{
- public interface IMySqlService : IDbService
- {
- public bool DeleteTableSqlQuery();
- public string GenerateTableSchema();
- }
+ public bool DeleteTableSqlQuery();
}
diff --git a/src/Plugins/BotSharp.Plugin.ExcelHandler/Services/MySqlService.cs b/src/Plugins/BotSharp.Plugin.ExcelHandler/Services/MySqlService.cs
index 64abbbd1..7ad1ba78 100644
--- a/src/Plugins/BotSharp.Plugin.ExcelHandler/Services/MySqlService.cs
+++ b/src/Plugins/BotSharp.Plugin.ExcelHandler/Services/MySqlService.cs
@@ -1,17 +1,8 @@
-using System;
-using System.Collections.Generic;
using System.Data;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using BotSharp.Plugin.ExcelHandler.Helpers.MySql;
using BotSharp.Plugin.ExcelHandler.Models;
-using Microsoft.Data.Sqlite;
-using Microsoft.EntityFrameworkCore.Metadata.Internal;
using MySql.Data.MySqlClient;
-//using MySqlConnector;
using NPOI.SS.UserModel;
-using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
namespace BotSharp.Plugin.ExcelHandler.Services
{
@@ -35,13 +26,13 @@ namespace BotSharp.Plugin.ExcelHandler.Services
{
try
{
- using var mySqlDbConnection = _mySqlDbHelpers.GetDbConnection();
+ /*using var mySqlDbConnection = _mySqlDbHelpers.GetDbConnection();
var tableNames = GetAllTableSchema(mySqlDbConnection);
if (tableNames.IsNullOrEmpty())
{
return true;
- }
- ExecuteDropTableQuery(tableNames, mySqlDbConnection);
+ }*/
+
return true;
}
catch (Exception ex)
@@ -49,7 +40,8 @@ namespace BotSharp.Plugin.ExcelHandler.Services
return false;
}
}
- private void ExecuteDropTableQuery(List dropTableNames, MySqlConnection connection)
+
+ /*private void ExecuteDropTableQuery(List dropTableNames, MySqlConnection connection)
{
dropTableNames.ForEach(x =>
{
@@ -58,7 +50,7 @@ namespace BotSharp.Plugin.ExcelHandler.Services
using var selectCmd = new MySqlCommand(dropTableQuery, connection);
selectCmd.ExecuteNonQuery();
});
- }
+ }*/
public List GetAllTableSchema(MySqlConnection mySqlDbConnection)
{
@@ -89,23 +81,6 @@ namespace BotSharp.Plugin.ExcelHandler.Services
}
}
- public string GenerateTableSchema()
- {
-
- var sb = new StringBuilder();
- sb.Append($"\nTable Schema for `{_tableName}`:");
- sb.Append("\n");
- sb.Append($"cid | name | type ");
- sb.Append("\n");
- //sb.Append("----|------------|------------");
- for (int i = 0; i < _excelColumnSize; i++)
- {
- sb.Append($"{i,-4} | {_headerColumns[i],-10} | {_columnTypes[i],-10}");
- sb.Append("\n");
- }
- return sb.ToString();
- }
-
public IEnumerable WriteExcelDataToDB(IWorkbook workbook)
{
var numTables = workbook.NumberOfSheets;
@@ -133,7 +108,7 @@ namespace BotSharp.Plugin.ExcelHandler.Services
commandResult = new SqlContextOut
{
isSuccessful = isInsertSuccess,
- Message = insertMessage,
+ Message = $"{insertMessage}\r\n{message}",
FileName = _currentFileName
};
commandList.Add(commandResult);
@@ -155,7 +130,7 @@ namespace BotSharp.Plugin.ExcelHandler.Services
string insertDataSql = ProcessInsertSqlQuery(dataSql);
ExecuteSqlQueryForInsertion(insertDataSql);
- return (true, $"{_currentFileName}: \r\n `**{_excelRowSize}**` data have been successfully stored into `{_tableName}` table");
+ return (true, $"{_currentFileName}: \r\n {_excelRowSize} records have been successfully inserted into `{_tableName}` table");
}
catch (Exception ex)
{
@@ -210,11 +185,11 @@ namespace BotSharp.Plugin.ExcelHandler.Services
{
try
{
- _tableName = sheet.SheetName;
+ _tableName = $"excel_{sheet.SheetName}";
_headerColumns = ParseSheetColumn(sheet);
string createTableSql = CreateDBTableSqlString(_tableName, _headerColumns, null ,true);
ExecuteSqlQueryForInsertion(createTableSql);
- return (true, $"{_tableName} has been successfully created.");
+ return (true, createTableSql);
}
catch (Exception ex)
{
diff --git a/src/Plugins/BotSharp.Plugin.ExcelHandler/Services/SqliteService.cs b/src/Plugins/BotSharp.Plugin.ExcelHandler/Services/SqliteService.cs
index 846883f7..35ee0ab4 100644
--- a/src/Plugins/BotSharp.Plugin.ExcelHandler/Services/SqliteService.cs
+++ b/src/Plugins/BotSharp.Plugin.ExcelHandler/Services/SqliteService.cs
@@ -118,7 +118,7 @@ namespace BotSharp.Plugin.ExcelHandler.Services
string insertDataSql = ProcessInsertSqlQuery(dataSql);
ExecuteSqlQueryForInsertion(insertDataSql);
- return (true, $"{_currentFileName}: \r\n `**{_excelRowSize}**` data have been successfully stored into `{_tableName}` table");
+ return (true, $"{_currentFileName}: \r\n {_excelRowSize} records have been successfully inserted into `{_tableName}` table");
}
catch (Exception ex)
{
diff --git a/src/Plugins/BotSharp.Plugin.SqlDriver/Settings/SqlDriverSetting.cs b/src/Plugins/BotSharp.Plugin.SqlDriver/Settings/SqlDriverSetting.cs
index b594e776..5815151c 100644
--- a/src/Plugins/BotSharp.Plugin.SqlDriver/Settings/SqlDriverSetting.cs
+++ b/src/Plugins/BotSharp.Plugin.SqlDriver/Settings/SqlDriverSetting.cs
@@ -5,6 +5,7 @@ public class SqlDriverSetting
public string DatabaseType { get; set; } = "MySql";
public string MySqlConnectionString { get; set; } = null!;
public string MySqlExecutionConnectionString { get; set; } = null!;
+ public string MySqlTempConnectionString { get; set; } = null!;
public string SqlServerConnectionString { get; set; } = null!;
public string SqlServerExecutionConnectionString { get; set; } = null!;
public string SqlLiteConnectionString { get; set; } = null!;