Refactoring FTW
This commit is contained in:
parent
157c0048ac
commit
7d07741e2c
@ -4,9 +4,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Matomat.Input;
|
||||
using Matomat.Output;
|
||||
using Matomat.Data;
|
||||
using Matomat.Database.Tables;
|
||||
using Matomat.Helper;
|
||||
using Matomat.Model;
|
||||
|
||||
namespace Matomat
|
||||
{
|
||||
@ -25,31 +25,47 @@ namespace Matomat
|
||||
{
|
||||
if (input.type == InputData.types.Card)
|
||||
{
|
||||
RfidCode user = new RfidCode(input.id);
|
||||
if (!user.vaild())
|
||||
User user;
|
||||
try
|
||||
{
|
||||
user = new User(input.id);
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
Factory.getLCD().print(e.ToString(), 5, LCDDisplay.Status.OK);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
|
||||
this.showUserInfo(user);
|
||||
Instruction.showUserInfo(user);
|
||||
|
||||
Factory.getLCD().printb("Bitte Produkt über den\nBarcodeleser halten");
|
||||
Factory.getLCD().print("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())
|
||||
Product prod;
|
||||
try
|
||||
{
|
||||
prod = new Product(prodid.id);
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
Factory.getLCD().print(e.ToString(), 5, LCDDisplay.Status.OK);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
|
||||
this.showProdInfo(prod);
|
||||
Instruction.ShowProdInfo(prod);
|
||||
|
||||
if (prod.GetProdType() == EAN13.ProdType.product)
|
||||
if (prod.GetProdType() == Product.ProdType.Product)
|
||||
{
|
||||
Instruction.sell(prod, user);
|
||||
}
|
||||
if (prod.GetProdType() == EAN13.ProdType.instruction)
|
||||
if (prod.GetProdType() == Product.ProdType.Instruction)
|
||||
{
|
||||
switch (prod.GetFunctName())
|
||||
switch (prod.GetName())
|
||||
{
|
||||
case "exit();": this.stopThread(true); break;
|
||||
case "aufladen(10);": Instruction.InsAufladen(10, user); break;
|
||||
@ -60,72 +76,39 @@ namespace Matomat
|
||||
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(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)
|
||||
Product prod;
|
||||
try
|
||||
{
|
||||
switch (prod.GetFunctName())
|
||||
prod = new Product(input.id);
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
Factory.getLCD().print(e.ToString(), 5, LCDDisplay.Status.OK);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (prod.GetProdType() == Product.ProdType.Instruction)
|
||||
{
|
||||
switch (prod.GetName())
|
||||
{
|
||||
case "exit();": this.stopThread(true); break;
|
||||
case "showStats();": Instruction.InsShowStats(); break;
|
||||
default: this.showProdInfo(prod); break;
|
||||
default: Instruction.ShowProdInfo(prod); break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.showProdInfo(prod);
|
||||
Instruction.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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,109 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Matomat.Output;
|
||||
using Matomat.Database.Tables;
|
||||
using Matomat.Helper;
|
||||
|
||||
namespace Matomat.Data
|
||||
{
|
||||
class EAN13
|
||||
{
|
||||
private long prodId;
|
||||
private bool found;
|
||||
private ProdType type;
|
||||
private int price;
|
||||
private string name;
|
||||
private string function;
|
||||
private int id;
|
||||
public enum ProdType
|
||||
{
|
||||
product,
|
||||
instruction
|
||||
}
|
||||
|
||||
public EAN13(long prodId)
|
||||
{
|
||||
this.prodId = prodId;
|
||||
this.load();
|
||||
}
|
||||
|
||||
private void load()
|
||||
{
|
||||
TProduct t = new Tables().getProdTable(this.prodId);
|
||||
if (t == null)
|
||||
{
|
||||
this.found = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.found = true;
|
||||
if (t.iscommand)
|
||||
{
|
||||
this.type = ProdType.instruction;
|
||||
this.function = t.name;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.type = ProdType.product;
|
||||
this.name = t.name;
|
||||
}
|
||||
this.price = t.cost;
|
||||
this.id = t.id;
|
||||
}
|
||||
|
||||
internal bool vaild()
|
||||
{
|
||||
if (!found)
|
||||
{
|
||||
Factory.getLCD().printb("Produkt wurde nich gefunden\nEAN13: " + this.GetProdId().ToString() + " unbekannt", LCDDisplay.Status.Error, 5);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
internal ProdType GetProdType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
internal long GetProdId()
|
||||
{
|
||||
return this.prodId;
|
||||
}
|
||||
|
||||
internal double GetProdPrice()
|
||||
{
|
||||
return ((double)this.price)/100;
|
||||
}
|
||||
|
||||
internal string GetProdName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
internal string GetFunctName()
|
||||
{
|
||||
return this.function;
|
||||
}
|
||||
|
||||
public int GetDbId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public bool vaild(bool silent)
|
||||
{
|
||||
if (silent)
|
||||
{
|
||||
return found;
|
||||
}
|
||||
else
|
||||
{
|
||||
return vaild();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Matomat.Output;
|
||||
using Matomat.Database;
|
||||
using Matomat.Database.Tables;
|
||||
using Matomat.Helper;
|
||||
|
||||
namespace Matomat.Data
|
||||
{
|
||||
class RfidCode
|
||||
{
|
||||
private long userId;
|
||||
private bool found;
|
||||
private string username;
|
||||
private string shortname;
|
||||
private int credits;
|
||||
private long all;
|
||||
private bool admin;
|
||||
private int id;
|
||||
|
||||
public RfidCode(long userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
load();
|
||||
}
|
||||
|
||||
private void load()
|
||||
{
|
||||
TUser u = new Tables().getUserTable(this.userId);
|
||||
if (u == null)
|
||||
{
|
||||
this.found = false;
|
||||
return;
|
||||
}
|
||||
TBest b = new Tables().getUserMax(u.id);
|
||||
this.found = true;
|
||||
this.shortname = u.shortname;
|
||||
this.credits = u.credits;
|
||||
this.all = b.num;
|
||||
this.admin = u.admin;
|
||||
this.id = u.id;
|
||||
}
|
||||
|
||||
public bool vaild(bool silent)
|
||||
{
|
||||
if (silent)
|
||||
{
|
||||
return found;
|
||||
}
|
||||
else
|
||||
{
|
||||
return vaild();
|
||||
}
|
||||
}
|
||||
|
||||
public bool vaild()
|
||||
{
|
||||
LCDDisplay lcd = Factory.getLCD();
|
||||
if (!found)
|
||||
{
|
||||
lcd.printb("User wurde nicht gefunden\nUserID:" + this.GetUserId().ToString() + " unbekannt", LCDDisplay.Status.Error, 5);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
internal string GetUserName()
|
||||
{
|
||||
return this.shortname;
|
||||
}
|
||||
|
||||
internal double GetUserKonto()
|
||||
{
|
||||
return ((double)this.credits) / 100;
|
||||
}
|
||||
|
||||
internal long GetUserId()
|
||||
{
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public int GetDbId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
internal double GetUserAll()
|
||||
{
|
||||
return ((double)this.all) / 100;
|
||||
}
|
||||
|
||||
internal bool IsAdmin()
|
||||
{
|
||||
return this.admin;
|
||||
}
|
||||
|
||||
internal void SetUserKonto(double cost)
|
||||
{
|
||||
int p = (int)(cost * 100);
|
||||
TDatabase db = Factory.getDBO();
|
||||
this.credits = p;
|
||||
db.query("UPDATE `user` SET `credits` = '" + db.quote(p.ToString())+"' WHERE "+
|
||||
"`id` = '"+db.quote(this.id.ToString())+"'");
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ using MySql.Data;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System.Threading;
|
||||
using Matomat.Helper;
|
||||
using Matomat.Database.Query;
|
||||
|
||||
namespace Matomat.Database
|
||||
{
|
||||
@ -17,6 +18,7 @@ namespace Matomat.Database
|
||||
private MySqlDataReader data;
|
||||
private long id;
|
||||
private Thread pingThread;
|
||||
protected string nameQuote = "`";
|
||||
public DBDriverMysqli()
|
||||
{
|
||||
}
|
||||
@ -218,6 +220,26 @@ namespace Matomat.Database
|
||||
this.data.Close();
|
||||
return null;
|
||||
}
|
||||
public override Dictionary<string, object> loadAssoc()
|
||||
{
|
||||
if (!data_b || this.data == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (this.data.HasRows)
|
||||
{
|
||||
this.data.Read();
|
||||
Dictionary<string, object> row = new Dictionary<string, object>();
|
||||
//object[] row = new object[this.data.FieldCount];
|
||||
for (int i = 0; i < this.data.FieldCount; i++)
|
||||
{
|
||||
row.Add(this.data.GetName(i),this.data[i]);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
this.data.Close();
|
||||
return null;
|
||||
}
|
||||
public override Exception getError()
|
||||
{
|
||||
return this.err;
|
||||
@ -228,8 +250,26 @@ namespace Matomat.Database
|
||||
}
|
||||
public override string quote(string str)
|
||||
{
|
||||
return str;
|
||||
return "'" + MySqlHelper.EscapeString(str) + "'";
|
||||
}
|
||||
public override string quoteName(string name, string alias = null)
|
||||
{
|
||||
string quotedName = this.quoteNameStr(name.Split('.'));
|
||||
if (alias != null)
|
||||
{
|
||||
quotedName += " AS " + this.quoteNameStr(new string[] { alias });
|
||||
}
|
||||
return quotedName;
|
||||
}
|
||||
|
||||
private string quoteNameStr(string[] strArr)
|
||||
{
|
||||
for(int i=0;i<strArr.Length;i++) {
|
||||
strArr[i] = this.nameQuote + MySqlHelper.EscapeString(strArr[i]) + this.nameQuote;
|
||||
}
|
||||
return string.Join(".",strArr);
|
||||
}
|
||||
|
||||
public override void RequestStop()
|
||||
{
|
||||
this.pingThread.Abort();
|
||||
@ -237,5 +277,13 @@ namespace Matomat.Database
|
||||
this.data.Close();
|
||||
this.conn.Close();
|
||||
}
|
||||
public override DBQuery getQuery(bool newQuery = true)
|
||||
{
|
||||
if (newQuery)
|
||||
{
|
||||
return new DBQueryMysqli(this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
447
Matomat/Database/Query/DBQuery.cs
Normal file
447
Matomat/Database/Query/DBQuery.cs
Normal file
@ -0,0 +1,447 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Matomat.Database.Query
|
||||
{
|
||||
class DBQuery
|
||||
{
|
||||
private TDatabase db;
|
||||
public enum QTypes
|
||||
{
|
||||
None,
|
||||
Select,
|
||||
Update,
|
||||
Insert,
|
||||
Union,
|
||||
Delete,
|
||||
From,
|
||||
Join,
|
||||
Set,
|
||||
Where,
|
||||
Group,
|
||||
Having,
|
||||
Order,
|
||||
Columns,
|
||||
Values,
|
||||
Limit,
|
||||
}
|
||||
private QTypes _type;
|
||||
private bool _autoIncrementField;
|
||||
private List<DatabaseQueryElement> _join;
|
||||
private DatabaseQueryElement _select;
|
||||
private DatabaseQueryElement _from;
|
||||
private DatabaseQueryElement _where;
|
||||
private DatabaseQueryElement _update;
|
||||
private DatabaseQueryElement _set;
|
||||
private DatabaseQueryElement _insert;
|
||||
private DatabaseQueryElement _columns;
|
||||
private DatabaseQueryElement _values;
|
||||
private DatabaseQueryElement _group;
|
||||
private DatabaseQueryElement _having;
|
||||
private DatabaseQueryElement _order;
|
||||
private DatabaseQueryElement _union;
|
||||
private DatabaseQueryElement _delete;
|
||||
private DatabaseQueryElement _limit;
|
||||
public DBQuery(TDatabase db)
|
||||
{
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
public DBQuery select(string columns)
|
||||
{
|
||||
this._type = QTypes.Select;
|
||||
if (this._select == null)
|
||||
{
|
||||
this._select = new DatabaseQueryElement("SELECT", columns);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._select.append(columns);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DBQuery from(string tables)
|
||||
{
|
||||
if (this._from == null)
|
||||
{
|
||||
this._from = new DatabaseQueryElement("FROM", tables);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._from.append(tables);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DBQuery where(string conditions, string glue="AND")
|
||||
{
|
||||
if (this._where == null)
|
||||
{
|
||||
glue = glue.ToUpper();
|
||||
this._where = new DatabaseQueryElement("WHERE", conditions, " " + glue + " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
this._where.append(conditions);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string query = "";
|
||||
|
||||
switch (this._type)
|
||||
{
|
||||
case QTypes.Select:
|
||||
query += this._select;
|
||||
query += this._from;
|
||||
if (this._join != null)
|
||||
{
|
||||
// special case for joins
|
||||
foreach (DatabaseQueryElement join in this._join)
|
||||
{
|
||||
query += join;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._where != null)
|
||||
{
|
||||
query += this._where;
|
||||
}
|
||||
|
||||
if (this._group != null)
|
||||
{
|
||||
query += this._group;
|
||||
}
|
||||
|
||||
if (this._having != null)
|
||||
{
|
||||
query += this._having;
|
||||
}
|
||||
|
||||
if (this._order != null)
|
||||
{
|
||||
query += this._order;
|
||||
}
|
||||
if (this._limit != null)
|
||||
{
|
||||
query += this._limit;
|
||||
}
|
||||
|
||||
break;
|
||||
case QTypes.Insert:
|
||||
query += this._insert;
|
||||
|
||||
if (this._set != null)
|
||||
{
|
||||
query += this._set;
|
||||
}
|
||||
else if (this._values != null)
|
||||
{
|
||||
if (this._columns != null)
|
||||
{
|
||||
query += this._columns;
|
||||
}
|
||||
|
||||
query += " VALUES ";
|
||||
query += this._values;
|
||||
}
|
||||
break;
|
||||
case QTypes.Update:
|
||||
query += this._update;
|
||||
|
||||
if (this._join != null)
|
||||
{
|
||||
// special case for joins
|
||||
foreach (DatabaseQueryElement join in this._join)
|
||||
{
|
||||
query += join;
|
||||
}
|
||||
}
|
||||
|
||||
query += this._set;
|
||||
|
||||
if (this._where != null)
|
||||
{
|
||||
query += this._where;
|
||||
}
|
||||
break;
|
||||
case QTypes.Union:
|
||||
query += this._union;
|
||||
break;
|
||||
case QTypes.Delete:
|
||||
query += this._delete;
|
||||
query += this._from;
|
||||
|
||||
if (this._join != null)
|
||||
{
|
||||
// special case for joins
|
||||
foreach (DatabaseQueryElement join in this._join)
|
||||
{
|
||||
query += join;
|
||||
}
|
||||
}
|
||||
if (this._where != null)
|
||||
{
|
||||
query += this._where;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return query.Trim();
|
||||
}
|
||||
|
||||
public DBQuery update(string table)
|
||||
{
|
||||
this._type = QTypes.Update;
|
||||
this._update = new DatabaseQueryElement("UPDATE", table);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DBQuery set(string conditions, string glue=",")
|
||||
{
|
||||
if (this._set == null)
|
||||
{
|
||||
glue = glue.ToUpper();
|
||||
this._set = new DatabaseQueryElement("SET", conditions, "\n\t" + glue + " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
this._set.append(conditions);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DBQuery insert(string table, bool incrementField = false)
|
||||
{
|
||||
this._type = QTypes.Insert;
|
||||
this._insert = new DatabaseQueryElement("INSERT INTO", table);
|
||||
this._autoIncrementField = incrementField;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DBQuery columns(string columns)
|
||||
{
|
||||
if (this._columns == null)
|
||||
{
|
||||
this._columns = new DatabaseQueryElement("()", columns);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._columns.append(columns);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DBQuery values(string values)
|
||||
{
|
||||
if (this._values == null)
|
||||
{
|
||||
this._values = new DatabaseQueryElement("()", values, "),(");
|
||||
}
|
||||
else
|
||||
{
|
||||
this._values.append(values);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public DBQuery join(string type, string conditions)
|
||||
{
|
||||
if (this._join == null)
|
||||
{
|
||||
this._join = new List<DatabaseQueryElement>();
|
||||
}
|
||||
this._join.Add(new DatabaseQueryElement(type.ToUpper() + " JOIN", conditions));
|
||||
return this;
|
||||
}
|
||||
public DBQuery outerJoin(string condition)
|
||||
{
|
||||
this.join("OUTER", condition);
|
||||
return this;
|
||||
}
|
||||
public DBQuery rightJoin(string condition)
|
||||
{
|
||||
this.join("RIGHT", condition);
|
||||
return this;
|
||||
}
|
||||
public DBQuery innerJoin(string condition)
|
||||
{
|
||||
this.join("INNER", condition);
|
||||
return this;
|
||||
}
|
||||
public DBQuery leftJoin(string condition)
|
||||
{
|
||||
this.join("LEFT", condition);
|
||||
return this;
|
||||
}
|
||||
public DBQuery group(string columns)
|
||||
{
|
||||
if (this._group == null)
|
||||
{
|
||||
this._group = new DatabaseQueryElement("GROUP BY", columns);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._group.append(columns);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public DBQuery having(string conditions, string glue = "AND")
|
||||
{
|
||||
if (this._having == null)
|
||||
{
|
||||
glue = glue.ToUpper();
|
||||
this._having = new DatabaseQueryElement("HAVING", conditions, " " + glue + " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
this._having.append(conditions);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public DBQuery order(string columns)
|
||||
{
|
||||
if (this._order == null)
|
||||
{
|
||||
this._order = new DatabaseQueryElement("ORDER BY", columns);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._order.append(columns);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public DBQuery union(string query, bool distinct = false, string glue = "")
|
||||
{
|
||||
|
||||
if (this._order != null)
|
||||
{
|
||||
this.clear(QTypes.Order);
|
||||
}
|
||||
string name;
|
||||
if (distinct)
|
||||
{
|
||||
name = "UNION DISTINCT ()";
|
||||
glue = ")\nUNION DISTINCT (";
|
||||
}
|
||||
else
|
||||
{
|
||||
glue = ")\nUNION (";
|
||||
name = "UNION ()";
|
||||
}
|
||||
if (this._union == null)
|
||||
{
|
||||
this._union = new DatabaseQueryElement(name, query, glue);
|
||||
}
|
||||
else
|
||||
{
|
||||
glue = "";
|
||||
this._union.append(query);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public DBQuery delete(string table)
|
||||
{
|
||||
this._type = QTypes.Delete;
|
||||
this._delete = new DatabaseQueryElement("DELETE", null);
|
||||
this.from(table);
|
||||
return this;
|
||||
}
|
||||
public DBQuery clear(QTypes clause = QTypes.None)
|
||||
{
|
||||
switch (clause)
|
||||
{
|
||||
case QTypes.Select:
|
||||
this._select = null;
|
||||
this._type = QTypes.None;
|
||||
break;
|
||||
|
||||
case QTypes.Delete:
|
||||
this._delete = null;
|
||||
this._type = QTypes.None;
|
||||
break;
|
||||
|
||||
case QTypes.Update:
|
||||
this._update = null;
|
||||
this._type = QTypes.None;
|
||||
break;
|
||||
|
||||
case QTypes.Insert:
|
||||
this._insert = null;
|
||||
this._type = QTypes.None;
|
||||
this._autoIncrementField = false;
|
||||
break;
|
||||
|
||||
case QTypes.From:
|
||||
this._from = null;
|
||||
break;
|
||||
|
||||
case QTypes.Join:
|
||||
this._join = null;
|
||||
break;
|
||||
|
||||
case QTypes.Set:
|
||||
this._set = null;
|
||||
break;
|
||||
|
||||
case QTypes.Where:
|
||||
this._where = null;
|
||||
break;
|
||||
|
||||
case QTypes.Group:
|
||||
this._group = null;
|
||||
break;
|
||||
|
||||
case QTypes.Having:
|
||||
this._having = null;
|
||||
break;
|
||||
|
||||
case QTypes.Order:
|
||||
this._order = null;
|
||||
break;
|
||||
|
||||
case QTypes.Columns:
|
||||
this._columns = null;
|
||||
break;
|
||||
|
||||
case QTypes.Values:
|
||||
this._values = null;
|
||||
break;
|
||||
|
||||
case QTypes.Limit:
|
||||
this._limit = null;
|
||||
break;
|
||||
|
||||
default:
|
||||
this._type = QTypes.None;
|
||||
this._select = null;
|
||||
this._delete = null;
|
||||
this._update = null;
|
||||
this._insert = null;
|
||||
this._from = null;
|
||||
this._join = null;
|
||||
this._set = null;
|
||||
this._where = null;
|
||||
this._group = null;
|
||||
this._having = null;
|
||||
this._order = null;
|
||||
this._columns = null;
|
||||
this._values = null;
|
||||
this._autoIncrementField = false;
|
||||
this._limit = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public DBQuery limit(int start, int limit)
|
||||
{
|
||||
this._limit = new DatabaseQueryElement("LIMIT", start + "," + limit);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
13
Matomat/Database/Query/DBQueryMysqli.cs
Normal file
13
Matomat/Database/Query/DBQueryMysqli.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Matomat.Database.Query
|
||||
{
|
||||
class DBQueryMysqli : DBQuery
|
||||
{
|
||||
public DBQueryMysqli(TDatabase db) : base(db) {
|
||||
}
|
||||
}
|
||||
}
|
62
Matomat/Database/Query/DatabaseQueryElement.cs
Normal file
62
Matomat/Database/Query/DatabaseQueryElement.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Matomat.Database.Query
|
||||
{
|
||||
class DatabaseQueryElement
|
||||
{
|
||||
private List<string> elements;
|
||||
private string name;
|
||||
private string glue;
|
||||
public DatabaseQueryElement(string name, string elements, string glue=",")
|
||||
{
|
||||
this.elements = new List<string>();
|
||||
this.name = name;
|
||||
this.glue = glue;
|
||||
|
||||
this.append(elements);
|
||||
}
|
||||
|
||||
public void append(string elements)
|
||||
{
|
||||
if (!this.elements.Contains(elements))
|
||||
{
|
||||
this.elements.Add(elements);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.elements.Remove(elements);
|
||||
this.elements.Add(elements);
|
||||
}
|
||||
}
|
||||
|
||||
public void append(string[] elements)
|
||||
{
|
||||
foreach (string element in elements)
|
||||
{
|
||||
if (!this.elements.Contains(element))
|
||||
{
|
||||
this.elements.Add(element);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.elements.Remove(element);
|
||||
this.elements.Add(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
if (this.name.Substring(this.name.Length - 2) == "()")
|
||||
{
|
||||
return "\n" + this.name.Substring(this.name.Length - 2) + "(" + String.Join(this.glue, this.elements) + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "\n" + this.name + " " + String.Join(this.glue, this.elements);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Matomat.Database.Query;
|
||||
using Matomat.Database.Tables;
|
||||
|
||||
namespace Matomat.Database
|
||||
{
|
||||
@ -43,9 +45,92 @@ namespace Matomat.Database
|
||||
public abstract void query(string sql);
|
||||
public abstract object[] getResult();
|
||||
public abstract List<object[]> getResultList();
|
||||
public abstract Dictionary<string, object> loadAssoc();
|
||||
public abstract Exception getError();
|
||||
public abstract long getID();
|
||||
public abstract string quote(string str);
|
||||
public abstract void RequestStop();
|
||||
public abstract DBQuery getQuery(bool newQuery=true);
|
||||
public abstract string quoteName(string name, string alias = null);
|
||||
|
||||
public void setQuery(DBQuery query)
|
||||
{
|
||||
this.query(query.ToString());
|
||||
}
|
||||
public bool updateObject(string table, Table row, string key, bool nulls)
|
||||
{
|
||||
DBQuery query = this.getQuery(true);
|
||||
|
||||
query.update(this.quoteName(table));
|
||||
System.Reflection.PropertyInfo[] p = row.GetType().GetProperties();
|
||||
foreach (System.Reflection.PropertyInfo item in p)
|
||||
{
|
||||
if (item.Name == key)
|
||||
{
|
||||
query.where(this.quoteName(key) + '=' + this.quote(item.GetValue(row, null).ToString()));
|
||||
continue;
|
||||
}
|
||||
string val = "";
|
||||
if (item.GetValue(row, null) == null)
|
||||
{
|
||||
if (nulls)
|
||||
{
|
||||
val = "NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
val = this.quote(item.GetValue(row, null).ToString());
|
||||
}
|
||||
query.set(this.quoteName(item.Name) + "=" + val);
|
||||
}
|
||||
if (p.Length == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
this.setQuery(query);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool updateObject(string table, Table row, string key)
|
||||
{
|
||||
return this.updateObject(table, row, key, false);
|
||||
}
|
||||
|
||||
public bool insertObject(string table, Table row, string key)
|
||||
{
|
||||
DBQuery query = this.getQuery(true);
|
||||
|
||||
query.insert(this.quoteName(table));
|
||||
System.Reflection.PropertyInfo[] p = row.GetType().GetProperties();
|
||||
|
||||
List<string> fields = new List<string>();
|
||||
List<string> values = new List<string>();
|
||||
|
||||
foreach (System.Reflection.PropertyInfo item in p)
|
||||
{
|
||||
fields.Add(this.quoteName(item.Name));
|
||||
values.Add(item.GetValue(row, null).ToString());
|
||||
}
|
||||
|
||||
if (p.Length == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
query.columns(String.Join("", fields));
|
||||
query.values(String.Join("", values));
|
||||
|
||||
this.setQuery(query);
|
||||
return true;
|
||||
}
|
||||
public bool insertObject(string table, Table row)
|
||||
{
|
||||
return this.insertObject(table, row, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
132
Matomat/Database/Tables/Table.cs
Normal file
132
Matomat/Database/Tables/Table.cs
Normal file
@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Matomat.Helper;
|
||||
using Matomat.Database.Query;
|
||||
|
||||
namespace Matomat.Database.Tables
|
||||
{
|
||||
abstract class Table
|
||||
{
|
||||
private string _tbl_key;
|
||||
private string _tbl;
|
||||
private TDatabase _db;
|
||||
protected void Constructor(string table, string key, TDatabase db)
|
||||
{
|
||||
this._tbl = table;
|
||||
this._tbl_key = key;
|
||||
this._db = db;
|
||||
}
|
||||
public void reset()
|
||||
{
|
||||
System.Reflection.PropertyInfo[] fields = base.GetType().GetProperties();
|
||||
foreach (System.Reflection.PropertyInfo item in fields)
|
||||
{
|
||||
if (item.Name != this._tbl_key)
|
||||
{
|
||||
item.SetValue(this, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool load(Dictionary<string, string> keys, bool reset = true)
|
||||
{
|
||||
if (reset)
|
||||
{
|
||||
this.reset();
|
||||
}
|
||||
DBQuery query = Factory.getDBO().getQuery(true);
|
||||
query.select("*");
|
||||
query.from(this._db.quoteName(this._tbl));
|
||||
System.Reflection.PropertyInfo[] fields = base.GetType().GetProperties();
|
||||
foreach (System.Reflection.PropertyInfo item in fields)
|
||||
{
|
||||
if (keys.Keys.Contains(item.Name))
|
||||
{
|
||||
query.where(this._db.quoteName(item.Name) + " = " + this._db.quote(keys[item.Name]));
|
||||
}
|
||||
}
|
||||
this._db.setQuery(query);
|
||||
|
||||
Dictionary<string, object> row;
|
||||
try
|
||||
{
|
||||
row = this._db.loadAssoc();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this._db.getError() != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (row.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.bind(row);
|
||||
}
|
||||
|
||||
public bool bind(Dictionary<string, object> src)
|
||||
{
|
||||
return bind(src, new string[] { });
|
||||
}
|
||||
|
||||
public bool bind(Dictionary<string, object> src, string[] ignore)
|
||||
{
|
||||
if (src.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
foreach (string itemignore in ignore)
|
||||
{
|
||||
if (src.Keys.Contains(itemignore))
|
||||
{
|
||||
src.Remove(itemignore);
|
||||
}
|
||||
}
|
||||
System.Reflection.PropertyInfo[] p = base.GetType().GetProperties();
|
||||
foreach (System.Reflection.PropertyInfo item in p)
|
||||
{
|
||||
if (src.Keys.Contains(item.Name))
|
||||
{
|
||||
item.SetValue(this, src[item.Name], null);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool store()
|
||||
{
|
||||
return this.store(false);
|
||||
}
|
||||
public bool store(bool updateNulls)
|
||||
{
|
||||
string k = this._tbl_key;
|
||||
bool stored;
|
||||
if (base.GetType().GetProperty(k).GetValue(this, null) == null || (base.GetType().GetProperty(k).GetValue(this, null) != null && base.GetType().GetProperty(k).GetValue(this, null).ToString() == "0"))
|
||||
{
|
||||
stored = this._db.insertObject(this._tbl, this, this._tbl_key);
|
||||
} else {
|
||||
stored = this._db.updateObject(this._tbl, this, this._tbl_key, updateNulls);
|
||||
}
|
||||
return stored;
|
||||
}
|
||||
public bool delete()
|
||||
{
|
||||
string k = this._tbl_key;
|
||||
if (base.GetType().GetProperty(k).GetValue(this, null) == null || (base.GetType().GetProperty(k).GetValue(this, null) != null && base.GetType().GetProperty(k).GetValue(this, null).ToString() == "0"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
DBQuery query = this._db.getQuery(true);
|
||||
query.delete(this._tbl);
|
||||
query.where(this._db.quoteName(this._tbl_key) + " = " + this._db.quote(base.GetType().GetProperty(k).GetValue(this, null).ToString()));
|
||||
this._db.setQuery(query);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
20
Matomat/Database/Tables/TableHistory.cs
Normal file
20
Matomat/Database/Tables/TableHistory.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Matomat.Database.Tables
|
||||
{
|
||||
class TableHistory : Table
|
||||
{
|
||||
public TableHistory()
|
||||
{
|
||||
base.Constructor("history", "id", Matomat.Helper.Factory.getDBO());
|
||||
}
|
||||
|
||||
public int id { get; private set; }
|
||||
public int prod { get; private set; }
|
||||
public int user { get; private set; }
|
||||
public DateTime time { get; private set; }
|
||||
}
|
||||
}
|
22
Matomat/Database/Tables/TableProduct.cs
Normal file
22
Matomat/Database/Tables/TableProduct.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Matomat.Database.Tables
|
||||
{
|
||||
class TableProduct : Table
|
||||
{
|
||||
public TableProduct()
|
||||
{
|
||||
base.Constructor("product", "id", Matomat.Helper.Factory.getDBO());
|
||||
}
|
||||
|
||||
public int id { get; private set; }
|
||||
public long barcode { get; private set; }
|
||||
public string name { get; private set; }
|
||||
public int cost { get; private set; }
|
||||
public int caffeine { get; private set; }
|
||||
public bool iscommand { get; private set; }
|
||||
}
|
||||
}
|
22
Matomat/Database/Tables/TableUser.cs
Normal file
22
Matomat/Database/Tables/TableUser.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Matomat.Database.Tables
|
||||
{
|
||||
class TableUser : Table
|
||||
{
|
||||
public TableUser() {
|
||||
base.Constructor("user", "id", Matomat.Helper.Factory.getDBO());
|
||||
}
|
||||
|
||||
public int id { get; private set; }
|
||||
public long userid { get; private set; }
|
||||
public string username { get; private set; }
|
||||
public int credits { get; private set; }
|
||||
public bool admin { get; private set; }
|
||||
public string shortname { get; private set; }
|
||||
public string email { get; private set; }
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
|
||||
namespace Matomat.Database.Tables
|
||||
{
|
||||
class TBest : Tables
|
||||
{
|
||||
public TBest(long num, string name)
|
||||
{
|
||||
this._num = num;
|
||||
this._name = name;
|
||||
}
|
||||
public TBest()
|
||||
{
|
||||
this._name = "";
|
||||
this._num = 0;
|
||||
}
|
||||
private long _num;
|
||||
public long num
|
||||
{
|
||||
get
|
||||
{
|
||||
return _num;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_num != value)
|
||||
{
|
||||
_num = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _name;
|
||||
public string name
|
||||
{
|
||||
get
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_name != value)
|
||||
{
|
||||
_name = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Matomat.Database.Tables
|
||||
{
|
||||
class TProduct : Tables
|
||||
{
|
||||
public TProduct()
|
||||
{
|
||||
}
|
||||
public TProduct(int id, long barcode, string name, int cost, bool iscommand, int caffeine)
|
||||
{
|
||||
this._id = id;
|
||||
this._barcode = barcode;
|
||||
this._name = name;
|
||||
this._cost = cost;
|
||||
this._iscommand = iscommand;
|
||||
this._caffeine = caffeine;
|
||||
}
|
||||
private int _id;
|
||||
public int id
|
||||
{
|
||||
get
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_id != value)
|
||||
{
|
||||
_id = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long _barcode;
|
||||
public long barcode
|
||||
{
|
||||
get
|
||||
{
|
||||
return _barcode;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_barcode != value)
|
||||
{
|
||||
_barcode = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _name;
|
||||
public string name
|
||||
{
|
||||
get
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_name != value)
|
||||
{
|
||||
_name = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _cost;
|
||||
public int cost
|
||||
{
|
||||
get
|
||||
{
|
||||
return _cost;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_cost != value)
|
||||
{
|
||||
_cost = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool _iscommand;
|
||||
public bool iscommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _iscommand;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_iscommand != value)
|
||||
{
|
||||
_iscommand = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int _caffeine { get; private set; }
|
||||
}
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
|
||||
namespace Matomat.Database.Tables
|
||||
{
|
||||
class TUser : Tables
|
||||
{
|
||||
public TUser()
|
||||
{
|
||||
}
|
||||
public TUser(int id, long userid, string username, int credits, bool admin, string shortname, string email)
|
||||
{
|
||||
this._id = id;
|
||||
this._userid = userid;
|
||||
this._username = username;
|
||||
this._credits = credits;
|
||||
this._admin = admin;
|
||||
this._shortname = shortname;
|
||||
this._email = email;
|
||||
}
|
||||
private int _id;
|
||||
public int id
|
||||
{
|
||||
get
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_id != value)
|
||||
{
|
||||
_id = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long _userid;
|
||||
public long userid
|
||||
{
|
||||
get
|
||||
{
|
||||
return _userid;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_userid != value)
|
||||
{
|
||||
_userid = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _username;
|
||||
public string username
|
||||
{
|
||||
get
|
||||
{
|
||||
return _username;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_username != value)
|
||||
{
|
||||
_username = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _credits;
|
||||
public int credits
|
||||
{
|
||||
get
|
||||
{
|
||||
return _credits;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_credits != value)
|
||||
{
|
||||
_credits = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _admin;
|
||||
public bool admin
|
||||
{
|
||||
get
|
||||
{
|
||||
return _admin;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_admin != value)
|
||||
{
|
||||
_admin = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _shortname;
|
||||
public string shortname
|
||||
{
|
||||
get
|
||||
{
|
||||
return _shortname;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_shortname != value)
|
||||
{
|
||||
_shortname = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _email;
|
||||
public string email
|
||||
{
|
||||
get
|
||||
{
|
||||
return _email;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_email != value)
|
||||
{
|
||||
_email = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Matomat.Database;
|
||||
using Matomat.Helper;
|
||||
|
||||
namespace Matomat.Database.Tables
|
||||
{
|
||||
class Tables
|
||||
{
|
||||
public TUser getUserTable(int id)
|
||||
{
|
||||
return new TUser();
|
||||
}
|
||||
public TUser getUserTable(long userid)
|
||||
{
|
||||
TDatabase db = Factory.getDBO();
|
||||
db.query("SELECT `id`, `userid`, `username`, `credits`, `admin`, `shortname`, `email` FROM `user` WHERE `userid` =" + db.quote(userid.ToString()));
|
||||
object[] row = db.getResult();
|
||||
if (row == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new TUser((int)row[0], (long)row[1], (string)row[2], (int)row[3], (bool)row[4], (string)row[5], (string)row[6]);
|
||||
}
|
||||
public TProduct getProdTable(int id)
|
||||
{
|
||||
return new TProduct();
|
||||
}
|
||||
public TProduct getProdTable(long barcode)
|
||||
{
|
||||
TDatabase db = Factory.getDBO();
|
||||
db.query("SELECT `id`, `barcode`,`name`,`cost`,`iscommand`,`caffeine` FROM `product` WHERE `barcode` = " + db.quote(barcode.ToString()));
|
||||
object[] row = db.getResult();
|
||||
if (row == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new TProduct((int)row[0], (long)row[1], (string)row[2], (int)row[3], (bool)row[4], (int)row[5]);
|
||||
}
|
||||
|
||||
internal List<TBest> getBestlist()
|
||||
{
|
||||
TDatabase db = Factory.getDBO();
|
||||
db.query("SELECT COUNT(*) AS `num`,`u`.`shortname` AS `name` "+
|
||||
"FROM `history` AS `h` "+
|
||||
"LEFT JOIN `product` AS `p` ON `p`.`id` = `h`.`prod` "+
|
||||
"LEFT JOIN `user` AS `u` ON `u`.`id` = `h`.`user` "+
|
||||
"WHERE `p`.`iscommand` = 0 GROUP BY `h`.`user` ORDER BY `num` DESC LIMIT 0,4");
|
||||
List<object[]> rows = db.getResultList();
|
||||
if (rows == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<TBest> ret = new List<TBest>();
|
||||
foreach (object[] row in rows)
|
||||
{
|
||||
ret.Add(new TBest((long)row[0], (string)row[1]));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
internal TBest getUserMax(int p)
|
||||
{
|
||||
TDatabase db = Factory.getDBO();
|
||||
string sql = "SELECT SUM(`p`.`cost`) AS `num`,`u`.`shortname` AS `name` "+
|
||||
"FROM `history` AS `h` "+
|
||||
"LEFT JOIN `product` AS `p` ON `p`.`id` = `h`.`prod` "+
|
||||
"RIGHT JOIN `user` AS `u` ON `u`.`id` = `h`.`user` "+
|
||||
"WHERE `p`.`iscommand` = 0 AND `h`.`user` = " + db.quote(p.ToString());
|
||||
db.query(sql);
|
||||
|
||||
object[] row = db.getResult();
|
||||
if (row == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (row[0] == System.DBNull.Value)
|
||||
{
|
||||
return new TBest(Decimal.ToInt64(0), (string)row[1]);
|
||||
}
|
||||
return new TBest(Decimal.ToInt64((decimal)row[0]), (string)row[1]);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,10 +2,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Matomat.Data;
|
||||
using Matomat.Helper;
|
||||
using Matomat.Output;
|
||||
using Matomat.Input;
|
||||
using Matomat.Model;
|
||||
|
||||
namespace Matomat
|
||||
{
|
||||
@ -16,129 +16,149 @@ namespace Matomat
|
||||
LastMonth,
|
||||
All
|
||||
}
|
||||
public static void InsAufladen(int betrag, RfidCode admin)
|
||||
public static void InsAufladen(int betrag, User admin)
|
||||
{
|
||||
if (!admin.IsAdmin())
|
||||
if (!admin.GetAdmin())
|
||||
{
|
||||
Factory.getLCD().printb("Du bist kein Admin,\ndu kannst nichts Aufladen!", LCDDisplay.Status.Error, 5);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
if (!Factory.getConfig().sell)
|
||||
{
|
||||
Factory.getLCD().printb("Das Aufladen\nist abgeschaltet!", LCDDisplay.Status.Error, 5);
|
||||
Factory.getLCD().print("Du bist kein Admin,\ndu kannst nichts Aufladen!", 5, LCDDisplay.Status.Error);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
|
||||
Factory.getLCD().printb("Bitte die Zielkarte auf den\nRFID Leser auflegen");
|
||||
if (!Factory.getConfig().sell)
|
||||
{
|
||||
Factory.getLCD().print("Das Aufladen\nist abgeschaltet!", 5, LCDDisplay.Status.Error);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
|
||||
Factory.getLCD().print("Bitte die Zielkarte auf den\nRFID Leser auflegen");
|
||||
InputData target = Factory.getInput().getCardInput(20);
|
||||
if (target.type == InputData.types.None)
|
||||
return;
|
||||
|
||||
RfidCode user = new RfidCode(target.id);
|
||||
if (!user.vaild())
|
||||
User user;
|
||||
try
|
||||
{
|
||||
user = new User(target.id);
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
Factory.getLCD().print(e.ToString(), 5, LCDDisplay.Status.OK);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
|
||||
Factory.getLCD().printb("Betrag von User " + user.GetUserName() + "\num " + betrag + " € verringert");
|
||||
user.SetUserKonto(user.GetUserKonto()-betrag);
|
||||
Factory.getLCD().print("Betrag von User " + user.GetShortname() + "\num " + betrag + " € verringert");
|
||||
user.SetUserKonto(betrag*-1);
|
||||
System.Threading.Thread.Sleep(2000);
|
||||
}
|
||||
|
||||
public static void InsAddUser(RfidCode admin)
|
||||
public static void InsAddUser(User admin)
|
||||
{
|
||||
if (!admin.IsAdmin())
|
||||
if (!admin.GetAdmin())
|
||||
{
|
||||
Factory.getLCD().printb("Du bist kein Admin,\ndu kannst niemanden Hinzufügen!", LCDDisplay.Status.Error, 5);
|
||||
Factory.getLCD().print("Du bist kein Admin,\ndu kannst niemanden Hinzufügen!", 5, LCDDisplay.Status.Error);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
|
||||
Factory.getLCD().printb("Bitte die neue Userkarte auf\nden RFID Leser auflegen.");
|
||||
Factory.getLCD().print("Bitte die neue Userkarte auf\nden RFID Leser auflegen.");
|
||||
InputData target = Factory.getInput().getCardInput(20);
|
||||
if (target.type == InputData.types.None)
|
||||
return;
|
||||
|
||||
RfidCode user = new RfidCode(target.id);
|
||||
if (user.vaild(true))
|
||||
try
|
||||
{
|
||||
Factory.getLCD().printb("Dieser User ist schon\nRegistriert", LCDDisplay.Status.Warn, 5);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
User user = new User(target.id);
|
||||
}
|
||||
|
||||
Factory.getLCD().printb("Bitte den Usernamen [255] eingeben:");
|
||||
catch (ArgumentException)
|
||||
{
|
||||
Factory.getLCD().print("Bitte den Usernamen [255] eingeben:");
|
||||
string username = Console.ReadLine();
|
||||
Factory.getLCD().printb("Username:\n" + username);
|
||||
Factory.getLCD().print("Username:\n" + username);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
|
||||
Factory.getLCD().printb("Bitte Kürzel [8] eingeben:");
|
||||
Factory.getLCD().print("Bitte Kürzel [8] eingeben:");
|
||||
string kurzel = Console.ReadLine();
|
||||
Factory.getLCD().printb("Kürzel:\n" + kurzel);
|
||||
Factory.getLCD().print("Kürzel:\n" + kurzel);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
|
||||
Factory.getLCD().printb("Bitte E-Mail [255] eingeben:");
|
||||
Factory.getLCD().print("Bitte E-Mail [255] eingeben:");
|
||||
string email = Console.ReadLine();
|
||||
Factory.getLCD().printb("E-Mail:\n" + email);
|
||||
Factory.getLCD().print("E-Mail:\n" + email);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
|
||||
Factory.getLCD().printb("Bitte Admin [1|0] eingeben:");
|
||||
string isadmin = Console.ReadLine();
|
||||
Factory.getLCD().printb("Admin:\n" + isadmin);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
|
||||
string sql = "INSERT INTO `user` (`userid`,`username`,`admin`,`shortname`,`email`) VALUES (" +
|
||||
"'" + Factory.getDBO().quote(target.id.ToString()) + "'," +
|
||||
"'" + Factory.getDBO().quote(username) + "'," +
|
||||
"'" + Factory.getDBO().quote(isadmin == "1" ? "1" : "0") + "'," +
|
||||
"'" + Factory.getDBO().quote(kurzel) + "'," +
|
||||
"'" + Factory.getDBO().quote(email) + "')";
|
||||
Factory.getDBO().query(sql);
|
||||
|
||||
Factory.getLCD().printb("Neuen User eingefügt:\n" + kurzel);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
Factory.getLCD().print("Bitte Admin [1|0] eingeben:");
|
||||
bool isadmin;
|
||||
try
|
||||
{
|
||||
isadmin = bool.Parse(Console.ReadLine());
|
||||
}
|
||||
|
||||
public static void InsDelUser(RfidCode admin)
|
||||
catch (Exception)
|
||||
{
|
||||
if (!admin.IsAdmin())
|
||||
{
|
||||
Factory.getLCD().printb("Du bist kein Admin,\ndu kannst niemanden Löschen!", LCDDisplay.Status.Error, 5);
|
||||
Factory.getLCD().print("Fehler bei der Eingabe\ndes Adminflags ABBRUCH!", 5, LCDDisplay.Status.Error);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
Factory.getLCD().printb("Bitte die alte Userkarte auf\nden RFID Leser auflegen.");
|
||||
Factory.getLCD().print("Admin:\n" + isadmin);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
|
||||
User.Add(target.id, username, isadmin, kurzel, email);
|
||||
|
||||
Factory.getLCD().print("Neuen User eingefügt:\n" + kurzel);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
Factory.getLCD().print("Dieser User ist schon\nRegistriert", 5, LCDDisplay.Status.Warn);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
|
||||
public static void InsDelUser(User admin)
|
||||
{
|
||||
if (!admin.GetAdmin())
|
||||
{
|
||||
Factory.getLCD().print("Du bist kein Admin,\ndu kannst niemanden Löschen!", 5, LCDDisplay.Status.Error);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
Factory.getLCD().print("Bitte die alte Userkarte auf\nden RFID Leser auflegen.");
|
||||
InputData target = Factory.getInput().getCardInput(20);
|
||||
if (target.type == InputData.types.None)
|
||||
return;
|
||||
|
||||
RfidCode user = new RfidCode(target.id);
|
||||
if (!user.vaild())
|
||||
User user;
|
||||
try
|
||||
{
|
||||
user = new User(target.id);
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
Factory.getLCD().print(e.ToString(), 5, LCDDisplay.Status.OK);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
|
||||
Factory.getDBO().query("DELETE * FROM `user` WHERE `id`='" + Factory.getDBO().quote(user.GetDbId().ToString()) + "'");
|
||||
User.Remove(user.GetId());
|
||||
|
||||
Factory.getLCD().printb("User erfolgreich gelöscht:\n" + user.GetUserName(), 3);
|
||||
Factory.getLCD().print("User erfolgreich gelöscht:\n" + user.GetShortname(), 3);
|
||||
System.Threading.Thread.Sleep(2500);
|
||||
}
|
||||
|
||||
public static void sell(EAN13 prod, RfidCode user)
|
||||
public static void sell(Product prod, User user)
|
||||
{
|
||||
if (Factory.getConfig().sell && user.GetUserKonto() > 1900)
|
||||
if (Factory.getConfig().sell && user.GetCredits() >= 20)
|
||||
{
|
||||
Factory.getLCD().printb("Du hast zu viel Geld auf dem Konto\nBITTE bezahlen! | Grenze 20€", LCDDisplay.Status.Error, 5);
|
||||
Factory.getLCD().print("Du hast zu viel Geld auf dem Konto\nBITTE bezahlen! | Grenze 20€", 5, LCDDisplay.Status.Error);
|
||||
return;
|
||||
}
|
||||
Factory.getDBO().query("INSERT INTO `history` (`prod`,`user`,`time`) VALUES (" +
|
||||
"'" + Factory.getDBO().quote(prod.GetDbId().ToString()) + "'," +
|
||||
"'" + Factory.getDBO().quote(user.GetDbId().ToString()) + "'," +
|
||||
"NOW())");
|
||||
History.Add(prod.GetId(), user.GetId());
|
||||
if (Factory.getConfig().sell)
|
||||
{
|
||||
Factory.getDBO().query("UPDATE `user` SET `credits` = `credits`+" + Factory.getDBO().quote((prod.GetProdPrice() * 100).ToString("N0")) + " WHERE `user`.`id` = '" +
|
||||
Factory.getDBO().quote(user.GetDbId().ToString()) + "'");
|
||||
user.SetUserKonto(prod.GetPrice());
|
||||
}
|
||||
Factory.getLCD().printb("Guten Durst mit der\n" + prod.GetProdName() + "!", 4);
|
||||
Factory.getLCD().print("Guten Durst mit der\n" + prod.GetName() + "!", 4);
|
||||
System.Threading.Thread.Sleep(3500);
|
||||
}
|
||||
|
||||
@ -147,62 +167,113 @@ namespace Matomat
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
internal static void InsAddProd(RfidCode admin)
|
||||
internal static void InsAddProd(User admin)
|
||||
{
|
||||
if (!admin.IsAdmin())
|
||||
if (!admin.GetAdmin())
|
||||
{
|
||||
Factory.getLCD().printb("Du bist kein Admin,\ndu kannst nichts Hinzufügen!", LCDDisplay.Status.Error, 5);
|
||||
Factory.getLCD().print("Du bist kein Admin,\ndu kannst nichts Hinzufügen!", 5, LCDDisplay.Status.Error);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
|
||||
Factory.getLCD().printb("Bitte das neue Produkt\nüber den Barcodeleser ziehen.");
|
||||
Factory.getLCD().print("Bitte das neue Produkt\nüber den Barcodeleser ziehen.");
|
||||
InputData target = Factory.getInput().getProdInput(20);
|
||||
if (target.type == InputData.types.None)
|
||||
return;
|
||||
|
||||
EAN13 code = new EAN13(target.id);
|
||||
if (code.vaild(true))
|
||||
try
|
||||
{
|
||||
Factory.getLCD().printb("Dieser Produkt ist schon\nRegistriert", LCDDisplay.Status.Warn, 5);
|
||||
Product code = new Product(target.id);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
Factory.getLCD().print("Bitte den Produktnamen [255] eingeben:");
|
||||
string name = Console.ReadLine();
|
||||
Factory.getLCD().print("Produktname:\n" + name);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
|
||||
Factory.getLCD().print("Bitte Preis [Cent] eingeben:");
|
||||
int preis;
|
||||
try
|
||||
{
|
||||
preis = int.Parse(Console.ReadLine());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Factory.getLCD().print("Fehler bei der Eingabe des Preises\nABBRUCH!", 5, LCDDisplay.Status.Error);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
Factory.getLCD().print("Preis:\n" + preis + " €Cent");
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
|
||||
Factory.getLCD().print("Bitte Koffeingehalt [mg] eingeben:");
|
||||
int coffeine;
|
||||
try
|
||||
{
|
||||
coffeine = int.Parse(Console.ReadLine());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Factory.getLCD().print("Fehler bei der Eingabe\ndes Koffeingehaltes ABBRUCH!", 5, LCDDisplay.Status.Error);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
Factory.getLCD().print("Koffeingehalt:\n" + coffeine + " mg");
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
|
||||
Product.Add(target.id, name, preis, coffeine);
|
||||
|
||||
Factory.getLCD().print("Neues Produkt eingefügt:\n" + name);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
Factory.getLCD().print("Dieser Produkt ist schon\nRegistriert", 5, LCDDisplay.Status.Warn);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return;
|
||||
}
|
||||
|
||||
Factory.getLCD().printb("Bitte den Produktnamen [255] eingeben:");
|
||||
string name = Console.ReadLine();
|
||||
Factory.getLCD().printb("Produktname:\n" + name);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
|
||||
Factory.getLCD().printb("Bitte Preis [Cent] eingeben:");
|
||||
string preis = Console.ReadLine();
|
||||
Factory.getLCD().printb("Preis:\n" + preis + " €Cent");
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
|
||||
Factory.getLCD().printb("Bitte Koffeingehalt [mg] eingeben:");
|
||||
string coffeine = Console.ReadLine();
|
||||
Factory.getLCD().printb("Koffeingehalt:\n" + coffeine + " mg");
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
|
||||
string sql = "INSERT INTO `product` (`barcode`,`name`,`cost`,`caffeine`) VALUES (" +
|
||||
"'" + Factory.getDBO().quote(target.id.ToString()) + "'," +
|
||||
"'" + Factory.getDBO().quote(name) + "'," +
|
||||
"'" + Factory.getDBO().quote(preis) + "'," +
|
||||
"'" + Factory.getDBO().quote(coffeine) + "')";
|
||||
Factory.getDBO().query(sql);
|
||||
|
||||
Factory.getLCD().printb("Neues Produkt eingefügt:\n" + name);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
}
|
||||
|
||||
internal static void InsDelProd(RfidCode user)
|
||||
internal static void InsDelProd(User user)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
internal static void InsShowStats(RfidCode user, Stats stats)
|
||||
internal static void InsShowStats(User user, Stats stats)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static void ShowProdInfo(Product prod)
|
||||
{
|
||||
if (prod.GetProdType() == Product.ProdType.Product)
|
||||
{
|
||||
Factory.getLCD().print("Produkt: " + prod.GetName() + "\nPreis: " + prod.GetPrice().ToString("N2") + "€ EAN13: " + prod.GetBarcode(), 2);
|
||||
}
|
||||
if (prod.GetProdType() == Product.ProdType.Instruction)
|
||||
{
|
||||
Factory.getLCD().print("Instruktion: " + prod.GetName() + "\nAdminCard + Instruction + TargetCard", 2);
|
||||
}
|
||||
}
|
||||
|
||||
public static void GetInitStatus()
|
||||
{
|
||||
List<Tuple<string, long>> l = History.GetBestlist();
|
||||
int k = History.GetCoffeine();
|
||||
int avg = History.GetAvgCoffeine();
|
||||
string[] p = new string[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
p[i] = (l.Count >= i + 1) ? l.ElementAt(i).Item1.PadRight(8, ' ').Substring(0, 8) + " " + (l.ElementAt(i).Item2 % 1000).ToString().PadLeft(3, '0') : " ";
|
||||
}
|
||||
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]);
|
||||
}
|
||||
|
||||
public static void showUserInfo(User user)
|
||||
{
|
||||
Factory.getLCD().print("User: " + user.GetShortname() + " Betrag: " + user.GetCredits().ToString("N2") + " €\nUserID: " + user.GetUserId() + " Gesamt: " + user.GetUserAll().ToString("N2") + " €", 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
975
Matomat/Matomat-UML.ncp
Normal file
975
Matomat/Matomat-UML.ncp
Normal file
@ -0,0 +1,975 @@
|
||||
<Project>
|
||||
<Name>Matomat</Name>
|
||||
<ProjectItem type="NClass.DiagramEditor.ClassDiagram.Diagram" assembly="NClass.DiagramEditor, Version=2.4.1823.0, Culture=neutral, PublicKeyToken=null">
|
||||
<Name>Matomat.exe</Name>
|
||||
<Language>CSharp</Language>
|
||||
<Entities>
|
||||
<Entity type="Class">
|
||||
<Name>Automat</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="685" top="748" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Event">public event stopEvent stopThread</Member>
|
||||
<Member type="Constructor">public Automat()</Member>
|
||||
<Member type="Method">internal Void doJob(InputData input)</Member>
|
||||
<Member type="Method">private Void showProdInfo(EAN13 prod)</Member>
|
||||
<Member type="Method">private Void showUserInfo(RfidCode user)</Member>
|
||||
<Member type="Method">internal Void GetInitStatus()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>DatabaseQueryElement</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="2872" top="2569" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private List<String> elements</Member>
|
||||
<Member type="Field">private String name</Member>
|
||||
<Member type="Field">private String glue</Member>
|
||||
<Member type="Constructor">public DatabaseQueryElement(String name, String elements)</Member>
|
||||
<Member type="Constructor">public DatabaseQueryElement(String name, String elements, String glue)</Member>
|
||||
<Member type="Method">public Void append(String elements)</Member>
|
||||
<Member type="Method">public Void append(String[] elements)</Member>
|
||||
<Member type="Method">public override String ToString()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>DBQuery</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="3101" top="2569" />
|
||||
<Size width="162" height="264" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private TDatabase db</Member>
|
||||
<Member type="Field">private QTypes _type</Member>
|
||||
<Member type="Field">private DatabaseQueryElement _select</Member>
|
||||
<Member type="Field">private DatabaseQueryElement _from</Member>
|
||||
<Member type="Field">private DatabaseQueryElement _where</Member>
|
||||
<Member type="Constructor">public DBQuery(TDatabase db)</Member>
|
||||
<Member type="Method">public DBQuery select(String columns)</Member>
|
||||
<Member type="Method">public DBQuery from(String tables)</Member>
|
||||
<Member type="Method">public DBQuery where(String conditions, String glue)</Member>
|
||||
<Member type="Method">public DBQuery where(String conditions)</Member>
|
||||
<Member type="Method">public override String ToString()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>DBQueryMysqli</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="3302" top="2569" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Constructor">public DBQueryMysqli(TDatabase db)</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>Table</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="3767" top="2248" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private String _tbl_key</Member>
|
||||
<Member type="Field">private String _tbl</Member>
|
||||
<Member type="Field">private TDatabase _db</Member>
|
||||
<Member type="Constructor">protected Table()</Member>
|
||||
<Member type="Method">protected Void Constructor(String table, String key, TDatabase db)</Member>
|
||||
<Member type="Method">public Boolean load(Dictionary<String, String> keys, Boolean reset)</Member>
|
||||
<Member type="Method">public Boolean bind(Dictionary<String, Object> src)</Member>
|
||||
<Member type="Method">public Boolean bind(Dictionary<String, Object> src, String[] ignore)</Member>
|
||||
<Modifier>Abstract</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>TableHistory</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="3539" top="2550" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Property">public Int32 id { get; private set; }</Member>
|
||||
<Member type="Property">public Int32 prod { get; private set; }</Member>
|
||||
<Member type="Property">public Int32 user { get; private set; }</Member>
|
||||
<Member type="Property">public DateTime time { get; private set; }</Member>
|
||||
<Member type="Constructor">public TableHistory()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>TableProduct</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="3905" top="2550" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Property">public Int32 id { get; private set; }</Member>
|
||||
<Member type="Property">public Int64 barcode { get; private set; }</Member>
|
||||
<Member type="Property">public String name { get; private set; }</Member>
|
||||
<Member type="Property">public Int32 cost { get; private set; }</Member>
|
||||
<Member type="Property">public Int32 caffeine { get; private set; }</Member>
|
||||
<Member type="Property">public Boolean iscommand { get; private set; }</Member>
|
||||
<Member type="Constructor">public TableProduct()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>TableUser</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="3724" top="2550" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Property">public Int32 id { get; private set; }</Member>
|
||||
<Member type="Property">public Int64 userid { get; private set; }</Member>
|
||||
<Member type="Property">public String username { get; private set; }</Member>
|
||||
<Member type="Property">public Int32 credits { get; private set; }</Member>
|
||||
<Member type="Property">public Boolean admin { get; private set; }</Member>
|
||||
<Member type="Property">public String shortname { get; private set; }</Member>
|
||||
<Member type="Property">public String email { get; private set; }</Member>
|
||||
<Member type="Constructor">public TableUser()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>BarcodeReader</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="4357" top="1860" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private Boolean _shouldStop</Member>
|
||||
<Member type="Constructor">public BarcodeReader()</Member>
|
||||
<Member type="Method">internal Int64 getCodeID()</Member>
|
||||
<Member type="Method">internal Void Abort()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>Config</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="2083" top="1429" />
|
||||
<Size width="162" height="366" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private AppSettingsReader config</Member>
|
||||
<Member type="Field">private static Dictionary<String, Config> instances</Member>
|
||||
<Member type="Property">public String com_display { get; private set; }</Member>
|
||||
<Member type="Property">public String com_rfid { get; private set; }</Member>
|
||||
<Member type="Property">public String mysql_server { get; private set; }</Member>
|
||||
<Member type="Property">public String mysql_user { get; private set; }</Member>
|
||||
<Member type="Property">public String mysql_db { get; private set; }</Member>
|
||||
<Member type="Property">public Int32 mysql_port { get; private set; }</Member>
|
||||
<Member type="Property">public String mysql_pw { get; private set; }</Member>
|
||||
<Member type="Property">public String mysql_driver { get; private set; }</Member>
|
||||
<Member type="Property">public Boolean debug { get; private set; }</Member>
|
||||
<Member type="Property">public Boolean sell { get; private set; }</Member>
|
||||
<Member type="Constructor">private Config()</Member>
|
||||
<Member type="Constructor">static Config()</Member>
|
||||
<Member type="Method">private Void loadFile()</Member>
|
||||
<Member type="Method">internal static Config getInstance(String file)</Member>
|
||||
<Member type="Method">public Void RequestStop()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>TDatabase</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="3318" top="1416" />
|
||||
<Size width="162" height="366" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private static Dictionary<String, TDatabase> instances</Member>
|
||||
<Member type="Constructor">protected TDatabase()</Member>
|
||||
<Member type="Constructor">static TDatabase()</Member>
|
||||
<Member type="Method">internal static TDatabase getInstance(String server, String dbs, String user, String pw, Int32 port, String driver)</Member>
|
||||
<Member type="Method">public abstract Boolean connect(String server, String dbs, String user, String pw, Int32 port, String driver)</Member>
|
||||
<Member type="Method">public abstract Void query(String sql)</Member>
|
||||
<Member type="Method">public abstract Object[] getResult()</Member>
|
||||
<Member type="Method">public abstract List<Object[]> getResultList()</Member>
|
||||
<Member type="Method">public abstract Dictionary<String, Object> loadAssoc()</Member>
|
||||
<Member type="Method">public abstract Exception getError()</Member>
|
||||
<Member type="Method">public abstract Int64 getID()</Member>
|
||||
<Member type="Method">public abstract String quote(String str)</Member>
|
||||
<Member type="Method">public abstract Void RequestStop()</Member>
|
||||
<Member type="Method">public abstract DBQuery getQuery(Boolean newQuery)</Member>
|
||||
<Member type="Method">public abstract String quoteName(String name)</Member>
|
||||
<Member type="Method">public abstract String quoteName(String name, String alias)</Member>
|
||||
<Member type="Method">public Void setQuery(DBQuery query)</Member>
|
||||
<Modifier>Abstract</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>DBDriverMysqli</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="3568" top="1513" />
|
||||
<Size width="162" height="587" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private MySqlConnection conn</Member>
|
||||
<Member type="Field">private Exception err</Member>
|
||||
<Member type="Field">private Boolean data_b</Member>
|
||||
<Member type="Field">private MySqlDataReader data</Member>
|
||||
<Member type="Field">private Int64 id</Member>
|
||||
<Member type="Field">private Thread pingThread</Member>
|
||||
<Member type="Field">protected String nameQuote</Member>
|
||||
<Member type="Constructor">public DBDriverMysqli()</Member>
|
||||
<Member type="Method">public override Boolean connect(String server, String dbs, String user, String pw, Int32 port, String driver)</Member>
|
||||
<Member type="Method">private Void startPing()</Member>
|
||||
<Member type="Method">public Void ping()</Member>
|
||||
<Member type="Method">public override Void query(String sql)</Member>
|
||||
<Member type="Method">private Void set(String sql)</Member>
|
||||
<Member type="Method">private Void create(String sql)</Member>
|
||||
<Member type="Method">private Void truncate(String sql)</Member>
|
||||
<Member type="Method">private Void delete(String sql)</Member>
|
||||
<Member type="Method">private Void update(String sql)</Member>
|
||||
<Member type="Method">private Void insert(String sql)</Member>
|
||||
<Member type="Method">private Void select(String sql)</Member>
|
||||
<Member type="Method">public override List<Object[]> getResultList()</Member>
|
||||
<Member type="Method">public override Object[] getResult()</Member>
|
||||
<Member type="Method">public override Dictionary<String, Object> loadAssoc()</Member>
|
||||
<Member type="Method">public override Exception getError()</Member>
|
||||
<Member type="Method">public override Int64 getID()</Member>
|
||||
<Member type="Method">public override String quote(String str)</Member>
|
||||
<Member type="Method">public override String quoteName(String name)</Member>
|
||||
<Member type="Method">public override String quoteName(String name, String alias)</Member>
|
||||
<Member type="Method">private String quoteNameStr(String[] strArr)</Member>
|
||||
<Member type="Method">public override Void RequestStop()</Member>
|
||||
<Member type="Method">public override DBQuery getQuery(Boolean newQuery)</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>Factory</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="2908" top="889" />
|
||||
<Size width="162" height="383" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private static LCDDisplay lcd_i</Member>
|
||||
<Member type="Field">private static TInput inp_i</Member>
|
||||
<Member type="Field">private static Config con_i</Member>
|
||||
<Member type="Field">private static TDatabase dbo_i</Member>
|
||||
<Member type="Constructor">public Factory()</Member>
|
||||
<Member type="Constructor">static Factory()</Member>
|
||||
<Member type="Method">public static LCDDisplay getLCD()</Member>
|
||||
<Member type="Method">public static Void rmLCD()</Member>
|
||||
<Member type="Method">private static LCDDisplay _createLCDDisplay()</Member>
|
||||
<Member type="Method">public static TInput getInput()</Member>
|
||||
<Member type="Method">private static TInput _createInput()</Member>
|
||||
<Member type="Method">public static Void rmInput()</Member>
|
||||
<Member type="Method">public static Config getConfig()</Member>
|
||||
<Member type="Method">private static Config _createConfig(String file)</Member>
|
||||
<Member type="Method">public static Void rmConfig()</Member>
|
||||
<Member type="Method">public static TDatabase getDBO()</Member>
|
||||
<Member type="Method">private static TDatabase _createDBO()</Member>
|
||||
<Member type="Method">public static Void rmDBO()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>String</Name>
|
||||
<Access>Public</Access>
|
||||
<Location left="1799" top="892" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Method">public static Byte[] ToCharArray(String str, String search, Byte[] replace)</Member>
|
||||
<Modifier>Static</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>Array</Name>
|
||||
<Access>Public</Access>
|
||||
<Location left="1587" top="892" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Method">public static Byte[] Substring(Byte[] b, Int32 start, Int32 length)</Member>
|
||||
<Member type="Method">public static Byte[] Substring(Byte[] b, Int32 start)</Member>
|
||||
<Modifier>Static</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>Double</Name>
|
||||
<Access>Public</Access>
|
||||
<Location left="1375" top="892" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Method">public static String ToString(Double d, Int32 f)</Member>
|
||||
<Modifier>Static</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>InputData</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="4262" top="1523" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Property">public types type { get; set; }</Member>
|
||||
<Member type="Property">public Int64 id { get; set; }</Member>
|
||||
<Member type="Constructor">public InputData()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>TInput</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="4047" top="1411" />
|
||||
<Size width="162" height="332" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private InputData data</Member>
|
||||
<Member type="Field">private RFIDReader rfid</Member>
|
||||
<Member type="Field">private BarcodeReader code</Member>
|
||||
<Member type="Field">private Boolean cardrunning</Member>
|
||||
<Member type="Field">private Boolean coderunning</Member>
|
||||
<Member type="Field">private static Dictionary<String, TInput> instances</Member>
|
||||
<Member type="Constructor">private TInput(String comport)</Member>
|
||||
<Member type="Constructor">static TInput()</Member>
|
||||
<Member type="Method">private Void doWorkCard()</Member>
|
||||
<Member type="Method">private Void doWorkCode()</Member>
|
||||
<Member type="Method">public InputData getAnyInput(Int32 timeout)</Member>
|
||||
<Member type="Method">public InputData getProdInput(Int32 timeout)</Member>
|
||||
<Member type="Method">public static TInput getInstance(String comport)</Member>
|
||||
<Member type="Method">public InputData getCardInput(Int32 timeout)</Member>
|
||||
<Member type="Method">public Void RequestStop()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>Instruction</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="685" top="1074" />
|
||||
<Size width="162" height="230" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Constructor">public Instruction()</Member>
|
||||
<Member type="Method">public static Void InsAufladen(Int32 betrag, RfidCode admin)</Member>
|
||||
<Member type="Method">public static Void InsAddUser(RfidCode admin)</Member>
|
||||
<Member type="Method">public static Void InsDelUser(RfidCode admin)</Member>
|
||||
<Member type="Method">public static Void sell(EAN13 prod, RfidCode user)</Member>
|
||||
<Member type="Method">internal static Void InsShowStats()</Member>
|
||||
<Member type="Method">internal static Void InsAddProd(RfidCode admin)</Member>
|
||||
<Member type="Method">internal static Void InsDelProd(RfidCode user)</Member>
|
||||
<Member type="Method">internal static Void InsShowStats(RfidCode user, Stats stats)</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>LCDDisplay</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="2699" top="1429" />
|
||||
<Size width="162" height="536" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private Queue<Message> messages</Member>
|
||||
<Member type="Field">private Queue<Beeb> beeb</Member>
|
||||
<Member type="Field">private volatile Boolean _shouldStop</Member>
|
||||
<Member type="Field">private SerialPort serialPort</Member>
|
||||
<Member type="Field">private Boolean disable</Member>
|
||||
<Member type="Field">private static Dictionary<String, LCDDisplay> instances</Member>
|
||||
<Member type="Constructor">private LCDDisplay(String port)</Member>
|
||||
<Member type="Constructor">static LCDDisplay()</Member>
|
||||
<Member type="Method">private Void BeebThread()</Member>
|
||||
<Member type="Method">private Void DisplayThread()</Member>
|
||||
<Member type="Method">private Void beep(Int32 frequency, Int32 duration)</Member>
|
||||
<Member type="Method">private Void display(String text, Status status)</Member>
|
||||
<Member type="Method">private Void displayClear()</Member>
|
||||
<Member type="Method">private Void displayCode(Byte[] p)</Member>
|
||||
<Member type="Method">private Void createChars()</Member>
|
||||
<Member type="Method">private Void displayEscCode(String code)</Member>
|
||||
<Member type="Method">public Void printb(String text)</Member>
|
||||
<Member type="Method">public Void printb(String text, Int32 time)</Member>
|
||||
<Member type="Method">public Void printb(String text, Status status)</Member>
|
||||
<Member type="Method">public Void printb(String text, Status status, Int32 time)</Member>
|
||||
<Member type="Method">public Void print(String text)</Member>
|
||||
<Member type="Method">public Void print(String text, Int32 time)</Member>
|
||||
<Member type="Method">public Void print(String text, Status status)</Member>
|
||||
<Member type="Method">public Void print(String text, Status status, Int32 time)</Member>
|
||||
<Member type="Method">private Void anzeige(String text, Status status, Int32 time)</Member>
|
||||
<Member type="Method">public static LCDDisplay getInstance(String port)</Member>
|
||||
<Member type="Method">public Void RequestStop()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>Message</Name>
|
||||
<Access>Public</Access>
|
||||
<Location left="2635" top="2047" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">public String text</Member>
|
||||
<Member type="Field">public Status status</Member>
|
||||
<Member type="Field">public Int32 time</Member>
|
||||
<Member type="Constructor">public Message(String text, Status status, Int32 time)</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>Beeb</Name>
|
||||
<Access>Public</Access>
|
||||
<Location left="2439" top="2047" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">public Int32 frequency</Member>
|
||||
<Member type="Field">public Int32 duration</Member>
|
||||
<Member type="Constructor">public Beeb(Int32 frequency, Int32 duration)</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>EAN13</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="1615" top="407" />
|
||||
<Size width="162" height="366" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private Int64 prodId</Member>
|
||||
<Member type="Field">private Boolean found</Member>
|
||||
<Member type="Field">private ProdType type</Member>
|
||||
<Member type="Field">private Int32 price</Member>
|
||||
<Member type="Field">private String name</Member>
|
||||
<Member type="Field">private String function</Member>
|
||||
<Member type="Field">private Int32 id</Member>
|
||||
<Member type="Constructor">public EAN13(Int64 prodId)</Member>
|
||||
<Member type="Method">private Void load()</Member>
|
||||
<Member type="Method">internal Boolean vaild()</Member>
|
||||
<Member type="Method">internal ProdType GetProdType()</Member>
|
||||
<Member type="Method">internal Int64 GetProdId()</Member>
|
||||
<Member type="Method">internal Double GetProdPrice()</Member>
|
||||
<Member type="Method">internal String GetProdName()</Member>
|
||||
<Member type="Method">internal String GetFunctName()</Member>
|
||||
<Member type="Method">public Int32 GetDbId()</Member>
|
||||
<Member type="Method">public Boolean vaild(Boolean silent)</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>Program</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="795" top="27" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Constructor">public Program()</Member>
|
||||
<Member type="Method">public static Void Main(String[] args)</Member>
|
||||
<Member type="Method">private static Void test()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>RFIDReader</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="4146" top="1860" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private RFIDReaderClass r</Member>
|
||||
<Member type="Constructor">public RFIDReader(String comport)</Member>
|
||||
<Member type="Method">internal Int64 getCardID()</Member>
|
||||
<Member type="Method">internal Void Abort()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>Tables</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="116" top="67" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Constructor">public Tables()</Member>
|
||||
<Member type="Method">public TUser getUserTable(Int32 id)</Member>
|
||||
<Member type="Method">public TUser getUserTable(Int64 userid)</Member>
|
||||
<Member type="Method">public TProduct getProdTable(Int32 id)</Member>
|
||||
<Member type="Method">public TProduct getProdTable(Int64 barcode)</Member>
|
||||
<Member type="Method">internal List<TBest> getBestlist()</Member>
|
||||
<Member type="Method">internal TBest getUserMax(Int32 p)</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>TBest</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="226" top="387" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private Int64 _num</Member>
|
||||
<Member type="Field">private String _name</Member>
|
||||
<Member type="Property">public Int64 num { get; set; }</Member>
|
||||
<Member type="Property">public String name { get; set; }</Member>
|
||||
<Member type="Constructor">public TBest(Int64 num, String name)</Member>
|
||||
<Member type="Constructor">public TBest()</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>TUser</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="21" top="387" />
|
||||
<Size width="162" height="349" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private Int32 _id</Member>
|
||||
<Member type="Field">private Int64 _userid</Member>
|
||||
<Member type="Field">private String _username</Member>
|
||||
<Member type="Field">private Int32 _credits</Member>
|
||||
<Member type="Field">private Boolean _admin</Member>
|
||||
<Member type="Field">private String _shortname</Member>
|
||||
<Member type="Field">private String _email</Member>
|
||||
<Member type="Property">public Int32 id { get; set; }</Member>
|
||||
<Member type="Property">public Int64 userid { get; set; }</Member>
|
||||
<Member type="Property">public String username { get; set; }</Member>
|
||||
<Member type="Property">public Int32 credits { get; set; }</Member>
|
||||
<Member type="Property">public Boolean admin { get; set; }</Member>
|
||||
<Member type="Property">public String shortname { get; set; }</Member>
|
||||
<Member type="Property">public String email { get; set; }</Member>
|
||||
<Member type="Constructor">public TUser()</Member>
|
||||
<Member type="Constructor">public TUser(Int32 id, Int64 userid, String username, Int32 credits, Boolean admin, String shortname, String email)</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>RfidCode</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="1425" top="407" />
|
||||
<Size width="162" height="400" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private Int64 userId</Member>
|
||||
<Member type="Field">private Boolean found</Member>
|
||||
<Member type="Field">private String username</Member>
|
||||
<Member type="Field">private String shortname</Member>
|
||||
<Member type="Field">private Int32 credits</Member>
|
||||
<Member type="Field">private Int64 all</Member>
|
||||
<Member type="Field">private Boolean admin</Member>
|
||||
<Member type="Field">private Int32 id</Member>
|
||||
<Member type="Constructor">public RfidCode(Int64 userId)</Member>
|
||||
<Member type="Method">private Void load()</Member>
|
||||
<Member type="Method">public Boolean vaild(Boolean silent)</Member>
|
||||
<Member type="Method">public Boolean vaild()</Member>
|
||||
<Member type="Method">internal String GetUserName()</Member>
|
||||
<Member type="Method">internal Double GetUserKonto()</Member>
|
||||
<Member type="Method">internal Int64 GetUserId()</Member>
|
||||
<Member type="Method">public Int32 GetDbId()</Member>
|
||||
<Member type="Method">internal Double GetUserAll()</Member>
|
||||
<Member type="Method">internal Boolean IsAdmin()</Member>
|
||||
<Member type="Method">internal Void SetUserKonto(Double cost)</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>Worker</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="795" top="449" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private volatile Boolean _shouldStop</Member>
|
||||
<Member type="Field">private Automat automat</Member>
|
||||
<Member type="Field">private LCDDisplay lcd</Member>
|
||||
<Member type="Field">private TInput inp</Member>
|
||||
<Member type="Constructor">public Worker()</Member>
|
||||
<Member type="Method">public Void DoWork()</Member>
|
||||
<Member type="Method">private Void RequestStop(Boolean stop)</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Class">
|
||||
<Name>TProduct</Name>
|
||||
<Access>Internal</Access>
|
||||
<Location left="444" top="387" />
|
||||
<Size width="162" height="298" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Member type="Field">private Int32 _id</Member>
|
||||
<Member type="Field">private Int64 _barcode</Member>
|
||||
<Member type="Field">private String _name</Member>
|
||||
<Member type="Field">private Int32 _cost</Member>
|
||||
<Member type="Field">private Boolean _iscommand</Member>
|
||||
<Member type="Property">public Int32 id { get; set; }</Member>
|
||||
<Member type="Property">public Int64 barcode { get; set; }</Member>
|
||||
<Member type="Property">public String name { get; set; }</Member>
|
||||
<Member type="Property">public Int32 cost { get; set; }</Member>
|
||||
<Member type="Property">public Boolean iscommand { get; set; }</Member>
|
||||
<Member type="Property">public Int32 _caffeine { get; private set; }</Member>
|
||||
<Member type="Constructor">public TProduct()</Member>
|
||||
<Member type="Constructor">public TProduct(Int32 id, Int64 barcode, String name, Int32 cost, Boolean iscommand, Int32 caffeine)</Member>
|
||||
<Modifier>None</Modifier>
|
||||
</Entity>
|
||||
<Entity type="Delegate">
|
||||
<Name>stopEvent</Name>
|
||||
<Access>Public</Access>
|
||||
<Location left="880" top="748" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<ReturnType>Void</ReturnType>
|
||||
<Param>Boolean stop</Param>
|
||||
</Entity>
|
||||
<Entity type="Enum">
|
||||
<Name>QTypes</Name>
|
||||
<Access>Public</Access>
|
||||
<Location left="3123" top="2909" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Value>Select = 0</Value>
|
||||
</Entity>
|
||||
<Entity type="Enum">
|
||||
<Name>types</Name>
|
||||
<Access>Public</Access>
|
||||
<Location left="4525" top="1523" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Value>Card = 0</Value>
|
||||
<Value>Prod = 1</Value>
|
||||
<Value>None = 2</Value>
|
||||
</Entity>
|
||||
<Entity type="Enum">
|
||||
<Name>Stats</Name>
|
||||
<Access>Public</Access>
|
||||
<Location left="896" top="1074" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Value>LastMonth = 0</Value>
|
||||
<Value>All = 1</Value>
|
||||
</Entity>
|
||||
<Entity type="Enum">
|
||||
<Name>Status</Name>
|
||||
<Access>Public</Access>
|
||||
<Location left="2872" top="2047" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Value>OK = 0</Value>
|
||||
<Value>Warn = 1</Value>
|
||||
<Value>Error = 2</Value>
|
||||
</Entity>
|
||||
<Entity type="Enum">
|
||||
<Name>ProdType</Name>
|
||||
<Access>Public</Access>
|
||||
<Location left="1816" top="549" />
|
||||
<Size width="162" height="216" />
|
||||
<Collapsed>False</Collapsed>
|
||||
<Value>product = 0</Value>
|
||||
<Value>instruction = 1</Value>
|
||||
</Entity>
|
||||
</Entities>
|
||||
<Relationships>
|
||||
<Relationship type="Nesting" first="19" second="20">
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>2795</X>
|
||||
<Y>1997</Y>
|
||||
</BendPoint>
|
||||
<BendPoint relativeToStartShape="False">
|
||||
<X>2665</X>
|
||||
<Y>2022</Y>
|
||||
</BendPoint>
|
||||
</Relationship>
|
||||
<Relationship type="Nesting" first="19" second="21">
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>2717</X>
|
||||
<Y>2001</Y>
|
||||
</BendPoint>
|
||||
<BendPoint relativeToStartShape="False">
|
||||
<X>2585</X>
|
||||
<Y>2001</Y>
|
||||
</BendPoint>
|
||||
</Relationship>
|
||||
<Relationship type="Nesting" first="2" second="32">
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
</Relationship>
|
||||
<Relationship type="Nesting" first="16" second="33">
|
||||
<StartOrientation>Horizontal</StartOrientation>
|
||||
<EndOrientation>Horizontal</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>4457</X>
|
||||
<Y>1654</Y>
|
||||
</BendPoint>
|
||||
<BendPoint relativeToStartShape="False">
|
||||
<X>4494</X>
|
||||
<Y>1654</Y>
|
||||
</BendPoint>
|
||||
</Relationship>
|
||||
<Relationship type="Nesting" first="18" second="34">
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>801</X>
|
||||
<Y>1345</Y>
|
||||
</BendPoint>
|
||||
</Relationship>
|
||||
<Relationship type="Nesting" first="19" second="35">
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>2832</X>
|
||||
<Y>1998</Y>
|
||||
</BendPoint>
|
||||
</Relationship>
|
||||
<Relationship type="Nesting" first="22" second="36">
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
</Relationship>
|
||||
<Relationship type="Nesting" first="0" second="31">
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>803</X>
|
||||
<Y>989</Y>
|
||||
</BendPoint>
|
||||
</Relationship>
|
||||
<Relationship type="Generalization" first="3" second="2">
|
||||
<StartOrientation>Horizontal</StartOrientation>
|
||||
<EndOrientation>Horizontal</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>3277</X>
|
||||
<Y>2688</Y>
|
||||
</BendPoint>
|
||||
</Relationship>
|
||||
<Relationship type="Generalization" first="5" second="4">
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Horizontal</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>3628</X>
|
||||
<Y>2513</Y>
|
||||
</BendPoint>
|
||||
</Relationship>
|
||||
<Relationship type="Generalization" first="6" second="4">
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Horizontal</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>3961</X>
|
||||
<Y>2521</Y>
|
||||
</BendPoint>
|
||||
</Relationship>
|
||||
<Relationship type="Generalization" first="7" second="4">
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>3811</X>
|
||||
<Y>2525</Y>
|
||||
</BendPoint>
|
||||
<BendPoint relativeToStartShape="False">
|
||||
<X>3811</X>
|
||||
<Y>2489</Y>
|
||||
</BendPoint>
|
||||
</Relationship>
|
||||
<Relationship type="Generalization" first="11" second="10">
|
||||
<StartOrientation>Horizontal</StartOrientation>
|
||||
<EndOrientation>Horizontal</EndOrientation>
|
||||
</Relationship>
|
||||
<Relationship type="Generalization" first="26" second="25">
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>247</X>
|
||||
<Y>362</Y>
|
||||
</BendPoint>
|
||||
<BendPoint relativeToStartShape="False">
|
||||
<X>247</X>
|
||||
<Y>308</Y>
|
||||
</BendPoint>
|
||||
</Relationship>
|
||||
<Relationship type="Generalization" first="27" second="25">
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>132</X>
|
||||
<Y>360</Y>
|
||||
</BendPoint>
|
||||
<BendPoint relativeToStartShape="False">
|
||||
<X>132</X>
|
||||
<Y>323</Y>
|
||||
</BendPoint>
|
||||
</Relationship>
|
||||
<Relationship type="Generalization" first="30" second="25">
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Horizontal</EndOrientation>
|
||||
<BendPoint relativeToStartShape="False">
|
||||
<X>325</X>
|
||||
<Y>210</Y>
|
||||
</BendPoint>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="2" second="10">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="False">
|
||||
<X>3353</X>
|
||||
<Y>1807</Y>
|
||||
</BendPoint>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>db</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="2" second="32">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>_type</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="2" second="1">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Horizontal</StartOrientation>
|
||||
<EndOrientation>Horizontal</EndOrientation>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>_select</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="2" second="1">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Horizontal</StartOrientation>
|
||||
<EndOrientation>Horizontal</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>3074</X>
|
||||
<Y>2643</Y>
|
||||
</BendPoint>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>_from</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="2" second="1">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Horizontal</StartOrientation>
|
||||
<EndOrientation>Horizontal</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>3073</X>
|
||||
<Y>2616</Y>
|
||||
</BendPoint>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>_where</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="4" second="10">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>3660</X>
|
||||
<Y>2176</Y>
|
||||
</BendPoint>
|
||||
<BendPoint relativeToStartShape="False">
|
||||
<X>3450</X>
|
||||
<Y>1807</Y>
|
||||
</BendPoint>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>_db</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="12" second="19">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>lcd_i</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="12" second="17">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Horizontal</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="False">
|
||||
<X>4087</X>
|
||||
<Y>1318</Y>
|
||||
</BendPoint>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>inp_i</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="12" second="9">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Horizontal</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>2829</X>
|
||||
<Y>1190</Y>
|
||||
</BendPoint>
|
||||
<BendPoint relativeToStartShape="False">
|
||||
<X>2172</X>
|
||||
<Y>1338</Y>
|
||||
</BendPoint>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>con_i</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="12" second="10">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Horizontal</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>3096</X>
|
||||
<Y>1209</Y>
|
||||
</BendPoint>
|
||||
<BendPoint relativeToStartShape="False">
|
||||
<X>3398</X>
|
||||
<Y>1303</Y>
|
||||
</BendPoint>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>dbo_i</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="17" second="16">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Horizontal</StartOrientation>
|
||||
<EndOrientation>Horizontal</EndOrientation>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>data</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="17" second="24">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>4061</X>
|
||||
<Y>1798</Y>
|
||||
</BendPoint>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>rfid</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="17" second="8">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>code</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="20" second="35">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Horizontal</StartOrientation>
|
||||
<EndOrientation>Horizontal</EndOrientation>
|
||||
<BendPoint relativeToStartShape="True">
|
||||
<X>2822</X>
|
||||
<Y>2184</Y>
|
||||
</BendPoint>
|
||||
<BendPoint relativeToStartShape="False">
|
||||
<X>2842</X>
|
||||
<Y>2184</Y>
|
||||
</BendPoint>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>status</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="22" second="36">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>type</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Association" first="29" second="0">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
<Direction>Unidirectional</Direction>
|
||||
<AssociationType>Association</AssociationType>
|
||||
<StartRole>automat</StartRole>
|
||||
<EndMultiplicity>1</EndMultiplicity>
|
||||
</Relationship>
|
||||
<Relationship type="Dependency" first="23" second="29">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
</Relationship>
|
||||
<Relationship type="Dependency" first="0" second="18">
|
||||
<Label>
|
||||
</Label>
|
||||
<StartOrientation>Vertical</StartOrientation>
|
||||
<EndOrientation>Vertical</EndOrientation>
|
||||
</Relationship>
|
||||
</Relationships>
|
||||
</ProjectItem>
|
||||
</Project>
|
@ -56,6 +56,13 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Automat.cs" />
|
||||
<Compile Include="Database\Query\DatabaseQueryElement.cs" />
|
||||
<Compile Include="Database\Query\DBQuery.cs" />
|
||||
<Compile Include="Database\Query\DBQueryMysqli.cs" />
|
||||
<Compile Include="Database\Tables\Table.cs" />
|
||||
<Compile Include="Database\Tables\TableHistory.cs" />
|
||||
<Compile Include="Database\Tables\TableProduct.cs" />
|
||||
<Compile Include="Database\Tables\TableUser.cs" />
|
||||
<Compile Include="Input\BarcodeReader.cs" />
|
||||
<Compile Include="Input\Config.cs" />
|
||||
<Compile Include="Database\TDatabase.cs" />
|
||||
@ -64,15 +71,13 @@
|
||||
<Compile Include="Helper\Types.cs" />
|
||||
<Compile Include="Input\TInput.cs" />
|
||||
<Compile Include="Instruction.cs" />
|
||||
<Compile Include="Model\History.cs" />
|
||||
<Compile Include="Model\Product.cs" />
|
||||
<Compile Include="Model\User.cs" />
|
||||
<Compile Include="Output\LCDDisplay.cs" />
|
||||
<Compile Include="Data\EAN13.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Input\RFIDReader.cs" />
|
||||
<Compile Include="Database\Tables\Tables.Best.cs" />
|
||||
<Compile Include="Database\Tables\Tables.cs" />
|
||||
<Compile Include="Database\Tables\Tables.User.cs" />
|
||||
<Compile Include="Data\RfidCode.cs" />
|
||||
<Compile Include="Worker.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -89,7 +94,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<Compile Include="Database\Tables\Tables.Product.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
90
Matomat/Model/History.cs
Normal file
90
Matomat/Model/History.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Matomat.Helper;
|
||||
using Matomat.Database.Query;
|
||||
using Matomat.Database.Tables;
|
||||
|
||||
namespace Matomat.Model
|
||||
{
|
||||
class History
|
||||
{
|
||||
public static List<Tuple<string, long>> GetBestlist(int limit = 3)
|
||||
{
|
||||
DBQuery query = Factory.getDBO().getQuery(true);
|
||||
query.select("COUNT(*) AS " + Factory.getDBO().quoteName("num"));
|
||||
query.select(Factory.getDBO().quoteName("u.shortname", "name"));
|
||||
query.from(Factory.getDBO().quoteName("history", "h"));
|
||||
query.leftJoin(Factory.getDBO().quoteName("product", "p") + " ON " + Factory.getDBO().quoteName("p.id") + " = " + Factory.getDBO().quoteName("h.prod"));
|
||||
query.leftJoin(Factory.getDBO().quoteName("user", "u") + " ON " + Factory.getDBO().quoteName("u.id") + " = " + Factory.getDBO().quoteName("h.user"));
|
||||
query.where(Factory.getDBO().quoteName("p.iscommand") + " = " + Factory.getDBO().quote(0.ToString()));
|
||||
query.where(Factory.getDBO().quoteName("h.time") + " >= DATE_SUB(NOW(),INTERVAL 7 DAY)");
|
||||
query.group(Factory.getDBO().quoteName("h.user"));
|
||||
query.order(Factory.getDBO().quoteName("num"));
|
||||
query.limit(0, limit);
|
||||
|
||||
Factory.getDBO().setQuery(query);
|
||||
|
||||
List<object[]> rows = Factory.getDBO().getResultList();
|
||||
List<Tuple<string, long>> ret = new List<Tuple<string, long>>();
|
||||
if (rows == null)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
foreach (object[] row in rows)
|
||||
{
|
||||
ret.Add(new Tuple<string, long>((string)row[1], (long)row[0]));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int GetCoffeine()
|
||||
{
|
||||
DBQuery query = Factory.getDBO().getQuery(true);
|
||||
query.select("SUM(ROUND(POW(0.5,TIMESTAMPDIFF(SECOND," + Factory.getDBO().quoteName("h.time") + ",NOW())/4/60/60)*" + Factory.getDBO().quoteName("p.caffeine") + ")) AS " + Factory.getDBO().quoteName("coffeine_act"));
|
||||
query.from(Factory.getDBO().quoteName("history", "h"));
|
||||
query.leftJoin(Factory.getDBO().quoteName("product", "p") + " ON " + Factory.getDBO().quoteName("p.id") + " = " + Factory.getDBO().quoteName("h.prod"));
|
||||
query.where(Factory.getDBO().quoteName("h.time") + " >= DATE_SUB(NOW(),INTERVAL 7 DAY)");
|
||||
Factory.getDBO().setQuery(query);
|
||||
|
||||
object[] row = Factory.getDBO().getResult();
|
||||
if (row == null)
|
||||
{
|
||||
Console.WriteLine(Factory.getDBO().getError());
|
||||
return 0;
|
||||
}
|
||||
return (int)(double)row[0];
|
||||
}
|
||||
|
||||
public static int GetAvgCoffeine()
|
||||
{
|
||||
DBQuery query = Factory.getDBO().getQuery(true);
|
||||
query.select("SUM(ROUND(POW(0.5,TIMESTAMPDIFF(SECOND," + Factory.getDBO().quoteName("h.time") + ",NOW())/4/60/60)*" + Factory.getDBO().quoteName("p.caffeine") + ")) AS " + Factory.getDBO().quoteName("coffeine_act"));
|
||||
query.select("SUM(if(ROUND(POW(0.5,TIMESTAMPDIFF(SECOND," + Factory.getDBO().quoteName("h.time") + ",NOW())/4/60/60)*" + Factory.getDBO().quoteName("p.caffeine") + ")=0,0,1)) AS " + Factory.getDBO().quoteName("num"));
|
||||
query.from(Factory.getDBO().quoteName("history", "h"));
|
||||
query.leftJoin(Factory.getDBO().quoteName("product", "p") + " ON " + Factory.getDBO().quoteName("p.id") + " = " + Factory.getDBO().quoteName("h.prod"));
|
||||
query.where(Factory.getDBO().quoteName("h.time") + " >= DATE_SUB(NOW(),INTERVAL 7 DAY)");
|
||||
Factory.getDBO().setQuery(query);
|
||||
|
||||
object[] row = Factory.getDBO().getResult();
|
||||
if (row == null)
|
||||
{
|
||||
Console.WriteLine(Factory.getDBO().getError());
|
||||
return 0;
|
||||
}
|
||||
return (int)((double)row[0]/ double.Parse(((decimal)row[1]).ToString()));
|
||||
}
|
||||
|
||||
public static void Add(int product_id, int user_id)
|
||||
{
|
||||
TableHistory h = new TableHistory();
|
||||
Dictionary<string, object> k = new Dictionary<string, object>();
|
||||
k.Add("prod",product_id);
|
||||
k.Add("user",user_id);
|
||||
k.Add("time",DateTime.Now);
|
||||
h.bind(k);
|
||||
h.store();
|
||||
}
|
||||
}
|
||||
}
|
75
Matomat/Model/Product.cs
Normal file
75
Matomat/Model/Product.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Matomat.Database.Tables;
|
||||
|
||||
namespace Matomat.Model
|
||||
{
|
||||
class Product
|
||||
{
|
||||
public enum ProdType
|
||||
{
|
||||
Product,
|
||||
Instruction
|
||||
}
|
||||
private long barcode;
|
||||
private TableProduct table;
|
||||
|
||||
public Product(long barcode)
|
||||
{
|
||||
this.barcode = barcode;
|
||||
if (this.init() == false)
|
||||
{
|
||||
throw new ArgumentException("Produkt wurde nich gefunden\nEAN13: " + barcode + " unbekannt");
|
||||
}
|
||||
}
|
||||
|
||||
private bool init()
|
||||
{
|
||||
this.table = new TableProduct();
|
||||
Dictionary<string, string> load = new Dictionary<string, string>();
|
||||
load.Add("barcode",barcode.ToString());
|
||||
this.table.load(load);
|
||||
return (this.table.barcode == this.barcode);
|
||||
}
|
||||
|
||||
|
||||
public long GetBarcode()
|
||||
{
|
||||
return this.table.barcode;
|
||||
}
|
||||
|
||||
public double GetPrice()
|
||||
{
|
||||
return ((double)this.table.cost)/100;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return this.table.name;
|
||||
}
|
||||
|
||||
public ProdType GetProdType()
|
||||
{
|
||||
return (this.table.iscommand) ? ProdType.Instruction : ProdType.Product;
|
||||
}
|
||||
|
||||
internal int GetId()
|
||||
{
|
||||
return this.table.id;
|
||||
}
|
||||
|
||||
public static void Add(long barcode, string name, int preis, int coffeine)
|
||||
{
|
||||
TableProduct p = new TableProduct();
|
||||
Dictionary<string, object> k = new Dictionary<string, object>();
|
||||
k.Add("barcode", barcode);
|
||||
k.Add("name", name);
|
||||
k.Add("cost", preis);
|
||||
k.Add("caffeine", coffeine);
|
||||
p.bind(k);
|
||||
p.store();
|
||||
}
|
||||
}
|
||||
}
|
110
Matomat/Model/User.cs
Normal file
110
Matomat/Model/User.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Matomat.Database.Tables;
|
||||
using Matomat.Database.Query;
|
||||
using Matomat.Helper;
|
||||
|
||||
namespace Matomat.Model
|
||||
{
|
||||
class User
|
||||
{
|
||||
private long userid;
|
||||
private TableUser table;
|
||||
|
||||
public User(long userid)
|
||||
{
|
||||
this.userid = userid;
|
||||
if (this.init() == false)
|
||||
{
|
||||
throw new ArgumentException("User wurde nich gefunden\nUserId: " + userid + " unbekannt");
|
||||
}
|
||||
}
|
||||
|
||||
private bool init()
|
||||
{
|
||||
this.table = new TableUser();
|
||||
Dictionary<string, string> load = new Dictionary<string, string>();
|
||||
load.Add("barcode", userid.ToString());
|
||||
this.table.load(load);
|
||||
return (this.table.userid == this.userid);
|
||||
}
|
||||
|
||||
public string GetShortname()
|
||||
{
|
||||
return this.table.shortname;
|
||||
}
|
||||
|
||||
public double GetCredits()
|
||||
{
|
||||
return ((double)this.table.credits) / 100;
|
||||
}
|
||||
|
||||
public long GetUserId()
|
||||
{
|
||||
return this.table.userid;
|
||||
}
|
||||
|
||||
public double GetUserAll()
|
||||
{
|
||||
DBQuery query = Factory.getDBO().getQuery();
|
||||
query.select("SUM(" + Factory.getDBO().quoteName("p.cost") + ") AS " + Factory.getDBO().quoteName("num"));
|
||||
query.from(Factory.getDBO().quoteName("history", "h"));
|
||||
query.leftJoin(Factory.getDBO().quoteName("product", "p") + " ON " + Factory.getDBO().quoteName("p.id") + " = " + Factory.getDBO().quoteName("h.prod"));
|
||||
query.where(Factory.getDBO().quoteName("p.iscommand") + " = " + Factory.getDBO().quote(0.ToString()));
|
||||
query.where(Factory.getDBO().quoteName("h.user") + " = " + Factory.getDBO().quote(this.table.id.ToString()));
|
||||
|
||||
Factory.getDBO().setQuery(query);
|
||||
|
||||
object[] row = Factory.getDBO().getResult();
|
||||
if (row == null)
|
||||
{
|
||||
Console.WriteLine(Factory.getDBO().getError());
|
||||
return 0.0;
|
||||
}
|
||||
return ((double)row[0])/100;
|
||||
}
|
||||
|
||||
public bool GetAdmin()
|
||||
{
|
||||
return this.table.admin;
|
||||
}
|
||||
|
||||
public void SetUserKonto(double p)
|
||||
{
|
||||
p = (int)(p * 100);
|
||||
Dictionary<string, object> k = new Dictionary<string, object>();
|
||||
k.Add("credits", this.table.credits + p);
|
||||
this.table.bind(k);
|
||||
this.table.store();
|
||||
}
|
||||
|
||||
public static void Add(long userid, string username, bool isadmin, string kurzel, string email)
|
||||
{
|
||||
TableUser u = new TableUser();
|
||||
Dictionary<string, object> k = new Dictionary<string, object>();
|
||||
k.Add("userid", userid);
|
||||
k.Add("username", username);
|
||||
k.Add("admin", isadmin);
|
||||
k.Add("shortname", kurzel);
|
||||
k.Add("email", email);
|
||||
u.bind(k);
|
||||
u.store();
|
||||
}
|
||||
|
||||
public int GetId()
|
||||
{
|
||||
return this.table.id;
|
||||
}
|
||||
|
||||
public static void Remove(int id)
|
||||
{
|
||||
TableUser u = new TableUser();
|
||||
Dictionary<string, string> load = new Dictionary<string, string>();
|
||||
load.Add("id", id.ToString());
|
||||
u.load(load);
|
||||
u.delete();
|
||||
}
|
||||
}
|
||||
}
|
@ -175,40 +175,7 @@ namespace Matomat.Output
|
||||
Warn,
|
||||
Error
|
||||
}
|
||||
#region printb Display method for two lines (Border)
|
||||
/// <summary>
|
||||
/// Displays a two line string on the display
|
||||
/// </summary>
|
||||
/// <param name="text">Text to display. Break with \n, max length 38 chars each line</param>
|
||||
public void printb(string text)
|
||||
{
|
||||
this.printb(text, Status.OK, 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// Displays a two line string on the display with the minimum duration of the time
|
||||
/// </summary>
|
||||
/// <param name="text">Text to display. Break with \n, max length 38 chars each line</param>
|
||||
/// <param name="time">Minimum duration of displaying the text</param>
|
||||
public void printb(string text, int time)
|
||||
{
|
||||
this.printb(text, Status.OK, time);
|
||||
}
|
||||
/// <summary>
|
||||
/// Displays a two line string on the display with beebcodes when Status is not OK
|
||||
/// </summary>
|
||||
/// <param name="text">Text to display. Break with \n, max length 38 chars each line</param>
|
||||
/// <param name="status">Status code for that Item</param>
|
||||
public void printb(string text, Status status)
|
||||
{
|
||||
this.printb(text, status, 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// Displays a two line string on the display with the minimum duration of the time and beebcodes when Status is not OK
|
||||
/// </summary>
|
||||
/// <param name="text">Text to display. Break with \n, max length 38 chars each line</param>
|
||||
/// <param name="status">Status code for that Item</param>
|
||||
/// <param name="time">Minimum duration of displaying the text</param>
|
||||
public void printb(string text, Status status, int time)
|
||||
private void printb(string text, int time = 0, Status status = Status.OK)
|
||||
{
|
||||
string[] lines = text.Split('\n');
|
||||
string line1 = "";
|
||||
@ -236,30 +203,28 @@ namespace Matomat.Output
|
||||
line2 = line2.PadLeft((int)Math.Floor(ll2) + line2.Length, ' ');
|
||||
line2 = line2.PadRight((int)Math.Ceiling(ll2) + line2.Length, ' ');
|
||||
|
||||
this.print("²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²" +
|
||||
this.anzeige("²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²" +
|
||||
"²" + line1 + "²" +
|
||||
"²" + line2 + "²" +
|
||||
"²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²", status, time);
|
||||
}
|
||||
#endregion
|
||||
#region print Display method for the whole display
|
||||
public void print(string text)
|
||||
|
||||
/// <summary>
|
||||
/// Prints a text on the display with the minimum duration of the time and beebcodes when status is not Status.OK
|
||||
/// if the text is >= than 160 Chars it will display a border.
|
||||
/// </summary>
|
||||
/// <param name="text">Text to display. Break with \n, max length 38 chars each line</param>
|
||||
/// <param name="time" value="0">Minimum duration of displaying the text</param>
|
||||
/// <param name="status" value="Status.OK">Status code for that Item</param>
|
||||
public void print(string text, int time = 0, Status status = Status.OK)
|
||||
{
|
||||
this.anzeige(text, Status.OK, 0);
|
||||
if (text.Length <= 80)
|
||||
{
|
||||
this.printb(text, time, status);
|
||||
return;
|
||||
}
|
||||
public void print(string text, int time)
|
||||
{
|
||||
this.anzeige(text, Status.OK, time);
|
||||
}
|
||||
public void print(string text, Status status)
|
||||
{
|
||||
this.anzeige(text, status, 0);
|
||||
}
|
||||
public void print(string text, Status status, int time)
|
||||
{
|
||||
this.anzeige(text, status, time);
|
||||
}
|
||||
#endregion
|
||||
private void anzeige(string text, Status status, int time)
|
||||
{
|
||||
Message m = new Message(text, status, time);
|
||||
|
@ -12,28 +12,26 @@ namespace Matomat
|
||||
{
|
||||
private volatile bool _shouldStop;
|
||||
private Automat automat;
|
||||
private LCDDisplay lcd;
|
||||
private TInput inp;
|
||||
public Worker()
|
||||
{
|
||||
automat = new Automat();
|
||||
automat.stopThread += new Automat.stopEvent(RequestStop);
|
||||
lcd = Factory.getLCD();
|
||||
inp = Factory.getInput();
|
||||
Factory.getLCD();
|
||||
Factory.getInput();
|
||||
_shouldStop = false;
|
||||
}
|
||||
public void DoWork()
|
||||
{
|
||||
while (!_shouldStop)
|
||||
{
|
||||
automat.GetInitStatus();
|
||||
InputData input = inp.getAnyInput(60);
|
||||
Instruction.GetInitStatus();
|
||||
InputData input = Factory.getInput().getAnyInput(60);
|
||||
if (input.type != InputData.types.None)
|
||||
{
|
||||
automat.doJob(input);
|
||||
}
|
||||
}
|
||||
Factory.getLCD().printb("Der Matomat wurde beendet.\nEinen schönen Tag!");
|
||||
Factory.getLCD().print("Der Matomat wurde beendet.\nEinen schönen Tag!");
|
||||
Factory.rmLCD();
|
||||
Factory.rmInput();
|
||||
Factory.rmDBO();
|
||||
|
Loading…
Reference in New Issue
Block a user