feat: add main plugin class
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Services.Plugins;
|
||||
using Disco.Services.Tasks;
|
||||
|
||||
namespace Disco.Plugins.ServiceTracker
|
||||
{
|
||||
[Plugin(
|
||||
Id = "Disco.Plugins.ServiceTracker",
|
||||
Name = "Service Tracker",
|
||||
Author = "Jess Rogerson",
|
||||
Url = "https://gitea.hideawaygaming.com.au/jessikitty/disco-service-tracker-plugin"
|
||||
)]
|
||||
public class ServiceTrackerPlugin : Plugin
|
||||
{
|
||||
public override void Initialize(DiscoDataContext Database)
|
||||
{
|
||||
// UIExtension registration is handled automatically by the plugin system
|
||||
// via the [PluginFeature] attributes on the UIExtension classes.
|
||||
// No manual registration needed here.
|
||||
}
|
||||
|
||||
public override void Install(DiscoDataContext Database, ScheduledTaskStatus Status)
|
||||
{
|
||||
Status.UpdateStatus(0, "Installing Service Tracker Plugin...");
|
||||
|
||||
// Ensure data directory exists
|
||||
var dataPath = PluginConfigurationHandler.GetPluginDataDirectory(this);
|
||||
if (!System.IO.Directory.Exists(dataPath))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(dataPath);
|
||||
}
|
||||
|
||||
// Initialize default configuration
|
||||
var configPath = System.IO.Path.Combine(dataPath, "config.json");
|
||||
if (!System.IO.File.Exists(configPath))
|
||||
{
|
||||
var defaultConfig = Models.ServiceTrackerConfig.CreateDefault();
|
||||
var json = Newtonsoft.Json.JsonConvert.SerializeObject(defaultConfig, Newtonsoft.Json.Formatting.Indented);
|
||||
System.IO.File.WriteAllText(configPath, json);
|
||||
}
|
||||
|
||||
// Initialize empty tickets store
|
||||
var ticketsPath = System.IO.Path.Combine(dataPath, "tickets.json");
|
||||
if (!System.IO.File.Exists(ticketsPath))
|
||||
{
|
||||
System.IO.File.WriteAllText(ticketsPath, "[]");
|
||||
}
|
||||
|
||||
Status.UpdateStatus(100, "Installation Complete");
|
||||
}
|
||||
|
||||
public override void Uninstall(DiscoDataContext Database, bool UninstallData, ScheduledTaskStatus Status)
|
||||
{
|
||||
Status.UpdateStatus(0, "Uninstalling Service Tracker Plugin...");
|
||||
if (UninstallData)
|
||||
{
|
||||
var dataPath = PluginConfigurationHandler.GetPluginDataDirectory(this);
|
||||
if (System.IO.Directory.Exists(dataPath))
|
||||
{
|
||||
System.IO.Directory.Delete(dataPath, true);
|
||||
}
|
||||
}
|
||||
Status.UpdateStatus(100, "Uninstallation Complete");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user