private string GetConditions(VoterStatus vs) { string result; switch (vs) { case VoterStatus.SuspendedVoter: result = "This voter is a suspense voter. Please obtain an affidavit of residence before you complete the check in."; break; case VoterStatus.MailBallotNotReturned: result = "This voter was sent an absentee ballot and has not yet returned it. Please obtain an " + "affidavit before you complete the check in."; break; case VoterStatus.OutOfCounty: result = "This voter is an out of county voter. Please obtain appropriate affidavits " + "before you complete the check in."; break; default: result = "This dialog box is being shown inappropriately. Please consult the developers."; break; } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="RequestStatusChangeCommand"/> class. /// May I have a new command that requests a ballot of the target? /// </summary> /// <param name="sender"> /// The address of the one sending the command. /// </param> /// <param name="voternumber"> /// The voternumber to request a ballot for. /// </param> public DemandStatusChangeCommand(IPEndPoint sender, VoterNumber voternumber, VoterStatus newstatus) { Contract.Requires(sender != null); Sender = sender; _voternumber = voternumber; _newstatus = newstatus; }
public static bool GotBallot(this VoterStatus vs) { return(vs == VoterStatus.ActiveVoter || vs == VoterStatus.SuspendedVoter || vs == VoterStatus.OutOfCounty || vs == VoterStatus.Provisional); }
/// <summary> /// Initializes a new instance of the <see cref="BallotRequestDeniedCommand"/> class. /// May I have a new command that lets the recipient know that a ballot request was denied? /// </summary> /// <param name="sender"> /// The address of the one sending the command. /// </param> public BallotRequestDeniedCommand(IPEndPoint sender, VoterNumber vn, VoterStatus oldStatus, VoterStatus newStatus) { Contract.Requires(sender != null); Sender = sender; _voternumber = vn; _oldStatus = oldStatus; _newStatus = newStatus; }
/// <summary> /// The ballot request reply. /// </summary> /// <param name="successful"> /// The hand out ballot. /// </param> public void BallotRequestReply(Voter voter, bool success, VoterStatus oldStatus, VoterStatus newStatus) { if (BallotRequestPage != null) { BallotRequestPage.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { BallotRequestPage.BallotResponse(voter, success, oldStatus, newStatus); })); } }
/// <summary> /// Request a ballot for this voter! /// </summary> /// <param name="voterNumber"> /// The voternumber to request a ballot for. /// </param> public void RequestStatusChange(Voter voter, VoterStatus voterStatus) { Communicator.Send(new RequestStatusChangeCommand(Address, new VoterNumber(voter.VoterId), (VoterStatus)voter.PollbookStatus, voterStatus), Manager); if (Logger != null) { Logger.Log("Requesting status change for voter number " + voter.VoterId + " to " + voterStatus, Level.Info); } }
/// <summary> /// This voter received a ballot! /// </summary> /// <param name="voterNumber"> /// The voternumber to request a ballot for. /// </param> public void BallotReceived(VoterNumber voterNumber, VoterStatus voterStatus) { Contract.Ensures(Database[voterNumber] == voterStatus); Database[voterNumber] = voterStatus; if (Logger != null) { Logger.Log("Changed voter number " + voterNumber + " status to " + voterStatus + ".", Level.Info); } UI.RefreshStatistics(); }
/// <summary> /// Initializes a new instance of the <see cref="StatusChangedCommand"/> class. /// May I have a new command that tells the target that a ballot should be handed out and be marked as received? /// </summary> /// <param name="sender"> /// The address of the one sending the command. /// </param> /// <param name="requester"> /// The address of the station who initially requested the ballot. /// </param> /// <param name="voterNumber"> /// The voternumber of the ballot to be handed out and to be marked as received. /// </param> /// <param name="cpr"> /// The CPR-number of the ballot to be handed out and to be marked as received. /// </param> public StatusChangedCommand(IPEndPoint sender, IPEndPoint requester, VoterNumber voterNumber, VoterStatus oldStatus, VoterStatus newStatus) { Contract.Requires(sender != null); Contract.Requires(requester != null); _requester = requester; _voterNumber = voterNumber; _oldStatus = oldStatus; _newStatus = newStatus; Sender = sender; }
/// <summary> /// Announce to all that they should revoke this update! /// </summary> /// <param name="voterNumber"> /// The voternumber to revoke a ballot for. /// </param> /// <param name="cpr"> /// The CPR number to revoke a ballot for. /// </param> public void AnnounceRevokeBallot(Voter voter, VoterStatus oldStatus) { Contract.Requires(IsManager); var cmd = new DemandStatusChangeCommand(Address, new VoterNumber(voter.VoterId), oldStatus); Peers.Keys.ForEach(peer => Communicator.Send(cmd, peer)); cmd.Execute(this); if (Logger != null) { Logger.Log("Announcing that this status change should be revoked for voter number " + voter.VoterId, Level.Warn); } }
private VoterStatus GetNewVoterStatus(Voter voter) { // let's figure out what the voter's status should be VoterStatus result = VoterStatus.Unavailable; if (voter.EligibleDate.Date > DateTime.Today.Date) { // voter is ineligible result = VoterStatus.Ineligible; } else if (!_ui._station.PollingPlace.PrecinctIds.Contains(voter.PrecinctSub)) { // voter doesn't belong here result = VoterStatus.WrongLocation; } else if (voter.Status.ToUpper().Equals("A")) { // active voter if (voter.Voted) { result = VoterStatus.EarlyVotedInPerson; } else if (voter.Absentee && voter.ReturnStatus.ToUpper().Equals("PB")) { result = VoterStatus.VotedByMail; } else if (voter.Absentee && voter.ReturnStatus.Trim().Length == 0) { result = VoterStatus.MailBallotNotReturned; } else if (voter.Absentee) { result = VoterStatus.AbsenteeVotedInPerson; } else if (voter.StateId >= 1900000000) { result = VoterStatus.OutOfCounty; } else { result = VoterStatus.ActiveVoter; } } else { // suspended voter result = VoterStatus.SuspendedVoter; } return(result); }
public ConfirmSingleVoterWithConditionsDialog(Voter v, VoterStatus vs) { InitializeComponent(); string votername; string middlename = " "; if (v.MiddleName != null && v.MiddleName.Trim().Length != 0) { middlename = " " + v.MiddleName + " "; } votername = v.FirstName + middlename + v.LastName; if (v.Suffix != null && v.Suffix.Trim().Length > 0) { votername = votername + ", " + v.Suffix; } NameBox.Content = votername; if (v.ProtectedAddress) { Address.Content = "Address Protected for Privacy"; MunicipalityAndZIP.Content = ""; } else { Address.Content = v.Address; MunicipalityAndZIP.Content = v.Municipality + ", TX " + v.ZipCode; } DateOfBirth.Content = "Date Of Birth: " + v.DateOfBirth.Date.ToString("MM/dd/yyyy"); VUID.Content = "VUID: " + v.StateId; if (v.DriversLicense.Length > 0) { DriversLicense.Content = "Drivers License: " + v.DriversLicense; } else { DriversLicense.Content = "Drivers License: Not On File"; } VoterConditions.Text = GetConditions(vs); OKButton.IsEnabled = false; }
/// <summary> /// This method is called when a voter wants to request a ballot after entering their voternumber and CPR number /// </summary> /// <param name="voterNumber"> /// the voternumber of the voter /// </param> public void RequestStatusChange(Voter voter, VoterStatus voterStatus) { _station.RequestStatusChange(voter, voterStatus); }
public void BallotRequestReply(VoterNumber vn, bool success, VoterStatus oldStatus, VoterStatus newStatus) { BallotRequestReply(_station.Database.GetVoterByVoterNumber(vn), success, oldStatus, newStatus); }
/// <summary> /// Called when the manager responds to a ballot request /// </summary> /// <param name="succes"> /// whether or not the ballot request was a success /// </param> public void BallotResponse(Voter voter, bool success, VoterStatus oldStatus, VoterStatus newStatus) { if (!success && newStatus != VoterStatus.NotSeenToday && newStatus != VoterStatus.WrongLocation) { string message; if (newStatus == VoterStatus.ActiveVoter || newStatus == VoterStatus.SuspendedVoter || newStatus == VoterStatus.OutOfCounty || newStatus == VoterStatus.MailBallotNotReturned) { message = GetFormattedName(voter) + "\nhas already checked in and received a ballot\n(style " + voter.BallotStyle + ") at this location today."; } else { message = GetFormattedName(voter) + "\nhas already checked in and did not receive a ballot\n" + "at this location today."; } FlexibleMessageBox.Show(_ui._stationNativeWindow, message, "Already Checked In", MessageBoxButtons.OK, MessageBoxIcon.Stop); } switch (newStatus) { case VoterStatus.Ineligible: FlexibleMessageBox.Show(_ui._stationNativeWindow, "According to our records,\n" + GetFormattedName(voter) + "\nis not eligible to vote until " + voter.EligibleDate.Date.ToString("MM/dd/yyyy")); break; case VoterStatus.WrongLocation: Precinct p = _ui._station.Database.GetPrecinctBySplitId(voter.PrecinctSub); if (p != null && p.Address.Trim().Length > 0) { WrongLocationDialog wrd = null; Boolean result = false; _ui._stationWindow.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action( delegate { wrd = new WrongLocationDialog(voter, p); wrd.Owner = _ui._stationWindow; result = (Boolean)wrd.ShowDialog(); })); if (result == true) { string here = _ui._station.PollingPlace.Address + ", " + _ui._station.PollingPlace.CityStateZIP; string there = p.Address + ", " + p.CityStateZIP; string url = "https://maps.google.com/maps/dir/" + here.Replace(" ", "+") + "/" + there.Replace(" ", "+"); System.Diagnostics.Process.Start(url); } } else { FlexibleMessageBox.Show(_ui._stationNativeWindow, "The precinct where\n" + GetFormattedName(voter) + "\nis registered is" + " not participating\nin this election."); } break; case VoterStatus.VotedByMail: FlexibleMessageBox.Show(_ui._stationNativeWindow, "According to our records,\n" + GetFormattedName(voter) + "\nhas already submitted a vote by mail\nand should not receive a ballot."); break; case VoterStatus.EarlyVotedInPerson: FlexibleMessageBox.Show(_ui._stationNativeWindow, "According to our records,\n" + GetFormattedName(voter) + "\nhas already voted at an early voting location."); break; case VoterStatus.AbsenteeVotedInPerson: FlexibleMessageBox.Show(_ui._stationNativeWindow, "According to our records,\n" + GetFormattedName(voter) + "\nregistered as an absentee voter but did not receive their ballot."); break; default: break; } if (success) { switch ((VoterStatus)voter.PollbookStatus) { case VoterStatus.SuspendedVoter: case VoterStatus.OutOfCounty: case VoterStatus.MailBallotNotReturned: case VoterStatus.ActiveVoter: case VoterStatus.Provisional: _ui._stationWindow.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action( delegate { var bd = new GiveBallotDialog(voter); bd.Owner = _ui._stationWindow; bd.ShowDialog(); })); break; default: break; } } EnableFields(true); ClearFields(); WaitingLabel.Content = string.Empty; Waiting = false; }
/// <summary> /// Called when the Done button is pressed /// </summary> /// <param name="sender"> /// autogenerated /// </param> /// <param name="e"> /// autogenerated /// </param> private void CheckValidityButtonClick(object sender, RoutedEventArgs e) { List <Voter> results = new List <Voter>(); Int64 stateId = -1; bool stateIdParsed = Int64.TryParse(StateId.Text.Trim().TrimEnd(System.Environment.NewLine.ToCharArray()), out stateId); if (!StateId.Text.Equals(string.Empty)) { // check state id first Voter v = _ui._station.Database.GetVoterByStateId(stateId); if (v != null) { results.Add(v); } } else if (!DriversLicense.Text.Equals(string.Empty)) { // check driver's license first Voter v = _ui._station.Database.GetVoterByDLNumber(DriversLicense.Text); if (v != null) { results.Add(v); } } else { results = _ui._station.Database.GetVotersBySearchStrings (LastName.Text, FirstName.Text, MiddleName.Text, Address.Text, Municipality.Text, ZipCode.Text); } Voter choice = null; VoterStatus vs = VoterStatus.Unavailable; if (results == null || results.Count == 0) { FlexibleMessageBox.Show(_ui._stationNativeWindow, "No voters match your search. Please try again\nor have the voter register for a provisional ballot."); } else if (results.Count == 1) { vs = GetNewVoterStatus(results[0]); Window dialog; Boolean result = false; _ui._stationWindow.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action( delegate { if (((int)vs != results[0].PollbookStatus) && ((vs == VoterStatus.SuspendedVoter) || (vs == VoterStatus.MailBallotNotReturned) || (vs == VoterStatus.OutOfCounty))) { dialog = new ConfirmSingleVoterWithConditionsDialog(results[0], vs); } else { dialog = new ConfirmSingleVoterDialog(results[0]); } dialog.Owner = _ui._stationWindow; result = (Boolean)dialog.ShowDialog(); })); if (result) { choice = results[0]; } } else { ConfirmMultiVoterDialog dialog = null; Boolean result = false; _ui._stationWindow.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action( delegate { dialog = new ConfirmMultiVoterDialog(results); dialog.Owner = _ui._stationWindow; result = (Boolean)dialog.ShowDialog(); })); if (result) { choice = dialog.SelectedVoter; vs = GetNewVoterStatus(choice); Window dialog2; Boolean result2 = false; _ui._stationWindow.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action( delegate { if (((int)vs != choice.PollbookStatus) && ((vs == VoterStatus.SuspendedVoter) || (vs == VoterStatus.MailBallotNotReturned) || (vs == VoterStatus.OutOfCounty))) { dialog2 = new ConfirmSingleVoterWithConditionsDialog(choice, vs); } else { dialog2 = new ConfirmSingleVoterDialog(choice); } dialog2.Owner = _ui._stationWindow; result2 = (Boolean)dialog2.ShowDialog(); })); if (!result2) { choice = null; vs = VoterStatus.Unavailable; } } } if (choice != null) { WaitingLabel.Content = "Waiting for response from manager..."; EnableFields(false); Waiting = true; if (vs == (VoterStatus)choice.PollbookStatus) { BallotResponse(choice, false, vs, vs); } else { _ui.RequestStatusChange(choice, vs); } } }
public void BallotRequestReply(Voter v, bool handOutBallot, VoterStatus oldStatus, VoterStatus newStatus) { HandOutBallot = handOutBallot; }