public static void ExternalIdentifier(ExternalIdentifier item, string id, string identificationScheme, string registryObject, string value, string name, string description) { Assert.AreEqual(id ?? "", item.Id ?? ""); Assert.AreEqual(identificationScheme ?? "", item.IdentificationScheme ?? ""); Assert.AreEqual(registryObject ?? "", item.RegistryObject ?? ""); Assert.AreEqual(value ?? "", item.Value ?? ""); Assert.AreEqual(name ?? "", (item.Name != null ? item.Name.GetValue() : null) ?? ""); Assert.AreEqual(name ?? "", (item.Name != null ? item.Name.GetValue("en-US") : null) ?? ""); Assert.AreEqual(description ?? "", (item.Description != null ? item.Description.GetValue() : null) ?? ""); Assert.AreEqual(description ?? "", (item.Description != null ? item.Description.GetValue("en-US") : null) ?? ""); }
public static XmlDocument EPBOutboundRecords(List <DemoRecords> vr) { XmlDocument response = new XmlDocument(); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("addr", "http://www.fgdc.gov/schemas/address/addr"); ns.Add("addr_type", "http://www.fgdc.gov/schemas/address/addr_type"); XmlSerializer xmlSerializer = new XmlSerializer(typeof(VoterRecordsResponse)); VoterRecordResults records = new VoterRecordResults(); records.VoterRecord = new VoterRecord[vr.Count]; records.TransactionId = "VRI-EPB-Example_" + DateTime.Now.ToString(); int rec = 0; foreach (DemoRecords d in vr) { VoterRecord voter = new VoterRecord(); voter.Voter = new Voter(); voter.Voter.DateOfBirthSpecified = true; voter.Voter.DateOfBirth = Convert.ToDateTime(d.DATE_OF_BIRTH); Name votername = new Name() { FirstName = d.FIRST_NAME, LastName = d.LAST_NAME, FullName = BuildFullName(d.FIRST_NAME, d.MIDDLE_NAME, d.LAST_NAME, d.SUFFIX) }; string[] midname = new string[] { d.MIDDLE_NAME }; votername.MiddleName = midname; voter.Voter.Name = votername; voter.Voter.ResidenceAddress = BuildAddress(d.HOUSE_NUMBER, d.PRE_DIRECTION, d.STREET_NAME, d.STREETTYPE, d.POST_DIRECTION, d.APT_NUM, d.CITY, d.STATE, d.ZIP, d.COUNTRY); //This example does not specify a party, but this is where it would be added Party p = new Party(); p.Name = "Not-specified"; voter.Voter.Party = p; //Known Voter ID Type VoterId vid = new VoterId(); VoterId dmv = new VoterId(); vid.Type = VoterIdType.statevoterregistrationid; dmv.Type = VoterIdType.driverslicense; vid.StringValue = d.VOTERID; dmv.StringValue = d.DMV_NUMBER; voter.Voter.VoterId = new VoterId[2]; voter.Voter.VoterId[0] = vid; voter.Voter.VoterId[1] = dmv; //adding districts - this exammple includes congressional, state senate and state house voter.District = new ReportingUnit[3]; voter.District[0] = BuildReportingUnit("congressional", d.CONGRESSIONAL_DISTRICT); voter.District[1] = BuildReportingUnit("state-senate", d.ST_LEG_UPPER_HOUSE); voter.District[2] = BuildReportingUnit("state-house", d.ST_LEG_LOWER_HOUSE); //Adding locality, precinct and splits voter.Locality = new ReportingUnit[3]; voter.Locality[0] = BuildReportingUnit("county", d.LOCALITY_NAME); voter.Locality[1] = BuildReportingUnit("precinct", d.PRECINCT_NAME); voter.Locality[2] = BuildReportingUnit("split-precinct", d.PRECINCT_SPLIT_NAME); //other information about voter voter.Voter.Gender = d.GENDER; //Protected voter VoterClassification prot = new VoterClassification(); if (d.PROTECTED != "") { prot.Type = VoterClassificationType.protectedvoter; } else { prot.OtherType = "not protected"; prot.Type = VoterClassificationType.other; } //UOCAVA Voter VoterClassification uocava = new VoterClassification(); if (d.UOCAVA_VOTER != "") { uocava.Type = VoterClassificationType.activeduty; } else { uocava.OtherType = "not uocava"; uocava.Type = VoterClassificationType.other; } //absentee ballot status VoterClassification ab = new VoterClassification(); if (d.VOTEBYMAIL_STATUS != "") { ab.OtherType = "absentee ballots sent"; ab.Type = VoterClassificationType.other; } else { ab.OtherType = "no absentee ballot sent"; ab.Type = VoterClassificationType.other; } //NVRA Status VoterClassification nvra = new VoterClassification(); nvra.OtherType = d.VOTER_STATUS; nvra.Type = VoterClassificationType.other; //NVRA Confirmation mailing sent VoterClassification conf = new VoterClassification(); if (d.NVRA_CONFIRMATION != "") { conf.OtherType = "Confirmation sent"; conf.Type = VoterClassificationType.other; } else { conf.OtherType = "No confirmation"; conf.Type = VoterClassificationType.other; } voter.Voter.VoterClassification = new VoterClassification[5]; voter.Voter.VoterClassification[0] = prot; voter.Voter.VoterClassification[1] = uocava; voter.Voter.VoterClassification[2] = ab; voter.Voter.VoterClassification[3] = nvra; voter.Voter.VoterClassification[4] = conf; //Election specific information using the VoterParticipation Object VoterParticipation participation = new VoterParticipation(); Election el = new Election(); el.Name = d.ELECTION_NAME; el.StartDate = Convert.ToDateTime(d.ELECTION_DATE); participation.Election = el; //for ballot style we will need to create an external identifier ExternalIdentifier bsiden = new ExternalIdentifier(); bsiden.Type = IdentifierType.locallevel; bsiden.Value = d.BALLOT_STYLE_NAME; BallotStyle bs = new BallotStyle(); bs.ExternalIdentifier = new ExternalIdentifier[1]; bs.ExternalIdentifier[0] = bsiden; participation.BallotStyle = bs; voter.VoterParticipation = new VoterParticipation[1]; voter.VoterParticipation[0] = participation; records.VoterRecord[rec] = voter; rec++; } VoterRecordsResponse vrresp = records; vrresp.TransactionId = "epb-vri-example"; TextWriter write = new StreamWriter("C:\\dev\\epb_example.xml"); xmlSerializer.Serialize(write, vrresp, ns); return(response); }