New: Report-System using globally available Interfaces.
This commit is contained in:
76
Server/Manager/ReportSystemManager.cs
Normal file
76
Server/Manager/ReportSystemManager.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Repository;
|
||||
using SZUAbsolventenverein.Module.AdminModules.Repository;
|
||||
using System.Threading.Tasks;
|
||||
using SZUAbsolventenverein.Module.ReportSystem.Models;
|
||||
using SZUAbsolventenverein.Module.ReportSystem.Repository;
|
||||
using SZUAbsolventenverein.Module.ReportSystem.Services;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.ReportSystem.Manager
|
||||
{
|
||||
public class ReportSystemManager : MigratableModuleBase, IInstallable, IPortable, ISearchable
|
||||
{
|
||||
private readonly IReportingRepository _reportSystemRepository;
|
||||
private readonly IDBContextDependencies _DBContextDependencies;
|
||||
|
||||
public ReportSystemManager(IReportingRepository reportSystemRepository, IDBContextDependencies DBContextDependencies)
|
||||
{
|
||||
_reportSystemRepository = reportSystemRepository;
|
||||
_DBContextDependencies = DBContextDependencies;
|
||||
}
|
||||
|
||||
public bool Install(Tenant tenant, string version)
|
||||
{
|
||||
Console.WriteLine("Installing ReportSystem module for tenant {TenantId}");
|
||||
return Migrate(new ReportingContext(_DBContextDependencies), tenant, MigrationType.Up);
|
||||
}
|
||||
|
||||
public bool Uninstall(Tenant tenant)
|
||||
{
|
||||
return Migrate(new ReportingContext(_DBContextDependencies), tenant, MigrationType.Down);
|
||||
}
|
||||
|
||||
public string ExportModule(Oqtane.Models.Module module)
|
||||
{
|
||||
string content = "";
|
||||
List<Reporting> reportings = _reportSystemRepository.GetReportings().ToList();
|
||||
if (reportings != null)
|
||||
{
|
||||
content = JsonSerializer.Serialize(reportings);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
public void ImportModule(Oqtane.Models.Module module, string content, string version)
|
||||
{
|
||||
List<Reporting> reportings = null;
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
reportings = JsonSerializer.Deserialize<List<Reporting>>(content);
|
||||
}
|
||||
if (reportings != null)
|
||||
{
|
||||
foreach(var reporting in reportings)
|
||||
{
|
||||
_reportSystemRepository.AddReporting(reporting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Task<List<SearchContent>> GetSearchContentsAsync(PageModule pageModule, DateTime lastIndexedOn)
|
||||
{
|
||||
var searchContentList = new List<SearchContent>();
|
||||
|
||||
return Task.FromResult(searchContentList);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user