public void UpdateAttemptState(ConnectionStateBase newState) { lock (_syncLock) switch (newState.State) { case ConnectionState.Connecting: Attempts.Add(new ConnectionAttempt(Now())); break; case ConnectionState.Failed: case ConnectionState.Closed: case ConnectionState.Connected: Reset(); break; case ConnectionState.Suspended: case ConnectionState.Disconnected: if (newState.Exception != null) { RecordAttemptFailure(newState.State, newState.Exception); } else { RecordAttemptFailure(newState.State, newState.Error); } break; } }
public void UpdateAttemptState(ConnectionStateBase newState, ILogger logger) { switch (newState.State) { case ConnectionState.Connecting: logger.Debug("Recording connection attempt."); Attempts.Add(new ConnectionAttempt(_now())); break; case ConnectionState.Failed: case ConnectionState.Closed: case ConnectionState.Connected: logger.Debug("Resetting Attempts collection."); Reset(); break; case ConnectionState.Suspended: case ConnectionState.Disconnected: logger.Debug($"Recording failed attempt for state {newState.State}."); if (newState.Exception != null) { RecordAttemptFailure(newState.State, newState.Exception); } else { RecordAttemptFailure(newState.State, newState.Error); } break; } }
public void OnAttempt(bool win, float timeOfDeath, float distanceTravelled, float previousCompetenceValue) { Attempts.AttemptModel attempt = new Attempts.AttemptModel(win, timeOfDeath, distanceTravelled, previousCompetenceValue); FileStream stream = new FileStream(Application.persistentDataPath + "/" + dataFileName, FileMode.OpenOrCreate); StreamReader reader = new StreamReader(stream); string json = reader.ReadToEnd(); stream.Close(); stream = new FileStream(Application.persistentDataPath + "/" + dataFileName, FileMode.Truncate); Attempts attempts = new Attempts(); if (!string.IsNullOrEmpty(json)) { attempts = JsonUtility.FromJson <Attempts> (json); } attempts.Add(attempt); json = JsonUtility.ToJson(attempts); StreamWriter writer = new StreamWriter(stream); writer.Write(json); writer.Flush(); stream.Close(); }
public void Add(Model.Model m) { switch (m.Table) { case "Educations": Educations.Add((Education)m); break; case "Students": Students.Add((Student)m); break; case "Exams": Exams.Add((Exam)m); break; case "Attempts": Attempts.Add((Attempt)m); break; } DataRow dr = dao.Data.Tables[m.Table].NewRow(); m.FillRow(dr); dao.Data.Tables[m.Table].Rows.Add(dr); dao.UpdateTable(m.Table); m.Data = dr; m.AfterCreate(); }
private void RecordAttemptFailure(ConnectionState state, ErrorInfo error) { var attempt = Attempts.LastOrDefault() ?? new ConnectionAttempt(_now()); attempt.FailedStates.Add(new AttemptFailedState(state, error)); if (Attempts.Count == 0) { Attempts.Add(attempt); } }
public void RecordAttemptFailure(ConnectionState state, ErrorInfo error) { lock (_syncLock) { var attempt = Attempts.LastOrDefault() ?? new ConnectionAttempt(Config.Now()); attempt.FailedStates.Add(new AttemptFailedState(state, error)); if (Attempts.Count == 0) { Attempts.Add(attempt); } } }
public CodeResult EnterCode(Code code) { var result = Code.Match(code); Attempts.Add(result); if (result.Correct) { FinishedAt = DateTimeOffset.UtcNow; Score = new Score(Id, (short)Attempts.Count, Duration.Value); } return(result); }
public override int Guess() { var result = BasicPlayer.Guess(); while (Attempts.Contains(result)) { result = BasicPlayer.Guess(); } Attempts.Add(result); return(result); }
public void UpdateLists() { Educations.Clear(); Students.Clear(); Exams.Clear(); Attempts.Clear(); foreach (DataRow dr in dao.Data.Tables["Educations"].Rows) { Education e = new Education(dr); Educations.Add(e); Students.AddRange(e.Students); Exams.AddRange(e.Exams); } foreach (DataRow dr in dao.Data.Tables["Attempts"].Rows) { Student s = (from stud in Students where stud.ID == (int)dr["student_id"] select stud).First(); Exam e = (from ex in Exams where ex.ID == (int)dr["exam_id"] select ex).First(); Attempts.Add(new Attempt(dr, e, s)); } }
public async void AttemptGame(string completeAttempt) { string attemptGameURL = $"{_baseURL}/Game/Attempt/{completeAttempt}"; StringContent queryString = new StringContent(completeAttempt); HttpResponseMessage response = await _client.PostAsync(new Uri(attemptGameURL), queryString); _hints = string.Empty; if (response.IsSuccessStatusCode) { _hints = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); } Attempt newAttempt = new Attempt { ValueOne = ValueOne, ValueTwo = ValueTwo, ValueThree = ValueThree, ValueFour = ValueFour, Hints = _hints }; Attempts.Add(newAttempt); }
public void OnNext(MoveEvent ev) { Attempts.Add(ev.Attempt); }