Compare commits

..

No commits in common. "b1f7fa53f8774ab86cfa107e158df68832fd07a4" and "550d53e9c764122750f9749e31a71b12b629d495" have entirely different histories.

15 changed files with 48 additions and 191 deletions

3
.gitignore vendored
View File

@ -398,6 +398,3 @@ FodyWeavers.xsd
# JetBrains Rider # JetBrains Rider
*.sln.iml *.sln.iml
/Manarah.App/Manarah.db
/Manarah.App/Manarah.db-shm
/Manarah.App/Manarah.db-wal

View File

@ -22,7 +22,6 @@
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -8,11 +8,11 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable #nullable disable
namespace Manarah.SqlServerMigrations.Migrations namespace Manarah.App.Migrations
{ {
[DbContext(typeof(ManarahContext))] [DbContext(typeof(ManarahContext))]
[Migration("20240505211647_InitCreate")] [Migration("20240327205653_InitialCreate")]
partial class InitCreate partial class InitialCreate
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@ -0,0 +1,33 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Manarah.App.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Server",
columns: table => new
{
IPAddress = table.Column<string>(type: "nvarchar(450)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Server", x => x.IPAddress);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Server");
}
}
}

View File

@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable #nullable disable
namespace Manarah.SqlServerMigrations.Migrations namespace Manarah.App.Migrations
{ {
[DbContext(typeof(ManarahContext))] [DbContext(typeof(ManarahContext))]
partial class ManarahContextModelSnapshot : ModelSnapshot partial class ManarahContextModelSnapshot : ModelSnapshot

View File

@ -10,25 +10,12 @@ var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
builder.Services.AddControllersWithViews(); builder.Services.AddControllersWithViews();
var configuration = builder.Configuration; builder.Services.AddDbContext<ManarahContext>(options =>
//Set db to Sqlite if as default db provider
var provider = configuration.GetValue("Provider", "Sqlite");
builder.Services.AddDbContext<ManarahContext>(
options => _ = provider switch
{ {
"Sqlite" => options.UseSqlite( options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
configuration.GetConnectionString("SqliteConnection"),
x => x.MigrationsAssembly("Manarah.SqliteMigrations")),
"SqlServer" => options.UseSqlServer(
configuration.GetConnectionString("SqlServerConnection"),
x => x.MigrationsAssembly("Manarah.SqlServerMigrations")),
_ => throw new Exception($"Unsupported provider: {provider}")
}); });
//Register Service of typ Base Service for DI //Register Service of typ Base Service for DI Container
var assembly = Assembly.Load(typeof(BaseService).Assembly.FullName); var assembly = Assembly.Load(typeof(BaseService).Assembly.FullName);
var serviceList = assembly.DefinedTypes.Where(d => d.BaseType == typeof(BaseService)); var serviceList = assembly.DefinedTypes.Where(d => d.BaseType == typeof(BaseService));
foreach (var service in serviceList) foreach (var service in serviceList)
@ -46,7 +33,7 @@ if (!app.Environment.IsDevelopment())
app.UseHsts(); app.UseHsts();
} }
app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseRouting(); app.UseRouting();

View File

@ -29,7 +29,7 @@
<div class="small-box text-bg-danger"> <div class="small-box text-bg-danger">
<div class="inner"> <div class="inner">
<p>Unreachable servers</p> <p>Unreachable servers</p>
<h3>@Model.Where(s => !s.IsReachable).Count()</h3> <h3>@Model.Where(s => s.IsReachable).Count()</h3>
</div> </div>
<svg class="small-box-icon" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"> <svg class="small-box-icon" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<path d="M4.5 5a.5.5 0 1 0 0-1 .5.5 0 0 0 0 1M3 4.5a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0" /> <path d="M4.5 5a.5.5 0 1 0 0-1 .5.5 0 0 0 0 1M3 4.5a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0" />

View File

@ -1,9 +1,8 @@
{ {
"ConnectionStrings": { "ConnectionStrings": {
"SqlServerConnection": "Server=localhost;Database=ManarahDb;Trusted_Connection=True;MultipleActiveResultSets=true;encrypt=false", "DefaultConnection": "Server=localhost;Database=ManarahDb;Trusted_Connection=True;MultipleActiveResultSets=true;encrypt=false"
"SqliteConnection": "Data Source=Manarah.db;Cache=Shared"
}, },
"Provider": "Sqlite",
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",

View File

@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<BaseOutputPath>..\Manarah.App\bin\</BaseOutputPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Manarah.App\Manarah.App.csproj" />
</ItemGroup>
</Project>

View File

@ -1,22 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Manarah.SqlServerMigrations.Migrations
{
/// <inheritdoc />
public partial class InitCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -1,12 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<BaseOutputPath>..\Manarah.App\bin\</BaseOutputPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Manarah.App\Manarah.App.csproj" />
</ItemGroup>
</Project>

View File

@ -1,37 +0,0 @@
// <auto-generated />
using Manarah.App.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Manarah.SqliteMigrations.Migrations
{
[DbContext(typeof(ManarahContext))]
[Migration("20240505211518_InitCreate")]
partial class InitCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.3");
modelBuilder.Entity("Manarah.Domain.Server", b =>
{
b.Property<string>("IPAddress")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT");
b.HasKey("IPAddress");
b.ToTable("Server", (string)null);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,22 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Manarah.SqliteMigrations.Migrations
{
/// <inheritdoc />
public partial class InitCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -1,34 +0,0 @@
// <auto-generated />
using Manarah.App.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Manarah.SqliteMigrations.Migrations
{
[DbContext(typeof(ManarahContext))]
partial class ManarahContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.3");
modelBuilder.Entity("Manarah.Domain.Server", b =>
{
b.Property<string>("IPAddress")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT");
b.HasKey("IPAddress");
b.ToTable("Server", (string)null);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -3,15 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116 VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manarah.App", "Manarah.App\Manarah.App.csproj", "{C505E413-CB8E-49A6-9186-AFDED3B878BD}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Manarah.App", "Manarah.App\Manarah.App.csproj", "{C505E413-CB8E-49A6-9186-AFDED3B878BD}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manarah.Domain", "Manarah.Domain\Manarah.Domain.csproj", "{1551179E-FA6B-4E87-8B50-9FA2AD2F0CB0}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Manarah.Domain", "Manarah.Domain\Manarah.Domain.csproj", "{1551179E-FA6B-4E87-8B50-9FA2AD2F0CB0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Database", "Database", "{D07B611D-55F9-4830-949C-850677ED48EB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Manarah.SqliteMigrations", "Manarah.SqliteMigrations\Manarah.SqliteMigrations.csproj", "{794BD3E8-AD7B-4C57-95E1-78CD0AA03DB8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Manarah.SqlServerMigrations", "Manarah.SqlServerMigrations\Manarah.SqlServerMigrations.csproj", "{DF9FC8BA-0854-465E-9C84-9FC330120527}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -27,22 +21,10 @@ Global
{1551179E-FA6B-4E87-8B50-9FA2AD2F0CB0}.Debug|Any CPU.Build.0 = Debug|Any CPU {1551179E-FA6B-4E87-8B50-9FA2AD2F0CB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1551179E-FA6B-4E87-8B50-9FA2AD2F0CB0}.Release|Any CPU.ActiveCfg = Release|Any CPU {1551179E-FA6B-4E87-8B50-9FA2AD2F0CB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1551179E-FA6B-4E87-8B50-9FA2AD2F0CB0}.Release|Any CPU.Build.0 = Release|Any CPU {1551179E-FA6B-4E87-8B50-9FA2AD2F0CB0}.Release|Any CPU.Build.0 = Release|Any CPU
{794BD3E8-AD7B-4C57-95E1-78CD0AA03DB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{794BD3E8-AD7B-4C57-95E1-78CD0AA03DB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{794BD3E8-AD7B-4C57-95E1-78CD0AA03DB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{794BD3E8-AD7B-4C57-95E1-78CD0AA03DB8}.Release|Any CPU.Build.0 = Release|Any CPU
{DF9FC8BA-0854-465E-9C84-9FC330120527}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF9FC8BA-0854-465E-9C84-9FC330120527}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF9FC8BA-0854-465E-9C84-9FC330120527}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF9FC8BA-0854-465E-9C84-9FC330120527}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{794BD3E8-AD7B-4C57-95E1-78CD0AA03DB8} = {D07B611D-55F9-4830-949C-850677ED48EB}
{DF9FC8BA-0854-465E-9C84-9FC330120527} = {D07B611D-55F9-4830-949C-850677ED48EB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A3C4374E-F704-4D7C-88D0-BBEB231C39FC} SolutionGuid = {A3C4374E-F704-4D7C-88D0-BBEB231C39FC}
EndGlobalSection EndGlobalSection