Добавьте файлы проекта.
This commit is contained in:
12
SQLVision.Core/Enums/ChartType.cs
Normal file
12
SQLVision.Core/Enums/ChartType.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace SQLVision.Core.Enums;
|
||||
|
||||
public enum ChartType
|
||||
{
|
||||
Line,
|
||||
Bar,
|
||||
Pie,
|
||||
Area,
|
||||
Scatter,
|
||||
Heatmap,
|
||||
Candlestick
|
||||
}
|
||||
10
SQLVision.Core/Enums/DatabaseProvider.cs
Normal file
10
SQLVision.Core/Enums/DatabaseProvider.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace SQLVision.Core.Enums;
|
||||
|
||||
public enum DatabaseProvider
|
||||
{
|
||||
SqlServer, // Только MSSQL для начала
|
||||
// PostgreSQL,
|
||||
// MySQL,
|
||||
// SQLite,
|
||||
// Oracle
|
||||
}
|
||||
9
SQLVision.Core/Enums/NotificationType.cs
Normal file
9
SQLVision.Core/Enums/NotificationType.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace SQLVision.Core.Enums;
|
||||
|
||||
public enum NotificationType
|
||||
{
|
||||
Information,
|
||||
Success,
|
||||
Warning,
|
||||
Error
|
||||
}
|
||||
11
SQLVision.Core/Enums/OutputType.cs
Normal file
11
SQLVision.Core/Enums/OutputType.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace SQLVision.Core.Enums;
|
||||
|
||||
public enum OutputType
|
||||
{
|
||||
Table,
|
||||
Chart,
|
||||
Text,
|
||||
Grid,
|
||||
Map,
|
||||
Custom
|
||||
}
|
||||
15
SQLVision.Core/Enums/ParameterType.cs
Normal file
15
SQLVision.Core/Enums/ParameterType.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace SQLVision.Core.Enums;
|
||||
|
||||
public enum ParameterType
|
||||
{
|
||||
String,
|
||||
Integer,
|
||||
Decimal,
|
||||
DateTime,
|
||||
Boolean,
|
||||
Table, // Для ComboBox с данными из БД
|
||||
MultiSelect, // ListBox с множественным выбором
|
||||
Color,
|
||||
File,
|
||||
Json
|
||||
}
|
||||
9
SQLVision.Core/Enums/ScriptChangeType.cs
Normal file
9
SQLVision.Core/Enums/ScriptChangeType.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace SQLVision.Core.Enums;
|
||||
|
||||
public enum ScriptChangeType
|
||||
{
|
||||
Created,
|
||||
Updated,
|
||||
Deleted,
|
||||
Renamed
|
||||
}
|
||||
11
SQLVision.Core/Interfaces/IExportHandler.cs
Normal file
11
SQLVision.Core/Interfaces/IExportHandler.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using SQLVision.Core.Models;
|
||||
using System.Data;
|
||||
|
||||
namespace SQLVision.Services.Exporters;
|
||||
|
||||
public interface IExportHandler
|
||||
{
|
||||
string FormatName { get; }
|
||||
Task ExportAsync(DataTable data, string filePath, ExportOptions options);
|
||||
Task<byte[]> ExportToMemoryAsync(DataTable data, ExportOptions options);
|
||||
}
|
||||
11
SQLVision.Core/Interfaces/IExportService.cs
Normal file
11
SQLVision.Core/Interfaces/IExportService.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using SQLVision.Core.Models;
|
||||
using System.Data;
|
||||
|
||||
namespace SQLVision.Core.Interfaces;
|
||||
|
||||
public interface IExportService
|
||||
{
|
||||
Task ExportAsync(DataTable data, string filePath, ExportOptions options);
|
||||
Task ExportAsync(DataSet dataSet, string filePath, ExportOptions options);
|
||||
Task<byte[]> ExportToMemoryAsync(DataTable data, ExportOptions options);
|
||||
}
|
||||
10
SQLVision.Core/Interfaces/IMemoryExportHandler.cs
Normal file
10
SQLVision.Core/Interfaces/IMemoryExportHandler.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using SQLVision.Core.Models;
|
||||
using System.Data;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SQLVision.Core.Interfaces;
|
||||
|
||||
public interface IMemoryExportHandler
|
||||
{
|
||||
Task<byte[]> ExportToMemoryAsync(DataTable data, ExportOptions options);
|
||||
}
|
||||
13
SQLVision.Core/Interfaces/IPluginContext.cs
Normal file
13
SQLVision.Core/Interfaces/IPluginContext.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SQLVision.Core.Enums;
|
||||
|
||||
namespace SQLVision.Core.Interfaces;
|
||||
|
||||
public interface IPluginContext
|
||||
{
|
||||
IServiceProvider ServiceProvider { get; }
|
||||
IConfiguration Configuration { get; }
|
||||
ILogger Logger { get; }
|
||||
Task ShowNotificationAsync(string message, NotificationType type);
|
||||
}
|
||||
13
SQLVision.Core/Interfaces/IPluginManager.cs
Normal file
13
SQLVision.Core/Interfaces/IPluginManager.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using SQLVision.Core.Models;
|
||||
|
||||
namespace SQLVision.Core.Interfaces;
|
||||
|
||||
public interface IPluginManager
|
||||
{
|
||||
void LoadPlugins(string pluginsDirectory);
|
||||
IEnumerable<ISqlVisionPlugin> GetPlugins();
|
||||
T? GetPlugin<T>() where T : ISqlVisionPlugin;
|
||||
|
||||
Task BeforeExecutionAsync(ScriptMetadata script, Dictionary<string, object> parameters);
|
||||
Task AfterExecutionAsync(ScriptMetadata script, ExecutionResult result);
|
||||
}
|
||||
38
SQLVision.Core/Interfaces/IScriptManager.cs
Normal file
38
SQLVision.Core/Interfaces/IScriptManager.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using SQLVision.Core.Enums;
|
||||
using SQLVision.Core.Models;
|
||||
|
||||
namespace SQLVision.Core.Interfaces;
|
||||
|
||||
public interface IScriptManager
|
||||
{
|
||||
Task<IEnumerable<ScriptMetadata>> LoadScriptsAsync(string? directory = null);
|
||||
Task<ScriptMetadata> ReloadScriptAsync(string filePath);
|
||||
void WatchDirectory(string directory, Action<string> onScriptChanged);
|
||||
|
||||
event EventHandler<ScriptChangedEventArgs> ScriptChanged;
|
||||
event EventHandler<ScriptsReloadedEventArgs> ScriptsReloaded;
|
||||
}
|
||||
|
||||
public class ScriptChangedEventArgs : EventArgs
|
||||
{
|
||||
public string FilePath { get; }
|
||||
public ScriptChangeType ChangeType { get; }
|
||||
public ScriptMetadata? Script { get; }
|
||||
|
||||
public ScriptChangedEventArgs(string filePath, ScriptChangeType changeType, ScriptMetadata? script = null)
|
||||
{
|
||||
FilePath = filePath;
|
||||
ChangeType = changeType;
|
||||
Script = script;
|
||||
}
|
||||
}
|
||||
|
||||
public class ScriptsReloadedEventArgs : EventArgs
|
||||
{
|
||||
public IEnumerable<ScriptMetadata> Scripts { get; }
|
||||
|
||||
public ScriptsReloadedEventArgs(IEnumerable<ScriptMetadata> scripts)
|
||||
{
|
||||
Scripts = scripts;
|
||||
}
|
||||
}
|
||||
30
SQLVision.Core/Interfaces/ISqlExecutionService.cs
Normal file
30
SQLVision.Core/Interfaces/ISqlExecutionService.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using SQLVision.Core.Enums;
|
||||
using SQLVision.Core.Models;
|
||||
using System.Data;
|
||||
|
||||
namespace SQLVision.Core.Interfaces;
|
||||
|
||||
public interface ISqlExecutionService
|
||||
{
|
||||
Task<ExecutionResult> ExecuteAsync(
|
||||
ScriptMetadata script,
|
||||
Dictionary<string, object> parameters,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<ExecutionResult> ExecuteAsync(
|
||||
string sql,
|
||||
Dictionary<string, object> parameters,
|
||||
string connectionString,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<bool> TestConnectionAsync(
|
||||
string connectionString,
|
||||
DatabaseProvider provider,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<DataTable> LoadComboBoxDataAsync(
|
||||
string query,
|
||||
string connectionString,
|
||||
DatabaseProvider provider,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
9
SQLVision.Core/Interfaces/ISqlScriptParser.cs
Normal file
9
SQLVision.Core/Interfaces/ISqlScriptParser.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using SQLVision.Core.Models;
|
||||
|
||||
namespace SQLVision.Core.Interfaces;
|
||||
|
||||
public interface ISqlScriptParser
|
||||
{
|
||||
ScriptMetadata Parse(string filePath, string sqlContent);
|
||||
Task<ScriptMetadata> ParseAsync(string filePath, CancellationToken cancellationToken = default);
|
||||
}
|
||||
11
SQLVision.Core/Interfaces/ISqlVisionPlugin.cs
Normal file
11
SQLVision.Core/Interfaces/ISqlVisionPlugin.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace SQLVision.Core.Interfaces;
|
||||
|
||||
public interface ISqlVisionPlugin
|
||||
{
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
Version Version { get; }
|
||||
|
||||
Task InitializeAsync(IPluginContext context);
|
||||
Task ShutdownAsync();
|
||||
}
|
||||
12
SQLVision.Core/Models/ChartSeries.cs
Normal file
12
SQLVision.Core/Models/ChartSeries.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SQLVision.Core.Models;
|
||||
|
||||
public class ChartSeries
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public List<object> Values { get; set; } = new();
|
||||
public string Color { get; set; }
|
||||
public double LineSmoothness { get; set; } = 0;
|
||||
public bool ShowPoints { get; set; } = true;
|
||||
}
|
||||
36
SQLVision.Core/Models/ExecutionHistoryItem.cs
Normal file
36
SQLVision.Core/Models/ExecutionHistoryItem.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SQLVision.Core.Models;
|
||||
|
||||
public class ExecutionHistoryItem
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public string Id { get; set; } = Guid.NewGuid().ToString();
|
||||
|
||||
[JsonPropertyName("scriptId")]
|
||||
public string ScriptId { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("scriptName")]
|
||||
public string ScriptName { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("executionTime")]
|
||||
public DateTime ExecutionTime { get; set; }
|
||||
|
||||
[JsonPropertyName("duration")]
|
||||
public TimeSpan Duration { get; set; }
|
||||
|
||||
[JsonPropertyName("success")]
|
||||
public bool Success { get; set; }
|
||||
|
||||
[JsonPropertyName("parameters")]
|
||||
public Dictionary<string, object> Parameters { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("rowCount")]
|
||||
public int RowCount { get; set; }
|
||||
|
||||
[JsonPropertyName("errorMessage")]
|
||||
public string? ErrorMessage { get; set; }
|
||||
|
||||
[JsonPropertyName("executedSql")]
|
||||
public string? ExecutedSql { get; set; }
|
||||
}
|
||||
41
SQLVision.Core/Models/ExecutionResult.cs
Normal file
41
SQLVision.Core/Models/ExecutionResult.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Data;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SQLVision.Core.Models;
|
||||
|
||||
public class ExecutionResult
|
||||
{
|
||||
[JsonPropertyName("data")]
|
||||
public DataSet? Data { get; set; }
|
||||
|
||||
[JsonPropertyName("isSuccess")]
|
||||
public bool IsSuccess { get; set; }
|
||||
|
||||
[JsonPropertyName("errorMessage")]
|
||||
public string? ErrorMessage { get; set; }
|
||||
|
||||
[JsonPropertyName("executionTime")]
|
||||
public TimeSpan ExecutionTime { get; set; }
|
||||
|
||||
[JsonPropertyName("isFromCache")]
|
||||
public bool IsFromCache { get; set; }
|
||||
|
||||
[JsonPropertyName("executionDate")]
|
||||
public DateTime ExecutionDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[JsonPropertyName("parameters")]
|
||||
public Dictionary<string, object> Parameters { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("executedSql")]
|
||||
public string ExecutedSql { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("rowCount")]
|
||||
public int RowCount { get; set; }
|
||||
|
||||
[JsonPropertyName("metrics")]
|
||||
public Dictionary<string, object> Metrics { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("connectionName")]
|
||||
public string? ConnectionName { get; set; }
|
||||
}
|
||||
|
||||
12
SQLVision.Core/Models/ExportOptions.cs
Normal file
12
SQLVision.Core/Models/ExportOptions.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace SQLVision.Core.Models;
|
||||
|
||||
public class ExportOptions
|
||||
{
|
||||
public string Format { get; set; } = "Excel";
|
||||
public bool IncludeHeaders { get; set; } = true;
|
||||
public bool AutoFilter { get; set; } = true;
|
||||
public bool IncludeCharts { get; set; } = false;
|
||||
public string? ChartType { get; set; }
|
||||
public bool OpenAfterExport { get; set; } = false;
|
||||
public Dictionary<string, object> CustomOptions { get; set; } = new();
|
||||
}
|
||||
38
SQLVision.Core/Models/OutputDefinition.cs
Normal file
38
SQLVision.Core/Models/OutputDefinition.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using SQLVision.Core.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SQLVision.Core.Models;
|
||||
|
||||
public class OutputDefinition
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public OutputType Type { get; set; } = OutputType.Table;
|
||||
|
||||
[JsonPropertyName("subType")]
|
||||
public string? SubType { get; set; }
|
||||
|
||||
[JsonPropertyName("description")]
|
||||
public string Description { get; set; } = "Result";
|
||||
|
||||
[JsonPropertyName("isPrimary")]
|
||||
public bool IsPrimary { get; set; } = false;
|
||||
|
||||
[JsonPropertyName("options")]
|
||||
public Dictionary<string, string> Options { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("dataTableName")]
|
||||
public string? DataTableName { get; set; }
|
||||
|
||||
// Для графиков
|
||||
[JsonPropertyName("xAxisColumn")]
|
||||
public string? XAxisColumn { get; set; }
|
||||
|
||||
[JsonPropertyName("yAxisColumn")]
|
||||
public string? YAxisColumn { get; set; }
|
||||
|
||||
[JsonPropertyName("seriesColumn")]
|
||||
public string? SeriesColumn { get; set; }
|
||||
|
||||
[JsonPropertyName("chartType")]
|
||||
public ChartType ChartType { get; set; } = ChartType.Line;
|
||||
}
|
||||
8
SQLVision.Core/Models/ScriptCategory.cs
Normal file
8
SQLVision.Core/Models/ScriptCategory.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace SQLVision.Core.Models;
|
||||
|
||||
public class ScriptCategory
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public List<ScriptMetadata> Scripts { get; set; } = new();
|
||||
public bool IsExpanded { get; set; } = true;
|
||||
}
|
||||
63
SQLVision.Core/Models/ScriptMetadata.cs
Normal file
63
SQLVision.Core/Models/ScriptMetadata.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using SQLVision.Core.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SQLVision.Core.Models;
|
||||
|
||||
public class ScriptMetadata
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public string Id { get; set; } = Guid.NewGuid().ToString();
|
||||
|
||||
[JsonPropertyName("fileName")]
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("fullPath")]
|
||||
public string FullPath { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("description")]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[JsonPropertyName("rawSql")]
|
||||
public string RawSql { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("processedSql")]
|
||||
public string ProcessedSql { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("connectionString")]
|
||||
public string? ConnectionString { get; set; }
|
||||
|
||||
[JsonPropertyName("databaseProvider")]
|
||||
public DatabaseProvider DatabaseProvider { get; set; } = DatabaseProvider.SqlServer;
|
||||
|
||||
[JsonPropertyName("parameters")]
|
||||
public List<ScriptParameter> Parameters { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("outputs")]
|
||||
public List<OutputDefinition> Outputs { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("metadata")]
|
||||
public Dictionary<string, object> Metadata { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("lastModified")]
|
||||
public DateTime LastModified { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[JsonPropertyName("category")]
|
||||
public string? Category { get; set; }
|
||||
|
||||
[JsonPropertyName("tags")]
|
||||
public List<string> Tags { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("executionCount")]
|
||||
public int ExecutionCount { get; set; }
|
||||
|
||||
[JsonPropertyName("averageExecutionTime")]
|
||||
public TimeSpan AverageExecutionTime { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string DisplayName => !string.IsNullOrEmpty(Description)
|
||||
? Description
|
||||
: Path.GetFileNameWithoutExtension(FileName);
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsVisible { get; set; } = true;
|
||||
}
|
||||
66
SQLVision.Core/Models/ScriptParameter.cs
Normal file
66
SQLVision.Core/Models/ScriptParameter.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using SQLVision.Core.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SQLVision.Core.Models;
|
||||
|
||||
public class ScriptParameter
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("type")]
|
||||
public ParameterType Type { get; set; } = ParameterType.String;
|
||||
|
||||
[JsonPropertyName("displayName")]
|
||||
public string? DisplayName { get; set; }
|
||||
|
||||
[JsonPropertyName("description")]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[JsonPropertyName("defaultValue")]
|
||||
public object? DefaultValue { get; set; }
|
||||
|
||||
[JsonPropertyName("isRequired")]
|
||||
public bool IsRequired { get; set; } = false;
|
||||
|
||||
[JsonPropertyName("order")]
|
||||
public int Order { get; set; } = 0;
|
||||
|
||||
[JsonPropertyName("group")]
|
||||
public string? Group { get; set; }
|
||||
|
||||
[JsonPropertyName("tableQuery")]
|
||||
public string? TableQuery { get; set; }
|
||||
|
||||
[JsonPropertyName("valueMember")]
|
||||
public string ValueMember { get; set; } = "Id";
|
||||
|
||||
[JsonPropertyName("displayMember")]
|
||||
public string DisplayMember { get; set; } = "Name";
|
||||
|
||||
[JsonPropertyName("dependsOn")]
|
||||
public string? DependsOn { get; set; }
|
||||
|
||||
[JsonPropertyName("dependencyValues")]
|
||||
public Dictionary<string, object>? DependencyValues { get; set; }
|
||||
|
||||
[JsonPropertyName("validationRules")]
|
||||
public Dictionary<string, object>? ValidationRules { get; set; }
|
||||
|
||||
[JsonPropertyName("watermark")]
|
||||
public string? Watermark { get; set; }
|
||||
|
||||
[JsonPropertyName("icon")]
|
||||
public string? Icon { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string EffectiveDisplayName => DisplayName ?? Name;
|
||||
|
||||
public bool Validate(object? value)
|
||||
{
|
||||
if (IsRequired && (value == null || string.IsNullOrWhiteSpace(value.ToString())))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
17
SQLVision.Core/SQLVision.Core.csproj
Normal file
17
SQLVision.Core/SQLVision.Core.csproj
Normal file
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Text.Json" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user