private void ClearState() { this.state = DICEState.Ready; this.fileName = ""; this.misreads = 0; this.reviewed = false; this.paperJam = false; this.ballotNotRecognized = false; }
public void ReadLine(string line) { // The timestamp is 20 characters long if (line.Length < 21) { // There is nothing useful in the line, do nothing return; } // Get the position of the first colon after the timestamp int colPos = 21 + line.Substring(21).IndexOf(":"); if (colPos == 20) { // Do nothing if the colon was not found return; } DateTime thisTime = GetTimestampFromDICELine(line); string rest = line.Substring(colPos + 1).Trim(); switch (rest) { case s_accessibleStarted: this.state = DICEState.AccessibleStarted; this.startTime = thisTime; break; case s_accessibleMarkingCompleted: this.state = DICEState.Ready; this.WriteAccessibleBallotMarkedRecord(startTime, thisTime); break; case s_ballotInserted: if (Util.GetDifferenceMinutes(this.lastTimestamp, thisTime) > 2) { // If there's a large difference in time here, the earlier session // was probably abandoned due to something. So we clear the state. this.ClearState(); } this.state = DICEState.BallotInserted; this.startTime = thisTime; break; case s_ballotCast: this.state = DICEState.BallotCast; break; case s_endOfSession: this.WriteRecordAccordingToState(this.startTime, thisTime); this.ClearState(); break; case s_ballotMisread: this.misreads++; break; case s_invokingBallotReview: this.reviewed = true; break; case s_noManifestation: this.ballotNotRecognized = true; break; default: if (rest.Contains(s_paperJam)) { this.paperJam = true; } break; } this.lastTimestamp = thisTime; }