|
|
|
@ -1,20 +1,18 @@ |
|
|
|
|
|
|
|
using System.Net.Http.Json; |
|
|
|
|
|
|
|
|
|
|
|
using System.Net.Http.Json; |
|
|
|
|
|
|
|
using Contexts; |
|
|
|
|
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
|
|
|
|
using Model.Work.Tasks; |
|
|
|
using Model.Work.Tasks; |
|
|
|
|
|
|
|
|
|
|
|
namespace Services.Development; |
|
|
|
namespace Services.Development; |
|
|
|
|
|
|
|
|
|
|
|
public class AgileService : IAgileService { |
|
|
|
public class AgileService : IAgileService |
|
|
|
|
|
|
|
{ |
|
|
|
private readonly HttpClient httpClient; |
|
|
|
private readonly HttpClient httpClient; |
|
|
|
|
|
|
|
|
|
|
|
private bool isLoaded; |
|
|
|
private bool isLoaded; |
|
|
|
|
|
|
|
|
|
|
|
private event Action OnChange = default!; |
|
|
|
private event Action OnChange = default!; |
|
|
|
|
|
|
|
|
|
|
|
public AgileService(HttpClient httpClient) { |
|
|
|
public AgileService(HttpClient httpClient) |
|
|
|
|
|
|
|
{ |
|
|
|
this.httpClient = httpClient; |
|
|
|
this.httpClient = httpClient; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -23,47 +21,53 @@ public class AgileService : IAgileService { |
|
|
|
public List<AgileSprintModel>? AgileSprintModels { get; set; } |
|
|
|
public List<AgileSprintModel>? AgileSprintModels { get; set; } |
|
|
|
public List<AgileTaskModel>? AgileTaskModels { get; set; } |
|
|
|
public List<AgileTaskModel>? AgileTaskModels { get; set; } |
|
|
|
#else |
|
|
|
#else |
|
|
|
|
|
|
|
|
|
|
|
private DatabaseContext Database { get; set; } |
|
|
|
private DatabaseContext Database { get; set; } |
|
|
|
public DbSet<SprintModel> SprintModels => Database.SprintModels; |
|
|
|
public DbSet<SprintModel> SprintModels => Database.SprintModels; |
|
|
|
public DbSet<TaskModel> TaskModels => Database.TaskModels; |
|
|
|
public DbSet<TaskModel> TaskModels => Database.TaskModels; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Subscribe(Action? action) { |
|
|
|
public void Subscribe(Action? action) |
|
|
|
|
|
|
|
{ |
|
|
|
OnChange += action; |
|
|
|
OnChange += action; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Unsubscribe(Action? action) { |
|
|
|
public void Unsubscribe(Action? action) |
|
|
|
|
|
|
|
{ |
|
|
|
OnChange -= action; |
|
|
|
OnChange -= action; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public bool IsLoaded() { |
|
|
|
public bool IsLoaded() |
|
|
|
|
|
|
|
{ |
|
|
|
return isLoaded; |
|
|
|
return isLoaded; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if NO_SQL |
|
|
|
#if NO_SQL |
|
|
|
public async Task Load() { |
|
|
|
public async Task Load() |
|
|
|
if (isLoaded) { |
|
|
|
{ |
|
|
|
return; |
|
|
|
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(); |
|
|
|
|
|
|
|
|
|
|
|
AgileSprintModels = (await httpClient.GetFromJsonAsync<AgileSprintModel[]>("generated/AgileSprintModels.json")?? Array.Empty<AgileSprintModel>() ).ToList(); |
|
|
|
|
|
|
|
AgileTaskModels = (await httpClient.GetFromJsonAsync<AgileTaskModel[]>("generated/AgileTaskModels.json") ?? Array.Empty<AgileTaskModel>()).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var agileTask in AgileTaskModels) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (agileTask.AgileSprintModelId != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SprintById(agileTask.AgileSprintModelId.Value)?.AgileTaskModels.Add(agileTask); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isLoaded = true; |
|
|
|
isLoaded = true; |
|
|
|
|
|
|
|
|
|
|
|
NotifyDataChanged(); |
|
|
|
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) |
|
|
|
private AgileSprintModel? SprintById(int id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (var data in AgileSprintModels!) |
|
|
|
foreach (var data in AgileSprintModels!) |
|
|
|
@ -72,7 +76,7 @@ public class AgileService : IAgileService { |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private AgileTaskModel? TaskById(int id) |
|
|
|
private AgileTaskModel? TaskById(int id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (var data in AgileTaskModels!) |
|
|
|
foreach (var data in AgileTaskModels!) |
|
|
|
@ -81,7 +85,7 @@ public class AgileService : IAgileService { |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#else |
|
|
|
#else |
|
|
|
public async Task Load(DatabaseContext database) { |
|
|
|
public async Task Load(DatabaseContext database) { |
|
|
|
Database = database; |
|
|
|
Database = database; |
|
|
|
@ -101,11 +105,13 @@ public class AgileService : IAgileService { |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
public void Update() { |
|
|
|
public void Update() |
|
|
|
|
|
|
|
{ |
|
|
|
NotifyDataChanged(); |
|
|
|
NotifyDataChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void NotifyDataChanged() { |
|
|
|
private void NotifyDataChanged() |
|
|
|
|
|
|
|
{ |
|
|
|
OnChange?.Invoke(); |
|
|
|
OnChange?.Invoke(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |