sharp-wawi/WaWi.cs

84 lines
2.1 KiB
C#
Raw Permalink Normal View History

2018-07-26 00:06:48 +02:00
using System;
using appsrv.attributes;
2018-07-30 17:55:15 +02:00
using sharpwawi.models;
using mapper.configuration;
2018-07-30 23:20:59 +02:00
using mapper;
using mapper.database;
using appsrv.test;
using mapper.database.model;
2018-09-12 21:29:58 +02:00
using mapper.persistence;
2018-07-30 17:55:15 +02:00
2018-07-26 00:06:48 +02:00
namespace sharpwawi
{
2018-07-30 17:55:15 +02:00
public class WaWi
2018-07-26 00:06:48 +02:00
{
2018-09-12 21:29:58 +02:00
public Mapper Mapper { get; protected set; }
2018-07-30 23:20:59 +02:00
[PublishedMember]
2018-07-30 17:55:15 +02:00
public readonly Parts Parts;
Configuration mapperConfiguration;
2018-09-12 21:29:58 +02:00
//public Mapper Mapper { get; protected set; }
2018-07-30 17:55:15 +02:00
public WaWi()
{
PrepareMapper();
2018-07-30 23:20:59 +02:00
2018-09-12 21:29:58 +02:00
Parts = new Parts(this);
2018-07-30 17:55:15 +02:00
}
private void PrepareMapper()
{
2018-09-12 21:29:58 +02:00
Mapper = new Mapper(new PostgresAdapter("demo", "feuerbach.lupus", "demo", "demo"));
2018-09-20 10:41:26 +02:00
Mapper.Register(typeof(Entity));
2018-09-12 21:29:58 +02:00
Mapper.Register(typeof(Part));
2018-09-20 10:41:26 +02:00
Mapper.Register(typeof(PartAssembly));
Mapper.Prepare();
2018-09-07 16:59:17 +02:00
2018-09-12 21:29:58 +02:00
Mapper.StorageAdapter.Setup(Mapper);
}
2018-09-07 16:59:17 +02:00
2018-09-12 21:29:58 +02:00
public void SaveObject(object o)
{
Mapper.Save(o);
2018-07-30 23:20:59 +02:00
}
2018-07-30 17:55:15 +02:00
2018-07-30 23:20:59 +02:00
private void TestMapper()
{
2018-09-07 16:59:17 +02:00
/* Console.WriteLine("TestMapper():");
2018-08-02 16:50:46 +02:00
Console.WriteLine("UpdateScheme():");
2018-08-01 13:38:57 +02:00
Mapper.UpdateScheme();
2018-08-02 16:50:46 +02:00
2018-08-03 09:25:36 +02:00
Random random = new Random();
2018-08-02 16:50:46 +02:00
Part[] parts = new Part[3];
2018-08-03 09:25:36 +02:00
parts[0] = new Part(String.Format("1P0001+{0}",random.Next()), "Ein Teil");
parts[1] = new Part(String.Format("1P0002+{0}", random.Next()), "Ein anderes Teil");
parts[2] = new Part(String.Format("1P0003+{0}", random.Next()), "Ein drittes Teil");
2018-08-02 16:50:46 +02:00
parts[0].ReplacedBy = parts[1];
Mapper.MappingInterface.SaveOrUpdate(parts[0]);
Mapper.MappingInterface.SaveOrUpdate(parts[1]);
Mapper.MappingInterface.SaveOrUpdate(parts[2]);
2018-08-03 09:25:36 +02:00
Entity[] entities = Mapper.MappingInterface.Load<Entity>();
2018-09-07 16:59:17 +02:00
*/
2018-07-30 23:20:59 +02:00
}
2018-07-30 17:55:15 +02:00
2018-09-07 16:59:17 +02:00
[PublishedMember]
2018-07-26 00:06:48 +02:00
public static String Version { get; } = "V0.0.1";
2018-09-07 16:59:17 +02:00
[PublishedMember]
2018-07-26 00:06:48 +02:00
public static String CurrentTime => DateTime.Now.ToString();
2018-07-30 17:55:15 +02:00
2018-07-26 00:06:48 +02:00
}
}