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 { public double Value { get; set; } } public class LogikalCodeModel : IExpressionModel { 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 { public override Filter DefineFilter(LogikalSettings[] items) => new Filter().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 { public override Filter DefineFilter(LogikalSettings[] items) { return new Filter(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 { public override Filter DefineFilter(LogikalSettings[] items) { return new Filter(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 { public override Filter DefineFilter(LogikalSettings[] items) { return new Filter(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 { public override Filter DefineFilter(LogikalSettings[] items) { return new Filter(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(bool enabled, Job? job) where TSecurity : ISecurityDescriptor, new() { if (!enabled) return false; if (job is null) return false; if (!InABox.Core.Security.IsAllowed()) return false; if (UseLogikalProjectNumber) return (string.IsNullOrWhiteSpace(ProjectPrefix) || job.JobNumber.StartsWith(ProjectPrefix)); return (string.IsNullOrWhiteSpace(job.SourceRef) || job.SourceRef.StartsWith("Logikal:")); } } }