Prechádzať zdrojové kódy

Added Constant Type to FormulaAttribute

Frank van den Bos 2 rokov pred
rodič
commit
3acc9c019b

+ 2 - 1
InABox.Core/Aggregate.cs

@@ -265,7 +265,8 @@ namespace InABox.Core
         Multiply,
         Divide,
         Minumum,
-        Maximum
+        Maximum,
+        Constant
     }
 
     public interface IFormula<TType, TProp>

+ 0 - 1
InABox.Server/Rest/RestListener.cs

@@ -109,7 +109,6 @@ namespace InABox.API
                                 return new ValueTask<IResponse?>(GetUpdateFile(request).Build());
                             case "info":
                                 return new ValueTask<IResponse?>(GetServerInfo(request).Build());
-
                         }
 
                         Logger.Send(LogType.Error, request.Client.IPAddress.ToString(),

+ 5 - 0
inabox.database.sqlite/SQLiteProvider.cs

@@ -1567,8 +1567,13 @@ namespace InABox.Database.SQLite
         {
             if (attribute.Operator == FormulaOperator.None)
                 throw new Exception(string.Format("{0}.{1} is not a valid formula", columnname, attribute.Calculator.GetType().Name));
+            
+            if (attribute.Operator == FormulaOperator.Constant)
+                return EscapeValue(attribute.Value);
+
             if (!fieldmap.ContainsKey(attribute.Value))
                 throw new Exception(string.Format("{0}.{1} -> {2} does not exist", columnname, attribute.GetType().Name, attribute.Value));
+            
             foreach (var modifier in attribute.Modifiers)
                 if (!fieldmap.ContainsKey(modifier))
                     throw new Exception(string.Format("{0}.{1} -> {2} does not exist", columnname, attribute.GetType().Name, modifier));