Version 1.0

This commit is contained in:
BlubbFish 2013-08-01 11:44:30 +00:00
parent 3603c9460e
commit 98b5efba0a
11 changed files with 104 additions and 40 deletions

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="com_display" value="COM1"/>
@ -12,4 +12,4 @@
<add key="debug" value="false"/>
<add key="sell" value="true"/>
</appSettings>
</configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration>

View File

@ -35,7 +35,18 @@ namespace Matomat.Database
if (db.getError() != null)
{
throw new Exception("db Fehler:" + db.getError());
Exception e = db.getError();
if (e.GetType() == typeof(MySql.Data.MySqlClient.MySqlException))
{
String mesg = e.Message;
if (mesg.Length > 38)
{
mesg = mesg.Substring(0, 38) + "\n" + mesg.Substring(38);
}
Matomat.Helper.Factory.getLCD().print(mesg, 10, Matomat.Output.LCDDisplay.Status.Error);
System.Threading.Thread.Sleep(10000);
throw new Exception("ENDE");
}
}
instances.Add(signature,db);

View File

@ -21,7 +21,8 @@ namespace Matomat.Model
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.order(Factory.getDBO().quoteName("num")+" DESC");
query.order(Factory.getDBO().quoteName("name"));
query.limit(0, limit);
Factory.getDBO().setQuery(query);
@ -54,6 +55,10 @@ namespace Matomat.Model
Console.WriteLine(Factory.getDBO().getError());
return 0;
}
if (row[0].GetType() == System.DBNull.Value.GetType())
{
return 0;
}
return (int)(double)row[0];
}
@ -65,19 +70,38 @@ namespace Matomat.Model
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)");
query.group(Factory.getDBO().quoteName("h.user"));
Factory.getDBO().setQuery(query);
object[] row = Factory.getDBO().getResult();
if (row == null)
List<object[]> rows = Factory.getDBO().getResultList();
if (rows == null)
{
Console.WriteLine(Factory.getDBO().getError());
return 0;
}
if ((double)row[0] == 0.0)
if (rows.Count == 0)
{
return 0;
}
return (int)((double)row[0]/ double.Parse(((decimal)row[1]).ToString()));
if (rows[0][0].GetType() == System.DBNull.Value.GetType())
{
return 0;
}
if ((double)rows[0][0] == 0.0)
{
return 0;
}
double num = 0;
double meng = 0;
foreach (var row in rows)
{
if (int.Parse(row[1].ToString()) != 0)
{
meng += double.Parse(row[0].ToString());
num++;
}
}
return (int)(meng/num);
}
public static void Add(int product_id, int user_id)

View File

@ -17,7 +17,6 @@ namespace Matomat
public static void Main(string[] args)
{
//test();
InitMainThread();
Thread t = new Thread(MainThread);
t.Start();
@ -42,6 +41,8 @@ namespace Matomat
}
private static void MainThread()
{
try
{
while (!_shouldStop)
{
@ -58,6 +59,17 @@ namespace Matomat
Factory.rmDBO();
Factory.rmConfig();
}
catch (Exception e)
{
Factory.getLCD().print("Der Matomat wurde kritisch beendet.\n" + e.Message);
Console.WriteLine(e.ToString());
Factory.rmLCD();
Factory.rmInput();
Factory.rmDBO();
Factory.rmConfig();
Thread.Sleep(10000);
}
}
private static void RequestStop(bool stop)
{

View File

@ -1,16 +1,17 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Resources;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("Matomat")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("Der Matomat")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyCompany("BlubbFish")]
[assembly: AssemblyProduct("Matomat")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[assembly: AssemblyCopyright("Copyright © BlubbFish 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -34,3 +35,4 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguageAttribute("de-DE")]

BIN
Working/Matomat.exe Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="com_display" value="COM1"/>
<add key="com_rfid" value="COM11"/>
<add key="mysql_server" value="127.0.0.1"/>
<add key="mysql_user" value="root"/>
<add key="mysql_db" value="matomat"/>
<add key="mysql_port" value="3306"/>
<add key="mysql_pw" value="mafia"/>
<add key="mysql_driver" value="mysqli"/>
<add key="debug" value="false"/>
<add key="sell" value="true"/>
</appSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration>

BIN
Working/RfidClass.dll Normal file

Binary file not shown.

BIN
Working/librfid-tool.exe Normal file

Binary file not shown.

BIN
Working/mysql.data.dll Normal file

Binary file not shown.

Binary file not shown.