//Downloads data about candidates from specified URL public void CandidateListFromURL(string url) { XmlWebClientConnection xmlWebClient = new XmlWebClientConnection(); string doc = xmlWebClient.GetXmlData(url); var serializer = new XmlSerializer(typeof(CandidateData), new XmlRootAttribute("candidates")); var stringReader = new StringReader(doc); var reader = XmlReader.Create(stringReader); Candidates = ((CandidateData)serializer.Deserialize(reader)).Candidates; }
//Checks if personal id number is disallowed to vote public static bool IsBlacklisted(string pesel) { //Connection and downloading disallowed personal id from server XmlWebClientConnection xmlWebClient = new XmlWebClientConnection(); string doc = xmlWebClient.GetXmlData(@"http://webtask.future-processing.com:8069/blocked"); XDocument xdoc = XDocument.Parse(doc); //Searching for "pesel" markup List <string> list = xdoc.Root.Descendants("pesel") .Select(x => x.Value) .ToList(); //Checking if personal id is on blacklist foreach (string element in list) { if (element == pesel) { return(true); } } return(false); }