mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Core - Refactored (unused) queued actions system
This commit is contained in:
1 parent
0ed367530f
commit
a6f52ce4a0
9 files changed
+134
-68
No files matched your search
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Storage.Entities.General
|
||||
{
|
||||
public class QueuedActionEntity
|
||||
{
|
||||
public QueuedActionEntity()
|
||||
{
|
||||
Parameters = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public string Type { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
|
||||
public Dictionary<string, object> Parameters { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -13,21 +13,4 @@ namespace Artemis.Storage.Entities.Plugins
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a queued action for a plugin
|
||||
/// </summary>
|
||||
public abstract class PluginQueuedActionEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid PluginGuid { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a queued delete action for a plugin
|
||||
/// </summary>
|
||||
public class PluginQueuedDeleteEntity : PluginQueuedActionEntity
|
||||
{
|
||||
public string Directory { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.Plugins;
|
||||
|
||||
namespace Artemis.Storage.Repositories.Interfaces
|
||||
@@ -9,16 +8,11 @@ namespace Artemis.Storage.Repositories.Interfaces
|
||||
void AddPlugin(PluginEntity pluginEntity);
|
||||
PluginEntity GetPluginByGuid(Guid pluginGuid);
|
||||
void SavePlugin(PluginEntity pluginEntity);
|
||||
|
||||
|
||||
void AddSetting(PluginSettingEntity pluginSettingEntity);
|
||||
PluginSettingEntity GetSettingByGuid(Guid pluginGuid);
|
||||
PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid);
|
||||
void SaveSetting(PluginSettingEntity pluginSettingEntity);
|
||||
void RemoveSettings(Guid pluginGuid);
|
||||
|
||||
void AddQueuedAction(PluginQueuedActionEntity pluginQueuedActionEntity);
|
||||
List<PluginQueuedActionEntity> GetQueuedActions();
|
||||
List<PluginQueuedActionEntity> GetQueuedActions(Guid pluginGuid);
|
||||
void RemoveQueuedAction(PluginQueuedActionEntity pluginQueuedActionEntity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.General;
|
||||
|
||||
namespace Artemis.Storage.Repositories.Interfaces
|
||||
{
|
||||
public interface IQueuedActionRepository : IRepository
|
||||
{
|
||||
void Add(QueuedActionEntity queuedActionEntity);
|
||||
void Remove(QueuedActionEntity queuedActionEntity);
|
||||
List<QueuedActionEntity> GetAll();
|
||||
List<QueuedActionEntity> GetByType(string type);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.Module;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Artemis.Storage.Repositories
|
||||
_repository = repository;
|
||||
|
||||
_repository.Database.GetCollection<PluginSettingEntity>().EnsureIndex(s => new {s.Name, s.PluginGuid}, true);
|
||||
_repository.Database.GetCollection<PluginQueuedActionEntity>().EnsureIndex(s => s.PluginGuid);
|
||||
}
|
||||
|
||||
public void AddPlugin(PluginEntity pluginEntity)
|
||||
@@ -59,24 +58,5 @@ namespace Artemis.Storage.Repositories
|
||||
{
|
||||
_repository.DeleteMany<PluginSettingEntity>(s => s.PluginGuid == pluginGuid);
|
||||
}
|
||||
|
||||
public List<PluginQueuedActionEntity> GetQueuedActions()
|
||||
{
|
||||
return _repository.Query<PluginQueuedActionEntity>().ToList();
|
||||
}
|
||||
|
||||
public List<PluginQueuedActionEntity> GetQueuedActions(Guid pluginGuid)
|
||||
{
|
||||
return _repository.Query<PluginQueuedActionEntity>().Where(q => q.PluginGuid == pluginGuid).ToList();
|
||||
}
|
||||
|
||||
public void AddQueuedAction(PluginQueuedActionEntity pluginQueuedActionEntity)
|
||||
{
|
||||
_repository.Upsert(pluginQueuedActionEntity);
|
||||
}
|
||||
public void RemoveQueuedAction(PluginQueuedActionEntity pluginQueuedActionEntity)
|
||||
{
|
||||
_repository.Delete<PluginQueuedActionEntity>(pluginQueuedActionEntity.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.General;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Repositories
|
||||
{
|
||||
public class QueuedActionRepository : IQueuedActionRepository
|
||||
{
|
||||
private readonly LiteRepository _repository;
|
||||
|
||||
public QueuedActionRepository(LiteRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
_repository.Database.GetCollection<QueuedActionEntity>().EnsureIndex(s => s.Type);
|
||||
}
|
||||
|
||||
#region Implementation of IQueuedActionRepository
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Add(QueuedActionEntity queuedActionEntity)
|
||||
{
|
||||
_repository.Insert(queuedActionEntity);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Remove(QueuedActionEntity queuedActionEntity)
|
||||
{
|
||||
_repository.Delete<QueuedActionEntity>(queuedActionEntity.Id);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<QueuedActionEntity> GetAll()
|
||||
{
|
||||
return _repository.Query<QueuedActionEntity>().ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<QueuedActionEntity> GetByType(string type)
|
||||
{
|
||||
return _repository.Query<QueuedActionEntity>().Where(q => q.Type == type).ToList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user