123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- using System;
- using InABox.Configuration;
- using InABox.Core;
- namespace Comal.Classes
- {
-
- public enum LogikalProjectType
- {
- None,
- Quote,
- Project
- }
-
- public enum LogikalDesignType
- {
- None,
- Approved,
- NotApproved
- }
- // public enum LogikalMeasurement
- // {
- // Millimetres,
- // Metres
- // }
-
- public class LogikalMeasurementModel : IExpressionModel<double>
- {
- public double Value { get; set; }
- }
-
- public class LogikalCodeModel : IExpressionModel<string>
- {
- public string Code { get; set; }
- }
- public enum LogikalDrawingFormat
- {
- DXF,
- PNG
- }
-
- public enum LogikalDrawingView
- {
- Interior,
- Exterior
- }
-
- public enum LogikalDrawingType
- {
- Explosion,
- Section,
- Elevation,
- ElevationWithSectionLines,
- SectionLine,
- }
-
- public class LogikalSettings : BaseObject, IGlobalConfigurationSettings
- {
- [EnumLookupEditor(typeof(LogikalProjectType))]
- [EditorSequence(1)]
- [Caption("Import Projects")]
- public LogikalProjectType ImportProjects { get; set; }
-
- [CheckBoxEditor]
- [EditorSequence(2)]
- public bool UseLogikalProjectNumber { get; set; }
-
- [CodeEditor(Editable=Editable.Enabled)]
- [EditorSequence(3)]
- [Caption("Job Prefix")]
- public string ProjectPrefix { get; set; }
- [CheckBoxEditor]
- [EditorSequence(4)]
- [Caption("Import BOMs")]
- public bool ImportBoms { get; set; }
-
- [CheckBoxEditor]
- [EditorSequence(5)]
- [Caption("Import Requis")]
- public bool ImportRequis { get; set; }
- [EnumLookupEditor(typeof(LogikalDesignType))]
- [EditorSequence(6)]
- [Caption("Import Designs")]
- public LogikalDesignType ImportDesigns { get; set; }
- [EnumLookupEditor(typeof(LogikalDrawingFormat))]
- [EditorSequence(7)]
- [Caption("Drawing Format")]
- public LogikalDrawingFormat DrawingFormat { get; set; } = LogikalDrawingFormat.PNG;
- [EnumLookupEditor(typeof(LogikalDrawingView))]
- [EditorSequence(8)]
- [Caption("Drawing View")]
- public LogikalDrawingView DrawingView { get; set; } = LogikalDrawingView.Interior;
-
- [EnumLookupEditor(typeof(LogikalDrawingType))]
- [EditorSequence(9)]
- [Caption("Drawing Type")]
- public LogikalDrawingType DrawingType { get; set; } = LogikalDrawingType.Elevation;
- [ExpressionEditor(typeof(LogikalCodeModel))]
- [EditorSequence(10)]
- [Caption("Image URL")]
- public string ImageUrl { get; set; } = "";
-
- [CheckBoxEditor]
- [EditorSequence(11)]
- public bool SaveFiles { get; set; }
-
-
- [MemoEditor]
- [EditorSequence("1. Groups", 1)]
- [Caption("Query")]
- public String GroupSQL { get; set; }
-
- private class TreatmentTypeLookup : LookupDefinitionGenerator<TreatmentType, LogikalSettings>
- {
- public override Filter<TreatmentType> DefineFilter(LogikalSettings[] items)
- => new Filter<TreatmentType>().All();
- }
-
- [LookupDefinition(typeof(TreatmentTypeLookup))]
- [EditorSequence("2. Finishes", 1)]
- [Caption("Powdercoated")]
- public TreatmentTypeLink PowdercoatedType { get; set; }
-
- [LookupDefinition(typeof(TreatmentTypeLookup))]
- [EditorSequence("2. Finishes", 2)]
- [Caption("Anodised")]
- public TreatmentTypeLink AnodisedType { get; set; }
-
- [LookupDefinition(typeof(TreatmentTypeLookup))]
- [EditorSequence("2. Finishes", 3)]
- [Caption("Varnished")]
- public TreatmentTypeLink VarnishedType { get; set; }
-
- [LookupDefinition(typeof(TreatmentTypeLookup))]
- [EditorSequence("2. Finishes", 4)]
- [Caption("Taped")]
- public TreatmentTypeLink TapedType { get; set; }
-
- [MemoEditor]
- [EditorSequence("2. Finishes", 5)]
- [Caption("Query")]
- public String FinishSQL { get; set; }
-
- private class ProfileUomLookup : LookupDefinitionGenerator<ProductDimensionUnit, LogikalSettings>
- {
- public override Filter<ProductDimensionUnit> DefineFilter(LogikalSettings[] items)
- {
- return new Filter<ProductDimensionUnit>(x => x.HasLength).IsEqualTo(true)
- .And(x=>x.HasWidth).IsEqualTo(false)
- .And(x=>x.HasHeight).IsEqualTo(false)
- .And(x=>x.HasQuantity).IsEqualTo(false);
- }
- }
-
- [EditorSequence("3. Profiles", 1)]
- [Caption("Unit")]
- [LookupDefinition(typeof(ProfileUomLookup))]
- public ProductDimensionUnitLink ProfileUom { get; set; }
-
- [EditorSequence("3. Profiles", 2)]
- [ExpressionEditor(typeof(LogikalMeasurementModel))]
- [Caption("Scale")]
- public string ProfileMeasurement { get; set; }
-
- [MemoEditor(Height=200)]
- [EditorSequence("3. Profiles", 3)]
- [Caption("BOM")]
- public String BillOfMaterialsProfileSQL { get; set; }
-
- [MemoEditor(Height=200)]
- [EditorSequence("3. Profiles", 4)]
- [Caption("Design")]
- public String DesignProfileSQL { get; set; }
-
- private class GasketUomLookup : LookupDefinitionGenerator<ProductDimensionUnit, LogikalSettings>
- {
- public override Filter<ProductDimensionUnit> DefineFilter(LogikalSettings[] items)
- {
- return new Filter<ProductDimensionUnit>(x => x.HasLength).IsEqualTo(true)
- .And(x=>x.HasWidth).IsEqualTo(false)
- .And(x=>x.HasHeight).IsEqualTo(false)
- .And(x=>x.HasQuantity).IsEqualTo(false);
- }
- }
-
- [EditorSequence("4. Gaskets", 1)]
- [LookupDefinition(typeof(GasketUomLookup))]
- [Caption("Unit")]
- public ProductDimensionUnitLink GasketUom { get; set; }
-
- [EditorSequence("4. Gaskets", 2)]
- [ExpressionEditor(typeof(LogikalMeasurementModel))]
- [Caption("Scale")]
- public string GasketMeasurement { get; set; }
-
- [MemoEditor]
- [EditorSequence("4. Gaskets", 3)]
- [Caption("Query")]
- public string GasketSQL { get; set; }
-
- private class ComponentUomLookup : LookupDefinitionGenerator<ProductDimensionUnit, LogikalSettings>
- {
- public override Filter<ProductDimensionUnit> DefineFilter(LogikalSettings[] items)
- {
- return new Filter<ProductDimensionUnit>(x=>x.HasQuantity).IsEqualTo(true)
- .And(x => x.HasLength).IsEqualTo(false)
- .And(x=>x.HasWidth).IsEqualTo(false)
- .And(x=>x.HasHeight).IsEqualTo(false);
- }
- }
-
- [EditorSequence("5. Components", 1)]
- [LookupDefinition(typeof(ComponentUomLookup))]
- [Caption("Unit")]
- public ProductDimensionUnitLink ComponentUom { get; set; }
-
- [MemoEditor]
- [EditorSequence("5. Components", 2)]
- [Caption("Query")]
- public String ComponentSQL { get; set; }
-
- private class GlassUomLookup : LookupDefinitionGenerator<ProductDimensionUnit, LogikalSettings>
- {
- public override Filter<ProductDimensionUnit> DefineFilter(LogikalSettings[] items)
- {
- return new Filter<ProductDimensionUnit>(x=>x.HasWidth).IsEqualTo(true)
- .And(x=>x.HasHeight).IsEqualTo(true)
- .And(x => x.HasLength).IsEqualTo(false)
- .And(x=>x.HasQuantity).IsEqualTo(false);
- }
- }
-
- [EditorSequence("6. Glass", 1)]
- [LookupDefinition(typeof(GlassUomLookup))]
- [Caption("Unit")]
- public ProductDimensionUnitLink GlassUom { get; set; }
-
- [EditorSequence("6. Glass", 2)]
- [ExpressionEditor(typeof(LogikalMeasurementModel))]
- [Caption("Scale")]
- public string GlassMeasurement { get; set; }
-
- [MemoEditor]
- [EditorSequence("6. Glass", 2)]
- [Caption("Query")]
- public String GlassSQL { get; set; }
-
- [MemoEditor]
- [EditorSequence("7. Labour", 1)]
- [Caption("Query")]
- public String LabourSQL { get; set; }
-
- public bool CanImport<TSecurity>(bool enabled, Job? job) where TSecurity : ISecurityDescriptor, new()
- {
- if (!enabled)
- return false;
-
- if (job is null)
- return false;
-
- if (!InABox.Core.Security.IsAllowed<TSecurity>())
- return false;
-
- if (UseLogikalProjectNumber)
- return (string.IsNullOrWhiteSpace(ProjectPrefix) || job.JobNumber.StartsWith(ProjectPrefix));
-
- return (string.IsNullOrWhiteSpace(job.SourceRef) || job.SourceRef.StartsWith("Logikal:"));
- }
-
- }
- }
|