From 6b17bd95a19a3bb1b08de9af7ef4ffcb4afa5243 Mon Sep 17 00:00:00 2001 From: Harald Christian Joachim Wolff Date: Wed, 12 Sep 2018 21:29:58 +0200 Subject: [PATCH] Work In Progress --- Parts.cs | 20 +++++++ WaWi.cs | 26 ++++----- WaWi.xml | 1 + models/AssemblyComponent.cs | 4 +- models/Entity.cs | 8 ++- models/Part.cs | 18 +++--- models/{Assembly.cs => PartAssembly.cs} | 15 ++--- sharp-wawi.csproj | 2 +- templates/sharpwawi.Parts.hfrm | 46 ++++++++++++++-- templates/sharpwawi.models.Part.hfrm | 52 ++++++++---------- www/style.css | 73 ++++++++++++++++++++++++- 11 files changed, 196 insertions(+), 69 deletions(-) rename models/{Assembly.cs => PartAssembly.cs} (89%) diff --git a/Parts.cs b/Parts.cs index 7363179..cfc1a92 100644 --- a/Parts.cs +++ b/Parts.cs @@ -2,6 +2,7 @@ using appsrv.attributes; using sharpwawi.models; using System.Collections.Generic; +using System.Linq; namespace sharpwawi { @@ -25,6 +26,25 @@ namespace sharpwawi return new Part(); } + [PublishedMember] + public Part ByKey(string key) + { + foreach (Part p in AllParts) + if (p.Key.Equals(key)) + return p; + + throw new KeyNotFoundException(); + } + + [PublishedMember] + public IEnumerable ByKeyword(string keyword) + { + return AllParts.Where((p) => (p.Key.Contains(keyword) || p.Name.Contains(keyword) || p.Description.Contains(keyword)|| p.Dimensions.Contains(keyword)|| p.Standards.Contains(keyword))); + } + + [PublishedMember] + public IEnumerable AllParts => WaWi.Mapper.Query(); + [PublishedMember] public Part TestPart { get; } = new Part("P001-456-8765", "Der universelle Testartikel"); } diff --git a/WaWi.cs b/WaWi.cs index 884ee6e..8b8b57d 100644 --- a/WaWi.cs +++ b/WaWi.cs @@ -6,40 +6,40 @@ using mapper; using mapper.database; using appsrv.test; using mapper.database.model; +using mapper.persistence; namespace sharpwawi { public class WaWi { + public Mapper Mapper { get; protected set; } + [PublishedMember] public readonly Parts Parts; Configuration mapperConfiguration; - public Mapper Mapper { get; protected set; } + //public Mapper Mapper { get; protected set; } public WaWi() { - Parts = new Parts(this); - PrepareMapper(); - TestMapper(); + Parts = new Parts(this); + } private void PrepareMapper() { -/* mapperConfiguration = new Configuration() - .AddClass(typeof(Entity)) - .AddClass(typeof(Part)) - .AddClass(typeof(Assembly)) - .AddClass(typeof(AssemblyComponent)) - .SetConnectionProvider(new PGSQLConnectionProvider("feuerbach.lupus","demo","demo","demo")); - - Mapper = new Mapper(mapperConfiguration); - */ + Mapper = new Mapper(new PostgresAdapter("demo", "feuerbach.lupus", "demo", "demo")); + Mapper.Register(typeof(Part)); + Mapper.StorageAdapter.Setup(Mapper); + } + public void SaveObject(object o) + { + Mapper.Save(o); } diff --git a/WaWi.xml b/WaWi.xml index 95b7882..6c9ea37 100644 --- a/WaWi.xml +++ b/WaWi.xml @@ -8,6 +8,7 @@ sharpwawi.WaWi templates true + SaveObject diff --git a/models/AssemblyComponent.cs b/models/AssemblyComponent.cs index b22e7ff..ac78ff5 100644 --- a/models/AssemblyComponent.cs +++ b/models/AssemblyComponent.cs @@ -6,7 +6,7 @@ namespace sharpwawi.models public class AssemblyComponent { [PrimaryKey] - public Assembly Assembly { get; private set; } + public PartAssembly Assembly { get; private set; } [PrimaryKey] public Part Component { get; private set; } @@ -17,7 +17,7 @@ namespace sharpwawi.models { } - public AssemblyComponent(Assembly assembly,Part component, double quantity) + public AssemblyComponent(PartAssembly assembly,Part component, double quantity) { this.Assembly = assembly; this.Component = component; diff --git a/models/Entity.cs b/models/Entity.cs index b3b3fbe..858a555 100644 --- a/models/Entity.cs +++ b/models/Entity.cs @@ -1,16 +1,18 @@ using System; using System.Collections.Generic; using mapper.attributes; +using appsrv.templates.editors; namespace sharpwawi.models { [MappingConstraint(FieldMappingConstraint = MappingConstraints.ANNOTATEDONLY,PropertyMappingConstraint = MappingConstraints.ALL)] public class Entity { [PrimaryKey] - public String Key { get; set; } - public String Name { get; set; } + public String Key; - public String Description { get; set; } + public String Name; + + public String Description; public IDictionary userFields = new Dictionary(); diff --git a/models/Part.cs b/models/Part.cs index 075691d..908e21d 100644 --- a/models/Part.cs +++ b/models/Part.cs @@ -8,14 +8,18 @@ namespace sharpwawi.models [MappingConstraint(FieldMappingConstraint = MappingConstraints.ANNOTATEDONLY,PropertyMappingConstraint = MappingConstraints.ANNOTATEDONLY)] public class Part : Entity { - public ISet Assemblies { get; private set; } = new HashSet(); + public ISet Assemblies { get; private set; } = new HashSet(); [Mapped] - public Assembly CurrentAssembly { get; set; } + public PartAssembly CurrentAssembly; [Mapped] public Part ReplacedBy; + public String Standards; // Teil entspricht diesen Normen + public String Dimensions; // Dimensionierung / Abmasse (ggf. gem. Norm) + + public Part() { } @@ -28,7 +32,7 @@ namespace sharpwawi.models public int HighestAssemblyRevision { get { int highest = 0; - foreach (Assembly assembly in Assemblies) + foreach (PartAssembly assembly in Assemblies) if (assembly.Revision > highest) highest = assembly.Revision; return highest; @@ -36,14 +40,14 @@ namespace sharpwawi.models } [PublishedMember] - public int Priority => 1; + public int Priority; [PublishedMember] - public double Rank => 2.345; + public double Rank; - public Assembly CreateAssembly(){ - Assembly assembly = new Assembly(this); + public PartAssembly CreateAssembly(){ + PartAssembly assembly = new PartAssembly(this); Assemblies.Add(assembly); return assembly; } diff --git a/models/Assembly.cs b/models/PartAssembly.cs similarity index 89% rename from models/Assembly.cs rename to models/PartAssembly.cs index a1e5940..340f7fc 100644 --- a/models/Assembly.cs +++ b/models/PartAssembly.cs @@ -6,22 +6,23 @@ using mapper.attributes; namespace sharpwawi.models { [MappingConstraintAttribute(FieldMappingConstraint = MappingConstraints.DONTMAP,PropertyMappingConstraint = MappingConstraints.ANNOTATEDONLY)] - public class Assembly + public class PartAssembly { [Mapped] [PrimaryKey] - public Part Part { get; private set; } + public Part Part; + [Mapped] [PrimaryKey] - public int Revision { get; private set; } + public int Revision; IList components = new List(); - protected Assembly() + protected PartAssembly() { } - internal Assembly(Part part) + internal PartAssembly(Part part) { Part = part; Revision = part.HighestAssemblyRevision + 1; @@ -49,8 +50,8 @@ namespace sharpwawi.models return false; } - public Assembly Clone(){ - Assembly clone = Part.CreateAssembly(); + public PartAssembly Clone(){ + PartAssembly clone = Part.CreateAssembly(); foreach (AssemblyComponent assemblyComponent in components) clone.AddComponent(assemblyComponent.Component, assemblyComponent.Quantity); diff --git a/sharp-wawi.csproj b/sharp-wawi.csproj index f7016e8..a824bda 100644 --- a/sharp-wawi.csproj +++ b/sharp-wawi.csproj @@ -41,7 +41,7 @@ - + diff --git a/templates/sharpwawi.Parts.hfrm b/templates/sharpwawi.Parts.hfrm index 6163085..e5a8e6b 100644 --- a/templates/sharpwawi.Parts.hfrm +++ b/templates/sharpwawi.Parts.hfrm @@ -1,14 +1,50 @@ 
- + + + + + + + + + + + + + + + + + + + + + +
SchlüsselBezeichnungBeschreibungDimensionenNormen / Standardisierung
+ + + + + + + + + +
+
diff --git a/templates/sharpwawi.models.Part.hfrm b/templates/sharpwawi.models.Part.hfrm index 473e0bc..27075a7 100644 --- a/templates/sharpwawi.models.Part.hfrm +++ b/templates/sharpwawi.models.Part.hfrm @@ -1,12 +1,13 @@  -

[ ]

+

[ ] [ ]

-
+ +
Allgemeine Angaben
@@ -19,6 +20,22 @@
+
+ + +
+
+
+
+ + +
+ +
+ + +
+
@@ -27,35 +44,10 @@
- -
- -
+ + + diff --git a/www/style.css b/www/style.css index f9803e7..b3efbdc 100644 --- a/www/style.css +++ b/www/style.css @@ -18,6 +18,41 @@ div { display: inline-block; } + +a, a:visited { + color: #00a5fe; +} + +/* +a::before { + content: "\00bb"; +} +*/ + +table { + border-collapse: collapse; +} + +td { + padding-right: 20px; + padding-top: 5px; + padding-bottom: 3px; + + border-bottom: 1px dotted black; +} + +thead > tr > td{ + padding-bottom: 2px; + margin-bottom: 15px; + + border-bottom: 1px solid black; +} + +textarea { + min-width: 360px; + min-height: 100px; +} + .left { float:left; width: 230px; @@ -131,7 +166,7 @@ div { } .box,.block{ - display: block; + display: flex; padding: 5px; } @@ -147,6 +182,23 @@ div { padding-top: 4px; } +.group.column { + display: inline-block; +} + +.group.column + .group.column { + border-top: none; + border-left: 1px solid #6fb9df; + + padding-top: 0px; + padding-left: 4px; +} + +.left .box, .left.box, .left .group, .left.group { + display: block; +} + + .center { text-align: center; width: 100%; @@ -191,6 +243,7 @@ div { height: 100%; padding: 4px; + color: black; } .navigation > .navigation { @@ -205,10 +258,28 @@ div { } +.table { + display: inline-flex; + flex-flow: row; +} + +.table > div { + display: flex; +} + + + + + + + + + #wawi { z-index: 1; + font-size: 24px; } #wawi:hover { color: #D02020;