/// <summary> /// Stops the current recording session. /// </summary> /// <returns>True if a session was saved, false otherwise. Note: we will return false if the manager was not /// currently recording.</returns> public Task <bool> StopRecording() { return(Task.Factory.StartNew(() => { Log.D(this, "Stopping Recording"); if (currentSession == null) { return false; } Log.D(this, "Cancelling current logging session."); currentSession.session.sessionEnd = DateTime.Now; currentSession.session.frn_JID = ion.preferences.jobs.activeJob; //if (!ion.database.SaveAsync<SessionRow>(currentSession.session).Result) { // Log.E(this, "Failed to update session end time."); //} Log.D(this, "Saving session: " + currentSession.session); var ret = ion.database.SaveAsync(currentSession.session).Result; Log.D(this, "about to cancel timer"); currentSession.Cancel(); // ion.database.Update(ret); Log.D(this, "Disposing current session"); currentSession.Dispose(); currentSession = null; NotifyEvent(DataLogManagerEvent.EType.RecordingEnded); return ret; })); }
/// <summary> /// Informs the DataLogManager that is should begin a new recording session. /// </summary> public Task <bool> BeginRecording(TimeSpan interval, JobRow job = null) { return(Task.Factory.StartNew(() => { if (currentSession != null) { return false; } var db = ion.database; var id = job != null ? job.JID : 0; var session = new SessionRow() { frn_JID = id, sessionStart = DateTime.Now, sessionEnd = DateTime.Now, }; if (!db.SaveAsync <SessionRow>(session).Result) { return false; } currentSession = new LoggingSession(ion, session, interval); recordingInterval = interval; NotifyEvent(DataLogManagerEvent.EType.RecordingStarted); return true; })); }