77 lines
2.6 KiB
C#
77 lines
2.6 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|