22 changed files with 2 additions and 764 deletions
@ -1,86 +0,0 @@ |
|||||||
@inject HttpClient httpClient |
|
||||||
|
|
||||||
@if (content == null) |
|
||||||
{ |
|
||||||
<LoadingComponent/> |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
<div class="doc"> |
|
||||||
<div class="docHeader"> |
|
||||||
<div class="docTitle">@docFrontMatter.Title</div> |
|
||||||
<div class="docDates"> |
|
||||||
<div class="docDateUpdated"><b>Updated</b>: @docFrontMatter.UpdatedDate.ToString("MM/dd/yyyy")</div> |
|
||||||
<div class="docDateCreated"><b>Created</b>: @docFrontMatter.CreatedDate.ToString("MM/dd/yyyy")</div> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
<div class="docContent">@((MarkupString)Markdown.ToHtml(content, Pipeline))</div> |
|
||||||
<div class="docFooter"> |
|
||||||
<LinkButtonComponent Href="@GitUrl"> |
|
||||||
Edit on GitHub <i class="fa-brands fa-github" style="font-size: 24px; margin-left: 5px;"></i> |
|
||||||
</LinkButtonComponent> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
} |
|
||||||
|
|
||||||
<style> |
|
||||||
.docTitle { |
|
||||||
font-weight: bold; |
|
||||||
} |
|
||||||
|
|
||||||
.docHeader { |
|
||||||
display: flex; |
|
||||||
justify-content: space-between; |
|
||||||
} |
|
||||||
|
|
||||||
.docDates { |
|
||||||
display: flex; |
|
||||||
flex-direction: column; |
|
||||||
} |
|
||||||
|
|
||||||
.docFooter { |
|
||||||
display: flex; |
|
||||||
justify-content: flex-end; |
|
||||||
} |
|
||||||
|
|
||||||
th { |
|
||||||
padding: 8px; |
|
||||||
border: 1px solid gray; |
|
||||||
} |
|
||||||
|
|
||||||
td { |
|
||||||
padding: 8px; |
|
||||||
border: 1px solid gray; |
|
||||||
} |
|
||||||
</style> |
|
||||||
|
|
||||||
@code { |
|
||||||
|
|
||||||
[Parameter] public DocContentModel DocContentModel { get; set; } = default!; |
|
||||||
|
|
||||||
DocFrontMatterModel docFrontMatter = null!; |
|
||||||
private string? content; |
|
||||||
|
|
||||||
private string Filepath => $"content/docs/{DocContentModel.Content}.md"; |
|
||||||
private string GitUrl => $"{Project.GitResourcesUrl}/{Filepath}"; |
|
||||||
private MarkdownPipeline Pipeline => MarkdownFiles.Pipeline; |
|
||||||
|
|
||||||
private async Task<DocFrontMatterModel> LoadContent() |
|
||||||
{ |
|
||||||
content = await MarkdownFiles.LoadMarkdown(httpClient, Filepath); |
|
||||||
|
|
||||||
return docFrontMatter = |
|
||||||
await MarkdownFiles.LoadFrontMatter<DocFrontMatterModel>(httpClient, Filepath); |
|
||||||
} |
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync() |
|
||||||
{ |
|
||||||
await LoadContent(); |
|
||||||
} |
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync() |
|
||||||
{ |
|
||||||
await LoadContent(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,33 +0,0 @@ |
|||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.ComponentModel.DataAnnotations.Schema; |
|
||||||
using Model.Work.Tasks.Enums; |
|
||||||
|
|
||||||
namespace Model.Work.Tasks; |
|
||||||
|
|
||||||
public class AgileSprintModel |
|
||||||
{ |
|
||||||
public int Id { get; set; } |
|
||||||
public string Name { get; set; } = "Add name..."; |
|
||||||
public string Description { get; set; } = "Add description..."; |
|
||||||
|
|
||||||
public DateTime? StartDate { get; set; } = null; |
|
||||||
public DateTime? EndDate { get; set; } = null; |
|
||||||
|
|
||||||
public string Notes { get; set; } = "Add notes..."; |
|
||||||
|
|
||||||
[NotMapped] public virtual ICollection<AgileTaskModel> AgileTaskModels { get; set; } = new List<AgileTaskModel>(); |
|
||||||
|
|
||||||
|
|
||||||
public string GetSprintType() |
|
||||||
{ |
|
||||||
var now = DateTime.Now; |
|
||||||
|
|
||||||
if (StartDate == null || EndDate == null) return SprintType.Planned; |
|
||||||
|
|
||||||
if (DateTime.Compare(now, EndDate.GetValueOrDefault()) > 0) return SprintType.Completed; |
|
||||||
if (DateTime.Compare(now, StartDate.GetValueOrDefault()) >= 0) return SprintType.Current; |
|
||||||
|
|
||||||
return SprintType.Planned; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,26 +0,0 @@ |
|||||||
using System; |
|
||||||
using Model.Work.Tasks.Enums; |
|
||||||
|
|
||||||
namespace Model.Work.Tasks; |
|
||||||
|
|
||||||
public class AgileTaskModel |
|
||||||
{ |
|
||||||
public int Id { get; set; } = 1; |
|
||||||
public int? AgileSprintModelId { get; set; } = null; |
|
||||||
public string Name { get; set; } = "Add name..."; |
|
||||||
public string Description { get; set; } = "Add description..."; |
|
||||||
public string Notes { get; set; } = "Add notes..."; |
|
||||||
public string Status { get; set; } = StatusType.Fun_Idea; |
|
||||||
public string Priority { get; set; } = PriorityType.Medium; |
|
||||||
public string Task { get; set; } = TaskType.Feature; |
|
||||||
|
|
||||||
public int OrderPriority => Status == StatusType.In_Progress ? 1 |
|
||||||
: Status == StatusType.Todo ? 2 |
|
||||||
: Status == StatusType.Done ? 3 |
|
||||||
: Status == StatusType.Canceled ? 4 |
|
||||||
: Status == StatusType.To_Test ? 2 |
|
||||||
: Status == StatusType.Fun_Idea ? 5 : 6; |
|
||||||
|
|
||||||
public DateTime? Created { get; set; } = null; |
|
||||||
public DateTime? Finished { get; set; } = null; |
|
||||||
} |
|
||||||
@ -1,10 +0,0 @@ |
|||||||
namespace Model.Work.Tasks.Enums; |
|
||||||
|
|
||||||
public class PriorityType |
|
||||||
{ |
|
||||||
public const string Blocker = "Blocker"; |
|
||||||
public const string High = "High"; |
|
||||||
public const string Medium = "Medium"; |
|
||||||
public const string Low = "Low"; |
|
||||||
public const string None = "None"; |
|
||||||
} |
|
||||||
@ -1,13 +0,0 @@ |
|||||||
namespace Model.Work.Tasks.Enums; |
|
||||||
|
|
||||||
public class ProjectType |
|
||||||
{ |
|
||||||
public const string Management = "Management"; |
|
||||||
public const string Immortal = "Management"; |
|
||||||
public const string Food = "Management"; |
|
||||||
public const string Job = "Management"; |
|
||||||
public const string Time = "Management"; |
|
||||||
public const string Maintence = "Management"; |
|
||||||
public const string Website = "Management"; |
|
||||||
public const string Tasks = "Management"; |
|
||||||
} |
|
||||||
@ -1,8 +0,0 @@ |
|||||||
namespace Model.Work.Tasks.Enums; |
|
||||||
|
|
||||||
public class SprintType |
|
||||||
{ |
|
||||||
public const string Current = "Current"; |
|
||||||
public const string Planned = "Planned"; |
|
||||||
public const string Completed = "Completed"; |
|
||||||
} |
|
||||||
@ -1,11 +0,0 @@ |
|||||||
namespace Model.Work.Tasks.Enums; |
|
||||||
|
|
||||||
public class StatusType |
|
||||||
{ |
|
||||||
public const string In_Progress = "In_Progress"; |
|
||||||
public const string Todo = "Todo"; |
|
||||||
public const string To_Test = "To_Test"; |
|
||||||
public const string Done = "Done"; |
|
||||||
public const string Canceled = "Canceled"; |
|
||||||
public const string Fun_Idea = "Fun_Idea"; |
|
||||||
} |
|
||||||
@ -1,8 +0,0 @@ |
|||||||
namespace Model.Work.Tasks.Enums; |
|
||||||
|
|
||||||
public class TaskType |
|
||||||
{ |
|
||||||
public const string Feature = "Feature"; |
|
||||||
public const string Bug = "Bug"; |
|
||||||
public const string Document = "Document"; |
|
||||||
} |
|
||||||
@ -1,10 +0,0 @@ |
|||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
|
|
||||||
namespace Model.Doc; |
|
||||||
|
|
||||||
public class DocConnectionModel |
|
||||||
{ |
|
||||||
[Key] public int Id { get; set; } = 1; |
|
||||||
public int ParentId { get; set; } = 1; |
|
||||||
public int ChildId { get; set; } = 1; |
|
||||||
} |
|
||||||
@ -1,40 +0,0 @@ |
|||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using System.ComponentModel.DataAnnotations.Schema; |
|
||||||
|
|
||||||
namespace Model.Doc; |
|
||||||
|
|
||||||
public class DocContentModel |
|
||||||
{ |
|
||||||
[Key] public int Id { get; set; } = 1; |
|
||||||
|
|
||||||
public int? ParentId { get; set; } = null; |
|
||||||
public int? DocSectionModelId { get; set; } = null; |
|
||||||
public string Href { get; set; } |
|
||||||
|
|
||||||
[NotMapped] |
|
||||||
public virtual ICollection<DocContentModel> DocumentationModels { get; set; } = new List<DocContentModel>(); |
|
||||||
|
|
||||||
[NotMapped] public virtual DocContentModel Parent { get; set; } |
|
||||||
[NotMapped] public virtual int PageOrder { get; set; } |
|
||||||
public DateTime CreatedDate { get; set; } |
|
||||||
public DateTime UpdatedDate { get; set; } |
|
||||||
public string Name { get; set; } = ""; |
|
||||||
public string Description { get; set; } = null; |
|
||||||
public string Content { get; set; } = ""; |
|
||||||
|
|
||||||
private string GetLink() |
|
||||||
{ |
|
||||||
var link = Href; |
|
||||||
|
|
||||||
if (Parent != null) link = $"{Parent.GetLink()}/" + link; |
|
||||||
|
|
||||||
return link; |
|
||||||
} |
|
||||||
|
|
||||||
public string GetDocLink() |
|
||||||
{ |
|
||||||
return $"docs/{GetLink()}"; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,12 +0,0 @@ |
|||||||
using System; |
|
||||||
using YamlDotNet.Serialization; |
|
||||||
|
|
||||||
namespace Model.Doc; |
|
||||||
|
|
||||||
public class DocFrontMatterModel |
|
||||||
{ |
|
||||||
[YamlMember(Alias = "title")] public string Title { get; set; } |
|
||||||
[YamlMember(Alias = "summary")] public string Summary { get; set; } |
|
||||||
[YamlMember(Alias = "created_date")] public DateTime CreatedDate { get; set; } |
|
||||||
[YamlMember(Alias = "updated_date")] public DateTime UpdatedDate { get; set; } |
|
||||||
} |
|
||||||
@ -1,15 +0,0 @@ |
|||||||
using System.Collections.Generic; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using System.ComponentModel.DataAnnotations.Schema; |
|
||||||
|
|
||||||
namespace Model.Doc; |
|
||||||
|
|
||||||
public class DocSectionModel |
|
||||||
{ |
|
||||||
[Key] public int Id { get; set; } |
|
||||||
|
|
||||||
public string Name { get; set; } |
|
||||||
|
|
||||||
[NotMapped] |
|
||||||
public virtual ICollection<DocContentModel> DocumentationModels { get; set; } = new List<DocContentModel>(); |
|
||||||
} |
|
||||||
@ -1,21 +0,0 @@ |
|||||||
namespace Model.Git; |
|
||||||
|
|
||||||
public class CommitType |
|
||||||
{ |
|
||||||
public const string Feature = "Feature"; |
|
||||||
public const string Game_Patch = "Game Patch"; |
|
||||||
public const string Fix = "Fix"; |
|
||||||
public const string Documents = "Documents"; |
|
||||||
public const string Style = "Style"; |
|
||||||
public const string Refactor = "Refactor"; |
|
||||||
public const string Perf = "Perf"; |
|
||||||
public const string Test = "Test"; |
|
||||||
public const string Build = "Build"; |
|
||||||
public const string CI = "CI"; |
|
||||||
public const string Chore = "Chore"; |
|
||||||
public const string Typo = "Typo"; |
|
||||||
public const string Revert = "Revert"; |
|
||||||
public const string Planning = "Planning"; |
|
||||||
public const string PrivacyPolicy = "Privacy Policy"; |
|
||||||
public const string None = "None"; |
|
||||||
} |
|
||||||
@ -1,11 +0,0 @@ |
|||||||
namespace Model.Git; |
|
||||||
|
|
||||||
public class GitChangeModel |
|
||||||
{ |
|
||||||
public int Id { get; set; } = 1; |
|
||||||
public int GitPatchModelId { get; set; } = 1; |
|
||||||
public string Name { get; set; } = "Add name..."; |
|
||||||
public string Description { get; set; } = "Add desciption..."; |
|
||||||
public string Commit { get; set; } = CommitType.Feature; |
|
||||||
public string Important { get; set; } = "False"; |
|
||||||
} |
|
||||||
@ -1,13 +0,0 @@ |
|||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
|
|
||||||
namespace Model.Git; |
|
||||||
|
|
||||||
public class GitPatchModel |
|
||||||
{ |
|
||||||
public int Id { get; set; } = 1; |
|
||||||
public string Name { get; set; } = "Add name..."; |
|
||||||
public DateTime Date { get; set; } = DateTime.Now; |
|
||||||
public ICollection<GitChangeModel> GitChangeModels { get; set; } = new List<GitChangeModel>(); |
|
||||||
public string Important { get; set; } = "False"; |
|
||||||
} |
|
||||||
@ -1,117 +0,0 @@ |
|||||||
using System.Net.Http.Json; |
|
||||||
using Model.Work.Tasks; |
|
||||||
|
|
||||||
namespace Services.Development; |
|
||||||
|
|
||||||
public class AgileService : IAgileService |
|
||||||
{ |
|
||||||
private readonly HttpClient httpClient; |
|
||||||
|
|
||||||
private bool isLoaded; |
|
||||||
|
|
||||||
private event Action OnChange = default!; |
|
||||||
|
|
||||||
public AgileService(HttpClient httpClient) |
|
||||||
{ |
|
||||||
this.httpClient = httpClient; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
#if NO_SQL |
|
||||||
public List<AgileSprintModel>? AgileSprintModels { get; set; } |
|
||||||
public List<AgileTaskModel>? AgileTaskModels { 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; |
|
||||||
} |
|
||||||
|
|
||||||
public void Unsubscribe(Action? action) |
|
||||||
{ |
|
||||||
OnChange -= action; |
|
||||||
} |
|
||||||
|
|
||||||
public bool IsLoaded() |
|
||||||
{ |
|
||||||
return isLoaded; |
|
||||||
} |
|
||||||
|
|
||||||
#if NO_SQL |
|
||||||
public async Task Load() |
|
||||||
{ |
|
||||||
if (isLoaded) return; |
|
||||||
|
|
||||||
AgileSprintModels = |
|
||||||
(await httpClient.GetFromJsonAsync<AgileSprintModel[]>("generated/AgileSprintModels.json") |
|
||||||
?? Array.Empty<AgileSprintModel>()).ToList(); |
|
||||||
AgileTaskModels = |
|
||||||
(await httpClient.GetFromJsonAsync<AgileTaskModel[]>("generated/AgileTaskModels.json") |
|
||||||
?? Array.Empty<AgileTaskModel>()).ToList(); |
|
||||||
|
|
||||||
SortSql(); |
|
||||||
|
|
||||||
isLoaded = true; |
|
||||||
|
|
||||||
NotifyDataChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
private void SortSql() |
|
||||||
{ |
|
||||||
foreach (var agileTask in AgileTaskModels!) |
|
||||||
if (agileTask.AgileSprintModelId != null) |
|
||||||
SprintById(agileTask.AgileSprintModelId.Value)?.AgileTaskModels.Add(agileTask); |
|
||||||
} |
|
||||||
|
|
||||||
private AgileSprintModel? SprintById(int id) |
|
||||||
{ |
|
||||||
foreach (var data in AgileSprintModels!) |
|
||||||
if (data.Id == id) |
|
||||||
return data; |
|
||||||
|
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
private AgileTaskModel? TaskById(int id) |
|
||||||
{ |
|
||||||
foreach (var data in AgileTaskModels!) |
|
||||||
if (data.Id == id) |
|
||||||
return data; |
|
||||||
|
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
#else |
|
||||||
public async Task Load(DatabaseContext database) { |
|
||||||
Database = database; |
|
||||||
|
|
||||||
if (isLoaded) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
Database.SprintModels.AddRange(await httpClient.GetFromJsonAsync<SprintModel[]>("generated/AgileSprintModels.json")); |
|
||||||
Database.TaskModels.AddRange(await httpClient.GetFromJsonAsync<TaskModel[]>("generated/AgileTaskModels.json")); |
|
||||||
|
|
||||||
Database.SaveChanges(); |
|
||||||
|
|
||||||
isLoaded = true; |
|
||||||
|
|
||||||
NotifyDataChanged(); |
|
||||||
} |
|
||||||
#endif |
|
||||||
|
|
||||||
public void Update() |
|
||||||
{ |
|
||||||
NotifyDataChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
private void NotifyDataChanged() |
|
||||||
{ |
|
||||||
OnChange?.Invoke(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,133 +0,0 @@ |
|||||||
using System.Net.Http.Json; |
|
||||||
using Model.Doc; |
|
||||||
|
|
||||||
namespace Services.Development; |
|
||||||
|
|
||||||
public class DocumentationService : IDocumentationService |
|
||||||
{ |
|
||||||
private readonly HttpClient httpClient; |
|
||||||
private bool isLoaded; |
|
||||||
|
|
||||||
public DocumentationService(HttpClient httpClient) |
|
||||||
{ |
|
||||||
this.httpClient = httpClient; |
|
||||||
} |
|
||||||
|
|
||||||
public List<DocContentModel> DocContentModels { get; set; } = new(); |
|
||||||
|
|
||||||
public List<DocContentModel> DocContentModelsByPageOrder { get; set; } = new(); |
|
||||||
|
|
||||||
public List<DocSectionModel> DocSectionModels { get; set; } = new(); |
|
||||||
|
|
||||||
public List<DocConnectionModel> DocConnectionModels { get; set; } = new(); |
|
||||||
|
|
||||||
|
|
||||||
public void Subscribe(Action? action) |
|
||||||
{ |
|
||||||
OnChange += action; |
|
||||||
} |
|
||||||
|
|
||||||
public void Unsubscribe(Action? action) |
|
||||||
{ |
|
||||||
OnChange -= action; |
|
||||||
} |
|
||||||
|
|
||||||
public bool IsLoaded() |
|
||||||
{ |
|
||||||
return isLoaded; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public async Task Load() |
|
||||||
{ |
|
||||||
if (isLoaded) return; |
|
||||||
|
|
||||||
DocContentModels = |
|
||||||
(await httpClient.GetFromJsonAsync<DocContentModel[]>("generated/DocContentModels.json") ?? |
|
||||||
Array.Empty<DocContentModel>()).ToList(); |
|
||||||
|
|
||||||
DocConnectionModels = |
|
||||||
(await httpClient.GetFromJsonAsync<DocConnectionModel[]>("generated/DocConnectionModels.json") ?? |
|
||||||
Array.Empty<DocConnectionModel>()).ToList(); |
|
||||||
|
|
||||||
DocSectionModels = |
|
||||||
(await httpClient.GetFromJsonAsync<DocSectionModel[]>("generated/DocSectionModels.json") ?? |
|
||||||
Array.Empty<DocSectionModel>()).ToList(); |
|
||||||
|
|
||||||
SortSql(); |
|
||||||
|
|
||||||
isLoaded = true; |
|
||||||
|
|
||||||
NotifyDataChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public void Update() |
|
||||||
{ |
|
||||||
NotifyDataChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
private event Action? OnChange; |
|
||||||
|
|
||||||
private DocContentModel? ContentById(int id) |
|
||||||
{ |
|
||||||
foreach (var doc in DocContentModels!) |
|
||||||
if (doc.Id == id) |
|
||||||
return doc; |
|
||||||
|
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
private void SortSql() |
|
||||||
{ |
|
||||||
foreach (var connection in DocConnectionModels) |
|
||||||
{ |
|
||||||
ContentById(connection.ParentId)!.DocumentationModels.Add(ContentById(connection.ChildId)); |
|
||||||
ContentById(connection.ChildId)!.Parent = ContentById(connection.ParentId); |
|
||||||
} |
|
||||||
|
|
||||||
foreach (var content in DocContentModels) |
|
||||||
if (content.DocSectionModelId != null) |
|
||||||
foreach (var section in DocSectionModels) |
|
||||||
if (section.Id == content.DocSectionModelId) |
|
||||||
section.DocumentationModels.Add(content); |
|
||||||
|
|
||||||
ByPageOrder(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private void ByPageOrder() |
|
||||||
{ |
|
||||||
DocContentModelsByPageOrder = new List<DocContentModel>(); |
|
||||||
|
|
||||||
var order = 1; |
|
||||||
foreach (var documentation in DocContentModels) |
|
||||||
{ |
|
||||||
if (documentation.Parent != null) continue; |
|
||||||
|
|
||||||
documentation.PageOrder = order++; |
|
||||||
DocContentModelsByPageOrder.Add(documentation); |
|
||||||
|
|
||||||
void GetAllChildren(DocContentModel docs) |
|
||||||
{ |
|
||||||
foreach (var doc in docs.DocumentationModels) |
|
||||||
{ |
|
||||||
doc.PageOrder = order++; |
|
||||||
DocContentModelsByPageOrder.Add(doc); |
|
||||||
|
|
||||||
if (doc.DocumentationModels.Count > 0) GetAllChildren(doc); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
GetAllChildren(documentation); |
|
||||||
} |
|
||||||
|
|
||||||
DocContentModelsByPageOrder = DocContentModelsByPageOrder.OrderBy(docContent => docContent.PageOrder).ToList(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private void NotifyDataChanged() |
|
||||||
{ |
|
||||||
OnChange?.Invoke(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,100 +0,0 @@ |
|||||||
using System.Net.Http.Json; |
|
||||||
using Model.Git; |
|
||||||
|
|
||||||
#if NO_SQL |
|
||||||
|
|
||||||
#else |
|
||||||
using Contexts; |
|
||||||
using Microsoft.EntityFrameworkCore; |
|
||||||
#endif |
|
||||||
|
|
||||||
namespace Services.Development; |
|
||||||
|
|
||||||
public class GitService : IGitService |
|
||||||
{ |
|
||||||
private readonly HttpClient httpClient; |
|
||||||
|
|
||||||
private bool isLoaded; |
|
||||||
|
|
||||||
private event Action OnChange = default!; |
|
||||||
|
|
||||||
|
|
||||||
public GitService(HttpClient httpClient) |
|
||||||
{ |
|
||||||
this.httpClient = httpClient; |
|
||||||
} |
|
||||||
|
|
||||||
#if NO_SQL |
|
||||||
public List<GitChangeModel> GitChangeModels { get; set; } = default!; |
|
||||||
public List<GitPatchModel> GitPatchModels { get; set; } = default!; |
|
||||||
#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; |
|
||||||
} |
|
||||||
|
|
||||||
public void Unsubscribe(Action action) |
|
||||||
{ |
|
||||||
OnChange -= action; |
|
||||||
} |
|
||||||
|
|
||||||
public bool IsLoaded() |
|
||||||
{ |
|
||||||
return isLoaded; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
#if NO_SQL |
|
||||||
|
|
||||||
public async Task Load() |
|
||||||
{ |
|
||||||
if (isLoaded) return; |
|
||||||
|
|
||||||
GitChangeModels = (await httpClient.GetFromJsonAsync<GitChangeModel[]>("generated/GitChangeModels.json") ?? |
|
||||||
Array.Empty<GitChangeModel>()).ToList(); |
|
||||||
GitPatchModels = (await httpClient.GetFromJsonAsync<GitPatchModel[]>("generated/GitPatchModels.json") ?? |
|
||||||
Array.Empty<GitPatchModel>()).ToList(); |
|
||||||
|
|
||||||
|
|
||||||
isLoaded = true; |
|
||||||
|
|
||||||
NotifyDataChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
#else |
|
||||||
public async Task Load(DatabaseContext database) { |
|
||||||
Database = database; |
|
||||||
|
|
||||||
if (isLoaded) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
Database.ChangeModels.AddRange(await httpClient.GetFromJsonAsync<ChangeModel[]>("generated/GitChangeModels.json")); |
|
||||||
Database.PatchModels.AddRange(await httpClient.GetFromJsonAsync<PatchModel[]>("generated/GitPatchModels.json")); |
|
||||||
Database.SaveChanges(); |
|
||||||
|
|
||||||
|
|
||||||
isLoaded = true; |
|
||||||
|
|
||||||
NotifyDataChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
#endif |
|
||||||
|
|
||||||
|
|
||||||
public void Update() |
|
||||||
{ |
|
||||||
NotifyDataChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
private void NotifyDataChanged() |
|
||||||
{ |
|
||||||
OnChange?.Invoke(); |
|
||||||
} |
|
||||||
} |
|
||||||
Loading…
Reference in new issue