132 lines
5.1 KiB
C#
132 lines
5.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Matomat.Input;
|
|
using Matomat.Output;
|
|
using Matomat.Data;
|
|
using Matomat.Database.Tables;
|
|
using Matomat.Helper;
|
|
|
|
namespace Matomat
|
|
{
|
|
class Automat
|
|
{
|
|
//private bool shutdown = false;
|
|
|
|
public delegate void stopEvent(bool stop);
|
|
|
|
public event stopEvent stopThread;
|
|
|
|
public Automat() {
|
|
|
|
}
|
|
internal void doJob(InputData input)
|
|
{
|
|
if (input.type == InputData.types.Card)
|
|
{
|
|
RfidCode user = new RfidCode(input.id);
|
|
if (!user.vaild())
|
|
return;
|
|
|
|
this.showUserInfo(user);
|
|
|
|
Factory.getLCD().printb("Bitte Produkt über den\nBarcodeleser halten");
|
|
|
|
InputData prodid = Factory.getInput().getProdInput(20);
|
|
if (prodid.type == InputData.types.None)
|
|
return;
|
|
|
|
EAN13 prod = new EAN13(prodid.id);
|
|
if(!prod.vaild())
|
|
return;
|
|
|
|
this.showProdInfo(prod);
|
|
|
|
if (prod.GetProdType() == EAN13.ProdType.product)
|
|
{
|
|
Instruction.sell(prod, user);
|
|
}
|
|
if (prod.GetProdType() == EAN13.ProdType.instruction)
|
|
{
|
|
switch (prod.GetFunctName())
|
|
{
|
|
case "exit();": this.stopThread(true); break;
|
|
case "aufladen(10);": Instruction.InsAufladen(10, user); break;
|
|
case "aufladen(20);": Instruction.InsAufladen(20, user); break;
|
|
case "aufladen(5);": Instruction.InsAufladen(5, user); break;
|
|
case "addUser();": Instruction.InsAddUser(user); break;
|
|
case "delUser();": Instruction.InsDelUser(user); break;
|
|
case "showStats();": Instruction.InsShowStats(); break;
|
|
case "addProd();": Instruction.InsAddProd(user); break;
|
|
case "delProd();": Instruction.InsDelProd(user); break;
|
|
case "showStats(Month);": Instruction.InsShowStats(user,Instruction.Stats.LastMonth); break;
|
|
case "showStats(All);": Instruction.InsShowStats(user, Instruction.Stats.All); break;
|
|
}
|
|
}
|
|
}
|
|
else if (input.type == InputData.types.Prod)
|
|
{
|
|
EAN13 prod = new EAN13(input.id);
|
|
if (!prod.vaild())
|
|
return;
|
|
|
|
if (prod.GetProdType() == EAN13.ProdType.instruction)
|
|
{
|
|
switch (prod.GetFunctName())
|
|
{
|
|
case "exit();": this.stopThread(true); break;
|
|
case "showStats();": Instruction.InsShowStats(); break;
|
|
default: this.showProdInfo(prod); break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.showProdInfo(prod);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void showProdInfo(EAN13 prod)
|
|
{
|
|
if (prod.GetProdType() == EAN13.ProdType.product)
|
|
{
|
|
long id = prod.GetProdId();
|
|
double price = prod.GetProdPrice();
|
|
string name = prod.GetProdName();
|
|
Factory.getLCD().printb("Produkt: " + name + "\nPreis: " + price.ToString("N2") + "€ EAN13: " + id, 2);
|
|
}
|
|
if (prod.GetProdType() == EAN13.ProdType.instruction)
|
|
{
|
|
string name = prod.GetFunctName();
|
|
Factory.getLCD().printb("Instruktion: " + name + "\nAdminCard + Instruction + TargetCard", 2);
|
|
}
|
|
}
|
|
|
|
private void showUserInfo(RfidCode user)
|
|
{
|
|
string name = user.GetUserName();
|
|
double konto = user.GetUserKonto();
|
|
long id = user.GetUserId();
|
|
double all = user.GetUserAll();
|
|
Factory.getLCD().printb("User: " + name + " Betrag: " + konto.ToString("N2") + " €\nUserID: " + id + " Gesamt: " + all.ToString("N2") + " €", 5);
|
|
}
|
|
|
|
internal void GetInitStatus()
|
|
{
|
|
List<TBest> l = new Tables().getBestlist();
|
|
string[] p = new string[3];
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
p[i] = (l.Count >= i + 1) ? l.ElementAt(i).name.PadRight(8, ' ').Substring(0, 8) + " " + (l.ElementAt(i).num % 1000).ToString().PadLeft(3, '0') : " ";
|
|
}
|
|
int k = 4232;
|
|
int avg = 234;
|
|
Factory.getLCD().print("Koffein im Umlauf: "+ k.ToString().PadLeft(4,' ') + " mg ("+ avg.ToString().PadLeft(4,' ')+" mg/Per)"+
|
|
"²²²²²²²²²²²²²²²²²²²²²²²²²²²²" + p[0] +
|
|
"² MATOMAT Wilkommen! ²" + p[1] +
|
|
"² Frohes genießen der Mate ²" + p[2]);
|
|
}
|
|
}
|
|
}
|