public void SetFillLevel(ContainerLevel cl) { if (cl.FillLevel > 100 || cl.FillLevel < 0) { throw new ArgumentException(); } string ID = cl.ID; Container container = GetContainer(ID); container.FillLevel = cl.FillLevel; container.LastUpdated = DateTime.Now; int fillLevel = GetFillLevel(ID); DateTime dateTime = GetDateTime(ID); Entry nEntry = new Entry(ID, dateTime, fillLevel); bool success = false; using (var tran = engine.GetTransaction()) { try { tran.Insert <string, DbXML <Container> >("containers", ID, container); tran.Commit(); success = true; } catch (DBreezeException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } } if (success == true) { ulong count = 0; using (var tran = engine.GetTransaction()) { count = tran.Count("history"); } using (var tran = engine.GetTransaction()) { tran.Insert <int, DbXML <Entry> >("history", (int)count, nEntry); tran.Commit(); } } bool isSent = GetSent(ID); if (cl.FillLevel > 80 && !isSent) { //send mail SendMail(ID); } if (cl.FillLevel < 80 && isSent) { SetSent(ID, false); } }
public void SetFillLevel(ContainerLevel cl) { if (cl.FillLevel > 100 || cl.FillLevel < 0) { throw new ArgumentException(); } using (var tran = engine.GetTransaction()) { tran.Insert <int, int>("containers", cl.ID, cl.FillLevel); tran.Commit(); } }