Пример #1
0
 /// <summary>
 /// Convert this CurrentSession into a PastSession.
 /// If we have not had at least 2 temperature readings, this will
 /// return null.
 /// </summary>
 public PastSession EndSession()
 {
     // If we don't have a temperature *range* (i.e. at least 2), no point in recording the session
     if (TempReadings.Count < 2)
     {
         return(null);
     }
     return(PastSession.FromFields(StartTime, DateTime.Now, FirstTemp.Value, LatestTemp.Value));
 }
Пример #2
0
        /// <summary>
        /// Create a new PastSession from the required fields.
        /// </summary>
        public static PastSession FromFields(DateTime StartDateTime, DateTime FinalDateTime, float StartTemp, float FinalTemp)
        {
            PastSession session = new PastSession();

            session.ID = 0;
            session.StartDateTimestamp = DateTimeToUnixTimestamp(StartDateTime);
            session.FinalDateTimestamp = DateTimeToUnixTimestamp(FinalDateTime);
            session.StartTemp          = StartTemp;
            session.FinalTemp          = FinalTemp;
            return(session);
        }
Пример #3
0
        /// <summary>
        /// Save a new PastSession or update an existing PastSession in the
        /// database.
        /// </summary>
        public int SaveSession(PastSession session)
        {
            InitDatabase();

            int retval;

            if (session.ID != 0)
            {
                retval = conn.Update(session);
            }
            else
            {
                retval = conn.Insert(session);
            }
            DatabaseChangeListeners?.Invoke();
            return(retval);
        }