Exemple #1
0
        /// <summary>
        /// Can you save the polling cards for this polling venue on the harddrive?
        /// </summary>
        /// <param name="pollingVenue">The polling venue</param>
        /// <param name="electionName">The name of the election</param>
        /// <param name="electionDate">The date of the election</param>
        public void SavePollingCards(PollingVenue pollingVenue, string electionName, string electionDate)
        {
            Contract.Requires(pollingVenue != null);
            Contract.Ensures(File.Exists(this.path + "\\PollingCards.pdf"));

            var pollingCards = new PollingCards(electionName, electionDate, "09.00 - 20.00");

            foreach (var person in pollingVenue.Persons){
                pollingCards.CreatePollingCard(person, pollingVenue.MunicipalityAddress, pollingVenue.PollingVenueAddress);
            }

            pollingCards.SaveToDisk(this.path+"\\PollingCards.pdf");
        }
Exemple #2
0
        /// <summary>
        /// Calculate the hash code of the instance.
        /// </summary>
        /// <returns>The hash code of the instance.</returns>
        public override int GetHashCode()
        {
            unchecked {
                var result = DbId;
                result = (result * 397) ^ (FirstName != null ? FirstName.GetHashCode() : 0);
                result = (result * 397) ^ (LastName != null ? LastName.GetHashCode() : 0);
                result = (result * 397) ^ (Street != null ? Street.GetHashCode() : 0);
                result = (result * 397) ^ (City != null ? City.GetHashCode() : 0);
                result = (result * 397) ^ (Cpr != null ? Cpr.GetHashCode() : 0);
                result = (result * 397) ^ VoterId;
                result = (result * 397) ^ (PollingVenue != null ? PollingVenue.GetHashCode() : 0);
                result = (result * 397) ^ (PollingTable != null ? PollingTable.GetHashCode() : 0);
                result = (result * 397) ^ Voted.GetHashCode();
                result = (result * 397) ^ VotedTime;
                result = (result * 397) ^ (VotedPollingTable != null ? VotedPollingTable.GetHashCode() : 0);
                result = (result * 397) ^ Exists.GetHashCode();

                return(result);
            }
        }
Exemple #3
0
        /// <summary>
        /// Parses the xml file into a list of polling venues 
        /// </summary>
        /// <param name="xDocument">The xml file</param>
        /// <param name="notifier">Event subscriber if validation of the xml file fails</param>
        /// <returns>A list of polling venues</returns>
        private List<PollingVenue> LoadVenues(XDocument xDocument, ValidationEventHandler notifier)
        {
            if (!this.ValidateXmlFile(xDocument, notifier)){
                var pollingVenuesElements = from n in xDocument.Descendants("PollingVenue") select n;

                List<PollingVenue> pollingVenues = new List<PollingVenue>();
                foreach (var xElement in pollingVenuesElements){

                    Address pollingVenueAddress = new Address{
                        Name = xElement.Element("Name").Value,
                        Street = xElement.Element("Street").Value,
                        City = xElement.Element("City").Value
                    };

                    Address municipalityAddress = new Address{
                        Name = xElement.Parent.Parent.Element("Name").Value,
                        Street = xElement.Parent.Parent.Element("Street").Value,
                        City = xElement.Parent.Parent.Element("City").Value
                    };

                    PollingVenue pollingVenue = new PollingVenue{
                        Persons = this.LoadPersons(xElement),
                        PollingVenueAddress = pollingVenueAddress,
                        MunicipalityAddress = municipalityAddress
                    };

                    pollingVenues.Add(pollingVenue);
                }
                return pollingVenues;
            }

            return null;
        }
Exemple #4
0
        /// <summary>
        /// Can you save these voters to a csv file seperated with a ;?
        /// </summary>
        /// <param name="pollingVenue">The polling venue</param>
        public void SaveVoters(PollingVenue pollingVenue)
        {
            Contract.Requires(pollingVenue != null);
            Contract.Ensures(File.Exists(this.path + "\\Voters.csv"));

            var sw = new StreamWriter(this.path+"\\Voters.csv", false);
            sw.WriteLine("FirstName;LastName;Cpr;VoterId;PollingTable;PollingVenueName"); //Header in the csv file

            foreach (var person in pollingVenue.Persons){
                sw.WriteLine(person.FirstName+";"+person.LastName+";"+person.Cpr+";"+person.VoterId+";"+person.PollingTable+";"+pollingVenue.PollingVenueAddress.Name);
            }

            sw.Close();
        }