private void DoorClose() { var eventTime = DateTime.UtcNow; var diff = eventTime - lastOpenTime; if (diff.Seconds > 0) { if (Log.IsEnabled(System.Diagnostics.Tracing.EventLevel.Verbose, System.Diagnostics.Tracing.EventKeywords.All)) { var data = new { OpenTime = lastOpenTime, CloseTime = eventTime, OpenedElasped = diff }; Log.Write("DOORCLOSE", data); } var ev = new DoorEvent { Id = 1, Opentime = lastOpenTime, Closetime = eventTime }; service.AddDoorEvent(ev); } else { if (Log.IsEnabled(System.Diagnostics.Tracing.EventLevel.Verbose, System.Diagnostics.Tracing.EventKeywords.All)) { var data = new { OpenTime = lastOpenTime, CloseTime = eventTime, OpenedElasped = diff, EventMessage = "this is an empty event, time between open and close is too short...." }; Log.Write("DOORCLOSE", data); } } }
public void AddDoorEvent(DoorEvent ev) { using (var cnx = getConnection()) { var openDate = ev.Opentime.ToString("O"); var closeDate = ev.Closetime.ToString("O"); bool insert = true; //parfois il y a un rebond de porte < 0.5 secondes, il faut donc mettre à jour l'enregistrement précédent //et ne pas inseré de nouveau using (var cmd = cnx.CreateCommand()) { cmd.CommandText = string.Format("UPDATE doorevent set eventclosetime = '{0}' where (julianday('{1}') - julianday(eventclosetime)) * 24 * 60 * 60 between 0 and 0.5", closeDate, openDate); if (cmd.ExecuteNonQuery() > 0) { insert = false; } } if (insert) { using (var cmdInsert = cnx.CreateCommand()) { cmdInsert.CommandText = string.Format("INSERT INTO doorevent (doorid, eventopentime, eventclosetime) VALUES ({0}, '{1}', '{2}')", ev.Id, openDate, closeDate); cmdInsert.ExecuteNonQuery(); } } } }
public IGetResponse MondayThursdayEvents(int year, int month) { DoorEvent[] data = new DoorEvent[0]; data = this._service.GetDoorEventsForMondayThursday(year, month).ToArray(); return(new GetResponse( GetResponse.ResponseStatus.OK, data )); }
private DoorAggregat MondayThursdayToDashBoard(DoorEvent ev) { var parisTime = ev.Opentime.ToLocalTime(); var v = $"{parisTime.Day}/{parisTime.Hour}.{parisTime.Minute:D2}"; return(new DoorAggregat { AggregatName = "monthmondaythirsday_data", AggregatValue = v, Unit = "", IdEvent = ev.Id }); }
public IGetResponse DoorEvents(string view, string syear, string smonth, string sday) { var dtOffsetRef = ParseDateParams(syear, smonth, sday); DoorEvent[] data = new DoorEvent[0]; switch (view) { case "month": data = this._service.GetDoorEventsForCurrentMonth(dtOffsetRef).ToArray(); break; case "year": data = this._service.GetDoorEventsForCurrentYear(dtOffsetRef).ToArray(); break; case "week": data = this._service.GetDoorEventsForCurrentWeek(dtOffsetRef).ToArray(); break; } return(new GetResponse( GetResponse.ResponseStatus.OK, data )); }
public void AddDoorEvent(DoorEvent ev) { this._db.AddDoorEvent(ev); }