/** * @return void **/ public void updateUser() { while (this.isMonitoring) { try { src.WebConnection.WebConnection useronlinerequest = new src.WebConnection.WebConnection("http://ontrackapp.org/ajax/updateUserOnlineStatus/" + User.username, "POST", "method=client app"); useronlinerequest.getResponse(); } catch (Exception e) { this.isConnected = false; Debug.WriteLine(e.Message); } Thread.Sleep(1000); } }
/** * @return void **/ public void updateMachine() { while (this.isMonitoring) { try { src.WebConnection.WebConnection deviceonlinerequest = new src.WebConnection.WebConnection("http://ontrackapp.org/ajax/updateDeviceOnlineStatus", "POST", "machine-name=" + machine.getMachineName() + "&username="******"&uptime=" + machine.getMachineUpTime()); if (deviceonlinerequest.getRequestStatusDescription() == "OK") { this.isConnected = true; } else { this.isConnected = false; } deviceonlinerequest.getResponse(); } catch (Exception) { this.isConnected = false; } Thread.Sleep(1000); } }
/** * @return void **/ public void run() { while (this.isMonitoring) { if (machine.isProcessRunning("Steam") || machine.isProcessRunning("Origin")) { this.timePlaying++; Debug.WriteLine("Playing - " + this.timePlaying); if ((this.timePlaying % 5) == 0) { src.WebConnection.WebConnection webrequest = new src.WebConnection.WebConnection("http://ontrackapp.org/update/playing", "POST", "username="******"&time="+this.timePlaying); Debug.WriteLine(webrequest.getResponse()); this.timePlaying = 0; } } else { } /** * @note check if process is running every 1000ms **/ Thread.Sleep(1000); } }
/** * @return bool **/ public bool submit() { double questionCount = this.questions.Count; double correct = 0; /** * @note iterate through each question and make sure it's been answered * @note also check if the supplied attempt is correct **/ foreach (var question in this.questions) { if (question != null) { if (question.getAttempt().Equals("") || question == null) { MessageBox.Show("Please complete all questions"); return false; } else if (question.getAttempt().Equals(question.getAnswer())) { correct++; } } } /** * @note get result of the quiz as a percentage **/ double result = (correct/questionCount)*100; /** * @note hide question panels **/ foreach (var question in this.questions) { question.getQuestionPanel().Hide(); } /** * @note sync the result upstream **/ src.WebConnection.WebConnection webrequest = new src.WebConnection.WebConnection("http://ontrackapp.org/quiz/submit/" + User.username, "POST", "result="+result); MessageBox.Show(correct + "/" + questionCount + " " + ((correct / questionCount) * 100) + "%"); return true; }