feat(Immortal) Disabling SQL
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.Net.Http.Json;
|
||||
|
||||
|
||||
using System.Net.Http.Json;
|
||||
using Contexts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Model.Work.Tasks;
|
||||
@@ -14,9 +16,17 @@ public class AgileService : IAgileService {
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
|
||||
#if NO_SQL
|
||||
public List<SprintModel> SprintModels { get; set; }
|
||||
public List<TaskModel> TaskModels { get; set; }
|
||||
#else
|
||||
|
||||
private DatabaseContext Database { get; set; }
|
||||
public DbSet<SprintModel> SprintModels => Database.SprintModels;
|
||||
public DbSet<TaskModel> TaskModels => Database.TaskModels;
|
||||
#endif
|
||||
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
_onChange += action;
|
||||
@@ -30,10 +40,26 @@ public class AgileService : IAgileService {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
#if NO_SQL
|
||||
public async Task Load() {
|
||||
if (isLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
SprintModels = (await httpClient.GetFromJsonAsync<SprintModel[]>("generated/SprintModels.json")).ToList();
|
||||
TaskModels =(await httpClient.GetFromJsonAsync<TaskModel[]>("generated/TaskModels.json")).ToList();
|
||||
|
||||
isLoaded = true;
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
#else
|
||||
public async Task Load(DatabaseContext database) {
|
||||
Database = database;
|
||||
|
||||
if (isLoaded) return;
|
||||
if (isLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
Database.SprintModels.AddRange(await httpClient.GetFromJsonAsync<SprintModel[]>("generated/SprintModels.json"));
|
||||
Database.TaskModels.AddRange(await httpClient.GetFromJsonAsync<TaskModel[]>("generated/TaskModels.json"));
|
||||
@@ -44,6 +70,7 @@ public class AgileService : IAgileService {
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
public void Update() {
|
||||
NotifyDataChanged();
|
||||
@@ -1,7 +1,14 @@
|
||||
using System.Net.Http.Json;
|
||||
|
||||
|
||||
using System.Net.Http.Json;
|
||||
using Model.Work.Git;
|
||||
|
||||
#if NO_SQL
|
||||
|
||||
#else
|
||||
using Contexts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Model.Work.Git;
|
||||
#endif
|
||||
|
||||
namespace Services.Work;
|
||||
|
||||
@@ -14,9 +21,16 @@ public class GitService : IGitService {
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
public DatabaseContext Database { get; set; }
|
||||
#if NO_SQL
|
||||
public List<ChangeModel> ChangeModels { get; set; }
|
||||
public List<PatchModel> PatchModels { get; set; }
|
||||
#else
|
||||
public DbSet<ChangeModel> ChangeModels => Database.ChangeModels;
|
||||
public DbSet<PatchModel> PatchModels => Database.PatchModels;
|
||||
public DatabaseContext Database { get; set; }
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
_onChange += action;
|
||||
@@ -30,20 +44,46 @@ public class GitService : IGitService {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
public async Task Load(DatabaseContext database) {
|
||||
Database = database;
|
||||
|
||||
#if NO_SQL
|
||||
|
||||
if (isLoaded) return;
|
||||
public async Task Load() {
|
||||
|
||||
if (isLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
ChangeModels = (await httpClient.GetFromJsonAsync<ChangeModel[]>("generated/ChangeModels.json")).ToList();
|
||||
PatchModels = (await httpClient.GetFromJsonAsync<PatchModel[]>("generated/PatchModels.json")).ToList();
|
||||
|
||||
Database.ChangeModels.AddRange(await httpClient.GetFromJsonAsync<ChangeModel[]>("generated/ChangeModels.json"));
|
||||
Database.PatchModels.AddRange(await httpClient.GetFromJsonAsync<PatchModel[]>("generated/PatchModels.json"));
|
||||
Database.SaveChanges();
|
||||
|
||||
isLoaded = true;
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
public async Task Load(DatabaseContext database) {
|
||||
Database = database;
|
||||
|
||||
if (isLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
Database.ChangeModels.AddRange(await httpClient.GetFromJsonAsync<ChangeModel[]>("generated/ChangeModels.json"));
|
||||
Database.PatchModels.AddRange(await httpClient.GetFromJsonAsync<PatchModel[]>("generated/PatchModels.json"));
|
||||
Database.SaveChanges();
|
||||
|
||||
|
||||
isLoaded = true;
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
public void Update() {
|
||||
NotifyDataChanged();
|
||||
}
|
||||
+47
-7
@@ -1,4 +1,6 @@
|
||||
using Contexts;
|
||||
|
||||
|
||||
using Contexts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Model.Immortal.BuildOrders;
|
||||
using Model.Immortal.Economy;
|
||||
@@ -12,34 +14,72 @@ using Services.Immortal;
|
||||
|
||||
namespace Services;
|
||||
|
||||
public interface IAgileService {
|
||||
public DbSet<SprintModel> SprintModels { get; }
|
||||
public DbSet<TaskModel> TaskModels { get; }
|
||||
public interface IWebsiteService {
|
||||
#if NO_SQL
|
||||
public List<WebPageModel> WebPageModels { get; set; }
|
||||
public List<WebSectionModel> WebSectionModels { get; set; }
|
||||
#else
|
||||
public DbSet<WebPageModel> WebPageModels { get; }
|
||||
public DbSet<WebSectionModel> WebSectionModels { get; }
|
||||
#endif
|
||||
|
||||
public void Subscribe(Action action);
|
||||
public void Unsubscribe(Action action);
|
||||
public void Update();
|
||||
|
||||
|
||||
#if NO_SQL
|
||||
public Task Load();
|
||||
#else
|
||||
|
||||
public Task Load(DatabaseContext database);
|
||||
#endif
|
||||
|
||||
|
||||
public bool IsLoaded();
|
||||
}
|
||||
|
||||
public interface IWebsiteService {
|
||||
public DbSet<WebPageModel> WebPageModels { get; }
|
||||
public DbSet<WebSectionModel> WebSectionModels { get; }
|
||||
public interface IAgileService {
|
||||
|
||||
#if NO_SQL
|
||||
public List<SprintModel> SprintModels { get; set; }
|
||||
public List<TaskModel> TaskModels { get; set; }
|
||||
#else
|
||||
public DbSet<SprintModel> SprintModels { get; }
|
||||
public DbSet<TaskModel> TaskModels { get; }
|
||||
#endif
|
||||
|
||||
public void Subscribe(Action action);
|
||||
public void Unsubscribe(Action action);
|
||||
public void Update();
|
||||
|
||||
#if NO_SQL
|
||||
public Task Load();
|
||||
#else
|
||||
public Task Load(DatabaseContext database);
|
||||
#endif
|
||||
public bool IsLoaded();
|
||||
}
|
||||
|
||||
public interface IGitService {
|
||||
|
||||
#if NO_SQL
|
||||
public List<ChangeModel> ChangeModels { get; set; }
|
||||
public List<PatchModel> PatchModels { get; set; }
|
||||
#else
|
||||
public DbSet<ChangeModel> ChangeModels { get; }
|
||||
public DbSet<PatchModel> PatchModels { get; }
|
||||
#endif
|
||||
|
||||
|
||||
public void Subscribe(Action action);
|
||||
public void Unsubscribe(Action action);
|
||||
public void Update();
|
||||
#if NO_SQL
|
||||
public Task Load();
|
||||
#else
|
||||
public Task Load(DatabaseContext database);
|
||||
#endif
|
||||
public bool IsLoaded();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,21 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<DefineConstants>TRACE;NO_SQL</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DefineConstants>TRACE;NO_SQL;</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="YamlDotNet" Version="11.2.1"/>
|
||||
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Contexts\Contexts.csproj"/>
|
||||
<ProjectReference Include="..\Model\Model.csproj"/>
|
||||
<ProjectReference Include="..\Contexts\Contexts.csproj" />
|
||||
<ProjectReference Include="..\Model\Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -14,9 +14,20 @@ public class WebsiteService : IWebsiteService {
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if NO_SQL
|
||||
public List<WebSectionModel> WebSectionModels { get; set; }
|
||||
public List<WebPageModel> WebPageModels { get; set; }
|
||||
#else
|
||||
|
||||
private DatabaseContext Database { get; set; }
|
||||
|
||||
|
||||
public DbSet<WebSectionModel> WebSectionModels => Database.WebSectionModels;
|
||||
public DbSet<WebPageModel> WebPageModels => Database.WebPageModels;
|
||||
#endif
|
||||
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
_onChange += action;
|
||||
@@ -29,11 +40,24 @@ public class WebsiteService : IWebsiteService {
|
||||
public bool IsLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
#if NO_SQL
|
||||
|
||||
public async Task Load() {
|
||||
if (isLoaded) {return;}
|
||||
|
||||
WebPageModels = (await httpClient.GetFromJsonAsync<WebPageModel[]>("generated/WebPageModels.json")).ToList();
|
||||
WebSectionModels =(await httpClient.GetFromJsonAsync<WebSectionModel[]>("generated/WebSectionModels.json")).ToList();
|
||||
|
||||
isLoaded = true;
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
#else
|
||||
public async Task Load(DatabaseContext database) {
|
||||
Database = database;
|
||||
|
||||
if (isLoaded) return;
|
||||
if (isLoaded) {return;}
|
||||
|
||||
Database.WebPageModels.AddRange(await httpClient.GetFromJsonAsync<WebPageModel[]>("generated/WebPageModels.json"));
|
||||
Database.WebSectionModels.AddRange(
|
||||
@@ -44,7 +68,9 @@ public class WebsiteService : IWebsiteService {
|
||||
isLoaded = true;
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
public void Update() {
|
||||
NotifyDataChanged();
|
||||
|
||||
Reference in New Issue
Block a user