mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 03:19:56 +00:00
Code style - Use file scoped namespaces
Code style - Ran code cleanup
This commit is contained in:
1 parent
e68e16df4d
commit
f6090dc296
691 files changed
+37301
-38119
No files matched your search
@@ -1,19 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Storage.Entities.General
|
||||
namespace Artemis.Storage.Entities.General;
|
||||
|
||||
public class QueuedActionEntity
|
||||
{
|
||||
public class QueuedActionEntity
|
||||
public 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; }
|
||||
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; }
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Storage.Entities.General
|
||||
{
|
||||
public class ScriptConfigurationEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
namespace Artemis.Storage.Entities.General;
|
||||
|
||||
public string Name { get; set; }
|
||||
public string ScriptingProviderId { get; set; }
|
||||
public string ScriptContent { get; set; }
|
||||
}
|
||||
public class ScriptConfigurationEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string ScriptingProviderId { get; set; }
|
||||
public string ScriptContent { get; set; }
|
||||
}
|
||||
@@ -1,30 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Storage.Entities.Plugins
|
||||
namespace Artemis.Storage.Entities.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the configuration of a plugin, each plugin has one configuration
|
||||
/// </summary>
|
||||
public class PluginEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the configuration of a plugin, each plugin has one configuration
|
||||
/// </summary>
|
||||
public class PluginEntity
|
||||
public PluginEntity()
|
||||
{
|
||||
public PluginEntity()
|
||||
{
|
||||
Features = new List<PluginFeatureEntity>();
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
public List<PluginFeatureEntity> Features { get; set; }
|
||||
Features = new List<PluginFeatureEntity>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the configuration of a plugin feature, each feature has one configuration
|
||||
/// </summary>
|
||||
public class PluginFeatureEntity
|
||||
{
|
||||
public string Type { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
public Guid Id { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
public List<PluginFeatureEntity> Features { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the configuration of a plugin feature, each feature has one configuration
|
||||
/// </summary>
|
||||
public class PluginFeatureEntity
|
||||
{
|
||||
public string Type { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Storage.Entities.Plugins
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the setting of a plugin, a plugin can have multiple settings
|
||||
/// </summary>
|
||||
public class PluginSettingEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid PluginGuid { get; set; }
|
||||
namespace Artemis.Storage.Entities.Plugins;
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Represents the setting of a plugin, a plugin can have multiple settings
|
||||
/// </summary>
|
||||
public class PluginSettingEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid PluginGuid { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile.Abstract
|
||||
namespace Artemis.Storage.Entities.Profile.Abstract;
|
||||
|
||||
public abstract class DataModelConditionPartEntity
|
||||
{
|
||||
public abstract class DataModelConditionPartEntity
|
||||
{
|
||||
public List<DataModelConditionPartEntity> Children { get; set; }
|
||||
}
|
||||
public List<DataModelConditionPartEntity> Children { get; set; }
|
||||
}
|
||||
@@ -1,19 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.Profile.Conditions;
|
||||
using Artemis.Storage.Entities.Profile.Nodes;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile.Abstract
|
||||
namespace Artemis.Storage.Entities.Profile.Abstract;
|
||||
|
||||
public abstract class RenderElementEntity
|
||||
{
|
||||
public abstract class RenderElementEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid ParentId { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
public Guid ParentId { get; set; }
|
||||
|
||||
public List<LayerEffectEntity> LayerEffects { get; set; }
|
||||
public List<PropertyEntity> PropertyEntities { get; set; }
|
||||
public List<LayerEffectEntity> LayerEffects { get; set; }
|
||||
public List<PropertyEntity> PropertyEntities { get; set; }
|
||||
|
||||
public IConditionEntity DisplayCondition { get; set; }
|
||||
public TimelineEntity Timeline { get; set; }
|
||||
}
|
||||
public IConditionEntity DisplayCondition { get; set; }
|
||||
public TimelineEntity Timeline { get; set; }
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
namespace Artemis.Storage.Entities.Profile.AdaptionHints
|
||||
{
|
||||
public class CategoryAdaptionHintEntity : IAdaptionHintEntity
|
||||
{
|
||||
public int Category { get; set; }
|
||||
namespace Artemis.Storage.Entities.Profile.AdaptionHints;
|
||||
|
||||
public bool LimitAmount { get; set; }
|
||||
public int Skip { get; set; }
|
||||
public int Amount { get; set; }
|
||||
}
|
||||
public class CategoryAdaptionHintEntity : IAdaptionHintEntity
|
||||
{
|
||||
public int Category { get; set; }
|
||||
|
||||
public bool LimitAmount { get; set; }
|
||||
public int Skip { get; set; }
|
||||
public int Amount { get; set; }
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
namespace Artemis.Storage.Entities.Profile.AdaptionHints
|
||||
namespace Artemis.Storage.Entities.Profile.AdaptionHints;
|
||||
|
||||
public class DeviceAdaptionHintEntity : IAdaptionHintEntity
|
||||
{
|
||||
public class DeviceAdaptionHintEntity : IAdaptionHintEntity
|
||||
{
|
||||
public int DeviceType { get; set; }
|
||||
|
||||
public bool LimitAmount { get; set; }
|
||||
public int Skip { get; set; }
|
||||
public int Amount { get; set; }
|
||||
}
|
||||
public int DeviceType { get; set; }
|
||||
|
||||
public bool LimitAmount { get; set; }
|
||||
public int Skip { get; set; }
|
||||
public int Amount { get; set; }
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
namespace Artemis.Storage.Entities.Profile.AdaptionHints
|
||||
namespace Artemis.Storage.Entities.Profile.AdaptionHints;
|
||||
|
||||
public interface IAdaptionHintEntity
|
||||
{
|
||||
public interface IAdaptionHintEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
+4
-5
@@ -1,7 +1,6 @@
|
||||
namespace Artemis.Storage.Entities.Profile.AdaptionHints
|
||||
namespace Artemis.Storage.Entities.Profile.AdaptionHints;
|
||||
|
||||
public class KeyboardSectionAdaptionHintEntity : IAdaptionHintEntity
|
||||
{
|
||||
public class KeyboardSectionAdaptionHintEntity : IAdaptionHintEntity
|
||||
{
|
||||
public int Section { get; set; }
|
||||
}
|
||||
public int Section { get; set; }
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
using Artemis.Storage.Entities.Profile.Abstract;
|
||||
using Artemis.Storage.Entities.Profile.Nodes;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile.Conditions
|
||||
namespace Artemis.Storage.Entities.Profile.Conditions;
|
||||
|
||||
public class AlwaysOnConditionEntity : IConditionEntity
|
||||
{
|
||||
public class AlwaysOnConditionEntity : IConditionEntity
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
using Artemis.Storage.Entities.Profile.Abstract;
|
||||
using Artemis.Storage.Entities.Profile.Nodes;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile.Conditions
|
||||
namespace Artemis.Storage.Entities.Profile.Conditions;
|
||||
|
||||
public class EventConditionEntity : IConditionEntity
|
||||
{
|
||||
public class EventConditionEntity : IConditionEntity
|
||||
{
|
||||
public int TriggerMode { get; set; }
|
||||
public int OverlapMode { get; set; }
|
||||
public int ToggleOffMode { get; set; }
|
||||
public DataModelPathEntity EventPath { get; set; }
|
||||
public NodeScriptEntity Script { get; set; }
|
||||
}
|
||||
public int TriggerMode { get; set; }
|
||||
public int OverlapMode { get; set; }
|
||||
public int ToggleOffMode { get; set; }
|
||||
public DataModelPathEntity EventPath { get; set; }
|
||||
public NodeScriptEntity Script { get; set; }
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
namespace Artemis.Storage.Entities.Profile.Abstract
|
||||
namespace Artemis.Storage.Entities.Profile.Abstract;
|
||||
|
||||
public interface IConditionEntity
|
||||
{
|
||||
public interface IConditionEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
using Artemis.Storage.Entities.Profile.Abstract;
|
||||
using Artemis.Storage.Entities.Profile.Nodes;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile.Conditions
|
||||
namespace Artemis.Storage.Entities.Profile.Conditions;
|
||||
|
||||
public class PlayOnceConditionEntity : IConditionEntity
|
||||
{
|
||||
public class PlayOnceConditionEntity : IConditionEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
using Artemis.Storage.Entities.Profile.Abstract;
|
||||
using Artemis.Storage.Entities.Profile.Nodes;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile.Conditions
|
||||
namespace Artemis.Storage.Entities.Profile.Conditions;
|
||||
|
||||
public class StaticConditionEntity : IConditionEntity
|
||||
{
|
||||
public class StaticConditionEntity : IConditionEntity
|
||||
{
|
||||
public int PlayMode { get; set; }
|
||||
public int StopMode { get; set; }
|
||||
public NodeScriptEntity Script { get; set; }
|
||||
}
|
||||
public int PlayMode { get; set; }
|
||||
public int StopMode { get; set; }
|
||||
public NodeScriptEntity Script { get; set; }
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
using Artemis.Storage.Entities.Profile.Nodes;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile.DataBindings
|
||||
namespace Artemis.Storage.Entities.Profile.DataBindings;
|
||||
|
||||
public class DataBindingEntity
|
||||
{
|
||||
public class DataBindingEntity
|
||||
{
|
||||
public string Identifier { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
public NodeScriptEntity NodeScript { get; set; }
|
||||
}
|
||||
public string Identifier { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
public NodeScriptEntity NodeScript { get; set; }
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
using System;
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
public class DataModelPathEntity
|
||||
{
|
||||
public class DataModelPathEntity
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public string DataModelId { get; set; }
|
||||
}
|
||||
public string Path { get; set; }
|
||||
public string DataModelId { get; set; }
|
||||
}
|
||||
@@ -3,24 +3,23 @@ using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.Profile.Abstract;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class FolderEntity : RenderElementEntity
|
||||
{
|
||||
public class FolderEntity : RenderElementEntity
|
||||
public FolderEntity()
|
||||
{
|
||||
public FolderEntity()
|
||||
{
|
||||
PropertyEntities = new List<PropertyEntity>();
|
||||
LayerEffects = new List<LayerEffectEntity>();
|
||||
}
|
||||
|
||||
public int Order { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool IsExpanded { get; set; }
|
||||
public bool Suspended { get; set; }
|
||||
|
||||
[BsonRef("ProfileEntity")]
|
||||
public ProfileEntity Profile { get; set; }
|
||||
|
||||
public Guid ProfileId { get; set; }
|
||||
PropertyEntities = new List<PropertyEntity>();
|
||||
LayerEffects = new List<LayerEffectEntity>();
|
||||
}
|
||||
|
||||
public int Order { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool IsExpanded { get; set; }
|
||||
public bool Suspended { get; set; }
|
||||
|
||||
[BsonRef("ProfileEntity")]
|
||||
public ProfileEntity Profile { get; set; }
|
||||
|
||||
public Guid ProfileId { get; set; }
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class KeyframeEntity
|
||||
{
|
||||
public class KeyframeEntity
|
||||
{
|
||||
public TimeSpan Position { get; set; }
|
||||
public int Timeline { get; set; }
|
||||
public string Value { get; set; }
|
||||
public int EasingFunction { get; set; }
|
||||
}
|
||||
public TimeSpan Position { get; set; }
|
||||
public int Timeline { get; set; }
|
||||
public string Value { get; set; }
|
||||
public int EasingFunction { get; set; }
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class LayerBrushEntity
|
||||
{
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
public class LayerEffectEntity
|
||||
{
|
||||
public class LayerEffectEntity
|
||||
{
|
||||
public string ProviderId { get; set; }
|
||||
public string EffectType { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool HasBeenRenamed { get; set; }
|
||||
public int Order { get; set; }
|
||||
public string ProviderId { get; set; }
|
||||
public string EffectType { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool HasBeenRenamed { get; set; }
|
||||
public int Order { get; set; }
|
||||
|
||||
public PropertyGroupEntity PropertyGroup { get; set; }
|
||||
}
|
||||
public PropertyGroupEntity PropertyGroup { get; set; }
|
||||
}
|
||||
@@ -4,31 +4,31 @@ using Artemis.Storage.Entities.Profile.Abstract;
|
||||
using Artemis.Storage.Entities.Profile.AdaptionHints;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class LayerEntity : RenderElementEntity
|
||||
{
|
||||
public class LayerEntity : RenderElementEntity
|
||||
public LayerEntity()
|
||||
{
|
||||
public LayerEntity()
|
||||
{
|
||||
Leds = new List<LedEntity>();
|
||||
AdaptionHints = new List<IAdaptionHintEntity>();
|
||||
PropertyEntities = new List<PropertyEntity>();
|
||||
LayerEffects = new List<LayerEffectEntity>();
|
||||
}
|
||||
|
||||
public int Order { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool Suspended { get; set; }
|
||||
|
||||
public List<LedEntity> Leds { get; set; }
|
||||
public List<IAdaptionHintEntity> AdaptionHints { get; set; }
|
||||
|
||||
public PropertyGroupEntity GeneralPropertyGroup { get; set; }
|
||||
public PropertyGroupEntity TransformPropertyGroup { get; set; }
|
||||
public LayerBrushEntity LayerBrush { get; set; }
|
||||
|
||||
[BsonRef("ProfileEntity")]
|
||||
public ProfileEntity Profile { get; set; }
|
||||
public Guid ProfileId { get; set; }
|
||||
Leds = new List<LedEntity>();
|
||||
AdaptionHints = new List<IAdaptionHintEntity>();
|
||||
PropertyEntities = new List<PropertyEntity>();
|
||||
LayerEffects = new List<LayerEffectEntity>();
|
||||
}
|
||||
|
||||
public int Order { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool Suspended { get; set; }
|
||||
|
||||
public List<LedEntity> Leds { get; set; }
|
||||
public List<IAdaptionHintEntity> AdaptionHints { get; set; }
|
||||
|
||||
public PropertyGroupEntity GeneralPropertyGroup { get; set; }
|
||||
public PropertyGroupEntity TransformPropertyGroup { get; set; }
|
||||
public LayerBrushEntity LayerBrush { get; set; }
|
||||
|
||||
[BsonRef("ProfileEntity")]
|
||||
public ProfileEntity Profile { get; set; }
|
||||
|
||||
public Guid ProfileId { get; set; }
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
{
|
||||
public class LedEntity
|
||||
{
|
||||
public string LedName { get; set; }
|
||||
public string DeviceIdentifier { get; set; }
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public int? PhysicalLayout { get; set; }
|
||||
}
|
||||
public class LedEntity
|
||||
{
|
||||
public string LedName { get; set; }
|
||||
public string DeviceIdentifier { get; set; }
|
||||
|
||||
public int? PhysicalLayout { get; set; }
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile.Nodes
|
||||
namespace Artemis.Storage.Entities.Profile.Nodes;
|
||||
|
||||
public class NodeConnectionEntity
|
||||
{
|
||||
public class NodeConnectionEntity
|
||||
{
|
||||
public string SourceType { get; set; }
|
||||
public Guid SourceNode { get; set; }
|
||||
public Guid TargetNode { get; set; }
|
||||
public int SourcePinCollectionId { get; set; }
|
||||
public int SourcePinId { get; set; }
|
||||
public string TargetType { get; set; }
|
||||
public int TargetPinCollectionId { get; set; }
|
||||
public int TargetPinId { get; set; }
|
||||
}
|
||||
public string SourceType { get; set; }
|
||||
public Guid SourceNode { get; set; }
|
||||
public Guid TargetNode { get; set; }
|
||||
public int SourcePinCollectionId { get; set; }
|
||||
public int SourcePinId { get; set; }
|
||||
public string TargetType { get; set; }
|
||||
public int TargetPinCollectionId { get; set; }
|
||||
public int TargetPinId { get; set; }
|
||||
}
|
||||
@@ -1,26 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile.Nodes
|
||||
namespace Artemis.Storage.Entities.Profile.Nodes;
|
||||
|
||||
public class NodeEntity
|
||||
{
|
||||
public class NodeEntity
|
||||
public NodeEntity()
|
||||
{
|
||||
public NodeEntity()
|
||||
{
|
||||
PinCollections = new List<NodePinCollectionEntity>();
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public string Type { get; set; }
|
||||
public Guid PluginId { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public bool IsExitNode { get; set; }
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
public string Storage { get; set; }
|
||||
|
||||
public List<NodePinCollectionEntity> PinCollections { get; set; }
|
||||
PinCollections = new List<NodePinCollectionEntity>();
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public string Type { get; set; }
|
||||
public Guid PluginId { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public bool IsExitNode { get; set; }
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
public string Storage { get; set; }
|
||||
|
||||
public List<NodePinCollectionEntity> PinCollections { get; set; }
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
namespace Artemis.Storage.Entities.Profile.Nodes
|
||||
namespace Artemis.Storage.Entities.Profile.Nodes;
|
||||
|
||||
public class NodePinCollectionEntity
|
||||
{
|
||||
public class NodePinCollectionEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int Direction { set; get; }
|
||||
public int Amount { get; set; }
|
||||
}
|
||||
public int Id { get; set; }
|
||||
public int Direction { set; get; }
|
||||
public int Amount { get; set; }
|
||||
}
|
||||
@@ -1,19 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile.Nodes
|
||||
namespace Artemis.Storage.Entities.Profile.Nodes;
|
||||
|
||||
public class NodeScriptEntity
|
||||
{
|
||||
public class NodeScriptEntity
|
||||
public NodeScriptEntity()
|
||||
{
|
||||
public NodeScriptEntity()
|
||||
{
|
||||
Nodes = new List<NodeEntity>();
|
||||
Connections = new List<NodeConnectionEntity>();
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
public List<NodeEntity> Nodes { get; set; }
|
||||
public List<NodeConnectionEntity> Connections { get; set; }
|
||||
Nodes = new List<NodeEntity>();
|
||||
Connections = new List<NodeConnectionEntity>();
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
public List<NodeEntity> Nodes { get; set; }
|
||||
public List<NodeConnectionEntity> Connections { get; set; }
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class ProfileCategoryEntity
|
||||
{
|
||||
public class ProfileCategoryEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public bool IsCollapsed { get; set; }
|
||||
public bool IsSuspended { get; set; }
|
||||
public int Order { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool IsCollapsed { get; set; }
|
||||
public bool IsSuspended { get; set; }
|
||||
public int Order { get; set; }
|
||||
|
||||
public List<ProfileConfigurationEntity> ProfileConfigurations { get; set; } = new();
|
||||
}
|
||||
public List<ProfileConfigurationEntity> ProfileConfigurations { get; set; } = new();
|
||||
}
|
||||
@@ -1,29 +1,28 @@
|
||||
using System;
|
||||
using Artemis.Storage.Entities.Profile.Nodes;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class ProfileConfigurationEntity
|
||||
{
|
||||
public class ProfileConfigurationEntity
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string MaterialIcon { get; set; }
|
||||
public string IconOriginalFileName { get; set; }
|
||||
public Guid FileIconId { get; set; }
|
||||
public int IconType { get; set; }
|
||||
public bool IconFill { get; set; }
|
||||
public int Order { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string MaterialIcon { get; set; }
|
||||
public string IconOriginalFileName { get; set; }
|
||||
public Guid FileIconId { get; set; }
|
||||
public int IconType { get; set; }
|
||||
public bool IconFill { get; set; }
|
||||
public int Order { get; set; }
|
||||
|
||||
public bool IsSuspended { get; set; }
|
||||
public int ActivationBehaviour { get; set; }
|
||||
public NodeScriptEntity ActivationCondition { get; set; }
|
||||
public bool IsSuspended { get; set; }
|
||||
public int ActivationBehaviour { get; set; }
|
||||
public NodeScriptEntity ActivationCondition { get; set; }
|
||||
|
||||
public int HotkeyMode { get; set; }
|
||||
public ProfileConfigurationHotkeyEntity EnableHotkey { get; set; }
|
||||
public ProfileConfigurationHotkeyEntity DisableHotkey { get; set; }
|
||||
public int HotkeyMode { get; set; }
|
||||
public ProfileConfigurationHotkeyEntity EnableHotkey { get; set; }
|
||||
public ProfileConfigurationHotkeyEntity DisableHotkey { get; set; }
|
||||
|
||||
public string ModuleId { get; set; }
|
||||
public string ModuleId { get; set; }
|
||||
|
||||
public Guid ProfileCategoryId { get; set; }
|
||||
public Guid ProfileId { get; set; }
|
||||
}
|
||||
public Guid ProfileCategoryId { get; set; }
|
||||
public Guid ProfileId { get; set; }
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class ProfileConfigurationHotkeyEntity
|
||||
{
|
||||
public class ProfileConfigurationHotkeyEntity
|
||||
{
|
||||
public int? Key { get; set; }
|
||||
public int? Modifiers { get; set; }
|
||||
}
|
||||
public int? Key { get; set; }
|
||||
public int? Modifiers { get; set; }
|
||||
}
|
||||
@@ -3,35 +3,34 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Storage.Entities.General;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class ProfileEntity
|
||||
{
|
||||
public class ProfileEntity
|
||||
public ProfileEntity()
|
||||
{
|
||||
public ProfileEntity()
|
||||
{
|
||||
Folders = new List<FolderEntity>();
|
||||
Layers = new List<LayerEntity>();
|
||||
ScriptConfigurations = new List<ScriptConfigurationEntity>();
|
||||
}
|
||||
Folders = new List<FolderEntity>();
|
||||
Layers = new List<LayerEntity>();
|
||||
ScriptConfigurations = new List<ScriptConfigurationEntity>();
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public bool IsFreshImport { get; set; }
|
||||
public Guid LastSelectedProfileElement { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool IsFreshImport { get; set; }
|
||||
public Guid LastSelectedProfileElement { get; set; }
|
||||
|
||||
public List<FolderEntity> Folders { get; set; }
|
||||
public List<LayerEntity> Layers { get; set; }
|
||||
public List<ScriptConfigurationEntity> ScriptConfigurations { get; set; }
|
||||
public List<FolderEntity> Folders { get; set; }
|
||||
public List<LayerEntity> Layers { get; set; }
|
||||
public List<ScriptConfigurationEntity> ScriptConfigurations { get; set; }
|
||||
|
||||
public void UpdateGuid(Guid guid)
|
||||
{
|
||||
Guid oldGuid = Id;
|
||||
Id = guid;
|
||||
public void UpdateGuid(Guid guid)
|
||||
{
|
||||
Guid oldGuid = Id;
|
||||
Id = guid;
|
||||
|
||||
FolderEntity rootFolder = Folders.FirstOrDefault(f => f.ParentId == oldGuid);
|
||||
if (rootFolder != null)
|
||||
rootFolder.ParentId = Id;
|
||||
}
|
||||
FolderEntity rootFolder = Folders.FirstOrDefault(f => f.ParentId == oldGuid);
|
||||
if (rootFolder != null)
|
||||
rootFolder.ParentId = Id;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class TimelineEntity
|
||||
{
|
||||
public class TimelineEntity
|
||||
{
|
||||
public TimeSpan StartSegmentLength { get; set; }
|
||||
public TimeSpan MainSegmentLength { get; set; }
|
||||
public TimeSpan EndSegmentLength { get; set; }
|
||||
}
|
||||
public TimeSpan StartSegmentLength { get; set; }
|
||||
public TimeSpan MainSegmentLength { get; set; }
|
||||
public TimeSpan EndSegmentLength { get; set; }
|
||||
}
|
||||
@@ -1,47 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Storage.Entities.Surface
|
||||
namespace Artemis.Storage.Entities.Surface;
|
||||
|
||||
public class DeviceEntity
|
||||
{
|
||||
public class DeviceEntity
|
||||
public DeviceEntity()
|
||||
{
|
||||
public DeviceEntity()
|
||||
{
|
||||
InputIdentifiers = new List<DeviceInputIdentifierEntity>();
|
||||
InputMappings = new List<InputMappingEntity>();
|
||||
Categories = new List<int>();
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string DeviceProvider { get; set; }
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
public float Rotation { get; set; }
|
||||
public float Scale { get; set; }
|
||||
public int ZIndex { get; set; }
|
||||
public float RedScale { get; set; }
|
||||
public float GreenScale { get; set; }
|
||||
public float BlueScale { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
public bool DisableDefaultLayout { get; set; }
|
||||
public int PhysicalLayout { get; set; }
|
||||
public string LogicalLayout { get; set; }
|
||||
public string CustomLayoutPath { get; set; }
|
||||
|
||||
public List<DeviceInputIdentifierEntity> InputIdentifiers { get; set; }
|
||||
public List<InputMappingEntity> InputMappings { get; set; }
|
||||
public List<int> Categories { get; set; }
|
||||
InputIdentifiers = new List<DeviceInputIdentifierEntity>();
|
||||
InputMappings = new List<InputMappingEntity>();
|
||||
Categories = new List<int>();
|
||||
}
|
||||
|
||||
public class InputMappingEntity
|
||||
{
|
||||
public int OriginalLedId { get; set; }
|
||||
public int MappedLedId { get; set; }
|
||||
}
|
||||
public string Id { get; set; }
|
||||
public string DeviceProvider { get; set; }
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
public float Rotation { get; set; }
|
||||
public float Scale { get; set; }
|
||||
public int ZIndex { get; set; }
|
||||
public float RedScale { get; set; }
|
||||
public float GreenScale { get; set; }
|
||||
public float BlueScale { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
public class DeviceInputIdentifierEntity
|
||||
{
|
||||
public string InputProvider { get; set; }
|
||||
public object Identifier { get; set; }
|
||||
}
|
||||
public bool DisableDefaultLayout { get; set; }
|
||||
public int PhysicalLayout { get; set; }
|
||||
public string LogicalLayout { get; set; }
|
||||
public string CustomLayoutPath { get; set; }
|
||||
|
||||
public List<DeviceInputIdentifierEntity> InputIdentifiers { get; set; }
|
||||
public List<InputMappingEntity> InputMappings { get; set; }
|
||||
public List<int> Categories { get; set; }
|
||||
}
|
||||
|
||||
public class InputMappingEntity
|
||||
{
|
||||
public int OriginalLedId { get; set; }
|
||||
public int MappedLedId { get; set; }
|
||||
}
|
||||
|
||||
public class DeviceInputIdentifierEntity
|
||||
{
|
||||
public string InputProvider { get; set; }
|
||||
public object Identifier { get; set; }
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Migrations.Interfaces
|
||||
namespace Artemis.Storage.Migrations.Interfaces;
|
||||
|
||||
public interface IStorageMigration
|
||||
{
|
||||
public interface IStorageMigration
|
||||
{
|
||||
int UserVersion { get; }
|
||||
void Apply(LiteRepository repository);
|
||||
}
|
||||
int UserVersion { get; }
|
||||
void Apply(LiteRepository repository);
|
||||
}
|
||||
@@ -1,22 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.Storage.Migrations.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Migrations
|
||||
{
|
||||
public class M0020AvaloniaReset : IStorageMigration
|
||||
{
|
||||
public int UserVersion => 20;
|
||||
namespace Artemis.Storage.Migrations;
|
||||
|
||||
public void Apply(LiteRepository repository)
|
||||
{
|
||||
repository.Database.Commit();
|
||||
|
||||
List<string> collectionNames = repository.Database.GetCollectionNames().ToList();
|
||||
foreach (string collectionName in collectionNames)
|
||||
repository.Database.DropCollection(collectionName);
|
||||
}
|
||||
public class M0020AvaloniaReset : IStorageMigration
|
||||
{
|
||||
public int UserVersion => 20;
|
||||
|
||||
public void Apply(LiteRepository repository)
|
||||
{
|
||||
repository.Database.Commit();
|
||||
|
||||
List<string> collectionNames = repository.Database.GetCollectionNames().ToList();
|
||||
foreach (string collectionName in collectionNames)
|
||||
repository.Database.DropCollection(collectionName);
|
||||
}
|
||||
}
|
||||
@@ -3,46 +3,45 @@ using Artemis.Storage.Entities.Surface;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Repositories
|
||||
namespace Artemis.Storage.Repositories;
|
||||
|
||||
internal class DeviceRepository : IDeviceRepository
|
||||
{
|
||||
internal class DeviceRepository : IDeviceRepository
|
||||
private readonly LiteRepository _repository;
|
||||
|
||||
public DeviceRepository(LiteRepository repository)
|
||||
{
|
||||
private readonly LiteRepository _repository;
|
||||
_repository = repository;
|
||||
_repository.Database.GetCollection<DeviceEntity>().EnsureIndex(s => s.Id);
|
||||
}
|
||||
|
||||
public DeviceRepository(LiteRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
_repository.Database.GetCollection<DeviceEntity>().EnsureIndex(s => s.Id);
|
||||
}
|
||||
public void Add(DeviceEntity deviceEntity)
|
||||
{
|
||||
_repository.Insert(deviceEntity);
|
||||
}
|
||||
|
||||
public void Add(DeviceEntity deviceEntity)
|
||||
{
|
||||
_repository.Insert(deviceEntity);
|
||||
}
|
||||
public void Remove(DeviceEntity deviceEntity)
|
||||
{
|
||||
_repository.Delete<DeviceEntity>(deviceEntity.Id);
|
||||
}
|
||||
|
||||
public void Remove(DeviceEntity deviceEntity)
|
||||
{
|
||||
_repository.Delete<DeviceEntity>(deviceEntity.Id);
|
||||
}
|
||||
public DeviceEntity Get(string id)
|
||||
{
|
||||
return _repository.FirstOrDefault<DeviceEntity>(s => s.Id == id);
|
||||
}
|
||||
|
||||
public DeviceEntity Get(string id)
|
||||
{
|
||||
return _repository.FirstOrDefault<DeviceEntity>(s => s.Id == id);
|
||||
}
|
||||
public List<DeviceEntity> GetAll()
|
||||
{
|
||||
return _repository.Query<DeviceEntity>().Include(s => s.InputIdentifiers).ToList();
|
||||
}
|
||||
|
||||
public List<DeviceEntity> GetAll()
|
||||
{
|
||||
return _repository.Query<DeviceEntity>().Include(s => s.InputIdentifiers).ToList();
|
||||
}
|
||||
public void Save(DeviceEntity deviceEntity)
|
||||
{
|
||||
_repository.Upsert(deviceEntity);
|
||||
}
|
||||
|
||||
public void Save(DeviceEntity deviceEntity)
|
||||
{
|
||||
_repository.Upsert(deviceEntity);
|
||||
}
|
||||
|
||||
public void Save(IEnumerable<DeviceEntity> deviceEntities)
|
||||
{
|
||||
_repository.Upsert(deviceEntities);
|
||||
}
|
||||
public void Save(IEnumerable<DeviceEntity> deviceEntities)
|
||||
{
|
||||
_repository.Upsert(deviceEntities);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.Surface;
|
||||
|
||||
namespace Artemis.Storage.Repositories.Interfaces
|
||||
namespace Artemis.Storage.Repositories.Interfaces;
|
||||
|
||||
public interface IDeviceRepository : IRepository
|
||||
{
|
||||
public interface IDeviceRepository : IRepository
|
||||
{
|
||||
void Add(DeviceEntity deviceEntity);
|
||||
void Remove(DeviceEntity deviceEntity);
|
||||
DeviceEntity Get(string id);
|
||||
List<DeviceEntity> GetAll();
|
||||
void Save(DeviceEntity deviceEntity);
|
||||
void Save(IEnumerable<DeviceEntity> deviceEntities);
|
||||
}
|
||||
void Add(DeviceEntity deviceEntity);
|
||||
void Remove(DeviceEntity deviceEntity);
|
||||
DeviceEntity Get(string id);
|
||||
List<DeviceEntity> GetAll();
|
||||
void Save(DeviceEntity deviceEntity);
|
||||
void Save(IEnumerable<DeviceEntity> deviceEntities);
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
using System;
|
||||
using Artemis.Storage.Entities.Plugins;
|
||||
|
||||
namespace Artemis.Storage.Repositories.Interfaces
|
||||
{
|
||||
public interface IPluginRepository : IRepository
|
||||
{
|
||||
void AddPlugin(PluginEntity pluginEntity);
|
||||
PluginEntity GetPluginByGuid(Guid pluginGuid);
|
||||
void SavePlugin(PluginEntity pluginEntity);
|
||||
namespace Artemis.Storage.Repositories.Interfaces;
|
||||
|
||||
void AddSetting(PluginSettingEntity pluginSettingEntity);
|
||||
PluginSettingEntity GetSettingByGuid(Guid pluginGuid);
|
||||
PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid);
|
||||
void SaveSetting(PluginSettingEntity pluginSettingEntity);
|
||||
void RemoveSettings(Guid pluginGuid);
|
||||
}
|
||||
public interface IPluginRepository : IRepository
|
||||
{
|
||||
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);
|
||||
}
|
||||
@@ -3,17 +3,16 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
|
||||
namespace Artemis.Storage.Repositories.Interfaces
|
||||
namespace Artemis.Storage.Repositories.Interfaces;
|
||||
|
||||
public interface IProfileCategoryRepository : IRepository
|
||||
{
|
||||
public interface IProfileCategoryRepository : IRepository
|
||||
{
|
||||
void Add(ProfileCategoryEntity profileCategoryEntity);
|
||||
void Remove(ProfileCategoryEntity profileCategoryEntity);
|
||||
List<ProfileCategoryEntity> GetAll();
|
||||
ProfileCategoryEntity Get(Guid id);
|
||||
Stream GetProfileIconStream(Guid id);
|
||||
void SaveProfileIconStream(ProfileConfigurationEntity profileConfigurationEntity, Stream stream);
|
||||
ProfileCategoryEntity IsUnique(string name, Guid? id);
|
||||
void Save(ProfileCategoryEntity profileCategoryEntity);
|
||||
}
|
||||
void Add(ProfileCategoryEntity profileCategoryEntity);
|
||||
void Remove(ProfileCategoryEntity profileCategoryEntity);
|
||||
List<ProfileCategoryEntity> GetAll();
|
||||
ProfileCategoryEntity Get(Guid id);
|
||||
Stream GetProfileIconStream(Guid id);
|
||||
void SaveProfileIconStream(ProfileConfigurationEntity profileConfigurationEntity, Stream stream);
|
||||
ProfileCategoryEntity IsUnique(string name, Guid? id);
|
||||
void Save(ProfileCategoryEntity profileCategoryEntity);
|
||||
}
|
||||
@@ -2,14 +2,13 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
|
||||
namespace Artemis.Storage.Repositories.Interfaces
|
||||
namespace Artemis.Storage.Repositories.Interfaces;
|
||||
|
||||
public interface IProfileRepository : IRepository
|
||||
{
|
||||
public interface IProfileRepository : IRepository
|
||||
{
|
||||
void Add(ProfileEntity profileEntity);
|
||||
void Remove(ProfileEntity profileEntity);
|
||||
List<ProfileEntity> GetAll();
|
||||
ProfileEntity Get(Guid id);
|
||||
void Save(ProfileEntity profileEntity);
|
||||
}
|
||||
void Add(ProfileEntity profileEntity);
|
||||
void Remove(ProfileEntity profileEntity);
|
||||
List<ProfileEntity> GetAll();
|
||||
ProfileEntity Get(Guid id);
|
||||
void Save(ProfileEntity profileEntity);
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.General;
|
||||
|
||||
namespace Artemis.Storage.Repositories.Interfaces
|
||||
namespace Artemis.Storage.Repositories.Interfaces;
|
||||
|
||||
public interface IQueuedActionRepository : IRepository
|
||||
{
|
||||
public interface IQueuedActionRepository : IRepository
|
||||
{
|
||||
void Add(QueuedActionEntity queuedActionEntity);
|
||||
void Remove(QueuedActionEntity queuedActionEntity);
|
||||
List<QueuedActionEntity> GetAll();
|
||||
List<QueuedActionEntity> GetByType(string type);
|
||||
}
|
||||
void Add(QueuedActionEntity queuedActionEntity);
|
||||
void Remove(QueuedActionEntity queuedActionEntity);
|
||||
List<QueuedActionEntity> GetAll();
|
||||
List<QueuedActionEntity> GetByType(string type);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
namespace Artemis.Storage.Repositories.Interfaces
|
||||
namespace Artemis.Storage.Repositories.Interfaces;
|
||||
|
||||
public interface IRepository
|
||||
{
|
||||
public interface IRepository
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,62 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.Plugins;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Repositories
|
||||
namespace Artemis.Storage.Repositories;
|
||||
|
||||
internal class PluginRepository : IPluginRepository
|
||||
{
|
||||
internal class PluginRepository : IPluginRepository
|
||||
private readonly LiteRepository _repository;
|
||||
|
||||
public PluginRepository(LiteRepository repository)
|
||||
{
|
||||
private readonly LiteRepository _repository;
|
||||
_repository = repository;
|
||||
|
||||
public PluginRepository(LiteRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
_repository.Database.GetCollection<PluginSettingEntity>().EnsureIndex(s => new {s.Name, s.PluginGuid}, true);
|
||||
}
|
||||
|
||||
_repository.Database.GetCollection<PluginSettingEntity>().EnsureIndex(s => new {s.Name, s.PluginGuid}, true);
|
||||
}
|
||||
public void AddPlugin(PluginEntity pluginEntity)
|
||||
{
|
||||
_repository.Insert(pluginEntity);
|
||||
}
|
||||
|
||||
public void AddPlugin(PluginEntity pluginEntity)
|
||||
{
|
||||
_repository.Insert(pluginEntity);
|
||||
}
|
||||
public PluginEntity GetPluginByGuid(Guid pluginGuid)
|
||||
{
|
||||
return _repository.FirstOrDefault<PluginEntity>(p => p.Id == pluginGuid);
|
||||
}
|
||||
|
||||
public PluginEntity GetPluginByGuid(Guid pluginGuid)
|
||||
{
|
||||
return _repository.FirstOrDefault<PluginEntity>(p => p.Id == pluginGuid);
|
||||
}
|
||||
public void SavePlugin(PluginEntity pluginEntity)
|
||||
{
|
||||
_repository.Upsert(pluginEntity);
|
||||
_repository.Database.Checkpoint();
|
||||
}
|
||||
|
||||
public void SavePlugin(PluginEntity pluginEntity)
|
||||
{
|
||||
_repository.Upsert(pluginEntity);
|
||||
_repository.Database.Checkpoint();
|
||||
}
|
||||
public void AddSetting(PluginSettingEntity pluginSettingEntity)
|
||||
{
|
||||
_repository.Insert(pluginSettingEntity);
|
||||
}
|
||||
|
||||
public void AddSetting(PluginSettingEntity pluginSettingEntity)
|
||||
{
|
||||
_repository.Insert(pluginSettingEntity);
|
||||
}
|
||||
public PluginSettingEntity GetSettingByGuid(Guid pluginGuid)
|
||||
{
|
||||
return _repository.FirstOrDefault<PluginSettingEntity>(p => p.PluginGuid == pluginGuid);
|
||||
}
|
||||
|
||||
public PluginSettingEntity GetSettingByGuid(Guid pluginGuid)
|
||||
{
|
||||
return _repository.FirstOrDefault<PluginSettingEntity>(p => p.PluginGuid == pluginGuid);
|
||||
}
|
||||
public PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid)
|
||||
{
|
||||
return _repository.FirstOrDefault<PluginSettingEntity>(p => p.Name == name && p.PluginGuid == pluginGuid);
|
||||
}
|
||||
|
||||
public PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid)
|
||||
{
|
||||
return _repository.FirstOrDefault<PluginSettingEntity>(p => p.Name == name && p.PluginGuid == pluginGuid);
|
||||
}
|
||||
public void SaveSetting(PluginSettingEntity pluginSettingEntity)
|
||||
{
|
||||
_repository.Upsert(pluginSettingEntity);
|
||||
}
|
||||
|
||||
public void SaveSetting(PluginSettingEntity pluginSettingEntity)
|
||||
{
|
||||
_repository.Upsert(pluginSettingEntity);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void RemoveSettings(Guid pluginGuid)
|
||||
{
|
||||
_repository.DeleteMany<PluginSettingEntity>(s => s.PluginGuid == pluginGuid);
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public void RemoveSettings(Guid pluginGuid)
|
||||
{
|
||||
_repository.DeleteMany<PluginSettingEntity>(s => s.PluginGuid == pluginGuid);
|
||||
}
|
||||
}
|
||||
@@ -5,72 +5,71 @@ using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Repositories
|
||||
namespace Artemis.Storage.Repositories;
|
||||
|
||||
internal class ProfileCategoryRepository : IProfileCategoryRepository
|
||||
{
|
||||
internal class ProfileCategoryRepository : IProfileCategoryRepository
|
||||
private readonly ILiteStorage<Guid> _profileIcons;
|
||||
private readonly LiteRepository _repository;
|
||||
|
||||
public ProfileCategoryRepository(LiteRepository repository)
|
||||
{
|
||||
private readonly LiteRepository _repository;
|
||||
private readonly ILiteStorage<Guid> _profileIcons;
|
||||
_repository = repository;
|
||||
_repository.Database.GetCollection<ProfileCategoryEntity>().EnsureIndex(s => s.Name, true);
|
||||
_profileIcons = _repository.Database.GetStorage<Guid>("profileIcons");
|
||||
}
|
||||
|
||||
public ProfileCategoryRepository(LiteRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
_repository.Database.GetCollection<ProfileCategoryEntity>().EnsureIndex(s => s.Name, true);
|
||||
_profileIcons = _repository.Database.GetStorage<Guid>("profileIcons");
|
||||
}
|
||||
public void Add(ProfileCategoryEntity profileCategoryEntity)
|
||||
{
|
||||
_repository.Insert(profileCategoryEntity);
|
||||
}
|
||||
|
||||
public void Add(ProfileCategoryEntity profileCategoryEntity)
|
||||
{
|
||||
_repository.Insert(profileCategoryEntity);
|
||||
}
|
||||
public void Remove(ProfileCategoryEntity profileCategoryEntity)
|
||||
{
|
||||
_repository.Delete<ProfileCategoryEntity>(profileCategoryEntity.Id);
|
||||
}
|
||||
|
||||
public void Remove(ProfileCategoryEntity profileCategoryEntity)
|
||||
{
|
||||
_repository.Delete<ProfileCategoryEntity>(profileCategoryEntity.Id);
|
||||
}
|
||||
public List<ProfileCategoryEntity> GetAll()
|
||||
{
|
||||
return _repository.Query<ProfileCategoryEntity>().ToList();
|
||||
}
|
||||
|
||||
public List<ProfileCategoryEntity> GetAll()
|
||||
{
|
||||
return _repository.Query<ProfileCategoryEntity>().ToList();
|
||||
}
|
||||
public ProfileCategoryEntity Get(Guid id)
|
||||
{
|
||||
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Id == id);
|
||||
}
|
||||
|
||||
public ProfileCategoryEntity Get(Guid id)
|
||||
{
|
||||
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Id == id);
|
||||
}
|
||||
public ProfileCategoryEntity IsUnique(string name, Guid? id)
|
||||
{
|
||||
name = name.Trim();
|
||||
if (id == null)
|
||||
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Name == name);
|
||||
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Name == name && p.Id != id.Value);
|
||||
}
|
||||
|
||||
public ProfileCategoryEntity IsUnique(string name, Guid? id)
|
||||
{
|
||||
name = name.Trim();
|
||||
if (id == null)
|
||||
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Name == name);
|
||||
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Name == name && p.Id != id.Value);
|
||||
}
|
||||
public void Save(ProfileCategoryEntity profileCategoryEntity)
|
||||
{
|
||||
_repository.Upsert(profileCategoryEntity);
|
||||
}
|
||||
|
||||
public void Save(ProfileCategoryEntity profileCategoryEntity)
|
||||
{
|
||||
_repository.Upsert(profileCategoryEntity);
|
||||
}
|
||||
public Stream GetProfileIconStream(Guid id)
|
||||
{
|
||||
if (!_profileIcons.Exists(id))
|
||||
return null;
|
||||
|
||||
public Stream GetProfileIconStream(Guid id)
|
||||
{
|
||||
if (!_profileIcons.Exists(id))
|
||||
return null;
|
||||
MemoryStream stream = new();
|
||||
_profileIcons.Download(id, stream);
|
||||
return stream;
|
||||
}
|
||||
|
||||
MemoryStream stream = new();
|
||||
_profileIcons.Download(id, stream);
|
||||
return stream;
|
||||
}
|
||||
public void SaveProfileIconStream(ProfileConfigurationEntity profileConfigurationEntity, Stream stream)
|
||||
{
|
||||
if (profileConfigurationEntity.FileIconId == Guid.Empty)
|
||||
profileConfigurationEntity.FileIconId = Guid.NewGuid();
|
||||
|
||||
public void SaveProfileIconStream(ProfileConfigurationEntity profileConfigurationEntity, Stream stream)
|
||||
{
|
||||
if (profileConfigurationEntity.FileIconId == Guid.Empty)
|
||||
profileConfigurationEntity.FileIconId = Guid.NewGuid();
|
||||
if (stream == null && _profileIcons.Exists(profileConfigurationEntity.FileIconId))
|
||||
_profileIcons.Delete(profileConfigurationEntity.FileIconId);
|
||||
|
||||
if (stream == null && _profileIcons.Exists(profileConfigurationEntity.FileIconId))
|
||||
_profileIcons.Delete(profileConfigurationEntity.FileIconId);
|
||||
|
||||
_profileIcons.Upload(profileConfigurationEntity.FileIconId, profileConfigurationEntity.IconOriginalFileName, stream);
|
||||
}
|
||||
_profileIcons.Upload(profileConfigurationEntity.FileIconId, profileConfigurationEntity.IconOriginalFileName, stream);
|
||||
}
|
||||
}
|
||||
@@ -4,41 +4,40 @@ using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Repositories
|
||||
namespace Artemis.Storage.Repositories;
|
||||
|
||||
internal class ProfileRepository : IProfileRepository
|
||||
{
|
||||
internal class ProfileRepository : IProfileRepository
|
||||
private readonly LiteRepository _repository;
|
||||
|
||||
public ProfileRepository(LiteRepository repository)
|
||||
{
|
||||
private readonly LiteRepository _repository;
|
||||
_repository = repository;
|
||||
_repository.Database.GetCollection<ProfileEntity>().EnsureIndex(s => s.Name);
|
||||
}
|
||||
|
||||
public ProfileRepository(LiteRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
_repository.Database.GetCollection<ProfileEntity>().EnsureIndex(s => s.Name);
|
||||
}
|
||||
public void Add(ProfileEntity profileEntity)
|
||||
{
|
||||
_repository.Insert(profileEntity);
|
||||
}
|
||||
|
||||
public void Add(ProfileEntity profileEntity)
|
||||
{
|
||||
_repository.Insert(profileEntity);
|
||||
}
|
||||
public void Remove(ProfileEntity profileEntity)
|
||||
{
|
||||
_repository.Delete<ProfileEntity>(profileEntity.Id);
|
||||
}
|
||||
|
||||
public void Remove(ProfileEntity profileEntity)
|
||||
{
|
||||
_repository.Delete<ProfileEntity>(profileEntity.Id);
|
||||
}
|
||||
public List<ProfileEntity> GetAll()
|
||||
{
|
||||
return _repository.Query<ProfileEntity>().ToList();
|
||||
}
|
||||
|
||||
public List<ProfileEntity> GetAll()
|
||||
{
|
||||
return _repository.Query<ProfileEntity>().ToList();
|
||||
}
|
||||
public ProfileEntity Get(Guid id)
|
||||
{
|
||||
return _repository.FirstOrDefault<ProfileEntity>(p => p.Id == id);
|
||||
}
|
||||
|
||||
public ProfileEntity Get(Guid id)
|
||||
{
|
||||
return _repository.FirstOrDefault<ProfileEntity>(p => p.Id == id);
|
||||
}
|
||||
|
||||
public void Save(ProfileEntity profileEntity)
|
||||
{
|
||||
_repository.Upsert(profileEntity);
|
||||
}
|
||||
public void Save(ProfileEntity profileEntity)
|
||||
{
|
||||
_repository.Upsert(profileEntity);
|
||||
}
|
||||
}
|
||||
@@ -3,44 +3,43 @@ using Artemis.Storage.Entities.General;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Repositories
|
||||
namespace Artemis.Storage.Repositories;
|
||||
|
||||
public class QueuedActionRepository : IQueuedActionRepository
|
||||
{
|
||||
public class QueuedActionRepository : IQueuedActionRepository
|
||||
private readonly LiteRepository _repository;
|
||||
|
||||
public QueuedActionRepository(LiteRepository repository)
|
||||
{
|
||||
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
|
||||
_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
|
||||
}
|
||||
@@ -3,61 +3,60 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage
|
||||
namespace Artemis.Storage;
|
||||
|
||||
public static class StorageManager
|
||||
{
|
||||
public static class StorageManager
|
||||
private static bool _inUse;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a backup of the database if the last backup is older than 10 minutes
|
||||
/// Removes the oldest backup if there are more than 5 backups present
|
||||
/// </summary>
|
||||
/// <param name="dataFolder">The Artemis data folder</param>
|
||||
public static void CreateBackup(string dataFolder)
|
||||
{
|
||||
private static bool _inUse;
|
||||
if (_inUse)
|
||||
throw new Exception("Storage is already in use, can't backup now.");
|
||||
|
||||
/// <summary>
|
||||
/// Creates a backup of the database if the last backup is older than 10 minutes
|
||||
/// Removes the oldest backup if there are more than 5 backups present
|
||||
/// </summary>
|
||||
/// <param name="dataFolder">The Artemis data folder</param>
|
||||
public static void CreateBackup(string dataFolder)
|
||||
string database = Path.Combine(dataFolder, "database.db");
|
||||
if (!File.Exists(database))
|
||||
return;
|
||||
|
||||
string backupFolder = Path.Combine(dataFolder, "database backups");
|
||||
Directory.CreateDirectory(backupFolder);
|
||||
FileSystemInfo[] files = new DirectoryInfo(backupFolder).GetFileSystemInfos();
|
||||
if (files.Length >= 5)
|
||||
{
|
||||
if (_inUse)
|
||||
throw new Exception("Storage is already in use, can't backup now.");
|
||||
|
||||
string database = Path.Combine(dataFolder, "database.db");
|
||||
if (!File.Exists(database))
|
||||
FileSystemInfo newest = files.OrderByDescending(fi => fi.CreationTime).First();
|
||||
FileSystemInfo oldest = files.OrderBy(fi => fi.CreationTime).First();
|
||||
if (DateTime.Now - newest.CreationTime < TimeSpan.FromMinutes(10))
|
||||
return;
|
||||
|
||||
string backupFolder = Path.Combine(dataFolder, "database backups");
|
||||
Directory.CreateDirectory(backupFolder);
|
||||
FileSystemInfo[] files = new DirectoryInfo(backupFolder).GetFileSystemInfos();
|
||||
if (files.Length >= 5)
|
||||
{
|
||||
FileSystemInfo newest = files.OrderByDescending(fi => fi.CreationTime).First();
|
||||
FileSystemInfo oldest = files.OrderBy(fi => fi.CreationTime).First();
|
||||
if (DateTime.Now - newest.CreationTime < TimeSpan.FromMinutes(10))
|
||||
return;
|
||||
|
||||
oldest.Delete();
|
||||
}
|
||||
|
||||
File.Copy(database, Path.Combine(backupFolder, $"database-{DateTime.Now:yyyy-dd-M--HH-mm-ss}.db"));
|
||||
oldest.Delete();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the LiteRepository that will be managed by dependency injection
|
||||
/// </summary>
|
||||
/// <param name="dataFolder">The Artemis data folder</param>
|
||||
public static LiteRepository CreateRepository(string dataFolder)
|
||||
{
|
||||
if (_inUse)
|
||||
throw new Exception("Storage is already in use, use dependency injection to get the repository.");
|
||||
File.Copy(database, Path.Combine(backupFolder, $"database-{DateTime.Now:yyyy-dd-M--HH-mm-ss}.db"));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_inUse = true;
|
||||
return new LiteRepository($"FileName={Path.Combine(dataFolder, "database.db")}");
|
||||
}
|
||||
catch (LiteException e)
|
||||
{
|
||||
// I don't like this way of error reporting, now I need to use reflection if I want a meaningful error message
|
||||
throw new Exception($"LiteDB threw error code {e.ErrorCode}. See inner exception for more details", e);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates the LiteRepository that will be managed by dependency injection
|
||||
/// </summary>
|
||||
/// <param name="dataFolder">The Artemis data folder</param>
|
||||
public static LiteRepository CreateRepository(string dataFolder)
|
||||
{
|
||||
if (_inUse)
|
||||
throw new Exception("Storage is already in use, use dependency injection to get the repository.");
|
||||
|
||||
try
|
||||
{
|
||||
_inUse = true;
|
||||
return new LiteRepository($"FileName={Path.Combine(dataFolder, "database.db")}");
|
||||
}
|
||||
catch (LiteException e)
|
||||
{
|
||||
// I don't like this way of error reporting, now I need to use reflection if I want a meaningful error message
|
||||
throw new Exception($"LiteDB threw error code {e.ErrorCode}. See inner exception for more details", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,47 +5,47 @@ using Artemis.Storage.Migrations.Interfaces;
|
||||
using LiteDB;
|
||||
using Serilog;
|
||||
|
||||
namespace Artemis.Storage
|
||||
namespace Artemis.Storage;
|
||||
|
||||
public class StorageMigrationService
|
||||
{
|
||||
public class StorageMigrationService
|
||||
private readonly ILogger _logger;
|
||||
private readonly List<IStorageMigration> _migrations;
|
||||
private readonly LiteRepository _repository;
|
||||
|
||||
public StorageMigrationService(ILogger logger, LiteRepository repository, List<IStorageMigration> migrations)
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly List<IStorageMigration> _migrations;
|
||||
private readonly LiteRepository _repository;
|
||||
_logger = logger;
|
||||
_repository = repository;
|
||||
_migrations = migrations;
|
||||
|
||||
public StorageMigrationService(ILogger logger, LiteRepository repository, List<IStorageMigration> migrations)
|
||||
ApplyPendingMigrations();
|
||||
}
|
||||
|
||||
public void ApplyPendingMigrations()
|
||||
{
|
||||
foreach (IStorageMigration storageMigration in _migrations.OrderBy(m => m.UserVersion))
|
||||
{
|
||||
_logger = logger;
|
||||
_repository = repository;
|
||||
_migrations = migrations;
|
||||
if (_repository.Database.UserVersion >= storageMigration.UserVersion)
|
||||
continue;
|
||||
|
||||
ApplyPendingMigrations();
|
||||
}
|
||||
_logger.Information("Applying storage migration {storageMigration} to update DB from v{oldVersion} to v{newVersion}",
|
||||
storageMigration.GetType().Name, _repository.Database.UserVersion, storageMigration.UserVersion);
|
||||
|
||||
public void ApplyPendingMigrations()
|
||||
{
|
||||
foreach (IStorageMigration storageMigration in _migrations.OrderBy(m => m.UserVersion))
|
||||
_repository.Database.BeginTrans();
|
||||
try
|
||||
{
|
||||
if (_repository.Database.UserVersion >= storageMigration.UserVersion)
|
||||
continue;
|
||||
|
||||
_logger.Information("Applying storage migration {storageMigration} to update DB from v{oldVersion} to v{newVersion}",
|
||||
storageMigration.GetType().Name, _repository.Database.UserVersion, storageMigration.UserVersion);
|
||||
|
||||
_repository.Database.BeginTrans();
|
||||
try
|
||||
{
|
||||
storageMigration.Apply(_repository);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_repository.Database.Rollback();
|
||||
throw;
|
||||
}
|
||||
_repository.Database.Commit();
|
||||
|
||||
_repository.Database.UserVersion = storageMigration.UserVersion;
|
||||
storageMigration.Apply(_repository);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_repository.Database.Rollback();
|
||||
throw;
|
||||
}
|
||||
|
||||
_repository.Database.Commit();
|
||||
|
||||
_repository.Database.UserVersion = storageMigration.UserVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user