Work In Progress

master
Harald Christian Joachim Wolff 2018-09-12 21:29:58 +02:00
parent b8ec9517eb
commit 6b17bd95a1
11 changed files with 196 additions and 69 deletions

View File

@ -2,6 +2,7 @@
using appsrv.attributes; using appsrv.attributes;
using sharpwawi.models; using sharpwawi.models;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace sharpwawi namespace sharpwawi
{ {
@ -25,6 +26,25 @@ namespace sharpwawi
return new Part(); 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<Part> 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<Part> AllParts => WaWi.Mapper.Query<Part>();
[PublishedMember] [PublishedMember]
public Part TestPart { get; } = new Part("P001-456-8765", "Der universelle Testartikel"); public Part TestPart { get; } = new Part("P001-456-8765", "Der universelle Testartikel");
} }

26
WaWi.cs
View File

@ -6,40 +6,40 @@ using mapper;
using mapper.database; using mapper.database;
using appsrv.test; using appsrv.test;
using mapper.database.model; using mapper.database.model;
using mapper.persistence;
namespace sharpwawi namespace sharpwawi
{ {
public class WaWi public class WaWi
{ {
public Mapper Mapper { get; protected set; }
[PublishedMember] [PublishedMember]
public readonly Parts Parts; public readonly Parts Parts;
Configuration mapperConfiguration; Configuration mapperConfiguration;
public Mapper Mapper { get; protected set; } //public Mapper Mapper { get; protected set; }
public WaWi() public WaWi()
{ {
Parts = new Parts(this);
PrepareMapper(); PrepareMapper();
TestMapper(); Parts = new Parts(this);
} }
private void PrepareMapper() private void PrepareMapper()
{ {
/* mapperConfiguration = new Configuration() Mapper = new Mapper(new PostgresAdapter("demo", "feuerbach.lupus", "demo", "demo"));
.AddClass(typeof(Entity)) Mapper.Register(typeof(Part));
.AddClass(typeof(Part))
.AddClass(typeof(Assembly))
.AddClass(typeof(AssemblyComponent))
.SetConnectionProvider(new PGSQLConnectionProvider("feuerbach.lupus","demo","demo","demo"));
Mapper = new Mapper(mapperConfiguration);
*/
Mapper.StorageAdapter.Setup(Mapper);
}
public void SaveObject(object o)
{
Mapper.Save(o);
} }

View File

@ -8,6 +8,7 @@
<Provider Name="ReflectiveResource">sharpwawi.WaWi</Provider> <Provider Name="ReflectiveResource">sharpwawi.WaWi</Provider>
<Parameter Name="templates">templates</Parameter> <Parameter Name="templates">templates</Parameter>
<Parameter Name="instantiate">true</Parameter> <Parameter Name="instantiate">true</Parameter>
<Parameter Name="method_save">SaveObject</Parameter>
</Resource> </Resource>
</Resource> </Resource>
</SharpWebApplication> </SharpWebApplication>

View File

@ -6,7 +6,7 @@ namespace sharpwawi.models
public class AssemblyComponent public class AssemblyComponent
{ {
[PrimaryKey] [PrimaryKey]
public Assembly Assembly { get; private set; } public PartAssembly Assembly { get; private set; }
[PrimaryKey] [PrimaryKey]
public Part Component { get; private set; } 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.Assembly = assembly;
this.Component = component; this.Component = component;

View File

@ -1,16 +1,18 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using mapper.attributes; using mapper.attributes;
using appsrv.templates.editors;
namespace sharpwawi.models namespace sharpwawi.models
{ {
[MappingConstraint(FieldMappingConstraint = MappingConstraints.ANNOTATEDONLY,PropertyMappingConstraint = MappingConstraints.ALL)] [MappingConstraint(FieldMappingConstraint = MappingConstraints.ANNOTATEDONLY,PropertyMappingConstraint = MappingConstraints.ALL)]
public class Entity public class Entity
{ {
[PrimaryKey] [PrimaryKey]
public String Key { get; set; } public String Key;
public String Name { get; set; }
public String Description { get; set; } public String Name;
public String Description;
public IDictionary<string, string> userFields = new Dictionary<string, string>(); public IDictionary<string, string> userFields = new Dictionary<string, string>();

View File

@ -8,14 +8,18 @@ namespace sharpwawi.models
[MappingConstraint(FieldMappingConstraint = MappingConstraints.ANNOTATEDONLY,PropertyMappingConstraint = MappingConstraints.ANNOTATEDONLY)] [MappingConstraint(FieldMappingConstraint = MappingConstraints.ANNOTATEDONLY,PropertyMappingConstraint = MappingConstraints.ANNOTATEDONLY)]
public class Part : Entity public class Part : Entity
{ {
public ISet<Assembly> Assemblies { get; private set; } = new HashSet<Assembly>(); public ISet<PartAssembly> Assemblies { get; private set; } = new HashSet<PartAssembly>();
[Mapped] [Mapped]
public Assembly CurrentAssembly { get; set; } public PartAssembly CurrentAssembly;
[Mapped] [Mapped]
public Part ReplacedBy; public Part ReplacedBy;
public String Standards; // Teil entspricht diesen Normen
public String Dimensions; // Dimensionierung / Abmasse (ggf. gem. Norm)
public Part() public Part()
{ {
} }
@ -28,7 +32,7 @@ namespace sharpwawi.models
public int HighestAssemblyRevision { public int HighestAssemblyRevision {
get { get {
int highest = 0; int highest = 0;
foreach (Assembly assembly in Assemblies) foreach (PartAssembly assembly in Assemblies)
if (assembly.Revision > highest) if (assembly.Revision > highest)
highest = assembly.Revision; highest = assembly.Revision;
return highest; return highest;
@ -36,14 +40,14 @@ namespace sharpwawi.models
} }
[PublishedMember] [PublishedMember]
public int Priority => 1; public int Priority;
[PublishedMember] [PublishedMember]
public double Rank => 2.345; public double Rank;
public Assembly CreateAssembly(){ public PartAssembly CreateAssembly(){
Assembly assembly = new Assembly(this); PartAssembly assembly = new PartAssembly(this);
Assemblies.Add(assembly); Assemblies.Add(assembly);
return assembly; return assembly;
} }

View File

@ -6,22 +6,23 @@ using mapper.attributes;
namespace sharpwawi.models namespace sharpwawi.models
{ {
[MappingConstraintAttribute(FieldMappingConstraint = MappingConstraints.DONTMAP,PropertyMappingConstraint = MappingConstraints.ANNOTATEDONLY)] [MappingConstraintAttribute(FieldMappingConstraint = MappingConstraints.DONTMAP,PropertyMappingConstraint = MappingConstraints.ANNOTATEDONLY)]
public class Assembly public class PartAssembly
{ {
[Mapped] [Mapped]
[PrimaryKey] [PrimaryKey]
public Part Part { get; private set; } public Part Part;
[Mapped] [Mapped]
[PrimaryKey] [PrimaryKey]
public int Revision { get; private set; } public int Revision;
IList<AssemblyComponent> components = new List<AssemblyComponent>(); IList<AssemblyComponent> components = new List<AssemblyComponent>();
protected Assembly() protected PartAssembly()
{ {
} }
internal Assembly(Part part) internal PartAssembly(Part part)
{ {
Part = part; Part = part;
Revision = part.HighestAssemblyRevision + 1; Revision = part.HighestAssemblyRevision + 1;
@ -49,8 +50,8 @@ namespace sharpwawi.models
return false; return false;
} }
public Assembly Clone(){ public PartAssembly Clone(){
Assembly clone = Part.CreateAssembly(); PartAssembly clone = Part.CreateAssembly();
foreach (AssemblyComponent assemblyComponent in components) foreach (AssemblyComponent assemblyComponent in components)
clone.AddComponent(assemblyComponent.Component, assemblyComponent.Quantity); clone.AddComponent(assemblyComponent.Component, assemblyComponent.Quantity);

View File

@ -41,7 +41,7 @@
<Compile Include="models\stock\StockLocation.cs" /> <Compile Include="models\stock\StockLocation.cs" />
<Compile Include="models\stock\StockShelf.cs" /> <Compile Include="models\stock\StockShelf.cs" />
<Compile Include="models\stock\WareHouse.cs" /> <Compile Include="models\stock\WareHouse.cs" />
<Compile Include="models\Assembly.cs" /> <Compile Include="models\PartAssembly.cs" />
<Compile Include="models\AssemblyComponent.cs" /> <Compile Include="models\AssemblyComponent.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,14 +1,50 @@
<?frame /layout.hfrm ?> <?frame /layout.hfrm ?>
<div class="left box navigation"> <div class="left box navigation">
<div class="group"> <form action="/WaWi/Parts">
<div>Recherche</div> <div class="group">
<input type="text" id="qpart" class="narrow" alt="schlüssel / bezeichnung"/> <div>Recherche</div>
</div> <input type="text" name="keyword" class="narrow" alt="schlüssel / bezeichnung" value="<?=request.GetParameterValue("keyword")?>"/>
<input type="submit" value="suchen..."/>
</div>
</form>
<div class="group"> <div class="group">
<div><a href="/WaWi/Parts/Create">anlegen</a></div> <div><a href="/WaWi/Parts/Create">anlegen</a></div>
</div> </div>
</div> </div>
<div class="block"> <div class="block">
<?framed?> <?if request.HasParameter("keyword") ?>
<table>
<thead>
<tr>
<td>Schlüssel</td>
<td>Bezeichnung</td>
<td>Beschreibung</td>
<td>Dimensionen</td>
<td>Normen / Standardisierung</td>
</tr>
</thead>
<?iterate part this.ByKeyword(request.GetParameterValue("keyword"))?>
<tr>
<td>
<a href="/WaWi/Parts/ByKey/<?=part.Key?>"><?=part.Key?></a>
</td>
<td>
<?=part.Name?>
</td>
<td>
<?=StrMax(part.Description, 32, "...")?>
</td>
<td>
<?=part.Dimensions?>
</td>
<td>
<?=part.Standards?>
</td>
</tr>
<?end?>
</table>
<?end?>
</div> </div>

View File

@ -1,12 +1,13 @@
<?frame /layout.hfrm ?> <?frame /layout.hfrm ?>
<?set pagetitle "Artikel Details"?> <?set pagetitle "Artikel Details"?>
<h1>[ <?=this.Key?> ] <?=this.Name?></h1> <h1>[ <?=this.Key?> ] <?=this.Name?> <?if this.Dimensions?><i><?=this.Dimensions?></i><?end?><?if this.Standards ?> [ <?=this.Standards?> ]<?end?></h1>
<form action="<?=REDIT_PATH?>" method="POST" ENCTYPE="multipart/form-data"/> <form action="<?=REDIT_PATH?>" method="POST" ENCTYPE="multipart/form-data"/>
<div class="block"> <div class="block">
<div class="group">
<div class="group column">
<div class="title">Allgemeine Angaben</div> <div class="title">Allgemeine Angaben</div>
<div class="block"> <div class="block">
@ -19,6 +20,22 @@
<?editor this.Name?> <?editor this.Name?>
</div> </div>
<div class="block">
<label>Beschreibung</label>
<?editor this.Description "MultiLine"?>
</div>
</div>
<div class="group column">
<div class="block">
<label>Eingehaltene Normen</label>
<?editor this.Standards?>
</div>
<div class="block">
<label>Dimensionen</label>
<?editor this.Dimensions?>
</div>
<div class="block"> <div class="block">
<label>TEST: Rank</label> <label>TEST: Rank</label>
<?editor this.Rank?> <?editor this.Rank?>
@ -27,35 +44,10 @@
<label>TEST: Priority</label> <label>TEST: Priority</label>
<?editor this.Priority?> <?editor this.Priority?>
</div> </div>
<!--
<div class="group">
<div class="title">Freie Felder</div>
<div class="block">
<table>
<thead>
<tr>
<th>Feldname</th>
<th>Wert</th>
</tr>
</thead>
<tfoot>
</tfoot>
<tbody>
<?iterate uf o.userFields?>
<tr>
<td><?=uf.Key?></td>
<td><?=uf.Value?></td>
</tr>
<?end?>
</tbody>
</table>
</div>
</div>
-->
</div> </div>
<input type="submit" value="Absenden"/>
</div> </div>
<input type="submit" value="Aktualisieren"/>
<input type="submit" name="REDIT_SUBMIT" value="save"/>
</form> </form>

View File

@ -18,6 +18,41 @@ div {
display: inline-block; 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 { .left {
float:left; float:left;
width: 230px; width: 230px;
@ -131,7 +166,7 @@ div {
} }
.box,.block{ .box,.block{
display: block; display: flex;
padding: 5px; padding: 5px;
} }
@ -147,6 +182,23 @@ div {
padding-top: 4px; 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 { .center {
text-align: center; text-align: center;
width: 100%; width: 100%;
@ -191,6 +243,7 @@ div {
height: 100%; height: 100%;
padding: 4px; padding: 4px;
color: black;
} }
.navigation > .navigation { .navigation > .navigation {
@ -205,10 +258,28 @@ div {
} }
.table {
display: inline-flex;
flex-flow: row;
}
.table > div {
display: flex;
}
#wawi { #wawi {
z-index: 1; z-index: 1;
font-size: 24px;
} }
#wawi:hover { #wawi:hover {
color: #D02020; color: #D02020;