KitFormula.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using InABox.Core;
  4. namespace Comal.Classes
  5. {
  6. [UserTracking(typeof(Quote))]
  7. public class KitFormula : Entity, IRemotable, IPersistent, ILicense<QuotesManagementLicense>
  8. {
  9. [EditorSequence(1)]
  10. [UniqueCodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)]
  11. public string Code { get; set; }
  12. [EditorSequence(2)]
  13. [TextBoxEditor]
  14. public string Description { get; set; }
  15. [EditorSequence(3)]
  16. [ExpressionEditor(null, typeof(KitFormulaExpressionGenerator))]
  17. public virtual string Formula { get; set; }
  18. private class KitFormulaExpressionGenerator : IExpressionModelGenerator
  19. {
  20. public List<string> GetVariables(object?[] items)
  21. {
  22. var dimensionUnits = items.Select(x => x as QuoteCostSheetItem).Where(x => x != null).Cast<QuoteCostSheetItem>();
  23. var variables = new List<string>();
  24. var props = CoreUtils.PropertyList(typeof(QuoteCostSheetItem), x => true, true);
  25. foreach (var prop in props.Keys)
  26. variables.Add(prop);
  27. return variables;
  28. }
  29. }
  30. public override string ToString()
  31. {
  32. return string.Format("{0}: {1}", Code, Description);
  33. }
  34. }
  35. }