static public MeetingElectionVote Create (MeetingElection poll, Geography voteGeography) { return FromIdentity(SwarmDb.GetDatabaseForWriting().CreateInternalPollVote(poll.Identity, voteGeography.Identity, Authentication. CreateRandomPassword(12))); }
static public MeetingElectionVote Create(MeetingElection poll, Geography voteGeography) { return (FromIdentity(SwarmDb.GetDatabaseForWriting().CreateInternalPollVote(poll.Identity, voteGeography.Identity, Authentication. CreateRandomPassword(12)))); }
public static MeetingElectionVoters ForPoll(MeetingElection poll, bool includeClosed) { if (includeClosed) { return(FromArray(SwarmDb.GetDatabaseForReading().GetInternalPollVoters(poll))); } return(FromArray(SwarmDb.GetDatabaseForReading().GetInternalPollVoters(poll, DatabaseCondition.OpenTrue))); }
public static MeetingElectionCandidate FromPersonAndPoll(Person person, MeetingElection poll) { MeetingElectionCandidates candidates = MeetingElectionCandidates.FromArray(SwarmDb.GetDatabaseForReading().GetInternalPollCandidates(person, poll)); if (candidates.Count == 0) { return(null); // Or throw exception? Which is the most accurate? } if (candidates.Count > 1) { throw new InvalidOperationException( "A specific person can not be a candidate more than once for a specific poll"); } return(candidates[0]); }
public static MeetingElectionCandidate FromPersonAndPoll (Person person, MeetingElection poll) { MeetingElectionCandidates candidates = MeetingElectionCandidates.FromArray(SwarmDb.GetDatabaseForReading().GetInternalPollCandidates(person, poll)); if (candidates.Count == 0) { return null; // Or throw exception? Which is the most accurate? } if (candidates.Count > 1) { throw new InvalidOperationException( "A specific person can not be a candidate more than once for a specific poll"); } return candidates[0]; }
public static MeetingElectionVoters ForPollClosed(MeetingElection poll) { return(FromArray(SwarmDb.GetDatabaseForReading().GetInternalPollVoters(poll, DatabaseCondition.OpenFalse))); }
public static MeetingElectionVoters ForPoll(MeetingElection poll) { return(ForPoll(poll, false)); }
public static MeetingElectionCandidate Create(MeetingElection poll, Person person, string candidacyStatement) { return(FromIdentity(SwarmDb.GetDatabaseForWriting().CreateInternalPollCandidate(poll.Identity, person.Identity, candidacyStatement))); }
private static void MailRawElectionResults(MeetingElection poll, SchulzeProcessor processor, bool stillOpen) { MeetingElectionCandidates candidates = processor.FinalOrder; Dictionary<int, bool> dropoutLookup = new Dictionary<int, bool>(); // TODO SOMETIME: implement and populate dropouts here string body = "These are " + (stillOpen ? "intermediate" : "THE FINAL") + " results for the poll \"" + poll.Name + "\". Note that the Dist field is purely informative and not part of the Schulze ranking.\r\n\r\n"; body += "Rank Dist Candidate\r\n"; for (int candidateIndex = 0; candidateIndex < candidates.Count; candidateIndex++) { int distance = processor.GetCandidateDistance(candidateIndex); body += String.Format("{0:D3}. {1} {2}{3}\r\n", candidateIndex + 1, (distance > 0 ? distance.ToString("D4") : "----"), candidates[candidateIndex].Person.Canonical, dropoutLookup.ContainsKey(candidates[candidateIndex].PersonId) ? " [hoppat av]" : string.Empty); } int[] recipients = new int[] { 1 , poll.CreatedByPersonId }; // Send to Rick too while stabilizing functionality -- remove as soon as Rick is running in any poll string subject = (stillOpen ? "Intermediate" : "FINAL") + " results for poll - " + poll.Name; foreach (int personId in recipients) { Person.FromIdentity(personId).SendNotice( subject, body, Organization.PPSEid); } }
static private void ReportPollResults (MeetingElection poll, bool stillOpen) { SchulzeProcessor processor = new SchulzeProcessor(); processor.Candidates = poll.Candidates; processor.Votes = MeetingElectionVotes.ForInternalPoll(poll); processor.Process(); MailRawElectionResults(poll, processor, stillOpen); }
public static MeetingElectionCandidates ForPoll(MeetingElection poll) { return(FromArray(SwarmDb.GetDatabaseForReading().GetInternalPollCandidates(poll))); }
public static MeetingElectionCandidate Create (MeetingElection poll, Person person, string candidacyStatement) { return FromIdentity (SwarmDb.GetDatabaseForWriting().CreateInternalPollCandidate(poll.Identity, person.Identity, candidacyStatement)); }